Commit 64e3c3be authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

CUDA error check

parent b08534ce
Pipeline #16404 passed with stage
in 2 seconds
......@@ -28,16 +28,25 @@ void reduce(double *arr) {
uint64_t len = npts >> 1;
while (1) {
reduce_sum<<<blocks,threads>>>(arr,len);
cudaCheck("reduce");
len = len >> 1;
if (len == 0)
return;
}
}
void cudaCheck(string msg) {
cudaError err;
err = cudaGetLastError();
if (cudaSuccess != err)
cerr << msg << ": " << cudaGetErrorString(err) << endl;
}
int main(void) {
double harr[1],*darr;
cudaMalloc(&darr,npts*sizeof(double));
cudaCheck("cudaMalloc");
auto tstart = std::chrono::high_resolution_clock::now();
init<<<blocks,threads>>>(darr,nloop);
cudaCheck("init");
reduce(darr);
cudaDeviceSynchronize();
auto tend = std::chrono::high_resolution_clock::now();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment