Skip to content

Commit

Permalink
Fixes #543: Fallback to cudaGetErrorString() for unknown error code…
Browse files Browse the repository at this point in the history
…s, which might be the Runtime API's rather than the Driver API's
  • Loading branch information
eyalroz committed Oct 3, 2023
1 parent f334f6d commit d46a65c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cuda/api/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,14 @@ constexpr bool is_failure(status_t status) { return not is_success(status); }
///@{
inline ::std::string describe(status_t status)
{
// Even though status_t aliases the driver's CUresult type, some values are actually
// runtime error codes. The driver will fail to identify them (they're luckily distinct),
// and we can't distinguish proper failure from the case of a Runtime-API-only error
// code - so we also try the runtime API.
const char* description;
auto description_lookup_status = cuGetErrorString(status, &description);
return (description_lookup_status != CUDA_SUCCESS) ? nullptr : description;
return (description_lookup_status == CUDA_SUCCESS) ?
description : cudaGetErrorString(static_cast<cudaError_t>(status));
}
inline ::std::string describe(cudaError_t status) { return cudaGetErrorString(status); }
///@}
Expand Down

0 comments on commit d46a65c

Please sign in to comment.