Error checking
cudaError_t cudaMalloc( void **devPtr, size_t size);
void *malloc(size_t size);
a_h = (int *) malloc(numElements * sizeof(int));
if(a_h == NULL) {
printf("Error in memory allocation\n");
exit(11);
}
cudaError_T error = cudaMalloc(&d_a, memSize);
if (error != cudaSuccess) {
printf("Error in device allocation:%s\n", cudaGetErrorString(error));
exit(11);
}
Last updated