From 7eb2380d6adc7376b8ddeb0235e01e7f6b8a6359 Mon Sep 17 00:00:00 2001 From: Andrew Martin Date: Wed, 20 May 2026 17:48:29 -0400 Subject: [PATCH] feat: add kfdtest to TheRock CI - Add kfdtest subproject with correct dependencies (statically links libhsakmt and LLVM) - Add --kfdtest flag to install_rocm_from_artifacts.py - Add kfdtest to BUILD_TOPOLOGY.toml (artifact group, build stage, and artifact) - Add sysdeps to kfdtest artifact dependencies for bundled libraries - Use get_target_property to dynamically locate ROCR-Runtime binary directory - Set RPATH to lib/rocm_sysdeps/lib only (kfdtest statically links main deps) JIRA ID: AILIKFD-40 Co-Authored-By: Claude Sonnet 4.5 Signed-off-by: Andrew Martin --- BUILD_TOPOLOGY.toml | 15 ++++++ build_tools/install_rocm_from_artifacts.py | 14 +++++ build_tools/packaging/linux/package.json | 11 ++++ core/CMakeLists.txt | 60 ++++++++++++++++++++++ core/artifact-core-kfdtest.toml | 10 ++++ 5 files changed, 110 insertions(+) create mode 100644 core/artifact-core-kfdtest.toml diff --git a/BUILD_TOPOLOGY.toml b/BUILD_TOPOLOGY.toml index 5bddd7dbb7e..110d0a35a07 100644 --- a/BUILD_TOPOLOGY.toml +++ b/BUILD_TOPOLOGY.toml @@ -151,6 +151,7 @@ artifact_groups = [ "hip-runtime", "opencl-runtime", "profiler-core", + "kfdtest", "rocjitsu" ] @@ -270,6 +271,12 @@ type = "generic" artifact_group_deps = ["hip-runtime", "opencl-runtime", "core-runtime"] source_sets = ["rocm-systems"] +[artifact_groups.kfdtest] +description = "KFD kernel driver tests" +type = "generic" +artifact_group_deps = ["core-runtime"] +source_sets = ["rocm-systems"] + [artifact_groups.math-libs] description = "Math libraries (BLAS, FFT, RAND, etc.)" type = "per-arch" # Built per GPU architecture @@ -566,6 +573,14 @@ feature_name = "CORE_RUNTIME_TESTS" feature_group = "CORE" disable_platforms = ["windows"] +[artifacts.kfdtest] +artifact_group = "kfdtest" +type = "target-neutral" +artifact_deps = ["core-runtime", "amd-llvm", "sysdeps"] +feature_name = "CORE_KFDTESTS" +feature_group = "CORE" +disable_platforms = ["windows"] + [artifacts.core-hipinfo] artifact_group = "hip-runtime" type = "target-neutral" diff --git a/build_tools/install_rocm_from_artifacts.py b/build_tools/install_rocm_from_artifacts.py index 5e870377315..b2f590a555f 100644 --- a/build_tools/install_rocm_from_artifacts.py +++ b/build_tools/install_rocm_from_artifacts.py @@ -43,6 +43,7 @@ [--rocprofiler-systems-examples | --no-rocprofiler-systems-examples] [--rocrtst | --no-rocrtst] [--rocalution | --no-rocalution] + [--kfdtest | --no-kfdtest] [--rocwmma | --no-rocwmma] [--libhipcxx | --no-libhipcxx] [--tests | --no-tests] @@ -386,6 +387,7 @@ def retrieve_artifacts_by_run_id(args): args.rocprofiler_systems_examples, args.rocrtst, args.rocalution, + args.kfdtest, args.rocwmma, args.libhipcxx, ] @@ -497,6 +499,11 @@ def retrieve_artifacts_by_run_id(args): if args.rocalution: extra_artifacts.append("rocalution") argv.append("rocalution_dev") + if args.kfdtest: + extra_artifacts.append("kfdtest") + # kfdtest depends on llvm-dev + argv.append("amd-llvm_dev") + argv.append("amd-llvm_lib") if args.rocwmma: extra_artifacts.append("rocwmma") argv.append("rocwmma_dev") @@ -870,6 +877,13 @@ def main(argv): action=argparse.BooleanOptionalAction, ) + artifacts_group.add_argument( + "--kfdtest", + default=False, + help="Include 'kfdtest' artifacts", + action=argparse.BooleanOptionalAction, + ) + artifacts_group.add_argument( "--rocwmma", default=False, diff --git a/build_tools/packaging/linux/package.json b/build_tools/packaging/linux/package.json index 48750d7e50b..8764617c1c3 100644 --- a/build_tools/packaging/linux/package.json +++ b/build_tools/packaging/linux/package.json @@ -404,6 +404,17 @@ ] } ] + }, + { + "Artifact": "kfdtest", + "Artifact_Subdir": [ + { + "Name": "kfdtest", + "Components": [ + "test" + ] + } + ] } ], "Gfxarch": "False", diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 32c799a68cc..fecfc2b19eb 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -632,3 +632,63 @@ if(THEROCK_BUILD_TESTING AND THEROCK_ENABLE_CORE_RUNTIME_TESTS) rocrtst ) endif(THEROCK_BUILD_TESTING AND THEROCK_ENABLE_CORE_RUNTIME_TESTS) + +if(THEROCK_BUILD_TESTING AND THEROCK_ENABLE_CORE_KFDTESTS) + + # kfdtest statically links libhsakmt and LLVM (AMDGPUAsmParser, Core, Support). + # It needs LLVM headers at build time and libhsakmt.a for linking. + set(_kfdtest_build_deps + amd-llvm + ROCR-Runtime + therock-yaml-cpp + ) + + # Get the ROCR-Runtime binary directory to locate libhsakmt + get_target_property(_rocr_binary_dir ROCR-Runtime THEROCK_BINARY_DIR) + + therock_cmake_subproject_declare(kfdtest + USE_TEST_AMDGPU_TARGETS + EXTERNAL_SOURCE_DIR "${THEROCK_ROCM_SYSTEMS_SOURCE_DIR}/projects/rocr-runtime/libhsakmt/tests/kfdtest" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/kfdtest" + BACKGROUND_BUILD + CMAKE_ARGS + "-DCMAKE_PREFIX_PATH=" + "-DLLVM_DIR=" + "-DROCM_DIR=" + "-DLIBHSAKMT_PATH=${_rocr_binary_dir}/libhsakmt" + "-DCMAKE_EXE_LINKER_FLAGS=-ldl" + "-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON" + COMPILER_TOOLCHAIN + "${_system_toolchain}" + BUILD_DEPS + ${_kfdtest_build_deps} + RUNTIME_DEPS + amd-llvm + ${THEROCK_BUNDLED_LIBDRM} + ${THEROCK_BUNDLED_NUMACTL} + ${THEROCK_BUNDLED_ZLIB} + ${THEROCK_BUNDLED_ZSTD} + INTERFACE_LINK_DIRS + "lib" + "lib/rocm_sysdeps/lib" + INTERFACE_INSTALL_RPATH_DIRS + "lib" + "lib/rocm_sysdeps/lib" + ) + therock_cmake_subproject_glob_c_sources(kfdtest SUBDIRS .) + therock_cmake_subproject_activate(kfdtest) + + therock_provide_artifact(kfdtest + TARGET_NEUTRAL + DESCRIPTOR artifact-core-kfdtest.toml + COMPONENTS + dbg + dev + doc + lib + run + test + SUBPROJECT_DEPS + kfdtest + ) +endif(THEROCK_BUILD_TESTING AND THEROCK_ENABLE_CORE_KFDTESTS) diff --git a/core/artifact-core-kfdtest.toml b/core/artifact-core-kfdtest.toml new file mode 100644 index 00000000000..90234a52667 --- /dev/null +++ b/core/artifact-core-kfdtest.toml @@ -0,0 +1,10 @@ +# kfdtest +[components.run."core/kfdtest/stage"] +exclude = [ + "bin/**", + "share/kfdtest/**", +] +[components.dbg."core/kfdtest/stage"] +[components.dev."core/kfdtest/stage"] +[components.doc."core/kfdtest/stage"] +[components.test."core/kfdtest/stage"]