From d3b03307dbbff95c40ed6a7c720b72840ab553fa Mon Sep 17 00:00:00 2001 From: Lenine Ajagappane Date: Fri, 3 Apr 2026 12:59:06 +0000 Subject: [PATCH 1/4] [math-libs] Enable rocPRIM benchmark builds Add -DBUILD_BENCHMARK=ON and amdsmi build dependency to the rocPRIM_tests subproject so that rocPRIM benchmark binaries are built alongside tests. Signed-off-by: Lenine Ajagappane --- math-libs/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/math-libs/CMakeLists.txt b/math-libs/CMakeLists.txt index 6b7b3dd93b3..96ad7e2b299 100644 --- a/math-libs/CMakeLists.txt +++ b/math-libs/CMakeLists.txt @@ -124,6 +124,7 @@ if(THEROCK_ENABLE_PRIM) -DROCM_PATH= -DROCM_DIR= -DBUILD_TEST=ON + -DBUILD_BENCHMARK=ON -DUSE_SYSTEM_LIB=ON COMPILER_TOOLCHAIN amd-hip @@ -131,6 +132,7 @@ if(THEROCK_ENABLE_PRIM) rocm-cmake therock-googletest rocPRIM + amdsmi RUNTIME_DEPS hip-clr ) From 9b3da1d0ffe6636fd1e652a2dd027ab17fad0925 Mon Sep 17 00:00:00 2001 From: Lenine Ajagappane Date: Fri, 17 Apr 2026 18:25:47 +0000 Subject: [PATCH 2/4] Guard rocPRIM benchmark build against Windows where amdsmi is unavailable Signed-off-by: Lenine Ajagappane --- math-libs/CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/math-libs/CMakeLists.txt b/math-libs/CMakeLists.txt index 1382eed6e1e..f3e4947016a 100644 --- a/math-libs/CMakeLists.txt +++ b/math-libs/CMakeLists.txt @@ -115,6 +115,15 @@ if(THEROCK_ENABLE_PRIM) # rocPRIM_tests declared as a separate target to stop the tests from clogging up the critical build path for libs # that depend on rocPRIM # passing BACKGROUND_BUILD ensures that the tests aren't built (too) concurrently with other projects that are demanding + # amdsmi is Linux-only; benchmarks depend on primbench which requires amd_smi + if(WIN32) + set(_rocprim_benchmark_enable "OFF") + set(_rocprim_benchmark_deps) + else() + set(_rocprim_benchmark_enable "ON") + set(_rocprim_benchmark_deps amdsmi) + endif() + therock_cmake_subproject_declare(rocPRIM_tests EXTERNAL_SOURCE_DIR "${THEROCK_ROCM_LIBRARIES_SOURCE_DIR}/projects/rocprim" BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/rocPRIM_tests" @@ -124,7 +133,7 @@ if(THEROCK_ENABLE_PRIM) -DROCM_PATH= -DROCM_DIR= -DBUILD_TEST=ON - -DBUILD_BENCHMARK=ON + -DBUILD_BENCHMARK=${_rocprim_benchmark_enable} -DUSE_SYSTEM_LIB=ON COMPILER_TOOLCHAIN amd-hip @@ -132,7 +141,7 @@ if(THEROCK_ENABLE_PRIM) rocm-cmake therock-googletest rocPRIM - amdsmi + ${_rocprim_benchmark_deps} RUNTIME_DEPS hip-clr ) From a88edf93e3af34857925a04c41b386d5892a2e33 Mon Sep 17 00:00:00 2001 From: Lenine Ajagappane Date: Fri, 17 Apr 2026 18:34:35 +0000 Subject: [PATCH 3/4] Workaround for upstream rocPRIM missing find_package(amd_smi) Signed-off-by: Lenine Ajagappane --- math-libs/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/math-libs/CMakeLists.txt b/math-libs/CMakeLists.txt index f3e4947016a..3d5f189d6cd 100644 --- a/math-libs/CMakeLists.txt +++ b/math-libs/CMakeLists.txt @@ -119,9 +119,11 @@ if(THEROCK_ENABLE_PRIM) if(WIN32) set(_rocprim_benchmark_enable "OFF") set(_rocprim_benchmark_deps) + set(_rocprim_benchmark_includes) else() set(_rocprim_benchmark_enable "ON") set(_rocprim_benchmark_deps amdsmi) + set(_rocprim_benchmark_includes therock_rocprim_benchmark_deps.cmake) endif() therock_cmake_subproject_declare(rocPRIM_tests @@ -135,6 +137,8 @@ if(THEROCK_ENABLE_PRIM) -DBUILD_TEST=ON -DBUILD_BENCHMARK=${_rocprim_benchmark_enable} -DUSE_SYSTEM_LIB=ON + CMAKE_INCLUDES + ${_rocprim_benchmark_includes} COMPILER_TOOLCHAIN amd-hip BUILD_DEPS From b0991e1df711c19dd5dc0f8234ceea1e6e2c7dae Mon Sep 17 00:00:00 2001 From: Lenine Ajagappane Date: Fri, 17 Apr 2026 19:24:30 +0000 Subject: [PATCH 4/4] Add cmake/therock_rocprim_benchmark_deps.cmake Signed-off-by: Lenine Ajagappane --- cmake/therock_rocprim_benchmark_deps.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 cmake/therock_rocprim_benchmark_deps.cmake diff --git a/cmake/therock_rocprim_benchmark_deps.cmake b/cmake/therock_rocprim_benchmark_deps.cmake new file mode 100644 index 00000000000..925fc0faa7e --- /dev/null +++ b/cmake/therock_rocprim_benchmark_deps.cmake @@ -0,0 +1,16 @@ +# Copyright Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT + +# Workaround: rocPRIM benchmarks link against amd_smi but the project never +# calls find_package(amd_smi). Without the imported target the include +# directories are not propagated and the build fails with a missing +# header. Injecting the find_package call here via +# CMAKE_INCLUDES ensures the target exists before the benchmark subdirectory +# is processed. +# +# TODO(https://github.com/ROCm/TheRock/issues/4651): Remove once upstream +# rocPRIM adds its own find_package(amd_smi). + +if(NOT TARGET amd_smi) + find_package(amd_smi REQUIRED CONFIG) +endif()