Skip to content

Commit c414b96

Browse files
committed
Remove interop handle tracking support
Signed-off-by: Neil R. Spruit <[email protected]>
1 parent 0ab2423 commit c414b96

File tree

6 files changed

+16
-29
lines changed

6 files changed

+16
-29
lines changed

unified-runtime/source/adapters/level_zero/v2/memory.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,10 @@ ur_integrated_buffer_handle_t::ur_integrated_buffer_handle_t(
107107

108108
ur_integrated_buffer_handle_t::ur_integrated_buffer_handle_t(
109109
ur_context_handle_t hContext, void *hostPtr, size_t size,
110-
device_access_mode_t accessMode, bool ownHostPtr, bool interopNativeHandle)
110+
device_access_mode_t accessMode, bool ownHostPtr)
111111
: ur_mem_buffer_t(hContext, size, accessMode) {
112-
this->IsInteropNativeHandle = interopNativeHandle;
113112
this->ptr =
114-
usm_unique_ptr_t(hostPtr, [hContext, ownHostPtr, this](void *ptr) {
113+
usm_unique_ptr_t(hostPtr, [hContext, ownHostPtr](void *ptr) {
115114
if (!ownHostPtr || !checkL0LoaderTeardown()) {
116115
return;
117116
}
@@ -222,7 +221,7 @@ ur_discrete_buffer_handle_t::ur_discrete_buffer_handle_t(
222221
ur_discrete_buffer_handle_t::ur_discrete_buffer_handle_t(
223222
ur_context_handle_t hContext, ur_device_handle_t hDevice, void *devicePtr,
224223
size_t size, device_access_mode_t accessMode, void *writeBackMemory,
225-
bool ownZePtr, bool interopNativeHandle)
224+
bool ownZePtr)
226225
: ur_mem_buffer_t(hContext, size, accessMode),
227226
deviceAllocations(hContext->getPlatform()->getNumDevices()),
228227
activeAllocationDevice(hDevice), writeBackPtr(writeBackMemory),
@@ -233,9 +232,8 @@ ur_discrete_buffer_handle_t::ur_discrete_buffer_handle_t(
233232
devicePtr = allocateOnDevice(hDevice, size);
234233
} else {
235234
assert(hDevice);
236-
this->IsInteropNativeHandle = interopNativeHandle;
237235
deviceAllocations[hDevice->Id.value()] = usm_unique_ptr_t(
238-
devicePtr, [this, hContext = this->hContext, ownZePtr](void *ptr) {
236+
devicePtr, [hContext = this->hContext, ownZePtr](void *ptr) {
239237
if (!ownZePtr || !checkL0LoaderTeardown()) {
240238
return;
241239
}
@@ -466,10 +464,8 @@ ur_mem_image_t::ur_mem_image_t(ur_context_handle_t hContext,
466464
ur_mem_image_t::ur_mem_image_t(ur_context_handle_t hContext,
467465
const ur_image_format_t *pImageFormat,
468466
const ur_image_desc_t *pImageDesc,
469-
ze_image_handle_t zeImage, bool ownZeImage,
470-
bool interopNativeHandle)
467+
ze_image_handle_t zeImage, bool ownZeImage)
471468
: hContext(hContext), zeImage(zeImage, ownZeImage) {
472-
this->IsInteropNativeHandle = interopNativeHandle;
473469
UR_CALL_THROWS(ur2zeImageDesc(pImageFormat, pImageDesc, zeImageDesc));
474470
}
475471

@@ -611,7 +607,7 @@ ur_result_t urMemBufferCreateWithNativeHandle(
611607

612608
if (useHostBuffer(hContext) && memoryAttrs.type == ZE_MEMORY_TYPE_HOST) {
613609
*phMem = ur_mem_handle_t_::create<ur_integrated_buffer_handle_t>(
614-
hContext, ptr, size, accessMode, ownNativeHandle, true);
610+
hContext, ptr, size, accessMode, ownNativeHandle);
615611
// if useHostBuffer(hContext) is true but the allocation is on device, we'll
616612
// treat it as discrete memory
617613
} else if (memoryAttrs.type == ZE_MEMORY_TYPE_SHARED) {
@@ -623,14 +619,12 @@ ur_result_t urMemBufferCreateWithNativeHandle(
623619
// For host allocation, we need to copy the data to a device buffer
624620
// and then copy it back on release
625621
*phMem = ur_mem_handle_t_::create<ur_discrete_buffer_handle_t>(
626-
hContext, hDevice, nullptr, size, accessMode, ptr, ownNativeHandle,
627-
true);
622+
hContext, hDevice, nullptr, size, accessMode, ptr, ownNativeHandle);
628623
} else {
629624
// For device allocation, we can use it directly
630625
assert(hDevice);
631626
*phMem = ur_mem_handle_t_::create<ur_discrete_buffer_handle_t>(
632-
hContext, hDevice, ptr, size, accessMode, nullptr, ownNativeHandle,
633-
true);
627+
hContext, hDevice, ptr, size, accessMode, nullptr, ownNativeHandle);
634628
}
635629
}
636630

@@ -740,7 +734,7 @@ ur_result_t urMemImageCreateWithNativeHandle(
740734
bool ownNativeHandle = pProperties ? pProperties->isNativeHandleOwned : false;
741735

742736
*phMem = ur_mem_handle_t_::create<ur_mem_image_t>(
743-
hContext, pImageFormat, pImageDesc, zeImage, ownNativeHandle, true);
737+
hContext, pImageFormat, pImageDesc, zeImage, ownNativeHandle);
744738
return UR_RESULT_SUCCESS;
745739
} catch (...) {
746740
return exceptionToResult(std::current_exception());

unified-runtime/source/adapters/level_zero/v2/memory.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
using usm_unique_ptr_t = std::unique_ptr<void, std::function<void(void *)>>;
2121

2222
struct ur_mem_buffer_t : _ur_object {
23-
// Indicates if this object is an interop handle.
24-
bool IsInteropNativeHandle = false;
2523

2624
enum class device_access_mode_t { read_write, read_only, write_only };
2725

@@ -85,7 +83,7 @@ struct ur_integrated_buffer_handle_t : ur_mem_buffer_t {
8583

8684
ur_integrated_buffer_handle_t(ur_context_handle_t hContext, void *hostPtr,
8785
size_t size, device_access_mode_t accesMode,
88-
bool ownHostPtr, bool interopNativeHandle);
86+
bool ownHostPtr);
8987

9088
void *
9189
getDevicePtr(ur_device_handle_t, device_access_mode_t, size_t offset,
@@ -125,8 +123,7 @@ struct ur_discrete_buffer_handle_t : ur_mem_buffer_t {
125123
ur_discrete_buffer_handle_t(ur_context_handle_t hContext,
126124
ur_device_handle_t hDevice, void *devicePtr,
127125
size_t size, device_access_mode_t accesMode,
128-
void *writeBackMemory, bool ownDevicePtr,
129-
bool interopNativeHandle);
126+
void *writeBackMemory, bool ownDevicePtr);
130127

131128
void *
132129
getDevicePtr(ur_device_handle_t, device_access_mode_t, size_t offset,
@@ -206,7 +203,7 @@ struct ur_mem_image_t : _ur_object {
206203
const ur_image_desc_t *pImageDesc, void *pHost);
207204
ur_mem_image_t(ur_context_handle_t, const ur_image_format_t *pImageFormat,
208205
const ur_image_desc_t *pImageDesc, ze_image_handle_t zeImage,
209-
bool ownZeImage, bool interopNativeHandle);
206+
bool ownZeImage);
210207

211208
ze_image_handle_t getZeImage() const { return zeImage.get(); }
212209

unified-runtime/source/adapters/level_zero/v2/queue_create.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ ur_result_t urQueueCreateWithNativeHandle(
5959
}
6060

6161
*phQueue = ur_queue_handle_t_::create<v2::ur_queue_immediate_in_order_t>(
62-
hContext, hDevice, hNativeQueue, flags, ownNativeHandle, true);
62+
hContext, hDevice, hNativeQueue, flags, ownNativeHandle);
6363

6464
return UR_RESULT_SUCCESS;
6565
} catch (...) {

unified-runtime/source/adapters/level_zero/v2/queue_handle.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,4 @@ struct ur_queue_handle_t_ {
4949
},
5050
queue_data);
5151
}
52-
// Indicates if this object is an interop handle.
53-
bool IsInteropNativeHandle = false;
5452
};

unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,13 @@ ur_queue_immediate_in_order_t::ur_queue_immediate_in_order_t(
7777

7878
ur_queue_immediate_in_order_t::ur_queue_immediate_in_order_t(
7979
ur_context_handle_t hContext, ur_device_handle_t hDevice,
80-
ur_native_handle_t hNativeHandle, ur_queue_flags_t flags, bool ownZeQueue,
81-
bool interopNativeHandle)
80+
ur_native_handle_t hNativeHandle, ur_queue_flags_t flags, bool ownZeQueue)
8281
: hContext(hContext), hDevice(hDevice), flags(flags),
8382
commandListManager(
8483
hContext, hDevice,
8584
raii::command_list_unique_handle(
8685
reinterpret_cast<ze_command_list_handle_t>(hNativeHandle),
87-
[ownZeQueue,
88-
interopNativeHandle](ze_command_list_handle_t hZeCommandList) {
86+
[ownZeQueue](ze_command_list_handle_t hZeCommandList) {
8987
if (ownZeQueue) {
9088
if (checkL0LoaderTeardown()) {
9189
ZE_CALL_NOCHECK(zeCommandListDestroy, (hZeCommandList));

unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct ur_queue_immediate_in_order_t : _ur_object, public ur_queue_t_ {
7272
const ur_queue_properties_t *);
7373
ur_queue_immediate_in_order_t(ur_context_handle_t, ur_device_handle_t,
7474
ur_native_handle_t, ur_queue_flags_t,
75-
bool ownZeQueue, bool interopNativeHandle);
75+
bool ownZeQueue);
7676

7777
~ur_queue_immediate_in_order_t();
7878

0 commit comments

Comments
 (0)