@@ -3321,14 +3321,7 @@ pi_result piEventsWait(pi_uint32 NumEvents, const pi_event *EventList) {
3321
3321
for (uint32_t I = 0 ; I < NumEvents; I++) {
3322
3322
ze_event_handle_t ZeEvent = EventList[I]->ZeEvent ;
3323
3323
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));
3332
3325
3333
3326
// NOTE: we are destroying associated command lists here to free
3334
3327
// 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,
4003
3996
assert (Buffer);
4004
3997
assert (Queue);
4005
3998
3999
+ // Check if this is an integrated device
4000
+ bool DeviceIsIntegrated = Queue->Device ->ZeDeviceProperties .flags &
4001
+ ZE_DEVICE_PROPERTY_FLAG_INTEGRATED;
4002
+
4006
4003
// Query the buffer allocation to determine if host allocation
4007
4004
ze_memory_allocation_properties_t ZeMemoryAllocationProperties = {};
4008
4005
ze_device_handle_t ZeDeviceHandle;
@@ -4012,6 +4009,7 @@ piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer, pi_bool BlockingMap,
4012
4009
&ZeMemoryAllocationProperties, &ZeDeviceHandle));
4013
4010
4014
4011
bool BufferUsesHostMem =
4012
+ DeviceIsIntegrated &&
4015
4013
(ZeMemoryAllocationProperties.type == ZE_MEMORY_TYPE_HOST);
4016
4014
4017
4015
// For discrete devices we don't need a commandlist
@@ -4051,8 +4049,9 @@ piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer, pi_bool BlockingMap,
4051
4049
} else {
4052
4050
*RetMap = pi_cast<char *>(Buffer->getZeHandle ()) + Offset;
4053
4051
}
4054
- // Mark this event as handled
4055
- (*Event)->HostSyncforMap = true ;
4052
+
4053
+ // Signal this event
4054
+ ZE_CALL (zeEventHostSignal (ZeEvent));
4056
4055
4057
4056
return Buffer->addMapping (*RetMap, Offset, Size);
4058
4057
}
@@ -4098,6 +4097,10 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
4098
4097
const pi_event *EventWaitList, pi_event *Event) {
4099
4098
assert (Queue);
4100
4099
4100
+ // Check if this is an integrated device
4101
+ bool DeviceIsIntegrated = Queue->Device ->ZeDeviceProperties .flags &
4102
+ ZE_DEVICE_PROPERTY_FLAG_INTEGRATED;
4103
+
4101
4104
// Query the buffer allocation to determine if host allocation
4102
4105
ze_memory_allocation_properties_t ZeMemoryAllocationProperties = {};
4103
4106
ze_device_handle_t ZeDeviceHandle;
@@ -4107,6 +4110,7 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
4107
4110
&ZeMemoryAllocationProperties, &ZeDeviceHandle));
4108
4111
4109
4112
bool BufferUsesHostMem =
4113
+ DeviceIsIntegrated &&
4110
4114
(ZeMemoryAllocationProperties.type == ZE_MEMORY_TYPE_HOST);
4111
4115
4112
4116
// Integrated devices don't need a command list.
@@ -4147,13 +4151,13 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
4147
4151
: (MemObj->MapHostPtr ? nullptr : MappedPtr));
4148
4152
4149
4153
if (BufferUsesHostMem) {
4150
- (*Event)->HostSyncforMap = true ;
4151
4154
// Wait on incoming events before doing the copy
4152
4155
piEventsWait (NumEventsInWaitList, EventWaitList);
4153
4156
memcpy (pi_cast<char *>(MemObj->getZeHandle ()) + MapInfo.Offset , MappedPtr,
4154
4157
MapInfo.Size );
4155
- // Mark this event as handled
4156
- (*Event)->HostSyncforMap = true ;
4158
+
4159
+ // Signal this event
4160
+ ZE_CALL (zeEventHostSignal (ZeEvent));
4157
4161
4158
4162
return PI_SUCCESS;
4159
4163
}
@@ -4173,8 +4177,7 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
4173
4177
4174
4178
// TODO: Level Zero is missing the memory "mapping" capabilities, so we are
4175
4179
// 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
4178
4181
//
4179
4182
// NOTE: Keep this in sync with the implementation of
4180
4183
// piEnqueueMemBufferMap/piEnqueueMemImageMap.
0 commit comments