Skip to content

Commit 019a66c

Browse files
committed
[Common] Add UR_CALL_THROWS
Similarly to ZE2UR_CALL_THROWS it makes handling errors in constructors easy.
1 parent a96fcbc commit 019a66c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

source/adapters/level_zero/common.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static auto getUrResultString = [](ur_result_t Result) {
168168
}
169169
};
170170

171-
// Trace an internal PI call; returns in case of an error.
171+
// Trace an internal UR call; returns in case of an error.
172172
#define UR_CALL(Call) \
173173
{ \
174174
if (PrintTrace) \
@@ -180,6 +180,18 @@ static auto getUrResultString = [](ur_result_t Result) {
180180
return Result; \
181181
}
182182

183+
// Trace an internal UR call; throw in case of an error.
184+
#define UR_CALL_THROWS(Call) \
185+
{ \
186+
if (PrintTrace) \
187+
logger::always("UR ---> {}", #Call); \
188+
ur_result_t Result = (Call); \
189+
if (PrintTrace) \
190+
logger::always("UR <--- {}({})", #Call, getUrResultString(Result)); \
191+
if (Result != UR_RESULT_SUCCESS) \
192+
throw Result; \
193+
}
194+
183195
// Controls UR L0 calls tracing.
184196
enum UrDebugLevel {
185197
UR_L0_DEBUG_NONE = 0x0,

0 commit comments

Comments
 (0)