Commit d6068c8f authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

add CUDA errors

parent 468d7ce4
Pipeline #16408 passed with stage
in 0 seconds
......@@ -6,8 +6,8 @@
//
#include <iostream>
#include <chrono>
#include <cstdint>
#include <string>
using namespace std;
uint64_t blocks = 1024;
uint64_t threads = 1024;
uint64_t nloop = 1000000;
......@@ -18,16 +18,6 @@ void cudaCheck(string msg) {
if (cudaSuccess != err)
cerr << msg << ": " << cudaGetErrorString(err) << endl;
}
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;
}
}
__global__ void init(double *arr,uint64_t nloop) {
uint64_t i = blockIdx.x*blockDim.x+threadIdx.x;
uint64_t start = nloop*i+1;
......@@ -41,6 +31,16 @@ __global__ void reduce_sum(double *arr,uint64_t len) {
if (i < len)
arr[i] += arr[i+len];
}
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;
}
}
int main(void) {
double harr[1],*darr;
cudaMalloc(&darr,npts*sizeof(double));
......
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