Add SubDevice support for Sysman Memory module

Change-Id: Iec5918486fc2c00e14de074aca18e6de63ba1600
Signed-off-by: SaiKishore Konda <saikishore.konda@intel.com>
This commit is contained in:
SaiKishore Konda
2020-09-29 03:32:35 -04:00
committed by sys_ocldev
parent 2d27570292
commit e28f937683
16 changed files with 173 additions and 35 deletions

View File

@@ -13,7 +13,7 @@
namespace L0 {
LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman) {
LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pDrm = &pLinuxSysmanImp->getDrm();
pDevice = pLinuxSysmanImp->getDeviceHandle();
@@ -26,8 +26,8 @@ bool LinuxMemoryImp::isMemoryModuleSupported() {
ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
pProperties->type = ZES_MEM_TYPE_DDR;
pProperties->location = ZES_MEM_LOC_DEVICE;
pProperties->onSubdevice = false;
pProperties->subdeviceId = 0;
pProperties->onSubdevice = isSubdevice;
pProperties->subdeviceId = subdeviceId;
pProperties->busWidth = -1;
pProperties->numChannels = -1;
pProperties->physicalSize = 0;
@@ -60,8 +60,8 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
return ZE_RESULT_SUCCESS;
}
OsMemory *OsMemory::create(OsSysman *pOsSysman) {
LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp(pOsSysman);
OsMemory *OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp(pOsSysman, onSubdevice, subdeviceId);
return static_cast<OsMemory *>(pLinuxMemoryImp);
}

View File

@@ -22,12 +22,16 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) override;
ze_result_t getState(zes_mem_state_t *pState) override;
bool isMemoryModuleSupported() override;
LinuxMemoryImp(OsSysman *pOsSysman);
LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
LinuxMemoryImp() = default;
~LinuxMemoryImp() override = default;
protected:
NEO::Drm *pDrm = nullptr;
Device *pDevice = nullptr;
private:
bool isSubdevice = false;
uint32_t subdeviceId = 0;
};
} // namespace L0

View File

@@ -11,7 +11,7 @@
namespace L0 {
LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman) {
LinuxMemoryImp::LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
LinuxSysmanImp *pLinuxSysmanImp = static_cast<LinuxSysmanImp *>(pOsSysman);
pDevice = pLinuxSysmanImp->getDeviceHandle();
}
@@ -20,9 +20,16 @@ bool LinuxMemoryImp::isMemoryModuleSupported() {
}
ze_result_t LinuxMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
pProperties->type = ZES_MEM_TYPE_DDR;
pProperties->location = ZES_MEM_LOC_DEVICE;
pProperties->onSubdevice = isSubdevice;
pProperties->subdeviceId = subdeviceId;
pProperties->busWidth = -1;
pProperties->numChannels = -1;
pProperties->physicalSize = 0;
return ZE_RESULT_SUCCESS;
}
ze_result_t LinuxMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
@@ -31,8 +38,8 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
OsMemory *OsMemory::create(OsSysman *pOsSysman) {
LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp(pOsSysman);
OsMemory *OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
LinuxMemoryImp *pLinuxMemoryImp = new LinuxMemoryImp(pOsSysman, onSubdevice, subdeviceId);
return static_cast<OsMemory *>(pLinuxMemoryImp);
}

View File

@@ -21,11 +21,15 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) override;
ze_result_t getState(zes_mem_state_t *pState) override;
bool isMemoryModuleSupported() override;
LinuxMemoryImp(OsSysman *pOsSysman);
LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
LinuxMemoryImp() = default;
~LinuxMemoryImp() override = default;
protected:
Device *pDevice = nullptr;
private:
bool isSubdevice = false;
uint32_t subdeviceId = 0;
};
} // namespace L0

View File

