Skip to content

Commit a799ff4

Browse files
committed
Merge branch 'ibuf3' of https://github.com/rdeodhar/llvm into ibuf3
2 parents a031173 + 4e7dc77 commit a799ff4

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3321,14 +3321,7 @@ pi_result piEventsWait(pi_uint32 NumEvents, const pi_event *EventList) {
33213321
for (uint32_t I = 0; I < NumEvents; I++) {
33223322
ze_event_handle_t ZeEvent = EventList[I]->ZeEvent;
33233323
zePrint("ZeEvent = %lx\n", pi_cast<std::uintptr_t>(ZeEvent));
3324-
3325-
// If event comes from a Map/UnMap operation on integrated device
3326-
// then nothing needs to be done here except signal the event.
3327-
if (EventList[I]->HostSyncforMap) {
3328-
ZE_CALL(zeEventHostSignal(ZeEvent));
3329-
} else {
3330-
ZE_CALL(zeEventHostSynchronize(ZeEvent, UINT32_MAX));
3331-
}
3324+
ZE_CALL(zeEventHostSynchronize(ZeEvent, UINT32_MAX));
33323325

33333326
// NOTE: we are destroying associated command lists here to free
33343327
// resources sooner in case RT is not calling piEventRelease soon enough.
@@ -4003,6 +3996,10 @@ piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer, pi_bool BlockingMap,
40033996
assert(Buffer);
40043997
assert(Queue);
40053998

3999+
// Check if this is an integrated device
4000+
bool DeviceIsIntegrated = Queue->Device->ZeDeviceProperties.flags &
4001+
ZE_DEVICE_PROPERTY_FLAG_INTEGRATED;
4002+
40064003
// Query the buffer allocation to determine if host allocation
40074004
ze_memory_allocation_properties_t ZeMemoryAllocationProperties = {};
40084005
ze_device_handle_t ZeDeviceHandle;
@@ -4012,6 +4009,7 @@ piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer, pi_bool BlockingMap,
40124009
&ZeMemoryAllocationProperties, &ZeDeviceHandle));
40134010

40144011
bool BufferUsesHostMem =
4012+
DeviceIsIntegrated &&
40154013
(ZeMemoryAllocationProperties.type == ZE_MEMORY_TYPE_HOST);
40164014

40174015
// For discrete devices we don't need a commandlist
@@ -4051,8 +4049,9 @@ piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer, pi_bool BlockingMap,
40514049
} else {
40524050
*RetMap = pi_cast<char *>(Buffer->getZeHandle()) + Offset;
40534051
}
4054-
// Mark this event as handled
4055-
(*Event)->HostSyncforMap = true;
4052+
4053+
// Signal this event
4054+
ZE_CALL(zeEventHostSignal(ZeEvent));
40564055

40574056
return Buffer->addMapping(*RetMap, Offset, Size);
40584057
}
@@ -4098,6 +4097,10 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
40984097
const pi_event *EventWaitList, pi_event *Event) {
40994098
assert(Queue);
41004099

4100+
// Check if this is an integrated device
4101+
bool DeviceIsIntegrated = Queue->Device->ZeDeviceProperties.flags &
4102+
ZE_DEVICE_PROPERTY_FLAG_INTEGRATED;
4103+
41014104
// Query the buffer allocation to determine if host allocation
41024105
ze_memory_allocation_properties_t ZeMemoryAllocationProperties = {};
41034106
ze_device_handle_t ZeDeviceHandle;
@@ -4107,6 +4110,7 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
41074110
&ZeMemoryAllocationProperties, &ZeDeviceHandle));
41084111

41094112
bool BufferUsesHostMem =
4113+
DeviceIsIntegrated &&
41104114
(ZeMemoryAllocationProperties.type == ZE_MEMORY_TYPE_HOST);
41114115

41124116
// Integrated devices don't need a command list.
@@ -4147,13 +4151,13 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
41474151
: (MemObj->MapHostPtr ? nullptr : MappedPtr));
41484152

41494153
if (BufferUsesHostMem) {
4150-
(*Event)->HostSyncforMap = true;
41514154
// Wait on incoming events before doing the copy
41524155
piEventsWait(NumEventsInWaitList, EventWaitList);
41534156
memcpy(pi_cast<char *>(MemObj->getZeHandle()) + MapInfo.Offset, MappedPtr,
41544157
MapInfo.Size);
4155-
// Mark this event as handled
4156-
(*Event)->HostSyncforMap = true;
4158+
4159+
// Signal this event
4160+
ZE_CALL(zeEventHostSignal(ZeEvent));
41574161

41584162
return PI_SUCCESS;
41594163
}
@@ -4173,8 +4177,7 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
41734177

41744178
// TODO: Level Zero is missing the memory "mapping" capabilities, so we are
41754179
// left to doing copy (write back to the device).
4176-
// See https://gitlab.devtools.intel.com/one-api/level_zero/issues/293. //
4177-
// INTEL
4180+
// See https://gitlab.devtools.intel.com/one-api/level_zero/issues/293. // INTEL
41784181
//
41794182
// NOTE: Keep this in sync with the implementation of
41804183
// piEnqueueMemBufferMap/piEnqueueMemImageMap.

sycl/plugins/level_zero/pi_level_zero.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,6 @@ struct _pi_event : _pi_object {
451451
// Level Zero event pool handle.
452452
ze_event_pool_handle_t ZeEventPool;
453453

454-
// This flag is used by MemBufferMap/UnMap on integrated devices
455-
// to indicate that all actions have already been done.
456-
bool HostSyncforMap = false;
457-
458454
// Level Zero command list where the command signaling this event was appended
459455
// to. This is currently used to remember/destroy the command list after all
460456
// commands in it are completed, i.e. this event signaled.

0 commit comments

Comments
 (0)