diff options
Diffstat (limited to 'Tests/Cuda')
-rw-r--r-- | Tests/Cuda/CMakeLists.txt | 7 | ||||
-rw-r--r-- | Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt | 11 | ||||
-rw-r--r-- | Tests/Cuda/SharedRuntimePlusToolkit/main.cpp | 17 | ||||
-rw-r--r-- | Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt | 26 | ||||
-rw-r--r-- | Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp | 8 | ||||
-rw-r--r-- | Tests/Cuda/StaticRuntimePlusToolkit/main.cpp | 27 | ||||
-rw-r--r-- | Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp | 14 | ||||
-rw-r--r-- | Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp | 8 | ||||
-rw-r--r-- | Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp | 10 | ||||
-rw-r--r-- | Tests/Cuda/StaticRuntimePlusToolkit/static.cpp | 14 | ||||
-rw-r--r-- | Tests/Cuda/Toolkit/CMakeLists.txt | 8 |
11 files changed, 115 insertions, 35 deletions
diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt index 669c412..0041b07 100644 --- a/Tests/Cuda/CMakeLists.txt +++ b/Tests/Cuda/CMakeLists.txt @@ -16,6 +16,7 @@ add_cuda_test_macro(Cuda.SeparableCompCXXOnly SeparableCompCXXOnly) add_cuda_test_macro(Cuda.Toolkit Toolkit) add_cuda_test_macro(Cuda.IncludePathNoToolkit IncludePathNoToolkit) add_cuda_test_macro(Cuda.SharedRuntimePlusToolkit SharedRuntimePlusToolkit) +add_cuda_test_macro(Cuda.StaticRuntimePlusToolkit StaticRuntimePlusToolkit) add_cuda_test_macro(Cuda.Complex CudaComplex) add_cuda_test_macro(Cuda.ProperLinkFlags ProperLinkFlags) @@ -24,10 +25,4 @@ if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang") add_cuda_test_macro(Cuda.ProperDeviceLibraries ProperDeviceLibraries) endif() -# The CUDA only ships the shared version of the toolkit libraries -# on windows -if(NOT WIN32) - add_cuda_test_macro(Cuda.StaticRuntimePlusToolkit StaticRuntimePlusToolkit) -endif() - add_cuda_test_macro(Cuda.WithC CudaWithC) diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt b/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt index 61a3190..088be3b 100644 --- a/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt +++ b/Tests/Cuda/SharedRuntimePlusToolkit/CMakeLists.txt @@ -15,16 +15,19 @@ add_library(SharedToolkit SHARED shared.cpp) target_link_libraries(SharedToolkit PRIVATE Common PUBLIC CUDA::curand CUDA::nppif) target_link_libraries(SharedToolkit PUBLIC CUDA::cudart) -# The CUDA only ships the shared version of the toolkit libraries -# on windows -if(NOT WIN32) +# Verify the CUDA Toolkit has static libraries +if(TARGET CUDA::curand_static AND + TARGET CUDA::nppif_static) #shared runtime with static toolkit libraries add_library(StaticToolkit SHARED static.cpp) + target_compile_definitions(StaticToolkit INTERFACE "HAS_STATIC_VERSION") target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) target_link_libraries(StaticToolkit PUBLIC CUDA::cudart) - #static runtime with mixed toolkit libraries + + #shared runtime with mixed toolkit libraries add_library(MixedToolkit SHARED mixed.cpp) + target_compile_definitions(MixedToolkit INTERFACE "HAS_MIXED_VERSION") target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand_static CUDA::nppif) target_link_libraries(MixedToolkit PUBLIC CUDA::cudart) endif() diff --git a/Tests/Cuda/SharedRuntimePlusToolkit/main.cpp b/Tests/Cuda/SharedRuntimePlusToolkit/main.cpp index 2a4da22..d958c3a 100644 --- a/Tests/Cuda/SharedRuntimePlusToolkit/main.cpp +++ b/Tests/Cuda/SharedRuntimePlusToolkit/main.cpp @@ -1,19 +1,28 @@ #ifdef _WIN32 # define IMPORT __declspec(dllimport) +#else +# define IMPORT +#endif + IMPORT int shared_version(); + +#ifdef HAS_STATIC_VERSION +IMPORT int static_version(); +#else int static_version() { return 0; } +#endif + +#ifdef HAS_MIXED_VERSION +IMPORT int mixed_version(); +#else int mixed_version() { return 0; } -#else -int shared_version(); -int static_version(); -int mixed_version(); #endif int main() diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt b/Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt index df6c392..bb3dadf 100644 --- a/Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt +++ b/Tests/Cuda/StaticRuntimePlusToolkit/CMakeLists.txt @@ -15,15 +15,23 @@ add_library(SharedToolkit SHARED shared.cpp) target_link_libraries(SharedToolkit PRIVATE Common PUBLIC CUDA::curand CUDA::nppif) target_link_libraries(SharedToolkit PUBLIC CUDA::cudart_static) -#static runtime with static toolkit libraries -add_library(StaticToolkit SHARED static.cpp) -target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) -target_link_libraries(StaticToolkit PUBLIC CUDA::cudart_static) +# Verify the CUDA Toolkit has static libraries +if(TARGET CUDA::curand_static AND + TARGET CUDA::nppif_static) + #static runtime with static toolkit libraries + add_library(StaticToolkit SHARED static.cpp) + target_compile_definitions(StaticToolkit INTERFACE "HAS_STATIC_VERSION") + target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) + target_link_libraries(StaticToolkit PUBLIC CUDA::cudart_static) -#static runtime with mixed toolkit libraries -add_library(MixedToolkit SHARED mixed.cpp) -target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand CUDA::nppif_static) -target_link_libraries(MixedToolkit PUBLIC CUDA::cudart_static) + #static runtime with mixed toolkit libraries + add_library(MixedToolkit SHARED mixed.cpp) + target_compile_definitions(MixedToolkit INTERFACE "HAS_MIXED_VERSION") + target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand CUDA::nppif_static) + target_link_libraries(MixedToolkit PUBLIC CUDA::cudart_static) +endif() add_executable(StaticRuntimePlusToolkit main.cpp) -target_link_libraries(StaticRuntimePlusToolkit PRIVATE SharedToolkit StaticToolkit MixedToolkit) +target_link_libraries(StaticRuntimePlusToolkit PRIVATE SharedToolkit + $<TARGET_NAME_IF_EXISTS:StaticToolkit> + $<TARGET_NAME_IF_EXISTS:MixedToolkit>) diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp index 95872f0..fdd7b53 100644 --- a/Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp +++ b/Tests/Cuda/StaticRuntimePlusToolkit/curand.cpp @@ -1,6 +1,12 @@ // Comes from: // https://docs.nvidia.com/cuda/curand/host-api-overview.html#host-api-example +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + /* * This program uses the host CURAND API to generate 100 * pseudorandom floats. @@ -25,7 +31,7 @@ } \ } while (0) -int curand_main() +EXPORT int curand_main() { size_t n = 100; size_t i; diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/main.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/main.cpp index 5a09f8e..d958c3a 100644 --- a/Tests/Cuda/StaticRuntimePlusToolkit/main.cpp +++ b/Tests/Cuda/StaticRuntimePlusToolkit/main.cpp @@ -1,8 +1,29 @@ +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +#else +# define IMPORT +#endif -int shared_version(); -int static_version(); -int mixed_version(); +IMPORT int shared_version(); + +#ifdef HAS_STATIC_VERSION +IMPORT int static_version(); +#else +int static_version() +{ + return 0; +} +#endif + +#ifdef HAS_MIXED_VERSION +IMPORT int mixed_version(); +#else +int mixed_version() +{ + return 0; +} +#endif int main() { diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp index a05140d..6de6886 100644 --- a/Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp +++ b/Tests/Cuda/StaticRuntimePlusToolkit/mixed.cpp @@ -1,8 +1,16 @@ -int curand_main(); -int nppif_main(); +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif -int mixed_version() +IMPORT int curand_main(); +IMPORT int nppif_main(); + +EXPORT int mixed_version() { return curand_main() == 0 && nppif_main() == 0; } diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp index 2871090..ac5341c 100644 --- a/Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp +++ b/Tests/Cuda/StaticRuntimePlusToolkit/nppif.cpp @@ -1,6 +1,12 @@ // Comes from // https://devtalk.nvidia.com/default/topic/1037482/gpu-accelerated-libraries/help-me-help-you-with-modern-cmake-and-cuda-mwe-for-npp/post/5271066/#5271066 +#ifdef _WIN32 +# define EXPORT __declspec(dllexport) +#else +# define EXPORT +#endif + #include <cstdio> #include <iostream> @@ -8,7 +14,7 @@ #include <cuda_runtime_api.h> #include <nppi_filtering_functions.h> -int nppif_main() +EXPORT int nppif_main() { /** * 8-bit unsigned single-channel 1D row convolution. diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp index 9967b66..f3c3dbc 100644 --- a/Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp +++ b/Tests/Cuda/StaticRuntimePlusToolkit/shared.cpp @@ -1,8 +1,16 @@ +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif + int curand_main(); int nppif_main(); -int shared_version() +EXPORT int shared_version() { return curand_main() == 0 && nppif_main() == 0; } diff --git a/Tests/Cuda/StaticRuntimePlusToolkit/static.cpp b/Tests/Cuda/StaticRuntimePlusToolkit/static.cpp index ca7eb4c..6932fa3 100644 --- a/Tests/Cuda/StaticRuntimePlusToolkit/static.cpp +++ b/Tests/Cuda/StaticRuntimePlusToolkit/static.cpp @@ -1,8 +1,16 @@ -int curand_main(); -int nppif_main(); +#ifdef _WIN32 +# define IMPORT __declspec(dllimport) +# define EXPORT __declspec(dllexport) +#else +# define IMPORT +# define EXPORT +#endif -int static_version() +IMPORT int curand_main(); +IMPORT int nppif_main(); + +EXPORT int static_version() { return curand_main() == 0 && nppif_main() == 0; } diff --git a/Tests/Cuda/Toolkit/CMakeLists.txt b/Tests/Cuda/Toolkit/CMakeLists.txt index 4df29fa..b67aa32 100644 --- a/Tests/Cuda/Toolkit/CMakeLists.txt +++ b/Tests/Cuda/Toolkit/CMakeLists.txt @@ -22,6 +22,9 @@ set(cuda_libs cudart cuda_driver cublas cufft cufftw curand cusolver cusparse) if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.1) list(APPEND cuda_libs cublasLt) endif() +if(CUDAToolkit_VERSION_MAJOR VERSION_GREATER 11) + list(APPEND cuda_libs nvJitLink) +endif() if(CUDAToolkit_VERSION_MAJOR VERSION_LESS 11) list(APPEND cuda_libs nvgraph) endif() @@ -30,6 +33,8 @@ endif() foreach (cuda_lib IN LISTS cuda_libs) if(NOT CUDA_${cuda_lib}_LIBRARY) message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found") + elseif(CUDA_${cuda_lib}_LIBRARY MATCHES [[\.\./]]) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY[\"${CUDA_${cuda_lib}_LIBRARY}\"] to not contain /..") endif() if(NOT TARGET CUDA::${cuda_lib}) message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found") @@ -41,6 +46,9 @@ if(CUDAToolkit_VERSION_MAJOR VERSION_LESS 11) list(APPEND npp_libs nppicom) endif() foreach (cuda_lib IN LISTS npp_libs) + if(CUDA_${cuda_lib}_LIBRARY MATCHES [[\.\./]]) + message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY[\"${CUDA_${cuda_lib}_LIBRARY}\"] to not contain /..") + endif() if(NOT TARGET CUDA::${cuda_lib}) message(FATAL_ERROR "The CUDA::${cuda_lib} target was expected but couldn't be found") endif() |