Skip to content

Commit c1fa801

Browse files
committed
Merge branch 'integ-buff' of github.com:mateuszpn/llvm into integ-buff
2 parents c8b075a + dac9ccd commit c1fa801

File tree

1 file changed

+7
-1
lines changed
  • unified-runtime/source/adapters/level_zero/v2

1 file changed

+7
-1
lines changed

unified-runtime/source/adapters/level_zero/v2/memory.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ ur_integrated_buffer_handle_t::ur_integrated_buffer_handle_t(
121121

122122
ur_integrated_buffer_handle_t::~ur_integrated_buffer_handle_t() {
123123
if (writeBackPtr) {
124-
std::memcpy(writeBackPtr, this->ptr.get(), size);
124+
std::memcpy(writeBackPtr, ptr.get(), size);
125125
}
126126
}
127127

@@ -618,6 +618,12 @@ ur_result_t urMemBufferCreate(ur_context_handle_t hContext,
618618
void *hostPtr = pProperties ? pProperties->pHost : nullptr;
619619
auto accessMode = ur_mem_buffer_t::getDeviceAccessMode(flags);
620620

621+
// For integrated devices, use zero-copy host buffers. The integrated buffer
622+
// constructor will handle all cases:
623+
// 1. No host pointer - allocate USM host memory
624+
// 2. Host pointer is already USM - use directly
625+
// 3. Host pointer can be imported - import it
626+
// 4. Otherwise - allocate USM and copy-back on destruction
621627
if (useHostBuffer(hContext)) {
622628
*phBuffer = ur_mem_handle_t_::create<ur_integrated_buffer_handle_t>(
623629
hContext, hostPtr, size, accessMode);

0 commit comments

Comments
 (0)