mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-07 21:27:04 +08:00
Update memory component to latest spec.
Change-Id: I766a3b87d240d26118cf72ea0717bc504784e764
This commit is contained in:
committed by
sys_ocldev
parent
881d7328bc
commit
2fa30d7d6c
@@ -5,6 +5,7 @@
|
||||
#
|
||||
|
||||
set(L0_SRCS_TOOLS_SYSMAN_MEMORY_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_imp.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -5,27 +5,182 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "sysman/memory/os_memory.h"
|
||||
#include "sysman/memory/windows/os_memory_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
class WddmMemoryImp : public OsMemory {
|
||||
ze_result_t WddmMemoryImp::getProperties(zes_mem_properties_t *pProperties) {
|
||||
ze_result_t status = ZE_RESULT_SUCCESS;
|
||||
uint32_t valueSmall = 0;
|
||||
uint64_t valueLarge = 0;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
|
||||
public:
|
||||
ze_result_t getMemorySize(uint64_t &maxSize, uint64_t &allocSize) override;
|
||||
ze_result_t getMemHealth(zes_mem_health_t &memHealth) override;
|
||||
};
|
||||
pProperties->onSubdevice = false;
|
||||
pProperties->subdeviceId = 0;
|
||||
|
||||
ze_result_t WddmMemoryImp::getMemorySize(uint64_t &maxSize, uint64_t &allocSize) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::MemoryComponent;
|
||||
request.requestId = KmdSysman::Requests::Memory::MemoryType;
|
||||
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
memcpy_s(&valueSmall, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
switch (valueSmall) {
|
||||
case KmdSysman::MemoryType::DDR4: {
|
||||
pProperties->type = ZES_MEM_TYPE_DDR4;
|
||||
} break;
|
||||
case KmdSysman::MemoryType::DDR5: {
|
||||
pProperties->type = ZES_MEM_TYPE_DDR5;
|
||||
} break;
|
||||
case KmdSysman::MemoryType::LPDDR5: {
|
||||
pProperties->type = ZES_MEM_TYPE_LPDDR5;
|
||||
} break;
|
||||
case KmdSysman::MemoryType::LPDDR4: {
|
||||
pProperties->type = ZES_MEM_TYPE_LPDDR4;
|
||||
} break;
|
||||
case KmdSysman::MemoryType::DDR3: {
|
||||
pProperties->type = ZES_MEM_TYPE_DDR3;
|
||||
} break;
|
||||
case KmdSysman::MemoryType::LPDDR3: {
|
||||
pProperties->type = ZES_MEM_TYPE_LPDDR3;
|
||||
} break;
|
||||
default: {
|
||||
pProperties->type = ZES_MEM_TYPE_FORCE_UINT32;
|
||||
} break;
|
||||
}
|
||||
|
||||
request.requestId = KmdSysman::Requests::Memory::PhysicalSize;
|
||||
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
memcpy_s(&valueLarge, sizeof(uint64_t), response.dataBuffer, sizeof(uint64_t));
|
||||
pProperties->physicalSize = valueLarge;
|
||||
|
||||
request.requestId = KmdSysman::Requests::Memory::NumChannels;
|
||||
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
memcpy_s(&valueSmall, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
pProperties->numChannels = valueSmall;
|
||||
|
||||
request.requestId = KmdSysman::Requests::Memory::MemoryLocation;
|
||||
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
memcpy_s(&valueSmall, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
pProperties->location = static_cast<zes_mem_loc_t>(valueSmall);
|
||||
|
||||
request.requestId = KmdSysman::Requests::Memory::MemoryWidth;
|
||||
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
memcpy_s(&valueSmall, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
pProperties->busWidth = valueSmall;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t WddmMemoryImp::getMemHealth(zes_mem_health_t &memHealth) {
|
||||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
ze_result_t WddmMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) {
|
||||
ze_result_t status = ZE_RESULT_SUCCESS;
|
||||
uint32_t valueSmall = 0;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
|
||||
pBandwidth->writeCounter = 0;
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::MemoryComponent;
|
||||
request.requestId = KmdSysman::Requests::Memory::MaxBandwidth;
|
||||
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
memcpy_s(&valueSmall, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
pBandwidth->maxBandwidth = valueSmall;
|
||||
|
||||
request.requestId = KmdSysman::Requests::Memory::CurrentBandwidthRead;
|
||||
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
memcpy_s(&valueSmall, sizeof(uint32_t), response.dataBuffer, sizeof(uint32_t));
|
||||
pBandwidth->readCounter = valueSmall * MbpsToBytesPerSecond;
|
||||
|
||||
std::chrono::time_point<std::chrono::steady_clock> ts = std::chrono::steady_clock::now();
|
||||
pBandwidth->timestamp = std::chrono::duration_cast<std::chrono::microseconds>(ts.time_since_epoch()).count();
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t WddmMemoryImp::getState(zes_mem_state_t *pState) {
|
||||
ze_result_t status = ZE_RESULT_SUCCESS;
|
||||
uint64_t valueLarge = 0;
|
||||
KmdSysman::RequestProperty request;
|
||||
KmdSysman::ResponseProperty response;
|
||||
|
||||
pState->health = ZES_MEM_HEALTH_OK;
|
||||
|
||||
request.commandId = KmdSysman::Command::Get;
|
||||
request.componentId = KmdSysman::Component::MemoryComponent;
|
||||
request.requestId = KmdSysman::Requests::Memory::PhysicalSize;
|
||||
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
memcpy_s(&valueLarge, sizeof(uint64_t), response.dataBuffer, sizeof(uint64_t));
|
||||
pState->size = valueLarge;
|
||||
|
||||
request.requestId = KmdSysman::Requests::Memory::CurrentFreeMemorySize;
|
||||
|
||||
status = pKmdSysManager->requestSingle(request, response);
|
||||
|
||||
if (status != ZE_RESULT_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
memcpy_s(&valueLarge, sizeof(uint64_t), response.dataBuffer, sizeof(uint64_t));
|
||||
pState->free = valueLarge;
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
WddmMemoryImp::WddmMemoryImp(OsSysman *pOsSysman) {
|
||||
WddmSysmanImp *pWddmSysmanImp = static_cast<WddmSysmanImp *>(pOsSysman);
|
||||
pKmdSysManager = &pWddmSysmanImp->getKmdSysManager();
|
||||
}
|
||||
|
||||
OsMemory *OsMemory::create(OsSysman *pOsSysman) {
|
||||
WddmMemoryImp *pWddmMemoryImp = new WddmMemoryImp();
|
||||
WddmMemoryImp *pWddmMemoryImp = new WddmMemoryImp(pOsSysman);
|
||||
return static_cast<OsMemory *>(pWddmMemoryImp);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
||||
|
||||
#include "sysman/memory/os_memory.h"
|
||||
#include "sysman/windows/os_sysman_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
class KmdSysManager;
|
||||
|
||||
constexpr uint32_t MbpsToBytesPerSecond = 125000;
|
||||
|
||||
class WddmMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass {
|
||||
public:
|
||||
ze_result_t getProperties(zes_mem_properties_t *pProperties) override;
|
||||
ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) override;
|
||||
ze_result_t getState(zes_mem_state_t *pState) override;
|
||||
WddmMemoryImp(OsSysman *pOsSysman);
|
||||
WddmMemoryImp() = default;
|
||||
~WddmMemoryImp() override = default;
|
||||
|
||||
protected:
|
||||
KmdSysManager *pKmdSysManager = nullptr;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user