Skip to content

Commit 664484f

Browse files
committed
Test CUDA provider when cuda is opened with RTLD_LOCAL
1 parent b0dd2fc commit 664484f

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

test/CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,20 @@ if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_CUDA_PROVIDER)
450450
LIBS ${UMF_UTILS_FOR_TEST} cuda)
451451

452452
add_umf_test(
453-
NAME provider_cuda_dlopen
453+
NAME provider_cuda_dlopen_global
454454
SRCS providers/provider_cuda.cpp providers/cuda_helpers.cpp
455455
${BA_SOURCES_FOR_TEST}
456456
LIBS ${UMF_UTILS_FOR_TEST})
457-
target_compile_definitions(umf_test-provider_cuda_dlopen
458-
PUBLIC USE_DLOPEN=1)
457+
target_compile_definitions(umf_test-provider_cuda_dlopen_global
458+
PUBLIC USE_DLOPEN=1 OPEN_CU_LIBRARY_GLOBAL=1)
459+
460+
add_umf_test(
461+
NAME provider_cuda_dlopen_local
462+
SRCS providers/provider_cuda.cpp providers/cuda_helpers.cpp
463+
${BA_SOURCES_FOR_TEST}
464+
LIBS ${UMF_UTILS_FOR_TEST})
465+
target_compile_definitions(umf_test-provider_cuda_dlopen_local
466+
PUBLIC USE_DLOPEN=1 OPEN_CU_LIBRARY_GLOBAL=0)
459467
else()
460468
message(
461469
STATUS

test/providers/cuda_helpers.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,15 @@ int InitCUDAOps() {
113113
const char *lib_name = "libcuda.so";
114114
#endif
115115
// CUDA symbols
116-
// NOTE that we use UMF_UTIL_OPEN_LIBRARY_GLOBAL which add all loaded
117-
// symbols to the global symbol table.
116+
#if OPEN_CU_LIBRARY_GLOBAL
117+
// NOTE UMF_UTIL_OPEN_LIBRARY_GLOBAL adds all loaded symbols to the
118+
// global symbol table.
119+
int open_flags = UMF_UTIL_OPEN_LIBRARY_GLOBAL;
120+
#else
121+
int open_flags = 0;
122+
#endif
118123
cuDlHandle = std::unique_ptr<void, DlHandleCloser>(
119-
utils_open_library(lib_name, UMF_UTIL_OPEN_LIBRARY_GLOBAL));
124+
utils_open_library(lib_name, open_flags));
120125

121126
// NOTE: some symbols defined in the lib have _vX postfixes - this is
122127
// important to load the proper version of functions

0 commit comments

Comments
 (0)