Skip to content

Commit ab67b94

Browse files
Updating Memory API implementations
- updating zet sysman for memory - updating memoryhandlecontext init and memory get by checking isLocalMemorySupported flag Change-Id: I084068eb0865bb037b7d80246c4a9c74d3ff2cc1 Signed-off-by: SaiKishore Konda <saikishore.konda@intel.com>
1 parent 6e07281 commit ab67b94

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

level_zero/api/tools/zet_sysman.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,21 +377,21 @@ __zedllexport ze_result_t __zecall
377377
zetSysmanMemoryGetProperties(
378378
zet_sysman_mem_handle_t hMemory,
379379
zet_mem_properties_t *pProperties) {
380-
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
380+
return L0::Memory::fromHandle(hMemory)->memoryGetProperties(pProperties);
381381
}
382382

383383
__zedllexport ze_result_t __zecall
384384
zetSysmanMemoryGetState(
385385
zet_sysman_mem_handle_t hMemory,
386386
zet_mem_state_t *pState) {
387-
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
387+
return L0::Memory::fromHandle(hMemory)->memoryGetState(pState);
388388
}
389389

390390
__zedllexport ze_result_t __zecall
391391
zetSysmanMemoryGetBandwidth(
392392
zet_sysman_mem_handle_t hMemory,
393393
zet_mem_bandwidth_t *pBandwidth) {
394-
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
394+
return L0::Memory::fromHandle(hMemory)->memoryGetBandwidth(pBandwidth);
395395
}
396396

397397
__zedllexport ze_result_t __zecall

level_zero/tools/source/sysman/memory/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#
66

77
set(L0_SRCS_TOOLS_SYSMAN_MEMORY
8-
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory.cpp
8+
${CMAKE_CURRENT_SOURCE_DIR}/memory.cpp
99
${CMAKE_CURRENT_SOURCE_DIR}/memory.h
1010
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory_imp.cpp
11-
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory_imp.h
11+
${CMAKE_CURRENT_SOURCE_DIR}/memory_imp.h
1212
${CMAKE_CURRENT_SOURCE_DIR}/os_memory.h
1313
)
1414

level_zero/tools/source/sysman/memory/memory.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
*
66
*/
77

8-
#include "level_zero/tools/source/sysman/memory/memory.h"
8+
#include "shared/source/memory_manager/memory_manager.h"
99

10+
#include "level_zero/core/source/device/device.h"
1011
#include "level_zero/tools/source/sysman/memory/memory_imp.h"
1112

1213
namespace L0 {
@@ -18,13 +19,30 @@ MemoryHandleContext::~MemoryHandleContext() {
1819
}
1920

2021
ze_result_t MemoryHandleContext::init() {
21-
Memory *pMemory = new MemoryImp(pOsSysman, hCoreDevice);
22-
handleList.push_back(pMemory);
22+
Device *device = L0::Device::fromHandle(hCoreDevice);
23+
24+
isLmemSupported = device->getDriverHandle()->getMemoryManager()->isLocalMemorySupported(device->getRootDeviceIndex());
25+
26+
if (isLmemSupported) {
27+
Memory *pMemory = new MemoryImp(pOsSysman, hCoreDevice);
28+
handleList.push_back(pMemory);
29+
}
2330
return ZE_RESULT_SUCCESS;
2431
}
2532

2633
ze_result_t MemoryHandleContext::memoryGet(uint32_t *pCount, zet_sysman_mem_handle_t *phMemory) {
27-
*pCount = 0;
34+
if (nullptr == phMemory) {
35+
*pCount = static_cast<uint32_t>(handleList.size());
36+
return ZE_RESULT_SUCCESS;
37+
}
38+
uint32_t i = 0;
39+
for (Memory *mem : handleList) {
40+
if (i >= *pCount) {
41+
break;
42+
}
43+
phMemory[i++] = mem->toHandle();
44+
}
45+
*pCount = i;
2846
return ZE_RESULT_SUCCESS;
2947
}
3048

level_zero/tools/source/sysman/memory/memory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct MemoryHandleContext {
3939
ze_result_t memoryGet(uint32_t *pCount, zet_sysman_mem_handle_t *phMemory);
4040

4141
OsSysman *pOsSysman;
42+
bool isLmemSupported;
4243
std::vector<Memory *> handleList;
4344
ze_device_handle_t hCoreDevice;
4445
};

0 commit comments

Comments
 (0)