@@ -19,8 +19,8 @@ MemoryHandleContext::~MemoryHandleContext() {
}
}
void MemoryHandleContext::createHandle() {
Memory *pMemory = new MemoryImp(pOsSysman);
void MemoryHandleContext::createHandle(ze_device_handle_t deviceHandle) {
Memory *pMemory = new MemoryImp(pOsSysman, deviceHandle);
if (pMemory->initSuccess == true) {
handleList.push_back(pMemory);
} else {
@@ -28,8 +28,10 @@ void MemoryHandleContext::createHandle() {
}
}
ze_result_t MemoryHandleContext::init() {
createHandle();
ze_result_t MemoryHandleContext::init(std::vector<ze_device_handle_t> &deviceHandles) {
for (auto deviceHandle : deviceHandles) {
createHandle(deviceHandle);
}
return ZE_RESULT_SUCCESS;
}

View File

@@ -6,6 +6,7 @@
*/
#pragma once
#include "level_zero/core/source/device/device.h"
#include <level_zero/zes_api.h>
#include <vector>
@@ -35,7 +36,7 @@ struct MemoryHandleContext {
MemoryHandleContext(OsSysman *pOsSysman) : pOsSysman(pOsSysman){};
~MemoryHandleContext();
ze_result_t init();
ze_result_t init(std::vector<ze_device_handle_t> &deviceHandles);
ze_result_t memoryGet(uint32_t *pCount, zes_mem_handle_t *phMemory);
@@ -44,7 +45,7 @@ struct MemoryHandleContext {
std::vector<Memory *> handleList = {};
private:
void createHandle();
void createHandle(ze_device_handle_t deviceHandle);
};
} // namespace L0

View File

@@ -29,8 +29,10 @@ void MemoryImp::init() {
}
}
MemoryImp::MemoryImp(OsSysman *pOsSysman) {
pOsMemory = OsMemory::create(pOsSysman);
MemoryImp::MemoryImp(OsSysman *pOsSysman, ze_device_handle_t handle) : deviceHandle(handle) {
ze_device_properties_t deviceProperties = {};
Device::fromHandle(deviceHandle)->getProperties(&deviceProperties);
pOsMemory = OsMemory::create(pOsSysman, deviceProperties.flags & ZE_DEVICE_PROPERTY_FLAG_SUBDEVICE, deviceProperties.subdeviceId);
init();
}

View File

@@ -20,7 +20,7 @@ class MemoryImp : public Memory, NEO::NonCopyableOrMovableClass {
ze_result_t memoryGetBandwidth(zes_mem_bandwidth_t *pBandwidth) override;
ze_result_t memoryGetState(zes_mem_state_t *pState) override;
MemoryImp(OsSysman *pOsSysman);
MemoryImp(OsSysman *pOsSysman, ze_device_handle_t handle);
~MemoryImp() override;
MemoryImp() = default;
@@ -29,6 +29,7 @@ class MemoryImp : public Memory, NEO::NonCopyableOrMovableClass {
private:
zes_mem_properties_t memoryProperties = {};
ze_device_handle_t deviceHandle = nullptr;
};
} // namespace L0

View File

@@ -18,7 +18,7 @@ class OsMemory {
virtual ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) = 0;
virtual ze_result_t getState(zes_mem_state_t *pState) = 0;
virtual bool isMemoryModuleSupported() = 0;
static OsMemory *create(OsSysman *pOsSysman);
static OsMemory *create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
virtual ~OsMemory() {}
};

View File

@@ -18,8 +18,8 @@ ze_result_t WddmMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
KmdSysman::RequestProperty request;
KmdSysman::ResponseProperty response;
pProperties->onSubdevice = false;
pProperties->subdeviceId = 0;
pProperties->onSubdevice = isSubdevice;
pProperties->subdeviceId = subdeviceId;
request.commandId = KmdSysman::Command::Get;
request.componentId = KmdSysman::Component::MemoryComponent;
@@ -176,14 +176,14 @@ ze_result_t WddmMemoryImp::getState(zes_mem_state_t *pState) {
return ZE_RESULT_SUCCESS;
}
WddmMemoryImp::WddmMemoryImp(OsSysman *pOsSysman) {
WddmMemoryImp::WddmMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) : isSubdevice(onSubdevice), subdeviceId(subdeviceId) {
WddmSysmanImp *pWddmSysmanImp = static_cast<WddmSysmanImp *>(pOsSysman);
pKmdSysManager = &pWddmSysmanImp->getKmdSysManager();
pDevice = pWddmSysmanImp->getDeviceHandle();
}
OsMemory *OsMemory::create(OsSysman *pOsSysman) {
WddmMemoryImp *pWddmMemoryImp = new WddmMemoryImp(pOsSysman);
OsMemory *OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) {
WddmMemoryImp *pWddmMemoryImp = new WddmMemoryImp(pOsSysman, onSubdevice, subdeviceId);
return static_cast<OsMemory *>(pWddmMemoryImp);
}

View File

@@ -22,13 +22,15 @@ class WddmMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) override;
ze_result_t getState(zes_mem_state_t *pState) override;
bool isMemoryModuleSupported() override;
WddmMemoryImp(OsSysman *pOsSysman);
WddmMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId);
WddmMemoryImp() = default;
~WddmMemoryImp() override = default;
protected:
KmdSysManager *pKmdSysManager = nullptr;
Device *pDevice = nullptr;
bool isSubdevice = false;
uint32_t subdeviceId = 0;
};
} // namespace L0

View File

@@ -94,7 +94,7 @@ void SysmanDeviceImp::init() {
pRasHandleContext->init();
}
if (pMemoryHandleContext) {
pMemoryHandleContext->init();
pMemoryHandleContext->init(deviceHandles);
}
if (pGlobalOperations) {
pGlobalOperations->init();