Tests: Don't presume that Linux CUDA Toolkits provide static libs
This commit is contained in:
parent
9278ae6f1b
commit
54d8044084
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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>)
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user