Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ __pycache__
# Patch control files.
.*.smrev

# Branch-specific flag overrides (see FLAGS.cmake).
/BRANCH_FLAGS.cmake

# Output directories.
/build/
/install/
Expand Down
12 changes: 1 addition & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ include(therock_sanitizers)
include(therock_subproject)
include(therock_job_pools)
include(therock_testing)
include("${CMAKE_CURRENT_SOURCE_DIR}/FLAGS.cmake")

################################################################################
# Python is used throughout the build. Ensure it is initialized early.
Expand Down Expand Up @@ -107,17 +108,6 @@ set(ROCM_SYMLINK_LIBS OFF)

set(THEROCK_ARTIFACT_ARCHIVE_SUFFIX "" CACHE STRING "Suffix to add to artifact archive file stem names")

# Kpack artifact splitting
option(THEROCK_KPACK_SPLIT_ARTIFACTS "Split target-specific artifacts into generic and arch-specific components" OFF)
# TODO: Once rocm-kpack is moved into the rocm-systems repo, hard-code the path.
# Check for unset OR empty to handle -DTHEROCK_KPACK_DIR="" edge case.
if(NOT THEROCK_KPACK_DIR)
set(THEROCK_KPACK_DIR "${THEROCK_SOURCE_DIR}/base/rocm-kpack")
endif()
if(THEROCK_KPACK_SPLIT_ARTIFACTS AND NOT THEROCK_KPACK_DIR)
message(FATAL_ERROR "THEROCK_KPACK_DIR must be set when THEROCK_KPACK_SPLIT_ARTIFACTS=ON")
endif()

