Skip to content

Commit ce1b7aa

Browse files
[SYCL] Revert support for pinned_host_memory extension in Level-Zero backend. Make it a NOP (#3349)
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 8f65cd4 commit ce1b7aa

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,20 +2295,16 @@ pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags, size_t Size,
22952295
Context->Devices[0]->ZeDeviceProperties.flags &
22962296
ZE_DEVICE_PROPERTY_FLAG_INTEGRATED;
22972297

2298-
// Having PI_MEM_FLAGS_HOST_PTR_ALLOC for buffer requires allocation of
2299-
// pinned host memory which then becomes automatically accessible from
2300-
// discrete devices through PCI. This property ensures that the memory
2301-
// map/unmap operations are free of cost and the buffer is optimized for
2302-
// frequent accesses from the host giving improved performance.
2303-
// see:
2304-
// https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/UsePinnedMemoryProperty/UsePinnedMemoryPropery.adoc
2305-
bool AllocHostPtr = Flags & PI_MEM_FLAGS_HOST_PTR_ALLOC;
2306-
2307-
if (AllocHostPtr) {
2308-
PI_ASSERT(HostPtr == nullptr, PI_INVALID_VALUE);
2298+
if (Flags & PI_MEM_FLAGS_HOST_PTR_ALLOC) {
2299+
// Having PI_MEM_FLAGS_HOST_PTR_ALLOC for buffer requires allocation of
2300+
// pinned host memory, see:
2301+
// https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/UsePinnedMemoryProperty/UsePinnedMemoryPropery.adoc
2302+
// We are however missing such functionality in Level Zero, so we just
2303+
// ignore the flag for now.
2304+
//
23092305
}
23102306

2311-
if (AllocHostPtr || DeviceIsIntegrated) {
2307+
if (DeviceIsIntegrated) {
23122308
ze_host_mem_alloc_desc_t ZeDesc = {};
23132309
ZeDesc.flags = 0;
23142310

@@ -2350,7 +2346,7 @@ pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags, size_t Size,
23502346
*RetMem = new _pi_buffer(
23512347
Context, pi_cast<char *>(Ptr) /* Level Zero Memory Handle */,
23522348
HostPtrOrNull, nullptr, 0, 0,
2353-
AllocHostPtr || DeviceIsIntegrated /* allocation in host memory */);
2349+
DeviceIsIntegrated /* allocation in host memory */);
23542350
} catch (const std::bad_alloc &) {
23552351
return PI_OUT_OF_HOST_MEMORY;
23562352
} catch (...) {
@@ -4602,18 +4598,17 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer,
46024598

46034599
// TODO: Level Zero is missing the memory "mapping" capabilities, so we are
46044600
// left to doing new memory allocation and a copy (read) on discrete devices.
4605-
// For pinned host memory and integrated devices, we have allocated the
4606-
// buffer in host memory so no actions are needed here except for
4607-
// synchronizing on incoming events. A host-to-host copy is done if a host
4608-
// pointer had been supplied during buffer creation on integrated devices.
4601+
// For integrated devices, we have allocated the buffer in host memory so no
4602+
// actions are needed here except for synchronizing on incoming events.
4603+
// A host-to-host copy is done if a host pointer had been supplied during
4604+
// buffer creation on integrated devices.
46094605
//
46104606
// TODO: for discrete, check if the input buffer is already allocated
46114607
// in shared memory and thus is accessible from the host as is.
46124608
// Can we get SYCL RT to predict/allocate in shared memory
46134609
// from the beginning?
46144610

4615-
// For pinned host memory and integrated devices the buffer has been
4616-
// allocated in host memory.
4611+
// For integrated devices the buffer has been allocated in host memory.
46174612
if (Buffer->OnHost) {
46184613
// Wait on incoming events before doing the copy
46194614
PI_CALL(piEventsWait(NumEventsInWaitList, EventWaitList));
@@ -4718,8 +4713,7 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
47184713
(*Event)->CommandData =
47194714
(MemObj->OnHost ? nullptr : (MemObj->MapHostPtr ? nullptr : MappedPtr));
47204715

4721-
// For pinned host memory and integrated devices the buffer is allocated
4722-
// in host memory.
4716+
// For integrated devices the buffer is allocated in host memory.
47234717
if (MemObj->OnHost) {
47244718
// Wait on incoming events before doing the copy
47254719
PI_CALL(piEventsWait(NumEventsInWaitList, EventWaitList));

0 commit comments

Comments
 (0)