Skip to content

[SYCL][UR][L0 v2] Use discrete buffer implementation for integrated GPUs #18354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: sycl
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions unified-runtime/source/adapters/level_zero/v2/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,16 @@ void *ur_integrated_buffer_handle_t::getDevicePtr(
void *ur_integrated_buffer_handle_t::mapHostPtr(
ur_map_flags_t /*flags*/, size_t offset, size_t /*size*/,
std::function<void(void *src, void *dst, size_t)> /*migrate*/) {
// TODO: if writeBackPtr is set, we should map to that pointer
// because that's what SYCL expects, SYCL will attempt to call free
// on the resulting pointer leading to double free with the current
// implementation. Investigate the SYCL implementation.
return ur_cast<char *>(ptr.get()) + offset;
}

void ur_integrated_buffer_handle_t::unmapHostPtr(
void * /*pMappedPtr*/, std::function<void(void *src, void *dst, size_t)>) {
// TODO: if writeBackPtr is set, we should copy the data back
/* nop */
}

Expand Down Expand Up @@ -381,15 +386,19 @@ void ur_shared_buffer_handle_t::unmapHostPtr(
// nop
}

static bool useHostBuffer(ur_context_handle_t hContext) {
static bool useHostBuffer(ur_context_handle_t /* hContext */) {
// We treat integrated devices (physical memory shared with the CPU)
// differently from discrete devices (those with distinct memories).
// For integrated devices, allocating the buffer in the host memory
// enables automatic access from the device, and makes copying
// unnecessary in the map/unmap operations. This improves performance.
return hContext->getDevices().size() == 1 &&
hContext->getDevices()[0]->ZeDeviceProperties->flags &
ZE_DEVICE_PROPERTY_FLAG_INTEGRATED;

// TODO: fix integrated buffer implementation
return false;

// return hContext->getDevices().size() == 1 &&
// hContext->getDevices()[0]->ZeDeviceProperties->flags &
// ZE_DEVICE_PROPERTY_FLAG_INTEGRATED;
}

ur_mem_sub_buffer_t::ur_mem_sub_buffer_t(ur_mem_handle_t hParent, size_t offset,
Expand Down
Loading