diff options
Diffstat (limited to 'Tests/CudaOnly')
-rw-r--r-- | Tests/CudaOnly/CMakeLists.txt | 7 | ||||
-rw-r--r-- | Tests/CudaOnly/SeparateCompilationPTX/main.cu | 9 | ||||
-rw-r--r-- | Tests/CudaOnly/SharedRuntimePlusToolkit/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/CudaOnly/SharedRuntimePlusToolkit/main.cu | 17 | ||||
-rw-r--r-- | Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt | 24 | ||||
-rw-r--r-- | Tests/CudaOnly/StaticRuntimePlusToolkit/curand.cu | 8 | ||||
-rw-r--r-- | Tests/CudaOnly/StaticRuntimePlusToolkit/main.cu | 27 | ||||
-rw-r--r-- | Tests/CudaOnly/StaticRuntimePlusToolkit/mixed.cu | 14 | ||||
-rw-r--r-- | Tests/CudaOnly/StaticRuntimePlusToolkit/nppif.cu | 8 | ||||
-rw-r--r-- | Tests/CudaOnly/StaticRuntimePlusToolkit/shared.cu | 10 | ||||
-rw-r--r-- | Tests/CudaOnly/StaticRuntimePlusToolkit/static.cu | 14 | ||||
-rw-r--r-- | Tests/CudaOnly/Toolkit/CMakeLists.txt | 10 |
12 files changed, 120 insertions, 38 deletions
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 39634ac..db08076 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -10,6 +10,7 @@ add_cuda_test_macro(CudaOnly.CompileFlags CudaOnlyCompileFlags) add_cuda_test_macro(CudaOnly.EnableStandard CudaOnlyEnableStandard) add_cuda_test_macro(CudaOnly.ExportPTX CudaOnlyExportPTX) add_cuda_test_macro(CudaOnly.SharedRuntimePlusToolkit CudaOnlySharedRuntimePlusToolkit) +add_cuda_test_macro(CudaOnly.StaticRuntimePlusToolkit CudaOnlyStaticRuntimePlusToolkit) add_cuda_test_macro(CudaOnly.Standard98 CudaOnlyStandard98) add_cuda_test_macro(CudaOnly.Toolkit CudaOnlyToolkit) add_cuda_test_macro(CudaOnly.ToolkitBeforeLang CudaOnlyToolkitBeforeLang) @@ -28,12 +29,6 @@ if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang") add_cuda_test_macro(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) endif() -# The CUDA only ships the shared version of the toolkit libraries -# on windows -if(NOT WIN32) - add_cuda_test_macro(CudaOnly.StaticRuntimePlusToolkit CudaOnlyStaticRuntimePlusToolkit) -endif() - add_cuda_test_macro(CudaOnly.DeviceLTO CudaOnlyDeviceLTO) if(MSVC) diff --git a/Tests/CudaOnly/SeparateCompilationPTX/main.cu b/Tests/CudaOnly/SeparateCompilationPTX/main.cu index 164cde5..f94beff 100644 --- a/Tests/CudaOnly/SeparateCompilationPTX/main.cu +++ b/Tests/CudaOnly/SeparateCompilationPTX/main.cu @@ -21,10 +21,11 @@ int main() cuCtxCreate(&context, 0, device); CUmodule module; - cuModuleLoadData(&module, kernels); - if (module == nullptr) { - std::cerr << "Failed to load the embedded ptx" << std::endl; + CUresult result = cuModuleLoadData(&module, kernels); + std::cout << "module pointer: " << module << '\n'; + if (result != CUDA_SUCCESS || module == nullptr) { + std::cerr << "Failed to load the embedded ptx with error: " + << static_cast<unsigned int>(result) << '\n'; return 1; } - std::cout << module << std::endl; } diff --git a/Tests/CudaOnly/SharedRuntimePlusToolkit/CMakeLists.txt b/Tests/CudaOnly/SharedRuntimePlusToolkit/CMakeLists.txt index 03fba22..0b01085 100644 --- a/Tests/CudaOnly/SharedRuntimePlusToolkit/CMakeLists.txt +++ b/Tests/CudaOnly/SharedRuntimePlusToolkit/CMakeLists.txt @@ -16,16 +16,18 @@ target_link_libraries(SharedToolkit PRIVATE Common PUBLIC CUDA::curand CUDA::npp set_target_properties(SharedToolkit PROPERTIES CUDA_RUNTIME_LIBRARY none) 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.cu) + target_compile_definitions(StaticToolkit INTERFACE "HAS_STATIC_VERSION") target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) set_target_properties(StaticToolkit PROPERTIES CUDA_RUNTIME_LIBRARY Shared) - #static runtime with mixed toolkit libraries + #shared runtime with mixed toolkit libraries add_library(MixedToolkit SHARED mixed.cu) + target_compile_definitions(MixedToolkit INTERFACE "HAS_MIXED_VERSION") target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand_static CUDA::nppif) set_target_properties(MixedToolkit PROPERTIES CUDA_RUNTIME_LIBRARY Shared) endif() diff --git a/Tests/CudaOnly/SharedRuntimePlusToolkit/main.cu b/Tests/CudaOnly/SharedRuntimePlusToolkit/main.cu index 2a4da22..d958c3a 100644 --- a/Tests/CudaOnly/SharedRuntimePlusToolkit/main.cu +++ b/Tests/CudaOnly/SharedRuntimePlusToolkit/main.cu @@ -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/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt b/Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt index 534bab2..ae03b66 100644 --- a/Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/CMakeLists.txt @@ -16,17 +16,25 @@ target_link_libraries(SharedToolkit PRIVATE Common CUDA::curand CUDA::nppif ) set_target_properties(SharedToolkit PROPERTIES CUDA_RUNTIME_LIBRARY none) target_link_libraries(SharedToolkit PUBLIC CUDA::cudart_static) -#static runtime with static toolkit libraries -add_library(StaticToolkit SHARED static.cu) -target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_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.cu) + target_compile_definitions(StaticToolkit INTERFACE "HAS_STATIC_VERSION") + target_link_libraries(StaticToolkit PRIVATE Common CUDA::curand_static CUDA::nppif_static) -#static runtime with mixed toolkit libraries -add_library(MixedToolkit SHARED mixed.cu) -target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand CUDA::nppif_static) -set_target_properties(MixedToolkit PROPERTIES CUDA_RUNTIME_LIBRARY Static) + #static runtime with mixed toolkit libraries + add_library(MixedToolkit SHARED mixed.cu) + target_compile_definitions(MixedToolkit INTERFACE "HAS_MIXED_VERSION") + target_link_libraries(MixedToolkit PRIVATE Common CUDA::curand CUDA::nppif_static) + set_target_properties(MixedToolkit PROPERTIES CUDA_RUNTIME_LIBRARY Static) +endif() add_executable(CudaOnlyStaticRuntimePlusToolkit main.cu) -target_link_libraries(CudaOnlyStaticRuntimePlusToolkit PRIVATE SharedToolkit StaticToolkit MixedToolkit) +target_link_libraries(CudaOnlyStaticRuntimePlusToolkit PRIVATE SharedToolkit + $<TARGET_NAME_IF_EXISTS:StaticToolkit> + $<TARGET_NAME_IF_EXISTS:MixedToolkit>) if(UNIX) # Help the shared cuda runtime find libcurand and libnppif when they are not located diff --git a/Tests/CudaOnly/StaticRuntimePlusToolkit/curand.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/curand.cu index 95872f0..fdd7b53 100644 --- a/Tests/CudaOnly/StaticRuntimePlusToolkit/curand.cu +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/curand.cu @@ -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/CudaOnly/StaticRuntimePlusToolkit/main.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/main.cu index 5a09f8e..d958c3a 100644 --- a/Tests/CudaOnly/StaticRuntimePlusToolkit/main.cu +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/main.cu @@ -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/CudaOnly/StaticRuntimePlusToolkit/mixed.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/mixed.cu index a05140d..6de6886 100644 --- a/Tests/CudaOnly/StaticRuntimePlusToolkit/mixed.cu +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/mixed.cu @@ -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/CudaOnly/StaticRuntimePlusToolkit/nppif.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/nppif.cu index 2871090..ac5341c 100644 --- a/Tests/CudaOnly/StaticRuntimePlusToolkit/nppif.cu +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/nppif.cu @@ -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/CudaOnly/StaticRuntimePlusToolkit/shared.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/shared.cu index 9967b66..f3c3dbc 100644 --- a/Tests/CudaOnly/StaticRuntimePlusToolkit/shared.cu +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/shared.cu @@ -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/CudaOnly/StaticRuntimePlusToolkit/static.cu b/Tests/CudaOnly/StaticRuntimePlusToolkit/static.cu index ca7eb4c..6932fa3 100644 --- a/Tests/CudaOnly/StaticRuntimePlusToolkit/static.cu +++ b/Tests/CudaOnly/StaticRuntimePlusToolkit/static.cu @@ -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/CudaOnly/Toolkit/CMakeLists.txt b/Tests/CudaOnly/Toolkit/CMakeLists.txt index 1486c1a..e0801a3 100644 --- a/Tests/CudaOnly/Toolkit/CMakeLists.txt +++ b/Tests/CudaOnly/Toolkit/CMakeLists.txt @@ -20,14 +20,20 @@ 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() + # Verify that all the CUDA:: targets and variables exist 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 +47,8 @@ endif() foreach (cuda_lib ) 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") @@ -50,6 +58,8 @@ endforeach() foreach (cuda_lib nvrtc nvToolsExt OpenCL) 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}) |