summaryrefslogtreecommitdiffstats
path: root/Tests/Cuda/Complex/dynamic.cu
diff options
context:
space:
mode:
authorPierre Moreau <dev@pmoreau.org>2017-02-02 12:58:09 (GMT)
committerBrad King <brad.king@kitware.com>2017-02-10 18:46:07 (GMT)
commitc0d7bb8368c3d157d1a2758b620fc726355e554d (patch)
tree20c1862708d423f6375eb86929c1ba6cc7bccc47 /Tests/Cuda/Complex/dynamic.cu
parent21a125cdbff24efa746249a3b8ccc6296c5f0aff (diff)
downloadCMake-c0d7bb8368c3d157d1a2758b620fc726355e554d.zip
CMake-c0d7bb8368c3d157d1a2758b620fc726355e554d.tar.gz
CMake-c0d7bb8368c3d157d1a2758b620fc726355e554d.tar.bz2
Tests/Cuda: Print asynchronous error messages, if any
As kernel launches are asynchronous, a `cudaGetLastError()` right after the kernel launch might be executed while the kernel is still running. Synchronizing the device will ensure that all the work is completed before progressing further on, and allows to catch errors that were previously missed. The `cudaGetLastError()` after the `cudaDeviceSynchronize()` is there to reset the error variable to `cudaSuccess`.
Diffstat (limited to 'Tests/Cuda/Complex/dynamic.cu')
-rw-r--r--Tests/Cuda/Complex/dynamic.cu6
1 files changed, 6 insertions, 0 deletions
diff --git a/Tests/Cuda/Complex/dynamic.cu b/Tests/Cuda/Complex/dynamic.cu
index fc22c8b..0206bb4 100644
--- a/Tests/Cuda/Complex/dynamic.cu
+++ b/Tests/Cuda/Complex/dynamic.cu
@@ -31,4 +31,10 @@ EXPORT void cuda_dynamic_lib_func()
std::cerr << "DetermineIfValidCudaDevice [SYNC] failed: "
<< cudaGetErrorString(err) << std::endl;
}
+ err = cudaDeviceSynchronize();
+ if(err != cudaSuccess)
+ {
+ std::cerr << "DetermineIfValidCudaDevice [ASYNC] failed: "
+ << cudaGetErrorString(cudaGetLastError()) << std::endl;
+ }
}