From d508c7bcd3758cfe009af8b6b8304ab8dda29bad Mon Sep 17 00:00:00 2001 From: zichguan-amd Date: Mon, 3 Nov 2025 15:15:50 -0500 Subject: [PATCH 1/2] Check hipSPARSELt for supported architectures Signed-off-by: zichguan-amd --- Libraries/hipSPARSELt/CMakeLists.txt | 8 ++++++++ Libraries/hipSPARSELt/spmm/CMakeLists.txt | 8 ++++++++ Libraries/hipSPARSELt/spmm_advanced/CMakeLists.txt | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/Libraries/hipSPARSELt/CMakeLists.txt b/Libraries/hipSPARSELt/CMakeLists.txt index 1207a4e1b..6c677cf10 100644 --- a/Libraries/hipSPARSELt/CMakeLists.txt +++ b/Libraries/hipSPARSELt/CMakeLists.txt @@ -47,6 +47,14 @@ else() if(NOT hipsparselt_FOUND) message(WARNING "hipSPARSELt could not be found, not building hipSPARSELt examples") else() + hipsparselt_get_supported_architectures(HIPSPARSELT_SUPPORTED_ARCH) + foreach(ARCH ${CMAKE_HIP_ARCHITECTURES}) + if(NOT ARCH IN_LIST HIPSPARSELT_SUPPORTED_ARCH) + message(WARNING "hipSPARSELt does not support architecture: ${ARCH}, not building hipSPARSELt examples") + return() + endif() + endforeach() + add_subdirectory(spmm) add_subdirectory(spmm_advanced) endif() diff --git a/Libraries/hipSPARSELt/spmm/CMakeLists.txt b/Libraries/hipSPARSELt/spmm/CMakeLists.txt index 41289996d..c89c74943 100644 --- a/Libraries/hipSPARSELt/spmm/CMakeLists.txt +++ b/Libraries/hipSPARSELt/spmm/CMakeLists.txt @@ -49,6 +49,14 @@ include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/ROCmPath.cmake") find_package(hip REQUIRED) find_package(hipsparselt REQUIRED) +hipsparselt_get_supported_architectures(HIPSPARSELT_SUPPORTED_ARCH) +foreach(ARCH ${CMAKE_HIP_ARCHITECTURES}) + if(NOT ARCH IN_LIST HIPSPARSELT_SUPPORTED_ARCH) + message(WARNING "hipSPARSELt does not support architecture: ${ARCH}, not building hipSPARSELt examples") + return() + endif() +endforeach() + add_executable(${example_name} main.cpp) # Make example runnable using CTest add_test(NAME ${example_name} COMMAND ${example_name}) diff --git a/Libraries/hipSPARSELt/spmm_advanced/CMakeLists.txt b/Libraries/hipSPARSELt/spmm_advanced/CMakeLists.txt index 843904d64..e8b1f6086 100644 --- a/Libraries/hipSPARSELt/spmm_advanced/CMakeLists.txt +++ b/Libraries/hipSPARSELt/spmm_advanced/CMakeLists.txt @@ -49,6 +49,14 @@ include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/ROCmPath.cmake") find_package(hip REQUIRED) find_package(hipsparselt REQUIRED) +hipsparselt_get_supported_architectures(HIPSPARSELT_SUPPORTED_ARCH) +foreach(ARCH ${CMAKE_HIP_ARCHITECTURES}) + if(NOT ARCH IN_LIST HIPSPARSELT_SUPPORTED_ARCH) + message(WARNING "hipSPARSELt does not support architecture: ${ARCH}, not building hipSPARSELt examples") + return() + endif() +endforeach() + add_executable(${example_name} main.cpp) # Make example runnable using CTest add_test(NAME ${example_name} COMMAND ${example_name}) From a453cfc031d148e9fa581c4229f27e3df4719476 Mon Sep 17 00:00:00 2001 From: mapatel-amd Date: Sat, 16 May 2026 18:53:18 -0400 Subject: [PATCH 2/2] Use new CMake function filter_hip_architectures --- Libraries/hipSPARSELt/CMakeLists.txt | 24 +++++-------------- Libraries/hipSPARSELt/spmm/CMakeLists.txt | 21 ++++------------ .../hipSPARSELt/spmm_advanced/CMakeLists.txt | 21 ++++------------ 3 files changed, 16 insertions(+), 50 deletions(-) diff --git a/Libraries/hipSPARSELt/CMakeLists.txt b/Libraries/hipSPARSELt/CMakeLists.txt index 6c677cf10..3c9ccfe85 100644 --- a/Libraries/hipSPARSELt/CMakeLists.txt +++ b/Libraries/hipSPARSELt/CMakeLists.txt @@ -27,16 +27,6 @@ include(CTest) file(RELATIVE_PATH folder_bin ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${folder_bin}) -# see https://github.com/ROCm/rocm-libraries/blob/40bbc75960836d1b9e0573606df9dd79800e412a/projects/hipsparselt/cmake/hipsparselt_supported_architectures.cmake#L10-L21 -set(HIPSPARSELT_SUPPORTED_ARCH gfx942 gfx950) - -foreach(ARCH ${CMAKE_HIP_ARCHITECTURES}) - if(NOT ARCH IN_LIST HIPSPARSELT_SUPPORTED_ARCH) - message(WARNING "hipSPARSELt does not support architecture: ${ARCH}, not building hipSPARSELt examples") - return() - endif() -endforeach() - include("${CMAKE_CURRENT_LIST_DIR}/../../Common/ROCmPath.cmake") if(CMAKE_SYSTEM_NAME STREQUAL "Windows") @@ -47,14 +37,12 @@ else() if(NOT hipsparselt_FOUND) message(WARNING "hipSPARSELt could not be found, not building hipSPARSELt examples") else() - hipsparselt_get_supported_architectures(HIPSPARSELT_SUPPORTED_ARCH) - foreach(ARCH ${CMAKE_HIP_ARCHITECTURES}) - if(NOT ARCH IN_LIST HIPSPARSELT_SUPPORTED_ARCH) - message(WARNING "hipSPARSELt does not support architecture: ${ARCH}, not building hipSPARSELt examples") - return() - endif() - endforeach() - + include("${CMAKE_CURRENT_LIST_DIR}/../../Common/FilterHIPArchitectures.cmake") + filter_hip_architectures("hipSPARSELt" "gfx942;gfx950" SHOULD_SKIP) + if(SHOULD_SKIP) + return() + endif() + add_subdirectory(spmm) add_subdirectory(spmm_advanced) endif() diff --git a/Libraries/hipSPARSELt/spmm/CMakeLists.txt b/Libraries/hipSPARSELt/spmm/CMakeLists.txt index c89c74943..4a9c99bc8 100644 --- a/Libraries/hipSPARSELt/spmm/CMakeLists.txt +++ b/Libraries/hipSPARSELt/spmm/CMakeLists.txt @@ -35,27 +35,16 @@ select_gpu_language() enable_language(${ROCM_EXAMPLES_GPU_LANGUAGE}) select_hip_platform() -# see https://github.com/ROCm/rocm-libraries/blob/40bbc75960836d1b9e0573606df9dd79800e412a/projects/hipsparselt/cmake/hipsparselt_supported_architectures.cmake#L10-L21 -set(HIPSPARSELT_SUPPORTED_ARCH gfx942 gfx950) - -foreach(ARCH ${CMAKE_HIP_ARCHITECTURES}) - if(NOT ARCH IN_LIST HIPSPARSELT_SUPPORTED_ARCH) - message(FATAL_ERROR "hipSPARSELt does not support architecture: ${ARCH}, not building hipSPARSELt examples") - endif() -endforeach() - include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/ROCmPath.cmake") find_package(hip REQUIRED) find_package(hipsparselt REQUIRED) -hipsparselt_get_supported_architectures(HIPSPARSELT_SUPPORTED_ARCH) -foreach(ARCH ${CMAKE_HIP_ARCHITECTURES}) - if(NOT ARCH IN_LIST HIPSPARSELT_SUPPORTED_ARCH) - message(WARNING "hipSPARSELt does not support architecture: ${ARCH}, not building hipSPARSELt examples") - return() - endif() -endforeach() +include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/FilterHIPArchitectures.cmake") +filter_hip_architectures("hipSPARSELt" "gfx942;gfx950" SHOULD_SKIP) +if(SHOULD_SKIP) + return() +endif() add_executable(${example_name} main.cpp) # Make example runnable using CTest diff --git a/Libraries/hipSPARSELt/spmm_advanced/CMakeLists.txt b/Libraries/hipSPARSELt/spmm_advanced/CMakeLists.txt index e8b1f6086..d21646962 100644 --- a/Libraries/hipSPARSELt/spmm_advanced/CMakeLists.txt +++ b/Libraries/hipSPARSELt/spmm_advanced/CMakeLists.txt @@ -35,27 +35,16 @@ select_gpu_language() enable_language(${ROCM_EXAMPLES_GPU_LANGUAGE}) select_hip_platform() -# see https://github.com/ROCm/rocm-libraries/blob/40bbc75960836d1b9e0573606df9dd79800e412a/projects/hipsparselt/cmake/hipsparselt_supported_architectures.cmake#L10-L21 -set(HIPSPARSELT_SUPPORTED_ARCH gfx942 gfx950) - -foreach(ARCH ${CMAKE_HIP_ARCHITECTURES}) - if(NOT ARCH IN_LIST HIPSPARSELT_SUPPORTED_ARCH) - message(FATAL_ERROR "hipSPARSELt does not support architecture: ${ARCH}, not building hipSPARSELt examples") - endif() -endforeach() - include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/ROCmPath.cmake") find_package(hip REQUIRED) find_package(hipsparselt REQUIRED) -hipsparselt_get_supported_architectures(HIPSPARSELT_SUPPORTED_ARCH) -foreach(ARCH ${CMAKE_HIP_ARCHITECTURES}) - if(NOT ARCH IN_LIST HIPSPARSELT_SUPPORTED_ARCH) - message(WARNING "hipSPARSELt does not support architecture: ${ARCH}, not building hipSPARSELt examples") - return() - endif() -endforeach() +include("${CMAKE_CURRENT_LIST_DIR}/../../../Common/FilterHIPArchitectures.cmake") +filter_hip_architectures("hipSPARSELt" "gfx942;gfx950" SHOULD_SKIP) +if(SHOULD_SKIP) + return() +endif() add_executable(${example_name} main.cpp) # Make example runnable using CTest