Skip to content

Commit 9473abc

Browse files
Jaime ArteagaCompute-Runtime-Automation
authored andcommitted
Correctly pass descriptors to L0 device and host alloc functions
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
1 parent 22a5665 commit 9473abc

File tree

15 files changed

+76
-50
lines changed

15 files changed

+76
-50
lines changed

level_zero/api/core/ze_memory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ zeMemAllocDevice(
2828
size_t alignment,
2929
ze_device_handle_t hDevice,
3030
void **pptr) {
31-
return L0::Context::fromHandle(hContext)->allocDeviceMem(hDevice, 0, size, alignment, pptr);
31+
return L0::Context::fromHandle(hContext)->allocDeviceMem(hDevice, deviceDesc, size, alignment, pptr);
3232
}
3333

3434
ZE_APIEXPORT ze_result_t ZE_APICALL
@@ -38,7 +38,7 @@ zeMemAllocHost(
3838
size_t size,
3939
size_t alignment,
4040
void **pptr) {
41-
return L0::Context::fromHandle(hContext)->allocHostMem(0, size, alignment, pptr);
41+
return L0::Context::fromHandle(hContext)->allocHostMem(hostDesc, size, alignment, pptr);
4242
}
4343

4444
ZE_APIEXPORT ze_result_t ZE_APICALL

