diff --git a/BUILD_TOPOLOGY.toml b/BUILD_TOPOLOGY.toml index 620f2afd558..dc403882ace 100644 --- a/BUILD_TOPOLOGY.toml +++ b/BUILD_TOPOLOGY.toml @@ -819,6 +819,13 @@ artifact_deps = [] feature_group = "EMULATION" disable_platforms = ["windows"] +[artifacts.rocjitsu-hotswap] +artifact_group = "rocjitsu" +type = "target-neutral" +artifact_deps = ["rocjitsu"] +feature_group = "EMULATION" +disable_platforms = ["windows"] + [artifacts.mirage] artifact_group = "rocjitsu" type = "target-neutral" diff --git a/build_tools/build_python_packages.py b/build_tools/build_python_packages.py index 5f9738e6953..ed6b4c94a87 100755 --- a/build_tools/build_python_packages.py +++ b/build_tools/build_python_packages.py @@ -520,12 +520,13 @@ def core_artifact_filter(an: ArtifactName) -> bool: "lib", "run", ] + hotswap = an.name == "rocjitsu-hotswap" and an.component == "lib" # hiprtc needs to be able to find HIP headers in its same tree. hip_dev = an.name in [ "core-hip", "core-ocl", ] and an.component in ["dev"] - return core or hip_dev + return core or hotswap or hip_dev def libraries_artifact_filter(target_family: str, an: ArtifactName) -> bool: diff --git a/build_tools/install_rocm_from_artifacts.py b/build_tools/install_rocm_from_artifacts.py index 965ff7dce2c..b2d8794bde0 100644 --- a/build_tools/install_rocm_from_artifacts.py +++ b/build_tools/install_rocm_from_artifacts.py @@ -350,6 +350,7 @@ def retrieve_artifacts_by_run_id(args): "core-hipinfo_run", "core-runtime_run", "core-runtime_lib", + "rocjitsu-hotswap_lib", "sysdeps_lib", "base_run", "base_lib", diff --git a/build_tools/packaging/linux/package.json b/build_tools/packaging/linux/package.json index 3106b41436c..b8ce4982038 100644 --- a/build_tools/packaging/linux/package.json +++ b/build_tools/packaging/linux/package.json @@ -214,6 +214,17 @@ } ] }, + { + "Artifact": "rocjitsu-hotswap", + "Artifact_Subdir": [ + { + "Name": "rocjitsu-hotswap", + "Components": [ + "lib" + ] + } + ] + }, { "Artifact": "core-hip", "Artifact_Subdir": [ diff --git a/build_tools/tests/install_rocm_from_artifacts_test.py b/build_tools/tests/install_rocm_from_artifacts_test.py index 301fc5a06d8..67e153ecfc2 100644 --- a/build_tools/tests/install_rocm_from_artifacts_test.py +++ b/build_tools/tests/install_rocm_from_artifacts_test.py @@ -68,6 +68,10 @@ def test_mirage_flag_includes_mirage_run(self): argv = self._run_main(["--mirage"]) self.assertIn("mirage_run", argv) + def test_base_only_includes_rocjitsu_hotswap(self): + argv = self._run_main(["--base-only"]) + self.assertIn("rocjitsu-hotswap_lib", argv) + class TestReleaseDiscovery(unittest.TestCase): def test_extract_version_ignores_test_tarball(self) -> None: diff --git a/build_tools/tests/py_packaging_test.py b/build_tools/tests/py_packaging_test.py index fbaf5a7825b..0744ae6ff6c 100644 --- a/build_tools/tests/py_packaging_test.py +++ b/build_tools/tests/py_packaging_test.py @@ -657,6 +657,23 @@ def test_device_artifact_filter(self): an_core = ArtifactName("core-hip", "lib", "gfx942") self.assertFalse(device_artifact_filter("gfx942", an_core)) + def test_core_artifact_filter_includes_only_rocjitsu_hotswap(self): + """The core wheel ships the HSA hotswap hook without the rocjitsu library.""" + sys.path.insert(0, os.fspath(Path(__file__).parent.parent)) + from build_python_packages import core_artifact_filter + + from _therock_utils.artifacts import ArtifactName + + self.assertTrue( + core_artifact_filter(ArtifactName("rocjitsu-hotswap", "lib", "generic")) + ) + self.assertFalse( + core_artifact_filter(ArtifactName("rocjitsu", "lib", "generic")) + ) + self.assertFalse( + core_artifact_filter(ArtifactName("rocjitsu", "run", "generic")) + ) + def test_device_dist_info_has_libraries_py_package_name(self): """Device package _dist_info.py must contain LIBRARIES_PY_PACKAGE_NAME.""" artifact_dir = self._setup_kpack_split_artifacts() diff --git a/emulation/CMakeLists.txt b/emulation/CMakeLists.txt index f228a97c7f7..8f5b7ed089f 100644 --- a/emulation/CMakeLists.txt +++ b/emulation/CMakeLists.txt @@ -40,6 +40,10 @@ if(THEROCK_ENABLE_ROCJITSU) LIB_NAMES librocjitsu.so ) + therock_test_validate_shared_lib(PATH rocjitsu/dist/lib + LIB_NAMES + libhsa_hotswap_rocjitsu.so + ) therock_provide_artifact(rocjitsu TARGET_NEUTRAL @@ -54,6 +58,33 @@ if(THEROCK_ENABLE_ROCJITSU) ) endif() +if(THEROCK_ENABLE_ROCJITSU_HOTSWAP) + # Artifact descriptors must own distinct stage directories. Re-stage the + # already-built hook without rebuilding rocjitsu so it can remain a + # separately selectable artifact. + therock_cmake_subproject_declare(rocjitsu-hotswap + DISABLE_AMDGPU_TARGETS + NO_MERGE_COMPILE_COMMANDS + EXTERNAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rocjitsu-hotswap" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/rocjitsu-hotswap" + CMAKE_ARGS + -DROCJITSU_HOTSWAP_LIBRARY=${CMAKE_CURRENT_BINARY_DIR}/rocjitsu/dist/lib/libhsa_hotswap_rocjitsu.so + BUILD_DEPS + rocjitsu + ) + + therock_cmake_subproject_activate(rocjitsu-hotswap) + + therock_provide_artifact(rocjitsu-hotswap + TARGET_NEUTRAL + DESCRIPTOR artifact-rocjitsu-hotswap.toml + COMPONENTS + lib + SUBPROJECT_DEPS + rocjitsu-hotswap + ) +endif() + if(THEROCK_ENABLE_MIRAGE) ############################################################################## # mirage diff --git a/emulation/artifact-rocjitsu-hotswap.toml b/emulation/artifact-rocjitsu-hotswap.toml new file mode 100644 index 00000000000..68691ba011e --- /dev/null +++ b/emulation/artifact-rocjitsu-hotswap.toml @@ -0,0 +1,6 @@ +# rocjitsu HSA hotswap hook +[components.lib."emulation/rocjitsu-hotswap/stage"] +default_patterns = false +include = [ + "lib/libhsa_hotswap_rocjitsu.so", +] diff --git a/emulation/rocjitsu-hotswap/CMakeLists.txt b/emulation/rocjitsu-hotswap/CMakeLists.txt new file mode 100644 index 00000000000..b0da59a0972 --- /dev/null +++ b/emulation/rocjitsu-hotswap/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT + +# Artifact descriptors cannot share a stage directory. This packaging-only +# subproject gives the hotswap hook its own stage without rebuilding rocjitsu. +cmake_minimum_required(VERSION 3.25) +project(rocjitsu_hotswap_package LANGUAGES NONE) + +if(NOT EXISTS "${ROCJITSU_HOTSWAP_LIBRARY}") + message(FATAL_ERROR + "ROCJITSU_HOTSWAP_LIBRARY does not exist: ${ROCJITSU_HOTSWAP_LIBRARY}" + ) +endif() + +install(FILES "${ROCJITSU_HOTSWAP_LIBRARY}" DESTINATION lib)