Skip to content

Commit 08948b7

Browse files
committed
Fix calls to ze destructors
1 parent c0e74d3 commit 08948b7

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

source/adapters/level_zero/common.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ bool setEnvVar(const char *name, const char *value);
340340
// Map Level Zero runtime error code to UR error code.
341341
ur_result_t ze2urResult(ze_result_t ZeResult);
342342

343+
// Parse Level Zero error code and return the error string.
344+
void zeParseError(ze_result_t ZeError, const char *&ErrorString);
345+
343346
// Trace a call to Level-Zero RT
344347
#define ZE2UR_CALL(ZeName, ZeArgs) \
345348
{ \
@@ -359,6 +362,9 @@ ur_result_t ze2urResult(ze_result_t ZeResult);
359362
// Perform traced call to L0 without checking for errors
360363
#define ZE_CALL_NOCHECK(ZeName, ZeArgs) \
361364
ZeCall().doCall(ZeName ZeArgs, #ZeName, #ZeArgs, false)
365+
366+
#define ZE_CALL_NOCHECK_NAME(ZeName, ZeArgs, callName) \
367+
ZeCall().doCall(ZeName ZeArgs, callName, #ZeArgs, false)
362368

363369
// This wrapper around std::atomic is created to limit operations with reference
364370
// counter and to make allowed operations more transparent in terms of

source/adapters/level_zero/v2/common.hpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,21 @@
1515

1616
#include "../common.hpp"
1717
#include "logger/ur_logger.hpp"
18+
namespace {
19+
const char* desturctorNames[] = {
20+
"zeKernelDestroy",
21+
"zeEventDestroy",
22+
"zeEventPoolDestroy",
23+
"zeContextDestroy",
24+
"zeCommandListDestroy"
25+
};
26+
}
1827

1928
namespace v2 {
2029

2130
namespace raii {
2231

23-
template <typename ZeHandleT, ze_result_t (*destroy)(ZeHandleT)>
32+
template <typename ZeHandleT, ze_result_t (*destroy)(ZeHandleT), size_t nameId>
2433
struct ze_handle_wrapper {
2534
ze_handle_wrapper(bool ownZeHandle = true)
2635
: handle(nullptr), ownZeHandle(ownZeHandle) {}
@@ -65,7 +74,7 @@ struct ze_handle_wrapper {
6574
}
6675

6776
if (ownZeHandle) {
68-
auto zeResult = ZE_CALL_NOCHECK(destroy, (handle));
77+
auto zeResult = ZE_CALL_NOCHECK_NAME(destroy, (handle), desturctorNames[nameId]);
6978
// Gracefully handle the case that L0 was already unloaded.
7079
if (zeResult && zeResult != ZE_RESULT_ERROR_UNINITIALIZED)
7180
throw ze2urResult(zeResult);
@@ -90,19 +99,19 @@ struct ze_handle_wrapper {
9099
};
91100

92101
using ze_kernel_handle_t =
93-
ze_handle_wrapper<::ze_kernel_handle_t, zeKernelDestroy>;
102+
ze_handle_wrapper<::ze_kernel_handle_t, zeKernelDestroy, 0>;
94103

95104
using ze_event_handle_t =
96-
ze_handle_wrapper<::ze_event_handle_t, zeEventDestroy>;
105+
ze_handle_wrapper<::ze_event_handle_t, zeEventDestroy, 1>;
97106

98107
using ze_event_pool_handle_t =
99-
ze_handle_wrapper<::ze_event_pool_handle_t, zeEventPoolDestroy>;
108+
ze_handle_wrapper<::ze_event_pool_handle_t, zeEventPoolDestroy, 2>;
100109

101110
using ze_context_handle_t =
102-
ze_handle_wrapper<::ze_context_handle_t, zeContextDestroy>;
111+
ze_handle_wrapper<::ze_context_handle_t, zeContextDestroy, 3>;
103112

104113
using ze_command_list_handle_t =
105-
ze_handle_wrapper<::ze_command_list_handle_t, zeCommandListDestroy>;
114+
ze_handle_wrapper<::ze_command_list_handle_t, zeCommandListDestroy, 4>;
106115

107116
} // namespace raii
108117
} // namespace v2

source/adapters/level_zero/v2/queue_immediate_in_order.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ ur_command_list_handler_t::ur_command_list_handler_t(
7373
: commandList(hZeCommandList,
7474
[ownZeHandle](ze_command_list_handle_t hZeCommandList) {
7575
if (ownZeHandle) {
76-
zeCommandListDestroy(hZeCommandList);
76+
ZE_CALL_NOCHECK(zeCommandListDestroy, (hZeCommandList));
7777
}
7878
}) {}
7979

0 commit comments

Comments
 (0)