From f41cd65a8bc3e8f7d457360dd4a38f09400c02bf Mon Sep 17 00:00:00 2001 From: Malcolm Roberts Date: Tue, 22 Jul 2025 10:23:57 -0600 Subject: [PATCH 1/5] Add rpath for hipfft-test to help find libomp. --- clients/tests/CMakeLists.txt | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/clients/tests/CMakeLists.txt b/clients/tests/CMakeLists.txt index e49c87b6..d5a399cb 100644 --- a/clients/tests/CMakeLists.txt +++ b/clients/tests/CMakeLists.txt @@ -98,6 +98,15 @@ endif() string( CONCAT TESTS_OUT_DIR "${PROJECT_BINARY_DIR}" ${TESTS_OUT_DIR} ) option( BUILD_CLIENTS_TESTS_OPENMP "Build tests with OpenMP" ON ) +if( BUILD_CLIENTS_TESTS_OPENMP ) + find_package(OpenMP REQUIRED) + if( BUILD_WITH_LIB STREQUAL "CUDA" ) + message( STATUS "OpenMP is not supported on CUDA, building tests without it" ) + else() + target_link_libraries( hipfft-test PRIVATE OpenMP::OpenMP_CXX + -L${HIP_CLANG_ROOT}/lib -Wl,-rpath=${HIP_CLANG_ROOT}/lib ) + endif() +endif() foreach( target ${TEST_TARGETS} ) set_target_properties( ${target} PROPERTIES @@ -140,20 +149,6 @@ foreach( target ${TEST_TARGETS} ) target_compile_definitions( ${target} PUBLIC _CUFFT_BACKEND ) endif() - if( BUILD_CLIENTS_TESTS_OPENMP ) - find_package(OpenMP REQUIRED) - if( BUILD_WITH_LIB STREQUAL "CUDA" ) - message( STATUS "OpenMP is not supported on CUDA, building tests without it" ) - else() - target_compile_options( ${target} PRIVATE -DBUILD_CLIENTS_TESTS_OPENMP ) - if(NOT (CMAKE_CXX_COMPILER MATCHES ".*hipcc$" OR CMAKE_CXX_COMPILER MATCHES ".*clang\\+\\+")) - target_link_libraries( ${target} PRIVATE OpenMP::OpenMP_CXX ) - target_include_directories( ${target} PRIVATE ${HIP_CLANG_ROOT}/include ) - else() - target_link_libraries( ${target} PRIVATE OpenMP::OpenMP_CXX ) - endif() - endif() - endif() target_include_directories( ${target} PRIVATE From 6df6ab6735a3cd17d57da1b499a9bb33e80b6e3d Mon Sep 17 00:00:00 2001 From: regan-amd Date: Wed, 23 Jul 2025 05:59:40 +0000 Subject: [PATCH 2/5] Define static class member of hipfft_params for hipfft_mpi_worker --- clients/tests/hipfft_mpi_worker.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/clients/tests/hipfft_mpi_worker.cpp b/clients/tests/hipfft_mpi_worker.cpp index 9a1e219c..a4b85c64 100644 --- a/clients/tests/hipfft_mpi_worker.cpp +++ b/clients/tests/hipfft_mpi_worker.cpp @@ -23,6 +23,9 @@ #include "../../shared/mpi_worker.h" #include "../hipfft_params.h" +// initialize static class member of hipfft_params +std::vector hipfft_params::externally_managed_workareas = std::vector(); + int main(int argc, char* argv[]) { return mpi_worker_main, false>( From 2fdaaba7384af8b20d155d8d38d79723095eabd8 Mon Sep 17 00:00:00 2001 From: Malcolm Roberts Date: Wed, 23 Jul 2025 16:58:57 -0600 Subject: [PATCH 3/5] Use INSTALL_RPATH_USE_LINK_PATH for linking test executables. --- clients/tests/CMakeLists.txt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/clients/tests/CMakeLists.txt b/clients/tests/CMakeLists.txt index d5a399cb..04e6b3ed 100644 --- a/clients/tests/CMakeLists.txt +++ b/clients/tests/CMakeLists.txt @@ -100,12 +100,6 @@ string( CONCAT TESTS_OUT_DIR "${PROJECT_BINARY_DIR}" ${TESTS_OUT_DIR} ) option( BUILD_CLIENTS_TESTS_OPENMP "Build tests with OpenMP" ON ) if( BUILD_CLIENTS_TESTS_OPENMP ) find_package(OpenMP REQUIRED) - if( BUILD_WITH_LIB STREQUAL "CUDA" ) - message( STATUS "OpenMP is not supported on CUDA, building tests without it" ) - else() - target_link_libraries( hipfft-test PRIVATE OpenMP::OpenMP_CXX - -L${HIP_CLANG_ROOT}/lib -Wl,-rpath=${HIP_CLANG_ROOT}/lib ) - endif() endif() foreach( target ${TEST_TARGETS} ) @@ -163,6 +157,16 @@ foreach( target ${TEST_TARGETS} ) hip::hipfft ${FFTW_LIBRARIES} ) + + if( BUILD_CLIENTS_TESTS_OPENMP ) + if( BUILD_WITH_LIB STREQUAL "CUDA" ) + message( STATUS "OpenMP is not supported on CUDA, building tests without it" ) + else() + set_target_properties( ${target} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) + set_target_properties( ${target} PROPERTIES BUILD_RPATH "${HIP_CLANG_ROOT}/lib" ) + target_link_libraries( ${target} PRIVATE OpenMP::OpenMP_CXX ) + endif() + endif() if( HIPFFT_MPI_ENABLE ) target_link_libraries( ${target} From d1c815715274f159d0cabf2148c4638b3f70f0ae Mon Sep 17 00:00:00 2001 From: Malcolm Roberts Date: Mon, 28 Jul 2025 16:06:16 -0600 Subject: [PATCH 4/5] openmp_LIB_DIR style rpath for tests when OpenMP CONFIG works. Fix linking directory to fix clients compilation. Allow for building from clients/tests. --- clients/tests/CMakeLists.txt | 28 ++++++++++++++++++++++++---- library/include/hipfft/hipfft.h | 4 ++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/clients/tests/CMakeLists.txt b/clients/tests/CMakeLists.txt index 04e6b3ed..55ca3b80 100644 --- a/clients/tests/CMakeLists.txt +++ b/clients/tests/CMakeLists.txt @@ -32,6 +32,13 @@ else( ) "Install path prefix, prepended onto install directories" ) endif( ) +# Dependencies + +find_package( ROCmCMakeBuildTools REQUIRED CONFIG PATHS /opt/rocm ) +include(ROCMInstallTargets) +list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake ) + + # This has to be initialized before the project() command appears # Set the default of CMAKE_BUILD_TYPE to be release, unless user # specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE @@ -42,13 +49,17 @@ endif() project( hipfft-clients-tests LANGUAGES CXX ) +find_package( hipfft REQUIRED CONFIG PATHS ) find_package( Boost REQUIRED) set( Boost_USE_STATIC_LIBS OFF ) + find_package( FFTW 3.0 REQUIRED MODULE COMPONENTS FLOAT DOUBLE ) +set( BUILD_WITH_LIB "ROCM" CACHE STRING "Build ${PROJECT_NAME} with ROCM or CUDA libraries" ) + set( THREADS_PREFER_PTHREAD_FLAG ON ) find_package( Threads REQUIRED ) @@ -84,7 +95,7 @@ if( NOT BUILD_WITH_LIB STREQUAL "CUDA" ) if( WIN32 ) find_package( HIP CONFIG REQUIRED ) else() - find_package( HIP MODULE REQUIRED ) + find_package( hip REQUIRED CONFIG PATHS /opt/rocm/lib/cmake/hip/ ) endif() endif() @@ -99,7 +110,12 @@ string( CONCAT TESTS_OUT_DIR "${PROJECT_BINARY_DIR}" ${TESTS_OUT_DIR} ) option( BUILD_CLIENTS_TESTS_OPENMP "Build tests with OpenMP" ON ) if( BUILD_CLIENTS_TESTS_OPENMP ) - find_package(OpenMP REQUIRED) + # Attempt to find a config version, which provides openmp_LIB_DIR. + #find_package( OpenMP CONFIG PATHS "${HIP_CLANG_ROOT}/lib/cmake" ) + if( NOT OPENMP_FOUND OR NOT DEFINED ${openmp_LIB_DIR} ) + # Fall-back to module mode. + find_package( OpenMP REQUIRED ) + endif() endif() foreach( target ${TEST_TARGETS} ) @@ -162,8 +178,10 @@ foreach( target ${TEST_TARGETS} ) if( BUILD_WITH_LIB STREQUAL "CUDA" ) message( STATUS "OpenMP is not supported on CUDA, building tests without it" ) else() - set_target_properties( ${target} PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE) - set_target_properties( ${target} PROPERTIES BUILD_RPATH "${HIP_CLANG_ROOT}/lib" ) + if( DEFINED ${openmp_LIB_DIR} ) + set_target_properties( ${target} PROPERTIES BUILD_RPATH "${HIP_CLANG_ROOT}/${openmp_LIB_DIR}" ) + set_target_properties( ${target} PROPERTIES INSTALL_RPATH "${HIP_CLANG_ROOT}/${openmp_LIB_DIR}" ) + endif() target_link_libraries( ${target} PRIVATE OpenMP::OpenMP_CXX ) endif() endif() @@ -183,6 +201,8 @@ foreach( target ${TEST_TARGETS} ) rocm_install(TARGETS ${target} COMPONENT tests) endforeach() +find_package( GTest 1.11.0 ) + if( GTEST_FOUND ) target_include_directories( hipfft-test PRIVATE $ ) target_link_libraries( hipfft-test PRIVATE ${GTEST_LIBRARIES} ) diff --git a/library/include/hipfft/hipfft.h b/library/include/hipfft/hipfft.h index fa1ecc6c..f970ce7f 100644 --- a/library/include/hipfft/hipfft.h +++ b/library/include/hipfft/hipfft.h @@ -45,8 +45,8 @@ #define DISABLE_WARNING_RETURN_TYPE #endif -#include "hipfft-export.h" -#include "hipfft-version.h" +#include "hipfft/hipfft-export.h" +#include "hipfft/hipfft-version.h" #include #include From 0dac5f52d46c5f3ed23ab7bac93f6da0c879e59c Mon Sep 17 00:00:00 2001 From: Malcolm Roberts Date: Tue, 29 Jul 2025 21:30:40 -0600 Subject: [PATCH 5/5] Make clients/tests find hipfft only of not in hipfft build scope --- clients/tests/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clients/tests/CMakeLists.txt b/clients/tests/CMakeLists.txt index 55ca3b80..87a7cd1d 100644 --- a/clients/tests/CMakeLists.txt +++ b/clients/tests/CMakeLists.txt @@ -49,7 +49,9 @@ endif() project( hipfft-clients-tests LANGUAGES CXX ) -find_package( hipfft REQUIRED CONFIG PATHS ) +if( NOT HIPFFT_BUILD_SCOPE ) + find_package( hipfft REQUIRED CONFIG PATHS ) +endif() find_package( Boost REQUIRED)