From b5c685ef9daada6777e64db847397887b3c1559b Mon Sep 17 00:00:00 2001 From: Aurelien Bouteiller Date: Mon, 16 Jun 2025 11:49:30 -0400 Subject: [PATCH] Fix rocshmem_info not compiling in out of source builds (#160) [ROCm/rocshmem commit: 8138d130b96f0709102c2e0a7e552623b659c6e7] --- projects/rocshmem/CMakeLists.txt | 15 +-------------- projects/rocshmem/src/CMakeLists.txt | 2 ++ projects/rocshmem/src/tools/CMakeLists.txt | 16 ++++++++++++++++ projects/rocshmem/src/tools/rocshmem_info.cpp | 6 +++--- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/projects/rocshmem/CMakeLists.txt b/projects/rocshmem/CMakeLists.txt index ec82461f86..773f401160 100644 --- a/projects/rocshmem/CMakeLists.txt +++ b/projects/rocshmem/CMakeLists.txt @@ -63,6 +63,7 @@ option(BUILD_FUNCTIONAL_TESTS "Build the functional tests" OFF) option(BUILD_EXAMPLES "Build the examples" ON) option(BUILD_UNIT_TESTS "Build the unit tests" OFF) option(BUILD_TESTS_ONLY "Build only tests. Used to link agains rocSHMEM in a ROCm Release" OFF) +option(BUILD_TOOLS "Build binary tools (e.g., rocshmem_info)" ON) option(BUILD_LOCAL_GPU_TARGET_ONLY "Build only for GPUs detected on this machine" OFF) option(BUILD_CODE_COVERAGE "Build with code coverage flags (gcc only)" OFF) @@ -124,20 +125,6 @@ else() endif() message(STATUS "rocSHMEM Version: " "${VERSION_STRING}") -execute_process ( - COMMAND bash -c "git rev-parse HEAD;" - OUTPUT_VARIABLE GIT_HASH -) - -string(STRIP ${GIT_HASH} GIT_HASH) -string(REPLACE ";" " " ROCSHMEM_DEFAULT_GPUS "${DEFAULT_GPUS}") - -add_compile_definitions( - ROCSHMEM_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" - ROCSHMEM_GIT_HASH="${GIT_HASH}" - ROCSHMEM_DEFAULT_GPUS="${ROCSHMEM_DEFAULT_GPUS}" -) - rocm_setup_version(VERSION ${VERSION_STRING}) project(rocshmem VERSION ${VERSION_STRING} LANGUAGES CXX) diff --git a/projects/rocshmem/src/CMakeLists.txt b/projects/rocshmem/src/CMakeLists.txt index 75c083271c..732eece2c9 100644 --- a/projects/rocshmem/src/CMakeLists.txt +++ b/projects/rocshmem/src/CMakeLists.txt @@ -73,4 +73,6 @@ add_subdirectory(host) add_subdirectory(memory) add_subdirectory(sync) add_subdirectory(bootstrap) +if (BUILD_TOOLS) add_subdirectory(tools) +endif() diff --git a/projects/rocshmem/src/tools/CMakeLists.txt b/projects/rocshmem/src/tools/CMakeLists.txt index fa9acfc106..4d40ba44e6 100644 --- a/projects/rocshmem/src/tools/CMakeLists.txt +++ b/projects/rocshmem/src/tools/CMakeLists.txt @@ -24,8 +24,24 @@ # SOURCES ############################################################################### +execute_process ( + COMMAND bash -c "git -C ${PROJECT_SOURCE_DIR} rev-parse HEAD;" + OUTPUT_VARIABLE GIT_HASH +) + +string(STRIP "${GIT_HASH}" GIT_HASH) +string(REPLACE ";" " " ROCSHMEM_OFFLOAD_TARGETS "${COMPILING_TARGETS}") + add_executable(rocshmem_info rocshmem_info.cpp) +target_compile_definitions( + rocshmem_info + PRIVATE + ROCSHMEM_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" + ROCSHMEM_GIT_HASH="${GIT_HASH}" + ROCSHMEM_OFFLOAD_TARGETS="${ROCSHMEM_OFFLOAD_TARGETS}" +) + target_include_directories( rocshmem_info PRIVATE diff --git a/projects/rocshmem/src/tools/rocshmem_info.cpp b/projects/rocshmem/src/tools/rocshmem_info.cpp index 610c9cdfe1..738b5b4f98 100644 --- a/projects/rocshmem/src/tools/rocshmem_info.cpp +++ b/projects/rocshmem/src/tools/rocshmem_info.cpp @@ -10,8 +10,8 @@ #include #include -#define NAME_COLUMN_WIDTH (24) -#define INFO_COLUMN_WIDTH (51) +#define NAME_COLUMN_WIDTH (28) +#define INFO_COLUMN_WIDTH (47) #define PRINT_ENTRY(NAME, INFO) \ printf("# %-*s: %-*s#\n", NAME_COLUMN_WIDTH, NAME, INFO_COLUMN_WIDTH, INFO) @@ -75,7 +75,7 @@ void print_arch_info() { int n_compiled_arch = 1; bool supported_arch = false; - std::istringstream compiled_arch_list(ROCSHMEM_DEFAULT_GPUS); + std::istringstream compiled_arch_list(ROCSHMEM_OFFLOAD_TARGETS); CHECK_HIP(hipGetDeviceProperties(&prop, 0));