diff options
Diffstat (limited to 'Tests/Cuda/StaticRuntimePlusToolkit')
-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 |
7 files changed, 86 insertions, 21 deletions
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; } |