option(THEROCK_BUNDLE_SYSDEPS "Builds bundled system deps for portable builds into lib/rocm_sysdeps" ON)
# TODO: Set default to true for Linux branch after necessary changes land
cmake_dependent_option(THEROCK_ENABLE_MPI
Expand Down
40 changes: 40 additions & 0 deletions FLAGS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

# FLAGS.cmake
# Central registry of build flags for TheRock.
#
# Each flag creates a THEROCK_FLAG_${NAME} cache variable that can be
# controlled via -DTHEROCK_FLAG_<NAME>=ON|OFF on the cmake command line.
#
# See docs/development/flags.md for documentation on this system.

include(therock_flag_utils)

###############################################################################
# Flag declarations
###############################################################################

therock_declare_flag(
NAME KPACK_SPLIT_ARTIFACTS
DEFAULT_VALUE OFF
DESCRIPTION "Split target-specific artifacts into generic and arch-specific components"
CMAKE_VARS
ROCM_KPACK_ENABLED=ON
SUB_PROJECTS
hip-clr
)

###############################################################################
# Branch-specific flag overrides.
# BRANCH_FLAGS.cmake is .gitignored on main but can be committed on
# integration branches to change default flag values via
# therock_override_flag_default().
###############################################################################
include("${CMAKE_CURRENT_SOURCE_DIR}/BRANCH_FLAGS.cmake" OPTIONAL)

###############################################################################
# Finalize all flags and report.
###############################################################################
therock_finalize_flags()
therock_report_flags()
4 changes: 3 additions & 1 deletion base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ therock_cmake_subproject_declare(therock-aux-overlay
EXTERNAL_SOURCE_DIR "aux-overlay"
USE_DIST_AMDGPU_TARGETS
BACKGROUND_BUILD
CMAKE_ARGS
"-DTHEROCK_FLAG_SETTINGS_FILE=${THEROCK_FLAG_SETTINGS_FILE}"
)
therock_cmake_subproject_activate(therock-aux-overlay)

Expand Down Expand Up @@ -152,7 +154,7 @@ therock_cmake_subproject_activate(rocm-half)
# rocm-kpack
################################################################################

if(THEROCK_KPACK_SPLIT_ARTIFACTS)
if(THEROCK_FLAG_KPACK_SPLIT_ARTIFACTS)

therock_cmake_subproject_declare(rocm-kpack
EXTERNAL_SOURCE_DIR "rocm-kpack"
Expand Down
9 changes: 8 additions & 1 deletion base/aux-overlay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,16 @@ find_package(Python3 COMPONENTS Interpreter REQUIRED)
set(THEROCK_MANIFEST_JSON "${CMAKE_CURRENT_BINARY_DIR}/therock_manifest.json")
set(THEROCK_MANIFEST_SCRIPT "${THEROCK_SOURCE_DIR}/build_tools/generate_therock_manifest.py")

set(_manifest_flag_args)
if(THEROCK_FLAG_SETTINGS_FILE)
list(APPEND _manifest_flag_args --flag-settings "${THEROCK_FLAG_SETTINGS_FILE}")
endif()

add_custom_command(
OUTPUT "${THEROCK_MANIFEST_JSON}"
COMMAND "${Python3_EXECUTABLE}" "${THEROCK_MANIFEST_SCRIPT}" -o "${THEROCK_MANIFEST_JSON}"
COMMAND "${Python3_EXECUTABLE}" "${THEROCK_MANIFEST_SCRIPT}"
-o "${THEROCK_MANIFEST_JSON}"
${_manifest_flag_args}
WORKING_DIRECTORY "${THEROCK_SOURCE_DIR}"
DEPENDS "${THEROCK_MANIFEST_SCRIPT}" "${THEROCK_SOURCE_DIR}/.gitmodules"
COMMENT "Generating TheRock manifest"
Expand Down
15 changes: 15 additions & 0 deletions build_tools/generate_therock_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,28 @@ def main():
ap.add_argument(
"--commit", help="TheRock commit/ref to inspect (default: HEAD)", default="HEAD"
)
ap.add_argument(
"--flag-settings",
help="Path to flag_settings.json to include in the manifest",
default=None,
)
args = ap.parse_args()

repo_root = git_root()
the_rock_commit = _run(["git", "rev-parse", args.commit], cwd=repo_root)

manifest = build_manifest_schema(repo_root, the_rock_commit)

# Merge flag settings into the manifest if provided.
if args.flag_settings:
flag_settings_path = Path(args.flag_settings)
if not flag_settings_path.exists():
raise FileNotFoundError(
f"Flag settings file not found: {flag_settings_path}"
)
with open(flag_settings_path, encoding="utf-8") as f:
manifest["flags"] = json.load(f)

# Decide output path
# if not provided, write to repo_root / "therock_manifest.json"
out_path = (
Expand Down
8 changes: 4 additions & 4 deletions cmake/therock_artifacts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ function(therock_provide_artifact slice_name)

# Determine if this artifact should be split into generic + arch-specific components
set(_should_split FALSE)
if(THEROCK_KPACK_SPLIT_ARTIFACTS)
if(THEROCK_FLAG_KPACK_SPLIT_ARTIFACTS)
set(_artifact_type "${THEROCK_ARTIFACT_TYPE_${slice_name}}")
if(NOT _artifact_type)
message(FATAL_ERROR
"THEROCK_KPACK_SPLIT_ARTIFACTS is enabled but THEROCK_ARTIFACT_TYPE_${slice_name} "
"THEROCK_FLAG_KPACK_SPLIT_ARTIFACTS is enabled but THEROCK_ARTIFACT_TYPE_${slice_name} "
"is not defined. Ensure topology_to_cmake.py has been run."
)
endif()
Expand Down Expand Up @@ -217,7 +217,7 @@ function(therock_provide_artifact slice_name)

# When splitting is enabled, run split_artifacts.py on each component
if(_should_split)
set(_split_tool "${THEROCK_KPACK_DIR}/python/rocm_kpack/tools/split_artifacts.py")
set(_split_tool "${THEROCK_ROCM_SYSTEMS_SOURCE_DIR}/shared/kpack/python/rocm_kpack/tools/split_artifacts.py")
set(_bundler_path "${THEROCK_BINARY_DIR}/compiler/amd-llvm/dist/lib/llvm/bin/clang-offload-bundler")
set(_split_manifest_files)
set(_split_component_dirs)
Expand Down Expand Up @@ -247,7 +247,7 @@ function(therock_provide_artifact slice_name)
add_custom_command(
OUTPUT "${_split_manifest}"
COMMENT "Splitting ${_artifact_prefix} into generic and arch-specific artifacts"
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${THEROCK_KPACK_DIR}/python"
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${THEROCK_ROCM_SYSTEMS_SOURCE_DIR}/shared/kpack/python"
"${Python3_EXECUTABLE}" "${_split_tool}" ${_split_command_args}
DEPENDS
"${_unsplit_manifest}"
Expand Down
Loading
Loading