|
8 | 8 | // |
9 | 9 | //===----------------------------------------------------------------------===// |
10 | 10 |
|
11 | | -#include "memory.hpp" |
12 | 11 | #include "../ur_interface_loader.hpp" |
13 | 12 | #include "context.hpp" |
| 13 | +#include "memory.hpp" |
14 | 14 |
|
15 | 15 | #include "../helpers/memory_helpers.hpp" |
16 | 16 | #include "../image_common.hpp" |
@@ -60,21 +60,19 @@ ur_integrated_buffer_handle_t::ur_integrated_buffer_handle_t( |
60 | 60 | if (hostPtr) { |
61 | 61 | // Host pointer provided - check if it's already USM or needs import |
62 | 62 | ZeStruct<ze_memory_allocation_properties_t> memProps; |
63 | | - auto ret = getMemoryAttrs(hContext->getZeHandle(), hostPtr, nullptr, &memProps); |
64 | | - |
| 63 | + auto ret = |
| 64 | + getMemoryAttrs(hContext->getZeHandle(), hostPtr, nullptr, &memProps); |
| 65 | + |
65 | 66 | if (ret == UR_RESULT_SUCCESS && memProps.type != ZE_MEMORY_TYPE_UNKNOWN) { |
66 | 67 | // Already a USM allocation - just use it directly without import |
67 | | - this->ptr = usm_unique_ptr_t(hostPtr, [](void *) { |
68 | | - // Don't free - we don't own this memory |
69 | | - }); |
| 68 | + this->ptr = usm_unique_ptr_t(hostPtr, [](void *) {}); |
70 | 69 | } else { |
71 | 70 | // Not USM - try to import it |
72 | 71 | bool hostPtrImported = |
73 | 72 | maybeImportUSM(hContext->getPlatform()->ZeDriverHandleExpTranslated, |
74 | 73 | hContext->getZeHandle(), hostPtr, size); |
75 | | - |
| 74 | + |
76 | 75 | if (!hostPtrImported) { |
77 | | - // This should not happen if urMemBufferCreate logic is correct |
78 | 76 | throw UR_RESULT_ERROR_INVALID_VALUE; |
79 | 77 | } |
80 | 78 |
|
@@ -110,10 +108,6 @@ ur_integrated_buffer_handle_t::ur_integrated_buffer_handle_t( |
110 | 108 | }); |
111 | 109 | } |
112 | 110 |
|
113 | | -ur_integrated_buffer_handle_t::~ur_integrated_buffer_handle_t() { |
114 | | - // No writeback needed - integrated buffers use zero-copy access |
115 | | -} |
116 | | - |
117 | 111 | void *ur_integrated_buffer_handle_t::getDevicePtr( |
118 | 112 | ur_device_handle_t /*hDevice*/, device_access_mode_t /*access*/, |
119 | 113 | size_t offset, size_t /*size*/, ze_command_list_handle_t /*cmdList*/, |
@@ -578,16 +572,17 @@ ur_result_t urMemBufferCreate(ur_context_handle_t hContext, |
578 | 572 | if (useHostBuffer(hContext) && hostPtr) { |
579 | 573 | // Check what type of memory this pointer is |
580 | 574 | ZeStruct<ze_memory_allocation_properties_t> memProps; |
581 | | - auto ret = getMemoryAttrs(hContext->getZeHandle(), hostPtr, nullptr, &memProps); |
582 | | - |
| 575 | + auto ret = |
| 576 | + getMemoryAttrs(hContext->getZeHandle(), hostPtr, nullptr, &memProps); |
| 577 | + |
583 | 578 | if (ret == UR_RESULT_SUCCESS) { |
584 | 579 | if (memProps.type != ZE_MEMORY_TYPE_UNKNOWN) { |
585 | 580 | // Already USM memory (host, device, or shared) - use integrated path |
586 | 581 | *phBuffer = ur_mem_handle_t_::create<ur_integrated_buffer_handle_t>( |
587 | 582 | hContext, hostPtr, size, accessMode); |
588 | 583 | return UR_RESULT_SUCCESS; |
589 | 584 | } |
590 | | - |
| 585 | + |
591 | 586 | // Memory type is UNKNOWN - try to import it |
592 | 587 | bool canImport = |
593 | 588 | maybeImportUSM(hContext->getPlatform()->ZeDriverHandleExpTranslated, |
|
0 commit comments