@@ -21,15 +21,7 @@ ur_command_list_manager::ur_command_list_manager(
21
21
ur_context_handle_t context, ur_device_handle_t device,
22
22
v2::raii::command_list_unique_handle &&commandList)
23
23
: hContext(context), hDevice(device),
24
- zeCommandList(std::move(commandList)) {
25
- UR_CALL_THROWS (ur::level_zero::urContextRetain (context));
26
- UR_CALL_THROWS (ur::level_zero::urDeviceRetain (device));
27
- }
28
-
29
- ur_command_list_manager::~ur_command_list_manager () {
30
- ur::level_zero::urContextRelease (hContext);
31
- ur::level_zero::urDeviceRelease (hDevice);
32
- }
24
+ zeCommandList(std::move(commandList)) {}
33
25
34
26
ur_result_t ur_command_list_manager::appendGenericFillUnlocked (
35
27
ur_mem_buffer_t *dst, size_t offset, size_t patternSize,
@@ -41,8 +33,8 @@ ur_result_t ur_command_list_manager::appendGenericFillUnlocked(
41
33
auto waitListView = getWaitListView (phEventWaitList, numEventsInWaitList);
42
34
43
35
auto pDst = ur_cast<char *>(dst->getDevicePtr (
44
- hDevice, ur_mem_buffer_t ::device_access_mode_t ::read_only, offset, size ,
45
- zeCommandList.get (), waitListView));
36
+ hDevice. get () , ur_mem_buffer_t ::device_access_mode_t ::read_only, offset,
37
+ size, zeCommandList.get (), waitListView));
46
38
47
39
// PatternSize must be a power of two for zeCommandListAppendMemoryFill.
48
40
// When it's not, the fill is emulated with zeCommandListAppendMemoryCopy.
@@ -78,12 +70,12 @@ ur_result_t ur_command_list_manager::appendGenericCopyUnlocked(
78
70
auto waitListView = getWaitListView (phEventWaitList, numEventsInWaitList);
79
71
80
72
auto pSrc = ur_cast<char *>(src->getDevicePtr (
81
- hDevice, ur_mem_buffer_t ::device_access_mode_t ::read_only, srcOffset ,
82
- size, zeCommandList.get (), waitListView));
73
+ hDevice. get () , ur_mem_buffer_t ::device_access_mode_t ::read_only,
74
+ srcOffset, size, zeCommandList.get (), waitListView));
83
75
84
76
auto pDst = ur_cast<char *>(dst->getDevicePtr (
85
- hDevice, ur_mem_buffer_t ::device_access_mode_t ::write_only, dstOffset ,
86
- size, zeCommandList.get (), waitListView));
77
+ hDevice. get () , ur_mem_buffer_t ::device_access_mode_t ::write_only,
78
+ dstOffset, size, zeCommandList.get (), waitListView));
87
79
88
80
ZE2UR_CALL (zeCommandListAppendMemoryCopy,
89
81
(zeCommandList.get (), pDst, pSrc, size, zeSignalEvent,
@@ -110,10 +102,10 @@ ur_result_t ur_command_list_manager::appendRegionCopyUnlocked(
110
102
auto waitListView = getWaitListView (phEventWaitList, numEventsInWaitList);
111
103
112
104
auto pSrc = ur_cast<char *>(src->getDevicePtr (
113
- hDevice, ur_mem_buffer_t ::device_access_mode_t ::read_only, 0 ,
105
+ hDevice. get () , ur_mem_buffer_t ::device_access_mode_t ::read_only, 0 ,
114
106
src->getSize (), zeCommandList.get (), waitListView));
115
107
auto pDst = ur_cast<char *>(dst->getDevicePtr (
116
- hDevice, ur_mem_buffer_t ::device_access_mode_t ::write_only, 0 ,
108
+ hDevice. get () , ur_mem_buffer_t ::device_access_mode_t ::write_only, 0 ,
117
109
dst->getSize (), zeCommandList.get (), waitListView));
118
110
119
111
ZE2UR_CALL (zeCommandListAppendMemoryCopyRegion,
@@ -168,22 +160,22 @@ ur_result_t ur_command_list_manager::appendKernelLaunchUnlocked(
168
160
UR_ASSERT (workDim > 0 , UR_RESULT_ERROR_INVALID_WORK_DIMENSION);
169
161
UR_ASSERT (workDim < 4 , UR_RESULT_ERROR_INVALID_WORK_DIMENSION);
170
162
171
- ze_kernel_handle_t hZeKernel = hKernel->getZeHandle (hDevice);
163
+ ze_kernel_handle_t hZeKernel = hKernel->getZeHandle (hDevice. get () );
172
164
173
165
std::scoped_lock<ur_shared_mutex> Lock (hKernel->Mutex );
174
166
175
167
ze_group_count_t zeThreadGroupDimensions{1 , 1 , 1 };
176
168
uint32_t WG[3 ]{};
177
- UR_CALL (calculateKernelWorkDimensions (hZeKernel, hDevice,
169
+ UR_CALL (calculateKernelWorkDimensions (hZeKernel, hDevice. get () ,
178
170
zeThreadGroupDimensions, WG, workDim,
179
171
pGlobalWorkSize, pLocalWorkSize));
180
172
181
173
auto zeSignalEvent = getSignalEvent (phEvent, UR_COMMAND_KERNEL_LAUNCH);
182
174
auto waitListView = getWaitListView (phEventWaitList, numEventsInWaitList);
183
175
184
- UR_CALL (hKernel->prepareForSubmission (hContext, hDevice, pGlobalWorkOffset,
185
- workDim, WG[0 ], WG[1 ], WG[ 2 ],
186
- getZeCommandList (), waitListView));
176
+ UR_CALL (hKernel->prepareForSubmission (
177
+ hContext. get (), hDevice. get (), pGlobalWorkOffset, workDim, WG[0 ], WG[1 ],
178
+ WG[ 2 ], getZeCommandList (), waitListView));
187
179
188
180
if (cooperative) {
189
181
TRACK_SCOPE_LATENCY (" ur_command_list_manager::"
@@ -284,7 +276,7 @@ ur_result_t ur_command_list_manager::appendUSMFill(
284
276
ur_event_handle_t phEvent) {
285
277
TRACK_SCOPE_LATENCY (" ur_command_list_manager::appendUSMFill" );
286
278
287
- ur_usm_handle_t dstHandle (hContext, size, pMem);
279
+ ur_usm_handle_t dstHandle (hContext. get () , size, pMem);
288
280
return appendGenericFillUnlocked (&dstHandle, 0 , patternSize, pPattern, size,
289
281
numEventsInWaitList, phEventWaitList,
290
282
phEvent, UR_COMMAND_USM_FILL);
@@ -351,7 +343,7 @@ ur_result_t ur_command_list_manager::appendMemBufferRead(
351
343
auto hBuffer = hMem->getBuffer ();
352
344
UR_ASSERT (offset + size <= hBuffer->getSize (), UR_RESULT_ERROR_INVALID_SIZE);
353
345
354
- ur_usm_handle_t dstHandle (hContext, size, pDst);
346
+ ur_usm_handle_t dstHandle (hContext. get () , size, pDst);
355
347
356
348
std::scoped_lock<ur_shared_mutex> lock (hBuffer->getMutex ());
357
349
@@ -369,7 +361,7 @@ ur_result_t ur_command_list_manager::appendMemBufferWrite(
369
361
auto hBuffer = hMem->getBuffer ();
370
362
UR_ASSERT (offset + size <= hBuffer->getSize (), UR_RESULT_ERROR_INVALID_SIZE);
371
363
372
- ur_usm_handle_t srcHandle (hContext, size, pSrc);
364
+ ur_usm_handle_t srcHandle (hContext. get () , size, pSrc);
373
365
374
366
std::scoped_lock<ur_shared_mutex> lock (hBuffer->getMutex ());
375
367
@@ -410,7 +402,7 @@ ur_result_t ur_command_list_manager::appendMemBufferReadRect(
410
402
TRACK_SCOPE_LATENCY (" ur_command_list_manager::appendMemBufferReadRect" );
411
403
412
404
auto hBuffer = hMem->getBuffer ();
413
- ur_usm_handle_t dstHandle (hContext, 0 , pDst);
405
+ ur_usm_handle_t dstHandle (hContext. get () , 0 , pDst);
414
406
415
407
std::scoped_lock<ur_shared_mutex> lock (hBuffer->getMutex ());
416
408
@@ -430,7 +422,7 @@ ur_result_t ur_command_list_manager::appendMemBufferWriteRect(
430
422
TRACK_SCOPE_LATENCY (" ur_command_list_manager::appendMemBufferWriteRect" );
431
423
432
424
auto hBuffer = hMem->getBuffer ();
433
- ur_usm_handle_t srcHandle (hContext, 0 , pSrc);
425
+ ur_usm_handle_t srcHandle (hContext. get () , 0 , pSrc);
434
426
435
427
std::scoped_lock<ur_shared_mutex> lock (hBuffer->getMutex ());
436
428
@@ -470,8 +462,8 @@ ur_result_t ur_command_list_manager::appendUSMMemcpy2D(
470
462
ur_rect_offset_t zeroOffset{0 , 0 , 0 };
471
463
ur_rect_region_t region{width, height, 0 };
472
464
473
- ur_usm_handle_t srcHandle (hContext, 0 , pSrc);
474
- ur_usm_handle_t dstHandle (hContext, 0 , pDst);
465
+ ur_usm_handle_t srcHandle (hContext. get () , 0 , pSrc);
466
+ ur_usm_handle_t dstHandle (hContext. get () , 0 , pDst);
475
467
476
468
return appendRegionCopyUnlocked (&srcHandle, &dstHandle, blocking, zeroOffset,
477
469
zeroOffset, region, srcPitch, 0 , dstPitch, 0 ,
@@ -784,13 +776,14 @@ ur_result_t ur_command_list_manager::appendUSMAllocHelper(
784
776
pPool = hContext->getAsyncPool ();
785
777
}
786
778
787
- auto device = (type == UR_USM_TYPE_HOST) ? nullptr : hDevice;
779
+ auto device = (type == UR_USM_TYPE_HOST) ? nullptr : hDevice. get () ;
788
780
789
781
ur_event_handle_t originAllocEvent = nullptr ;
790
- auto asyncAlloc = pPool->allocateEnqueued (hContext, Queue, true , device,
782
+ auto asyncAlloc = pPool->allocateEnqueued (hContext. get () , Queue, true , device,
791
783
nullptr , type, size);
792
784
if (!asyncAlloc) {
793
- auto Ret = pPool->allocate (hContext, device, nullptr , type, size, ppMem);
785
+ auto Ret =
786
+ pPool->allocate (hContext.get (), device, nullptr , type, size, ppMem);
794
787
if (Ret) {
795
788
return Ret;
796
789
}
0 commit comments