level_zero/core/source/context/context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ struct Context : _ze_context_handle_t {
2323
virtual ze_result_t destroy() = 0;
2424
virtual ze_result_t getStatus() = 0;
2525
virtual DriverHandle *getDriverHandle() = 0;
26-
virtual ze_result_t allocHostMem(ze_host_mem_alloc_flags_t flags,
26+
virtual ze_result_t allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc,
2727
size_t size,
2828
size_t alignment,
2929
void **ptr) = 0;
3030
virtual ze_result_t allocDeviceMem(ze_device_handle_t hDevice,
31-
ze_device_mem_alloc_flags_t flags,
31+
const ze_device_mem_alloc_desc_t *deviceDesc,
3232
size_t size,
3333
size_t alignment, void **ptr) = 0;
3434
virtual ze_result_t allocSharedMem(ze_device_handle_t hDevice,

level_zero/core/source/context/context_imp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,24 @@ ContextImp::ContextImp(DriverHandle *driverHandle) {
4040
this->driverHandle = driverHandle;
4141
}
4242

43-
ze_result_t ContextImp::allocHostMem(ze_host_mem_alloc_flags_t flags,
43+
ze_result_t ContextImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc,
4444
size_t size,
4545
size_t alignment,
4646
void **ptr) {
4747
DEBUG_BREAK_IF(nullptr == this->driverHandle);
48-
return this->driverHandle->allocHostMem(flags,
48+
return this->driverHandle->allocHostMem(hostDesc,
4949
size,
5050
alignment,
5151
ptr);
5252
}
5353

5454
ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
55-
ze_device_mem_alloc_flags_t flags,
55+
const ze_device_mem_alloc_desc_t *deviceDesc,
5656
size_t size,
5757
size_t alignment, void **ptr) {
5858
DEBUG_BREAK_IF(nullptr == this->driverHandle);
5959
return this->driverHandle->allocDeviceMem(hDevice,
60-
flags,
60+
deviceDesc,
6161
size,
6262
alignment,
6363
ptr);

level_zero/core/source/context/context_imp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ struct ContextImp : Context {
1818
ze_result_t destroy() override;
1919
ze_result_t getStatus() override;
2020
DriverHandle *getDriverHandle() override;
21-
ze_result_t allocHostMem(ze_host_mem_alloc_flags_t flags,
21+
ze_result_t allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc,
2222
size_t size,
2323
size_t alignment,
2424
void **ptr) override;
2525
ze_result_t allocDeviceMem(ze_device_handle_t hDevice,
26-
ze_device_mem_alloc_flags_t flags,
26+
const ze_device_mem_alloc_desc_t *deviceDesc,
2727
size_t size,
2828
size_t alignment, void **ptr) override;
2929
ze_result_t allocSharedMem(ze_device_handle_t hDevice,

level_zero/core/source/driver/driver_handle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ struct DriverHandle : _ze_driver_handle_t {
3636
ze_memory_allocation_properties_t *pMemAllocProperties,
3737
ze_device_handle_t *phDevice) = 0;
3838

39-
virtual ze_result_t allocHostMem(ze_host_mem_alloc_flags_t flags, size_t size, size_t alignment, void **ptr) = 0;
39+
virtual ze_result_t allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc, size_t size, size_t alignment, void **ptr) = 0;
4040

41-
virtual ze_result_t allocDeviceMem(ze_device_handle_t hDevice, ze_device_mem_alloc_flags_t flags, size_t size,
41+
virtual ze_result_t allocDeviceMem(ze_device_handle_t hDevice, const ze_device_mem_alloc_desc_t *deviceDesc, size_t size,
4242
size_t alignment, void **ptr) = 0;
4343

4444
virtual ze_result_t allocSharedMem(ze_device_handle_t hDevice, ze_device_mem_alloc_flags_t deviceFlags,

level_zero/core/source/driver/driver_handle_imp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ struct DriverHandleImp : public DriverHandle {
2828
ze_memory_allocation_properties_t *pMemAllocProperties,
2929
ze_device_handle_t *phDevice) override;
3030

31-
ze_result_t allocHostMem(ze_host_mem_alloc_flags_t flags, size_t size, size_t alignment, void **ptr) override;
31+
ze_result_t allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc, size_t size, size_t alignment, void **ptr) override;
3232

33-
ze_result_t allocDeviceMem(ze_device_handle_t hDevice, ze_device_mem_alloc_flags_t flags, size_t size,
33+
ze_result_t allocDeviceMem(ze_device_handle_t hDevice, const ze_device_mem_alloc_desc_t *deviceDesc, size_t size,
3434
size_t alignment, void **ptr) override;
3535

3636
ze_result_t allocSharedMem(ze_device_handle_t hDevice, ze_device_mem_alloc_flags_t deviceFlags,

level_zero/core/source/memory/memory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ ze_result_t DriverHandleImp::getMemAddressRange(const void *ptr, void **pBase, s
9999
return ZE_RESULT_ERROR_UNKNOWN;
100100
}
101101

102-
ze_result_t DriverHandleImp::allocHostMem(ze_host_mem_alloc_flags_t flags, size_t size, size_t alignment,
102+
ze_result_t DriverHandleImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc, size_t size, size_t alignment,
103103
void **ptr) {
104104
if (size > this->devices[0]->getDeviceInfo().maxMemAllocSize) {
105105
*ptr = nullptr;
@@ -119,7 +119,7 @@ ze_result_t DriverHandleImp::allocHostMem(ze_host_mem_alloc_flags_t flags, size_
119119
return ZE_RESULT_SUCCESS;
120120
}
121121

122-
ze_result_t DriverHandleImp::allocDeviceMem(ze_device_handle_t hDevice, ze_device_mem_alloc_flags_t flags,
122+
ze_result_t DriverHandleImp::allocDeviceMem(ze_device_handle_t hDevice, const ze_device_mem_alloc_desc_t *deviceDesc,
123123
size_t size, size_t alignment, void **ptr) {
124124
if (size > this->devices[0]->getNEODevice()->getHardwareCapabilities().maxMemAllocSize) {
125125
*ptr = nullptr;

level_zero/core/test/unit_tests/mocks/mock_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ struct Mock<Context> : public Context {
4141
(override));
4242
MOCK_METHOD(ze_result_t,
4343
allocHostMem,
44-
(ze_host_mem_alloc_flags_t flags,
44+
(const ze_host_mem_alloc_desc_t *hostDesc,
4545
size_t size,
4646
size_t alignment,
4747
void **ptr),
4848
(override));
4949
MOCK_METHOD(ze_result_t,
5050
allocDeviceMem,
5151
(ze_device_handle_t hDevice,
52-
ze_device_mem_alloc_flags_t flags,
52+
const ze_device_mem_alloc_desc_t *deviceDesc,
5353
size_t size,
5454
size_t alignment,
5555
void **ptr),

level_zero/core/test/unit_tests/mocks/mock_driver_handle.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ze_result_t Mock<DriverHandle>::doGetDevice(uint32_t *pCount, ze_device_handle_t
5454
return ZE_RESULT_SUCCESS;
5555
}
5656

57-
ze_result_t Mock<DriverHandle>::doAllocHostMem(ze_host_mem_alloc_flags_t flags, size_t size, size_t alignment,
57+
ze_result_t Mock<DriverHandle>::doAllocHostMem(const ze_host_mem_alloc_desc_t *hostDesc, size_t size, size_t alignment,
5858
void **ptr) {
5959
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::HOST_UNIFIED_MEMORY, NEO::mockDeviceBitfield);
6060

@@ -69,7 +69,8 @@ ze_result_t Mock<DriverHandle>::doAllocHostMem(ze_host_mem_alloc_flags_t flags,
6969
return ZE_RESULT_SUCCESS;
7070
}
7171

72-
ze_result_t Mock<DriverHandle>::doAllocDeviceMem(ze_device_handle_t hDevice, ze_device_mem_alloc_flags_t flags, size_t size, size_t alignment, void **ptr) {
72+
ze_result_t Mock<DriverHandle>::doAllocDeviceMem(ze_device_handle_t hDevice, const ze_device_mem_alloc_desc_t *deviceDesc,
73+
size_t size, size_t alignment, void **ptr) {
7374
NEO::SVMAllocsManager::UnifiedMemoryProperties unifiedMemoryProperties(InternalMemoryType::DEVICE_UNIFIED_MEMORY, NEO::mockDeviceBitfield);
7475

7576
auto allocation = svmAllocsManager->createUnifiedMemoryAllocation(0u, size, unifiedMemoryProperties);

level_zero/core/test/unit_tests/mocks/mock_driver_handle.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ struct Mock<DriverHandle> : public DriverHandleImp {
9999
(override));
100100
MOCK_METHOD(ze_result_t,
101101
allocHostMem,
102-
(ze_host_mem_alloc_flags_t flags,
102+
(const ze_host_mem_alloc_desc_t *hostDesc,
103103
size_t size,
104104
size_t alignment,
105105
void **ptr),
106106
(override));
107107
MOCK_METHOD(ze_result_t,
108108
allocDeviceMem,
109109
(ze_device_handle_t hDevice,
110-
ze_device_mem_alloc_flags_t flags,
110+
const ze_device_mem_alloc_desc_t *deviceDesc,
111111
size_t size,
112112
size_t alignment,
113113
void **ptr),
@@ -139,12 +139,12 @@ struct Mock<DriverHandle> : public DriverHandleImp {
139139
ze_device_handle_t *phDevices);
140140
NEO::MemoryManager *doGetMemoryManager();
141141
NEO::SVMAllocsManager *doGetSvmAllocManager();
142-
ze_result_t doAllocHostMem(ze_host_mem_alloc_flags_t flags,
142+
ze_result_t doAllocHostMem(const ze_host_mem_alloc_desc_t *hostDesc,
143143
size_t size,
144144
size_t alignment,
145145
void **ptr);
146146
ze_result_t doAllocDeviceMem(ze_device_handle_t hDevice,
147-
ze_device_mem_alloc_flags_t flags,
147+
const ze_device_mem_alloc_desc_t *deviceDesc,
148148
size_t size,
149149
size_t alignment,
150150
void **ptr);

0 commit comments

Comments
 (0)