Skip to content

Commit 3e9993a

Browse files
evetssoassistant-librarian[bot]
authored andcommitted
[rocm-libraries] ROCm/rocm-libraries#1308 (commit 7f16ceb)
Add build and install rpath for hipfft-test and rocfft-test for finding libomp.so (#1308) ## Motivation Cherry-pick ~~#995~~ #1004 and #1164 to 7.0, to fix RHEL10/OL10. ## Technical Details Test executables have absolute rpaths, which are not allowed in RHEL10 and OL10. ## Test Plan Regular regression tests are now runnable via packages on these OSes.
1 parent 1366947 commit 3e9993a

File tree

2 files changed

+48
-20
lines changed

2 files changed

+48
-20
lines changed

clients/tests/CMakeLists.txt

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,34 @@ set( rocfft-test_include_dirs
186186
)
187187

188188
set( rocfft-test_link_libs
189-
${FFTW_LIBRARIES} OpenMP::OpenMP_CXX
189+
${FFTW_LIBRARIES}
190190
)
191191

192+
option( BUILD_CLIENTS_TESTS_OPENMP "Build tests with OpenMP" ON )
193+
if( BUILD_CLIENTS_TESTS_OPENMP )
194+
# Attempt to find a config version, which provides openmp_LIB_DIR.
195+
#find_package( OpenMP CONFIG PATHS "${HIP_CLANG_ROOT}/lib/cmake" )
196+
if( NOT OPENMP_FOUND OR NOT DEFINED ${openmp_LIB_DIR} )
197+
# Fall-back to module mode.
198+
find_package( OpenMP REQUIRED )
199+
set( BUILD_RPATH "${HIP_CLANG_ROOT}/lib" )
200+
set( INSTALL_RPATH "$ORIGIN/../llvm/lib" )
201+
else()
202+
set( BUILD_RPATH "${HIP_CLANG_ROOT}/${openmp_LIB_DIR}" )
203+
set( INSTALL_RPATH "$ORIGIN/../llvm/${openmp_LIB_DIR}" )
204+
endif()
205+
list( APPEND rocfft-test_link_libs OpenMP::OpenMP_CXX )
206+
207+
set_target_properties( rocfft-test PROPERTIES
208+
BUILD_RPATH "{$BUILD_RPATH}"
209+
)
210+
set_target_properties( rocfft-test PROPERTIES
211+
INSTALL_RPATH "${INSTALL_RPATH}"
212+
)
213+
endif()
214+
215+
216+
192217
include( ../cmake/build-gtest.cmake )
193218

194219
if( BUILD_GTEST OR NOT GTEST_FOUND )
@@ -262,28 +287,16 @@ if( USE_CUDA )
262287
)
263288
target_compile_definitions( rocfft-test PRIVATE __HIP_PLATFORM_NVCC__ )
264289
endif( )
265-
target_link_libraries( rocfft-test PRIVATE ${ROCFFT_CLIENTS_HOST_LINK_LIBS} ${ROCFFT_CLIENTS_DEVICE_LINK_LIBS} )
290+
target_link_libraries( rocfft-test PRIVATE
291+
${ROCFFT_CLIENTS_HOST_LINK_LIBS}
292+
${ROCFFT_CLIENTS_DEVICE_LINK_LIBS} )
266293

267294
include( ../../cmake/sqlite.cmake )
268295
target_link_libraries( rocfft-test PUBLIC ${ROCFFT_SQLITE_LIB} )
269296
target_include_directories( rocfft-test PRIVATE ${sqlite_local_SOURCE_DIR} )
270297

271298
set_property( TARGET rocfft-test APPEND PROPERTY LINK_LIBRARIES ${ROCFFT_SQLITE_LIB} )
272299

273-
option( BUILD_CLIENTS_TESTS_OPENMP "Build tests with OpenMP" ON )
274-
275-
if( BUILD_CLIENTS_TESTS_OPENMP )
276-
find_package(OpenMP REQUIRED)
277-
if( CMAKE_CXX_COMPILER MATCHES ".*/hipcc$" )
278-
target_link_libraries( rocfft-test PRIVATE OpenMP::OpenMP_CXX -L${HIP_CLANG_ROOT}/lib -Wl,-rpath=${HIP_CLANG_ROOT}/lib )
279-
target_include_directories( rocfft-test PRIVATE ${HIP_CLANG_ROOT}/include )
280-
else()
281-
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
282-
target_link_libraries( rocfft-test PRIVATE OpenMP::OpenMP_CXX )
283-
endif()
284-
endif()
285-
endif()
286-
287300
if(FFTW_MULTITHREAD)
288301
target_compile_options( rocfft-test PRIVATE -DFFTW_MULTITHREAD )
289302
endif( )
@@ -335,7 +348,16 @@ if( ROCFFT_MPI_ENABLE )
335348
# normal and dynamic-loading MPI worker processes
336349
foreach(worker rocfft_mpi_worker dyna_rocfft_mpi_worker)
337350
add_executable( ${worker} rocfft_mpi_worker.cpp )
338-
if( BUILD_FFTW )
351+
352+
if( BUILD_CLIENTS_TESTS_OPENMP )
353+
set_target_properties( ${worker} PROPERTIES
354+
BUILD_RPATH "${BUILD_RPATH}"
355+
)
356+
set_target_properties( ${worker} PROPERTIES
357+
INSTALL_RPATH "${INSTALL_RPATH}"
358+
)
359+
endif()
360+
if( BUILD_FFTW OR NOT FFTW_FOUND )
339361
add_dependencies( ${worker} fftw_double fftw_single )
340362
endif()
341363
target_include_directories( ${worker}
@@ -390,7 +412,7 @@ if( ROCFFT_MPI_ENABLE )
390412

391413
endif()
392414

393-
set(COVERAGE_TEST_OPTIONS "--smoketest" CACHE STRING "Command line arguments for rocfft-test when generating a code coverage report")
415+
set(COVERAGE_TEST_OPTIONS "--smoketest;--gtest_filter=-*call*" CACHE STRING "Command line arguments for rocfft-test when generating a code coverage report")
394416

395417
if(BUILD_CODE_COVERAGE)
396418
# Coverage won't work in a standalone build of the tests, as we can't

shared/fft_params.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,10 @@ class fft_params
614614
}
615615
}
616616

617-
assert(selected_grid[0] * selected_grid[1] * selected_grid[2] == mp_ranks);
617+
if(selected_grid[0] * selected_grid[1] * selected_grid[2] != mp_ranks)
618+
{
619+
throw std::runtime_error("Grid dimensions do not multiply to mp_ranks.");
620+
}
618621

619622
fft_grid = {selected_grid[0], selected_grid[1], selected_grid[2]};
620623
}
@@ -653,7 +656,10 @@ class fft_params
653656
}
654657
}
655658

656-
assert(selected_grid[0] * selected_grid[1] == mp_ranks);
659+
if(selected_grid[0] * selected_grid[1] != mp_ranks)
660+
{
661+
throw std::runtime_error("Grid dimensions do not multiply to mp_ranks.");
662+
}
657663

658664
fft_grid = {selected_grid[0], selected_grid[1]};
659665
}

0 commit comments

Comments
 (0)