summaryrefslogtreecommitdiffstats
path: root/Tests/CudaOnly
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2018-10-22 14:54:44 (GMT)
committerBrad King <brad.king@kitware.com>2018-10-24 14:15:48 (GMT)
commit2cc050b53b4afb1ed62621360b860e25b7c46015 (patch)
treec2446498b1c4db63138987a8d62390c5c1478e34 /Tests/CudaOnly
parent83c13ca44f661ba22acf4abe63d84fd5651b4dbc (diff)
downloadCMake-2cc050b53b4afb1ed62621360b860e25b7c46015.zip
CMake-2cc050b53b4afb1ed62621360b860e25b7c46015.tar.gz
CMake-2cc050b53b4afb1ed62621360b860e25b7c46015.tar.bz2
CUDA: Add test for device linking when host linking uses threads
Convert the `CudaOnly.LinkSystemDeviceLibraries` test to a new `Cuda.ProperDeviceLibraries` test. The former covered only the `cublas_device` library which is removed by CUDA 10. Extend the new test to also cover various cases of using threads. Issue: #18008
Diffstat (limited to 'Tests/CudaOnly')
-rw-r--r--Tests/CudaOnly/CMakeLists.txt1
-rw-r--r--Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt15
-rw-r--r--Tests/CudaOnly/LinkSystemDeviceLibraries/main.cu83
3 files changed, 0 insertions, 99 deletions
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt
index 5b7c0e6..9c4f86a 100644
--- a/Tests/CudaOnly/CMakeLists.txt
+++ b/Tests/CudaOnly/CMakeLists.txt
@@ -3,7 +3,6 @@ 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/LinkSystemDeviceLibraries/CMakeLists.txt b/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt
deleted file mode 100644
index 7f7f606..0000000
--- a/Tests/CudaOnly/LinkSystemDeviceLibraries/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-cmake_minimum_required(VERSION 3.8)
-project(LinkSystemDeviceLibraries 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;
-}