Skip to content

Commit f1b62a9

Browse files
committed
some cleanups
Signed-off-by: Mateusz P. Nowak <mateusz.p.nowak@intel.com>
1 parent 33b3f69 commit f1b62a9

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

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

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
//
99
//===----------------------------------------------------------------------===//
1010

11-
#include "memory.hpp"
1211
#include "../ur_interface_loader.hpp"
1312
#include "context.hpp"
13+
#include "memory.hpp"
1414

1515
#include "../helpers/memory_helpers.hpp"
1616
#include "../image_common.hpp"
@@ -60,21 +60,19 @@ ur_integrated_buffer_handle_t::ur_integrated_buffer_handle_t(
6060
if (hostPtr) {
6161
// Host pointer provided - check if it's already USM or needs import
6262
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+
6566
if (ret == UR_RESULT_SUCCESS && memProps.type != ZE_MEMORY_TYPE_UNKNOWN) {
6667
// 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 *) {});
7069
} else {
7170
// Not USM - try to import it
7271
bool hostPtrImported =
7372
maybeImportUSM(hContext->getPlatform()->ZeDriverHandleExpTranslated,
7473
hContext->getZeHandle(), hostPtr, size);
75-
74+
7675
if (!hostPtrImported) {
77-
// This should not happen if urMemBufferCreate logic is correct
7876
throw UR_RESULT_ERROR_INVALID_VALUE;
7977
}
8078

@@ -110,10 +108,6 @@ ur_integrated_buffer_handle_t::ur_integrated_buffer_handle_t(
110108
});
111109
}
112110

113-
ur_integrated_buffer_handle_t::~ur_integrated_buffer_handle_t() {
114-
// No writeback needed - integrated buffers use zero-copy access
115-
}
116-
117111
void *ur_integrated_buffer_handle_t::getDevicePtr(
118112
ur_device_handle_t /*hDevice*/, device_access_mode_t /*access*/,
119113
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,
578572
if (useHostBuffer(hContext) && hostPtr) {
579573
// Check what type of memory this pointer is
580574
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+
583578
if (ret == UR_RESULT_SUCCESS) {
584579
if (memProps.type != ZE_MEMORY_TYPE_UNKNOWN) {
585580
// Already USM memory (host, device, or shared) - use integrated path
586581
*phBuffer = ur_mem_handle_t_::create<ur_integrated_buffer_handle_t>(
587582
hContext, hostPtr, size, accessMode);
588583
return UR_RESULT_SUCCESS;
589584
}
590-
585+
591586
// Memory type is UNKNOWN - try to import it
592587
bool canImport =
593588
maybeImportUSM(hContext->getPlatform()->ZeDriverHandleExpTranslated,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ struct ur_integrated_buffer_handle_t : ur_mem_buffer_t {
9898
size_t size, device_access_mode_t accessMode,
9999
bool ownHostPtr);
100100

101-
~ur_integrated_buffer_handle_t();
102-
103101
void *getDevicePtr(ur_device_handle_t, device_access_mode_t, size_t offset,
104102
size_t size, ze_command_list_handle_t cmdList,
105103
wait_list_view &waitListView) override;

0 commit comments

Comments
 (0)