You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lot of CUDA host codes use a macro to check the error codes of native API calls. E.g.:
#defineCUDA_CHECK_ERROR(call) do { \
cudaError_t err = call; \
if (err != cudaSuccess) { \
std::cerr << "CUDA error in " << __FILE__ << " at line " << __LINE__ << ": " \
<< cudaGetErrorString(err) << std::endl; \
std::exit(EXIT_FAILURE); \
} \
} while (0)
CUDA_CHECK_ERROR(cudaMalloc(...));
CUDA_CHECK_ERROR(cudaDeviceSynchronize());
Given the wide use of such macros, we should provide one in CCCL for public use.
We should probably not name it CUDA_CHECK_ERROR to avoid clashing with equally-named macros in user code, but CCCL_CHECK_ERROR or similar should work. Furthermore, we should probably use exceptions over exiting as error handling strategy, since this is in line with Thrust. Otherwise, we could provide two macros CCCL_THROW_ON_ERROR and CCCL_DIE_ON_ERROR.
The text was updated successfully, but these errors were encountered:
do you mean for internal or external use? IIRC @miscco has strong opinion about exposing macros for user code
For public use, since everybody always has to copy and paste it from somewhere. As a CUDA standard library, we are the ideal place to host such a macro.
Internally, we have _CCCL_TRY_CUDA_API and _CCCL_ASSERT_CUDA_API.
there are tons of macros that are copy&paste in most CUDA projects, e.g. attributes like host/device, nodiscard, etc. or compiler macros, or platform macros. Would be nice to have a similar decision...
A lot of CUDA host codes use a macro to check the error codes of native API calls. E.g.:
Given the wide use of such macros, we should provide one in CCCL for public use.
We should probably not name it
CUDA_CHECK_ERROR
to avoid clashing with equally-named macros in user code, butCCCL_CHECK_ERROR
or similar should work. Furthermore, we should probably use exceptions over exiting as error handling strategy, since this is in line with Thrust. Otherwise, we could provide two macrosCCCL_THROW_ON_ERROR
andCCCL_DIE_ON_ERROR
.The text was updated successfully, but these errors were encountered: