From d428516f25aee434e94da97dd7ed773ae518d880 Mon Sep 17 00:00:00 2001 From: Igor Chorazewicz Date: Wed, 7 May 2025 18:09:36 +0000 Subject: [PATCH] [SYCL][UR][L0 v2] the ur_integrated_buffer_handle_t does not follow SYCL expectations. For now, use discrete_buffer which works fine. --- .../source/adapters/level_zero/v2/memory.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/unified-runtime/source/adapters/level_zero/v2/memory.cpp b/unified-runtime/source/adapters/level_zero/v2/memory.cpp index 18c72eb592303..c7938c15bb4ba 100644 --- a/unified-runtime/source/adapters/level_zero/v2/memory.cpp +++ b/unified-runtime/source/adapters/level_zero/v2/memory.cpp @@ -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 /*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(ptr.get()) + offset; } void ur_integrated_buffer_handle_t::unmapHostPtr( void * /*pMappedPtr*/, std::function) { + // TODO: if writeBackPtr is set, we should copy the data back /* nop */ } @@ -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,