Skip to content

Commit 02383b0

Browse files
JackAKirkfabiomestre
authored andcommitted
[UR][CUDA][HIP] Replace ur::assertion with UR_CHECK_ERROR (#10986)
Lots of hip/cu driver API calls were wrapped in `ur::assertion(res == CU_SUCCESS)` etc which: - Means that any native error messages returned from the affected driver api calls were lost. - Since these APIs report errors asynchronously, such that they are thrown from the last API call rather than the call which led to the error, previous asynchronous error messages from different APIs to the ones wrapped by the `ur::assertion` could also be lost depending on user code. These problems are fixed by swapping these assertions with `UR_CHECK_ERROR`. Note that in the future UR may want to adjust `UR_CHECK_ERROR` so that it throws `UR_RESULT_ERROR_ADAPTER_SPECIFIC` etc instead of using `std::cerr` etc to report the error etc. But I think it makes sense to still use `UR_CHECK_ERROR` to wrap driver API calls because it means that the __LINE__, __FUNCTION__ etc info can be correctly passed to native error reporting. --------- Signed-off-by: JackAKirk <jack.kirk@codeplay.com>
1 parent 7ba3c58 commit 02383b0

File tree

3 files changed

+156
-232
lines changed

3 files changed

+156
-232
lines changed

context.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextGetInfo(
8484
}
8585
case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: {
8686
int Major = 0;
87-
detail::ur::assertion(
88-
cuDeviceGetAttribute(&Major,
89-
CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
90-
hContext->getDevice()->get()) == CUDA_SUCCESS);
87+
UR_CHECK_ERROR(cuDeviceGetAttribute(
88+
&Major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
89+
hContext->getDevice()->get()));
9190
uint32_t Capabilities =
9291
(Major >= 7) ? UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
9392
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |

0 commit comments

Comments
 (0)