mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Memory API's boilerplate for Level Zero Sysman
- Implementing MemoryGet, MemoryGetProperites & MemoryGetState boilerplate for Level Zero Sysman Change-Id: I46661aac9cd6974af986aede7484fd59688046a4 Signed-off-by: SaiKishore Konda <saikishore.konda@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
7fc44aa60e
commit
a0c13490e5
@@ -17,16 +17,7 @@ target_sources(${L0_STATIC_LIB_NAME}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
|
||||
add_subdirectory(sysman_device)
|
||||
add_subdirectory(pci)
|
||||
add_subdirectory(frequency)
|
||||
add_subdirectory(standby)
|
||||
|
||||
if(UNIX)
|
||||
add_subdirectory(linux)
|
||||
else()
|
||||
add_subdirectory(windows)
|
||||
endif()
|
||||
add_subdirectories()
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN ${L0_SRCS_TOOLS_SYSMAN})
|
||||
|
||||
25
level_zero/tools/source/sysman/memory/CMakeLists.txt
Executable file
25
level_zero/tools/source/sysman/memory/CMakeLists.txt
Executable file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_SYSMAN_MEMORY
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/memory.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory_imp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory.h
|
||||
)
|
||||
|
||||
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${L0_SRCS_TOOLS_SYSMAN_MEMORY}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_MEMORY ${L0_SRCS_TOOLS_SYSMAN_MEMORY})
|
||||
18
level_zero/tools/source/sysman/memory/linux/CMakeLists.txt
Executable file
18
level_zero/tools/source/sysman/memory/linux/CMakeLists.txt
Executable file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_SYSMAN_MEMORY_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/os_memory_imp.cpp
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${L0_SRCS_TOOLS_SYSMAN_MEMORY_LINUX})
|
||||
endif()
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_MEMORY_LINUX ${L0_SRCS_TOOLS_SYSMAN_MEMORY_LINUX})
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sysman/memory/os_memory.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class LinuxMemoryImp : public OsMemory {
|
||||
public:
|
||||
ze_result_t getAllocSize(uint64_t &allocSize) override;
|
||||
ze_result_t getMaxSize(uint64_t &maxSize) override;
|
||||
ze_result_t getMemHealth(zet_mem_health_t &memHealth) override;
|
||||
};
|
||||
|
||||
ze_result_t LinuxMemoryImp::getAllocSize(uint64_t &allocSize) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t LinuxMemoryImp::getMaxSize(uint64_t &maxSize) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
ze_result_t LinuxMemoryImp::getMemHealth(zet_mem_health_t &memHealth) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
OsMemory *OsMemory::create(OsSysman *pOsSysman) {
|
||||
LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp();
|
||||
return static_cast<OsMemory *>(pLinuxMemoryImp);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
31
level_zero/tools/source/sysman/memory/memory.cpp
Normal file
31
level_zero/tools/source/sysman/memory/memory.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/memory/memory.h"
|
||||
|
||||
#include "level_zero/tools/source/sysman/memory/memory_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
MemoryHandleContext::~MemoryHandleContext() {
|
||||
for (Memory *pMemory : handleList) {
|
||||
delete pMemory;
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t MemoryHandleContext::init() {
|
||||
Memory *pMemory = new MemoryImp(pOsSysman, hCoreDevice);
|
||||
handleList.push_back(pMemory);
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t MemoryHandleContext::memoryGet(uint32_t *pCount, zet_sysman_mem_handle_t *phMemory) {
|
||||
*pCount = 0;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
46
level_zero/tools/source/sysman/memory/memory.h
Normal file
46
level_zero/tools/source/sysman/memory/memory.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
struct _zet_sysman_mem_handle_t {
|
||||
virtual ~_zet_sysman_mem_handle_t() = default;
|
||||
};
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct OsSysman;
|
||||
|
||||
class Memory : _zet_sysman_mem_handle_t {
|
||||
public:
|
||||
virtual ze_result_t memoryGetProperties(zet_mem_properties_t *pProperties) = 0;
|
||||
virtual ze_result_t memoryGetBandwidth(zet_mem_bandwidth_t *pBandwidth) = 0;
|
||||
virtual ze_result_t memoryGetState(zet_mem_state_t *pState) = 0;
|
||||
|
||||
static Memory *fromHandle(zet_sysman_mem_handle_t handle) {
|
||||
return static_cast<Memory *>(handle);
|
||||
}
|
||||
inline zet_sysman_mem_handle_t toHandle() { return this; }
|
||||
};
|
||||
|
||||
struct MemoryHandleContext {
|
||||
MemoryHandleContext(OsSysman *pOsSysman, ze_device_handle_t hCoreDevice) : pOsSysman(pOsSysman), hCoreDevice(hCoreDevice){};
|
||||
~MemoryHandleContext();
|
||||
|
||||
ze_result_t init();
|
||||
|
||||
ze_result_t memoryGet(uint32_t *pCount, zet_sysman_mem_handle_t *phMemory);
|
||||
|
||||
OsSysman *pOsSysman;
|
||||
std::vector<Memory *> handleList;
|
||||
ze_device_handle_t hCoreDevice;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
51
level_zero/tools/source/sysman/memory/memory_imp.cpp
Normal file
51
level_zero/tools/source/sysman/memory/memory_imp.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/tools/source/sysman/memory/memory_imp.h"
|
||||
|
||||
#include "level_zero/core/source/device/device.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
ze_result_t MemoryImp::memoryGetBandwidth(zet_mem_bandwidth_t *pBandwidth) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t MemoryImp::memoryGetState(zet_mem_state_t *pState) {
|
||||
|
||||
ze_result_t result;
|
||||
|
||||
result = pOsMemory->getAllocSize(pState->allocatedSize);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = pOsMemory->getMaxSize(pState->maxSize);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = pOsMemory->getMemHealth(pState->health);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ze_result_t MemoryImp::memoryGetProperties(zet_mem_properties_t *pProperties) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
MemoryImp::MemoryImp(OsSysman *pOsSysman, ze_device_handle_t hDevice) {
|
||||
pOsMemory = OsMemory::create(pOsSysman);
|
||||
hCoreDevice = hDevice;
|
||||
}
|
||||
|
||||
MemoryImp::~MemoryImp() {
|
||||
if (nullptr != pOsMemory) {
|
||||
delete pOsMemory;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
35
level_zero/tools/source/sysman/memory/memory_imp.h
Normal file
35
level_zero/tools/source/sysman/memory/memory_imp.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/tools/source/sysman/memory/memory.h"
|
||||
#include "level_zero/tools/source/sysman/memory/os_memory.h"
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class MemoryImp : public Memory {
|
||||
public:
|
||||
ze_result_t memoryGetProperties(zet_mem_properties_t *pProperties) override;
|
||||
ze_result_t memoryGetBandwidth(zet_mem_bandwidth_t *pBandwidth) override;
|
||||
ze_result_t memoryGetState(zet_mem_state_t *pState) override;
|
||||
|
||||
MemoryImp(OsSysman *pOsSysman, ze_device_handle_t hDevice);
|
||||
~MemoryImp() override;
|
||||
|
||||
MemoryImp(const MemoryImp &obj) = delete;
|
||||
MemoryImp &operator=(const MemoryImp &obj) = delete;
|
||||
|
||||
private:
|
||||
OsMemory *pOsMemory;
|
||||
zet_mem_properties_t memoryProperties;
|
||||
void init();
|
||||
ze_device_handle_t hCoreDevice;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
24
level_zero/tools/source/sysman/memory/os_memory.h
Normal file
24
level_zero/tools/source/sysman/memory/os_memory.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
struct OsSysman;
|
||||
class OsMemory {
|
||||
public:
|
||||
virtual ze_result_t getAllocSize(uint64_t &allocSize) = 0;
|
||||
virtual ze_result_t getMaxSize(uint64_t &maxSize) = 0;
|
||||
virtual ze_result_t getMemHealth(zet_mem_health_t &memHealth) = 0;
|
||||
static OsMemory *create(OsSysman *pOsSysman);
|
||||
virtual ~OsMemory() {}
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
18
level_zero/tools/source/sysman/memory/windows/CMakeLists.txt
Executable file
18
level_zero/tools/source/sysman/memory/windows/CMakeLists.txt
Executable file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_SYSMAN_MEMORY_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${L0_SRCS_TOOLS_SYSMAN_MEMORY_WINDOWS})
|
||||
endif()
|
||||
|
||||
# Make our source files visible to parent
|
||||
set_property(GLOBAL PROPERTY L0_SRCS_TOOLS_SYSMAN_MEMORY_WINDOWS ${L0_SRCS_TOOLS_SYSMAN_MEMORY_WINDOWS})
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sysman/memory/os_memory.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class WddmMemoryImp : public OsMemory {
|
||||
|
||||
public:
|
||||
ze_result_t getAllocSize(uint64_t &allocSize) override;
|
||||
ze_result_t getMaxSize(uint64_t &maxSize) override;
|
||||
ze_result_t getMemHealth(zet_mem_health_t &memHealth) override;
|
||||
};
|
||||
|
||||
ze_result_t WddmMemoryImp::getAllocSize(uint64_t &allocSize) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t WddmMemoryImp::getMaxSize(uint64_t &maxSize) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
ze_result_t WddmMemoryImp::getMemHealth(zet_mem_health_t &memHealth) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
OsMemory *OsMemory::create(OsSysman *pOsSysman) {
|
||||
WddmMemoryImp *pWddmMemoryImp = new WddmMemoryImp();
|
||||
return static_cast<OsMemory *>(pWddmMemoryImp);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "level_zero/tools/source/sysman/frequency/frequency.h"
|
||||
#include "level_zero/tools/source/sysman/memory/memory.h"
|
||||
#include "level_zero/tools/source/sysman/pci/pci.h"
|
||||
#include "level_zero/tools/source/sysman/standby/standby.h"
|
||||
#include "level_zero/tools/source/sysman/sysman_device/sysman_device.h"
|
||||
|
||||
@@ -20,26 +20,50 @@ namespace L0 {
|
||||
SysmanImp::SysmanImp(ze_device_handle_t hDevice) {
|
||||
hCoreDevice = hDevice;
|
||||
pOsSysman = OsSysman::create(this);
|
||||
UNRECOVERABLE_IF(nullptr == pOsSysman);
|
||||
pPci = new PciImp(pOsSysman);
|
||||
pSysmanDevice = new SysmanDeviceImp(pOsSysman, hCoreDevice);
|
||||
pFrequencyHandleContext = new FrequencyHandleContext(pOsSysman);
|
||||
pStandbyHandleContext = new StandbyHandleContext(pOsSysman);
|
||||
pMemoryHandleContext = new MemoryHandleContext(pOsSysman, hCoreDevice);
|
||||
}
|
||||
|
||||
SysmanImp::~SysmanImp() {
|
||||
delete pStandbyHandleContext;
|
||||
delete pFrequencyHandleContext;
|
||||
delete pSysmanDevice;
|
||||
delete pPci;
|
||||
if (pMemoryHandleContext) {
|
||||
delete pMemoryHandleContext;
|
||||
}
|
||||
if (pStandbyHandleContext) {
|
||||
delete pStandbyHandleContext;
|
||||
}
|
||||
if (pFrequencyHandleContext) {
|
||||
delete pFrequencyHandleContext;
|
||||
}
|
||||
if (pSysmanDevice) {
|
||||
delete pSysmanDevice;
|
||||
}
|
||||
if (pPci) {
|
||||
delete pPci;
|
||||
}
|
||||
delete pOsSysman;
|
||||
}
|
||||
|
||||
void SysmanImp::init() {
|
||||
pOsSysman->init();
|
||||
pFrequencyHandleContext->init();
|
||||
pStandbyHandleContext->init();
|
||||
pPci->init();
|
||||
pSysmanDevice->init();
|
||||
if (pFrequencyHandleContext) {
|
||||
pFrequencyHandleContext->init();
|
||||
}
|
||||
if (pStandbyHandleContext) {
|
||||
pStandbyHandleContext->init();
|
||||
}
|
||||
if (pMemoryHandleContext) {
|
||||
pMemoryHandleContext->init();
|
||||
}
|
||||
if (pPci) {
|
||||
pPci->init();
|
||||
}
|
||||
if (pSysmanDevice) {
|
||||
pSysmanDevice->init();
|
||||
}
|
||||
}
|
||||
|
||||
ze_result_t SysmanImp::deviceGetProperties(zet_sysman_properties_t *pProperties) {
|
||||
@@ -123,7 +147,7 @@ ze_result_t SysmanImp::firmwareGet(uint32_t *pCount, zet_sysman_firmware_handle_
|
||||
}
|
||||
|
||||
ze_result_t SysmanImp::memoryGet(uint32_t *pCount, zet_sysman_mem_handle_t *phMemory) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
return pMemoryHandleContext->memoryGet(pCount, phMemory);
|
||||
}
|
||||
|
||||
ze_result_t SysmanImp::fabricPortGet(uint32_t *pCount, zet_sysman_fabric_port_handle_t *phPort) {
|
||||
|
||||
@@ -28,11 +28,12 @@ struct SysmanImp : Sysman {
|
||||
|
||||
ze_device_handle_t hCoreDevice;
|
||||
|
||||
OsSysman *pOsSysman;
|
||||
Pci *pPci;
|
||||
SysmanDevice *pSysmanDevice;
|
||||
FrequencyHandleContext *pFrequencyHandleContext;
|
||||
StandbyHandleContext *pStandbyHandleContext;
|
||||
OsSysman *pOsSysman = nullptr;
|
||||
Pci *pPci = nullptr;
|
||||
SysmanDevice *pSysmanDevice = nullptr;
|
||||
FrequencyHandleContext *pFrequencyHandleContext = nullptr;
|
||||
StandbyHandleContext *pStandbyHandleContext = nullptr;
|
||||
MemoryHandleContext *pMemoryHandleContext = nullptr;
|
||||
|
||||
ze_result_t deviceGetProperties(zet_sysman_properties_t *pProperties) override;
|
||||
ze_result_t schedulerGetCurrentMode(zet_sched_mode_t *pMode) override;
|
||||
|
||||
Reference in New Issue
Block a user