Skip to content

Commit

Permalink
grid: Check for errors after GPU kernel launch
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed May 16, 2023
1 parent b823aae commit 801dac1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/grid/gpu/grid_gpu_collocate.cu
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ void grid_gpu_collocate_one_grid_level(
collocate_kernel_anyfunc<<<nblocks, threads_per_block, smem_per_block,
stream>>>(params);
}
OFFLOAD_CHECK(offloadGetLastError());
}

#endif // defined(__OFFLOAD) && !defined(__NO_OFFLOAD_GRID)
Expand Down
1 change: 1 addition & 0 deletions src/grid/gpu/grid_gpu_integrate.cu
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ void grid_gpu_integrate_one_grid_level(
grid_integrate_tau_forces<<<nblocks, threads_per_block, smem_per_block,
stream>>>(params);
}
OFFLOAD_CHECK(offloadGetLastError());
}

#endif // defined(__OFFLOAD) && !defined(__NO_OFFLOAD_GRID)
Expand Down
15 changes: 9 additions & 6 deletions src/offload/offload_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ typedef hipError_t offloadError_t;
* \brief Check given Cuda status and upon failure abort with a nice message.
* \author Ole Schuett
******************************************************************************/
#define OFFLOAD_CHECK(status) \
if (status != offloadSuccess) { \
fprintf(stderr, "ERROR: %s %s %d\n", offloadGetErrorName(status), \
__FILE__, __LINE__); \
abort(); \
}
#define OFFLOAD_CHECK(cmd) \
do { \
offloadError_t error = cmd; \
if (error != offloadSuccess) { \
fprintf(stderr, "ERROR: %s %s %d\n", offloadGetErrorName(error), \
__FILE__, __LINE__); \
abort(); \
} \
} while (0)

/*******************************************************************************
* \brief Wrapper around cudaGetErrorName.
Expand Down

0 comments on commit 801dac1

Please sign in to comment.