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
1928namespace v2 {
2029
2130namespace raii {
2231
23- template <typename ZeHandleT, ze_result_t (*destroy)(ZeHandleT)>
32+ template <typename ZeHandleT, ze_result_t (*destroy)(ZeHandleT), size_t nameId >
2433struct 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
92101using ze_kernel_handle_t =
93- ze_handle_wrapper<::ze_kernel_handle_t , zeKernelDestroy>;
102+ ze_handle_wrapper<::ze_kernel_handle_t , zeKernelDestroy, 0 >;
94103
95104using ze_event_handle_t =
96- ze_handle_wrapper<::ze_event_handle_t , zeEventDestroy>;
105+ ze_handle_wrapper<::ze_event_handle_t , zeEventDestroy, 1 >;
97106
98107using 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
101110using ze_context_handle_t =
102- ze_handle_wrapper<::ze_context_handle_t , zeContextDestroy>;
111+ ze_handle_wrapper<::ze_context_handle_t , zeContextDestroy, 3 >;
103112
104113using 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
0 commit comments