     double *buf_xs = NULL;
     double *buf_ys = NULL;
     // Allocate memory and copy to device
-    cudaMalloc( &buf_xs, n*sizeof(double) );
-    cudaMalloc( &buf_ys, n*sizeof(double) );
-    cudaMemcpy(buf_xs, xs, n*sizeof(double), cudaMemcpyHostToDevice);
-    cudaMemcpy(buf_ys, ys, n*sizeof(double), cudaMemcpyHostToDevice);
+    GPU_ASSERT( cudaMalloc( &buf_xs, n*sizeof(double) ) );
+    GPU_ASSERT( cudaMalloc( &buf_ys, n*sizeof(double) ) );
+    GPU_ASSERT( cudaMemcpy(buf_xs, xs, n*sizeof(double), cudaMemcpyHostToDevice) );
+    GPU_ASSERT( cudaMemcpy(buf_ys, ys, n*sizeof(double), cudaMemcpyHostToDevice) );
     // Execute kernel
     dotp_kernel<<<grid, block>>>(buf_xs, buf_ys);
     // Free buffers & obtain data
     cudaFree( &buf_xs );
     cudaFree( &buf_ys );
     double res;
-    cudaMemcpyFromSymbol(&res, g_res, sizeof(double), 0, cudaMemcpyDeviceToHost);
+    GPU_ASSERT( cudaMemcpyFromSymbol(&res, g_res, sizeof(double), 0, cudaMemcpyDeviceToHost) );
     return res;
 }

    double mine = xs[idx] * ys[idx];
    atomicAdd(&g_res, mine);
}

/* Execute kernel on GPU */
extern "C"


#include <stdio.h>
/* Global variable for returning result of computation */
__device__ float g_res;

