15
15
16
16
#include " ../common.hpp"
17
17
#include " logger/ur_logger.hpp"
18
+ namespace {
19
+ const char * desturctorNames[] = {
20
+ " zeKernelDestroy" ,
21
+ " zeEventDestroy" ,
22
+ " zeEventPoolDestroy" ,
23
+ " zeContextDestroy" ,
24
+ " zeCommandListDestroy"
25
+ };
26
+ }
18
27
19
28
namespace v2 {
20
29
21
30
namespace raii {
22
31
23
- template <typename ZeHandleT, ze_result_t (*destroy)(ZeHandleT)>
32
+ template <typename ZeHandleT, ze_result_t (*destroy)(ZeHandleT), size_t nameId >
24
33
struct ze_handle_wrapper {
25
34
ze_handle_wrapper (bool ownZeHandle = true )
26
35
: handle(nullptr ), ownZeHandle(ownZeHandle) {}
@@ -65,7 +74,7 @@ struct ze_handle_wrapper {
65
74
}
66
75
67
76
if (ownZeHandle) {
68
- auto zeResult = ZE_CALL_NOCHECK (destroy, (handle));
77
+ auto zeResult = ZE_CALL_NOCHECK_NAME (destroy, (handle), desturctorNames[nameId] );
69
78
// Gracefully handle the case that L0 was already unloaded.
70
79
if (zeResult && zeResult != ZE_RESULT_ERROR_UNINITIALIZED)
71
80
throw ze2urResult (zeResult);
@@ -90,19 +99,19 @@ struct ze_handle_wrapper {
90
99
};
91
100
92
101
using ze_kernel_handle_t =
93
- ze_handle_wrapper<::ze_kernel_handle_t , zeKernelDestroy>;
102
+ ze_handle_wrapper<::ze_kernel_handle_t , zeKernelDestroy, 0 >;
94
103
95
104
using ze_event_handle_t =
96
- ze_handle_wrapper<::ze_event_handle_t , zeEventDestroy>;
105
+ ze_handle_wrapper<::ze_event_handle_t , zeEventDestroy, 1 >;
97
106
98
107
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 >;
100
109
101
110
using ze_context_handle_t =
102
- ze_handle_wrapper<::ze_context_handle_t , zeContextDestroy>;
111
+ ze_handle_wrapper<::ze_context_handle_t , zeContextDestroy, 3 >;
103
112
104
113
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 >;
106
115
107
116
} // namespace raii
108
117
} // namespace v2
0 commit comments