From: Daniel Arndt Date: Fri, 20 Oct 2017 14:20:59 +0000 (+0200) Subject: Add AssertCuda checks X-Git-Tag: v9.0.0-rc1~924^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8926f50f8a2f9aa978623ed754cd714325fb5542;p=dealii.git Add AssertCuda checks --- diff --git a/tests/quick_tests/cuda.cu b/tests/quick_tests/cuda.cu index 2c65d06cd2..841a0dbb19 100644 --- a/tests/quick_tests/cuda.cu +++ b/tests/quick_tests/cuda.cu @@ -37,18 +37,23 @@ int main() // Copy input data to device. double *device_x; double *device_y; - cudaMalloc(&device_x, n * sizeof(double)); - cudaMalloc(&device_y, n * sizeof(double)); - cudaMemcpy(device_x, host_x.data(), n * sizeof(double), - cudaMemcpyHostToDevice); + cudaError_t cuda_error = cudaMalloc(&device_x, n * sizeof(double)); + AssertCuda(cuda_error); + cuda_error = cudaMalloc(&device_y, n * sizeof(double)); + AssertCuda(cuda_error); + cuda_error = cudaMemcpy(device_x, host_x.data(), n * sizeof(double), + cudaMemcpyHostToDevice); + AssertCuda(cuda_error); // Launch the kernel. double_value<<<1, n>>>(device_x, device_y); // Copy output data to host. - cudaDeviceSynchronize(); - cudaMemcpy(host_y.data(), device_y, n * sizeof(double), - cudaMemcpyDeviceToHost); + cuda_error = cudaDeviceSynchronize(); + AssertCuda(cuda_error); + cuda_error = cudaMemcpy(host_y.data(), device_y, n * sizeof(double), + cudaMemcpyDeviceToHost); + AssertCuda(cuda_error); // Print the results and test for (int i = 0; i < n; ++i) @@ -57,6 +62,7 @@ int main() AssertThrow(std::abs(host_y[i]-2*host_x[i])<1.e-10, ExcInternalError()); } - cudaDeviceReset(); + cuda_error = cudaDeviceReset(); + AssertCuda(cuda_error); return 0; }