summaryrefslogtreecommitdiff
path: root/Tests/Cuda/Complex/file3.cu
diff options
context:
space:
mode:
authorPierre Moreau <dev@pmoreau.org>2017-02-02 13:58:09 +0100
committerBrad King <brad.king@kitware.com>2017-02-10 13:46:07 -0500
commitc0d7bb8368c3d157d1a2758b620fc726355e554d (patch)
tree20c1862708d423f6375eb86929c1ba6cc7bccc47 /Tests/Cuda/Complex/file3.cu
parent21a125cdbff24efa746249a3b8ccc6296c5f0aff (diff)
downloadcmake-c0d7bb8368c3d157d1a2758b620fc726355e554d.tar.gz
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/file3.cu')
-rw-r--r--Tests/Cuda/Complex/file3.cu7
1 files changed, 7 insertions, 0 deletions
diff --git a/Tests/Cuda/Complex/file3.cu b/Tests/Cuda/Complex/file3.cu
index 1daf47e0c5..912105a79b 100644
--- a/Tests/Cuda/Complex/file3.cu
+++ b/Tests/Cuda/Complex/file3.cu
@@ -26,5 +26,12 @@ int file3_launch_kernel(int x)
<< cudaGetErrorString(err) << std::endl;
return x;
}
+ err = cudaDeviceSynchronize();
+ if(err != cudaSuccess)
+ {
+ std::cerr << "file3_kernel [ASYNC] failed: "
+ << cudaGetErrorString(cudaGetLastError()) << std::endl;
+ return x;
+ }
return r.sum;
}