diff options
Diffstat (limited to 'Tests/CudaOnly')
-rw-r--r-- | Tests/CudaOnly/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CudaOnly/CircularLinkLine/CMakeLists.txt | 34 | ||||
-rw-r--r-- | Tests/CudaOnly/CircularLinkLine/file1.cu | 6 | ||||
-rw-r--r-- | Tests/CudaOnly/CircularLinkLine/file2.cu | 6 | ||||
-rw-r--r-- | Tests/CudaOnly/CircularLinkLine/file3.cu | 8 | ||||
-rw-r--r-- | Tests/CudaOnly/CircularLinkLine/main.cu | 5 | ||||
-rw-r--r-- | Tests/CudaOnly/EnableStandard/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CudaOnly/ExportPTX/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt | 15 | ||||
-rw-r--r-- | Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu | 83 | ||||
-rw-r--r-- | Tests/CudaOnly/PDB/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CudaOnly/SeparateCompilation/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CudaOnly/WithDefs/CMakeLists.txt | 2 |
15 files changed, 67 insertions, 106 deletions
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index 59f3e84..9c4f86a 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -1,8 +1,8 @@ +ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine) ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard) ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX) ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag) -ADD_TEST_MACRO(CudaOnly.LinkSystemDeviceLibraries CudaOnlyLinkSystemDeviceLibraries) ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols) ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation) ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs) diff --git a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt new file mode 100644 index 0000000..5e6f7ab --- /dev/null +++ b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.7) +project (CircularLinkLine CUDA) + +#Goal for this example: +# Verify that we de-duplicate the device link line +# Verify that a de-duplicated link line still works with circular static libraries + +string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30]") +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CUDA_STANDARD 11) + +add_library(CUDACircularDeviceLinking1 STATIC file1.cu) +add_library(CUDACircularDeviceLinking2 STATIC file2.cu) +add_library(CUDACircularDeviceLinking3 STATIC file3.cu) +add_executable(CudaOnlyCircularLinkLine main.cu) + +target_link_libraries(CUDACircularDeviceLinking1 PUBLIC CUDACircularDeviceLinking2) +target_link_libraries(CUDACircularDeviceLinking2 PUBLIC CUDACircularDeviceLinking3) +target_link_libraries(CUDACircularDeviceLinking3 PUBLIC CUDACircularDeviceLinking1) + +target_link_libraries(CudaOnlyCircularLinkLine PRIVATE CUDACircularDeviceLinking3) + + +set_target_properties(CUDACircularDeviceLinking1 + PROPERTIES + CUDA_SEPARABLE_COMPILATION ON) + +set_target_properties(CUDACircularDeviceLinking2 + PROPERTIES + CUDA_SEPARABLE_COMPILATION ON) + +set_target_properties(CUDACircularDeviceLinking3 + PROPERTIES + CUDA_SEPARABLE_COMPILATION ON) diff --git a/Tests/CudaOnly/CircularLinkLine/file1.cu b/Tests/CudaOnly/CircularLinkLine/file1.cu new file mode 100644 index 0000000..88ac4e3 --- /dev/null +++ b/Tests/CudaOnly/CircularLinkLine/file1.cu @@ -0,0 +1,6 @@ + +extern __device__ int file2_func(int); +int __device__ file1_func(int x) +{ + return file2_func(x); +} diff --git a/Tests/CudaOnly/CircularLinkLine/file2.cu b/Tests/CudaOnly/CircularLinkLine/file2.cu new file mode 100644 index 0000000..b32dbff --- /dev/null +++ b/Tests/CudaOnly/CircularLinkLine/file2.cu @@ -0,0 +1,6 @@ + +extern __device__ int file3_func(int); +int __device__ file2_func(int x) +{ + return x + file3_func(x); +} diff --git a/Tests/CudaOnly/CircularLinkLine/file3.cu b/Tests/CudaOnly/CircularLinkLine/file3.cu new file mode 100644 index 0000000..7f67187 --- /dev/null +++ b/Tests/CudaOnly/CircularLinkLine/file3.cu @@ -0,0 +1,8 @@ + +extern __device__ int file1_func(int); +int __device__ file3_func(int x) +{ + if (x > 0) + return file1_func(-x); + return x; +} diff --git a/Tests/CudaOnly/CircularLinkLine/main.cu b/Tests/CudaOnly/CircularLinkLine/main.cu new file mode 100644 index 0000000..1c19e8d --- /dev/null +++ b/Tests/CudaOnly/CircularLinkLine/main.cu @@ -0,0 +1,5 @@ + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/CudaOnly/EnableStandard/CMakeLists.txt b/Tests/CudaOnly/EnableStandard/CMakeLists.txt index 35a1deb..54e2c14 100644 --- a/Tests/CudaOnly/EnableStandard/CMakeLists.txt +++ b/Tests/CudaOnly/EnableStandard/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.7) -project (CudaOnlyEnableStandard CUDA) +project (EnableStandard CUDA) #Goal for this example: #build cuda sources that require C++11 to be enabled. diff --git a/Tests/CudaOnly/ExportPTX/CMakeLists.txt b/Tests/CudaOnly/ExportPTX/CMakeLists.txt index 65d5243..ff6e77c 100644 --- a/Tests/CudaOnly/ExportPTX/CMakeLists.txt +++ b/Tests/CudaOnly/ExportPTX/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.8) -project (CudaOnlyExportPTX CUDA) +project (ExportPTX CUDA) #Goal for this example: # How to generate PTX files instead of OBJECT files diff --git a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt index 5b96906..fbef15f 100644 --- a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt +++ b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.7) -project (CudaOnlGPUDebugFlag CUDA) +project (GPUDebugFlag CUDA) #Goal for this example: #verify that -G enables gpu debug flags diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt b/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt deleted file mode 100644 index 62be1e6..0000000 --- a/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(CudaOnlyLinkSystemDeviceLibraries CUDA) - -string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35") -set(CMAKE_CUDA_STANDARD 11) - -add_executable(CudaOnlyLinkSystemDeviceLibraries main.cu) -set_target_properties( CudaOnlyLinkSystemDeviceLibraries - PROPERTIES CUDA_SEPARABLE_COMPILATION ON) -target_link_libraries( CudaOnlyLinkSystemDeviceLibraries PRIVATE cublas_device) - -if(APPLE) - # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. - set_property(TARGET CudaOnlyLinkSystemDeviceLibraries PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) -endif() diff --git a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu b/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu deleted file mode 100644 index 2c7c388..0000000 --- a/Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu +++ /dev/null @@ -1,83 +0,0 @@ - -#include <cublas_v2.h> -#include <cuda_runtime.h> -#include <iostream> - -// this test only makes sense for versions of CUDA that ships -// static libraries that have separable compilation device symbols -#if __CUDACC_VER_MAJOR__ <= 9 -__global__ void deviceCublasSgemm(int n, float alpha, float beta, - const float* d_A, const float* d_B, - float* d_C) -{ - cublasHandle_t cnpHandle; - cublasStatus_t status = cublasCreate(&cnpHandle); - - if (status != CUBLAS_STATUS_SUCCESS) { - return; - } - - // Call function defined in the cublas_device system static library. - // This way we can verify that we properly pass system libraries to the - // device link line - status = cublasSgemm(cnpHandle, CUBLAS_OP_N, CUBLAS_OP_N, n, n, n, &alpha, - d_A, n, d_B, n, &beta, d_C, n); - - cublasDestroy(cnpHandle); -} -#endif - -int choose_cuda_device() -{ - int nDevices = 0; - cudaError_t err = cudaGetDeviceCount(&nDevices); - if (err != cudaSuccess) { - std::cerr << "Failed to retrieve the number of CUDA enabled devices" - << std::endl; - return 1; - } - for (int i = 0; i < nDevices; ++i) { - cudaDeviceProp prop; - cudaError_t err = cudaGetDeviceProperties(&prop, i); - if (err != cudaSuccess) { - std::cerr << "Could not retrieve properties from CUDA device " << i - << std::endl; - return 1; - } - - if (prop.major > 3 || (prop.major == 3 && prop.minor >= 5)) { - err = cudaSetDevice(i); - if (err != cudaSuccess) { - std::cout << "Could not select CUDA device " << i << std::endl; - } else { - return 0; - } - } - } - - std::cout << "Could not find a CUDA enabled card supporting compute >=3.5" - << std::endl; - return 1; -} - -int main(int argc, char** argv) -{ - int ret = choose_cuda_device(); - if (ret) { - return 0; - } - -#if __CUDACC_VER_MAJOR__ <= 9 - // initial values that will make sure that the cublasSgemm won't actually - // do any work - int n = 0; - float alpha = 1; - float beta = 1; - float* d_A = nullptr; - float* d_B = nullptr; - float* d_C = nullptr; - deviceCublasSgemm<<<1, 1>>>(n, alpha, beta, d_A, d_B, d_C); -#endif - - return 0; -} diff --git a/Tests/CudaOnly/PDB/CMakeLists.txt b/Tests/CudaOnly/PDB/CMakeLists.txt index 34e1e5c..6ecf989 100644 --- a/Tests/CudaOnly/PDB/CMakeLists.txt +++ b/Tests/CudaOnly/PDB/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.11) -project (CudaOnlyPDB CUDA) +project (PDB CUDA) add_executable(CudaOnlyPDB main.cu) set_target_properties(CudaOnlyPDB PROPERTIES diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt index 0c453a9..796e133 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.7) -project (CudaOnlyResolveDeviceSymbols CUDA) +project (ResolveDeviceSymbols CUDA) # Find nm and dumpbin if(CMAKE_NM) diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt index c934c51..1e574d6 100644 --- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.7) -project (CudaOnlySeparateCompilation CUDA) +project (SeparateCompilation CUDA) #Goal for this example: #Build a static library that defines multiple methods and kernels that diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index 926d9ed..e58204d 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.7) -project (CudaOnlyWithDefs CUDA) +project (WithDefs CUDA) #verify that we can pass explicit cuda arch flags string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") |