@@ -1913,7 +1913,8 @@ pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags, size_t Size,
1913
1913
try {
1914
1914
*RetMem = new _pi_buffer (
1915
1915
Context, pi_cast<char *>(Ptr) /* Level Zero Memory Handle */ ,
1916
- HostPtrOrNull);
1916
+ HostPtrOrNull, nullptr , 0 , 0 ,
1917
+ DeviceIsIntegrated /* Flag indicating allocation in host memory */ );
1917
1918
} catch (const std::bad_alloc &) {
1918
1919
return PI_OUT_OF_HOST_MEMORY;
1919
1920
} catch (...) {
@@ -3996,22 +3997,6 @@ piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer, pi_bool BlockingMap,
3996
3997
assert (Buffer);
3997
3998
assert (Queue);
3998
3999
3999
- // Check if this is an integrated device
4000
- bool DeviceIsIntegrated = Queue->Device ->ZeDeviceProperties .flags &
4001
- ZE_DEVICE_PROPERTY_FLAG_INTEGRATED;
4002
-
4003
- // Query the buffer allocation to determine if host allocation
4004
- ze_memory_allocation_properties_t ZeMemoryAllocationProperties = {};
4005
- ze_device_handle_t ZeDeviceHandle;
4006
-
4007
- ZE_CALL (
4008
- zeMemGetAllocProperties (Queue->Context ->ZeContext , Buffer->getZeHandle (),
4009
- &ZeMemoryAllocationProperties, &ZeDeviceHandle));
4010
-
4011
- bool BufferUsesHostMem =
4012
- DeviceIsIntegrated &&
4013
- (ZeMemoryAllocationProperties.type == ZE_MEMORY_TYPE_HOST);
4014
-
4015
4000
// For discrete devices we don't need a commandlist
4016
4001
ze_command_list_handle_t ZeCommandList = nullptr ;
4017
4002
ze_fence_handle_t ZeFence = nullptr ;
@@ -4040,7 +4025,9 @@ piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer, pi_bool BlockingMap,
4040
4025
// in shared memory and thus is accessible from the host as is.
4041
4026
// Can we get SYCL RT to predict/allocate in shared memory
4042
4027
// from the beginning?
4043
- if (BufferUsesHostMem) {
4028
+ //
4029
+ // On integrated devices the buffer has been allocated in host memory.
4030
+ if (Buffer->OnHost ) {
4044
4031
// Wait on incoming events before doing the copy
4045
4032
piEventsWait (NumEventsInWaitList, EventWaitList);
4046
4033
if (Buffer->MapHostPtr ) {
@@ -4097,22 +4084,6 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
4097
4084
const pi_event *EventWaitList, pi_event *Event) {
4098
4085
assert (Queue);
4099
4086
4100
- // Check if this is an integrated device
4101
- bool DeviceIsIntegrated = Queue->Device ->ZeDeviceProperties .flags &
4102
- ZE_DEVICE_PROPERTY_FLAG_INTEGRATED;
4103
-
4104
- // Query the buffer allocation to determine if host allocation
4105
- ze_memory_allocation_properties_t ZeMemoryAllocationProperties = {};
4106
- ze_device_handle_t ZeDeviceHandle;
4107
-
4108
- ZE_CALL (
4109
- zeMemGetAllocProperties (Queue->Context ->ZeContext , MemObj->getZeHandle (),
4110
- &ZeMemoryAllocationProperties, &ZeDeviceHandle));
4111
-
4112
- bool BufferUsesHostMem =
4113
- DeviceIsIntegrated &&
4114
- (ZeMemoryAllocationProperties.type == ZE_MEMORY_TYPE_HOST);
4115
-
4116
4087
// Integrated devices don't need a command list.
4117
4088
// If discrete we will get a commandlist later.
4118
4089
ze_command_list_handle_t ZeCommandList = nullptr ;
@@ -4147,10 +4118,10 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
4147
4118
// any memory, so there is nothing to free. This is indicated by a nullptr.
4148
4119
if (Event)
4149
4120
(*Event)->CommandData =
4150
- (BufferUsesHostMem ? nullptr
4151
- : (MemObj->MapHostPtr ? nullptr : MappedPtr));
4121
+ (MemObj->OnHost ? nullptr : (MemObj->MapHostPtr ? nullptr : MappedPtr));
4152
4122
4153
- if (BufferUsesHostMem) {
4123
+ // On integrated devices the buffer is allocated in host memory.
4124
+ if (MemObj->OnHost ) {
4154
4125
// Wait on incoming events before doing the copy
4155
4126
piEventsWait (NumEventsInWaitList, EventWaitList);
4156
4127
memcpy (pi_cast<char *>(MemObj->getZeHandle ()) + MapInfo.Offset , MappedPtr,
0 commit comments