mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Refactor memory info
Related-To: NEO-6149 Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c81c57ec71
commit
d61741dd9f
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
|
||||
@@ -18,33 +19,68 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct MemoryInfoImpl : public MemoryInfo {
|
||||
class MemoryInfoImpl : public MemoryInfo {
|
||||
public:
|
||||
using RegionContainer = std::vector<drm_i915_memory_region_info>;
|
||||
|
||||
~MemoryInfoImpl() override = default;
|
||||
|
||||
MemoryInfoImpl(const drm_i915_memory_region_info *regionInfo, size_t count) : regions(regionInfo, regionInfo + count) {
|
||||
}
|
||||
MemoryInfoImpl(const drm_i915_memory_region_info *regionInfo, size_t count);
|
||||
|
||||
drm_i915_gem_memory_class_instance getMemoryRegionClassAndInstance(uint32_t memoryBank) {
|
||||
auto index = (memoryBank > 0) ? Math::log2(memoryBank) + 1 : 0;
|
||||
if (index < regions.size()) {
|
||||
return regions[index].region;
|
||||
void assignRegionsFromDistances(const void *distanceInfosPtr, size_t size);
|
||||
|
||||
drm_i915_gem_memory_class_instance getMemoryRegionClassAndInstance(uint32_t memoryBank, const HardwareInfo &hwInfo) {
|
||||
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
if (!hwHelper.getEnableLocalMemory(hwInfo) || memoryBank == 0) {
|
||||
return systemMemoryRegion.region;
|
||||
}
|
||||
return {invalidMemoryRegion(), invalidMemoryRegion()};
|
||||
|
||||
auto index = Math::log2(memoryBank);
|
||||
|
||||
index = hwHelper.isBankOverrideRequired(hwInfo) ? 0 : index;
|
||||
|
||||
if (DebugManager.flags.OverrideDrmRegion.get() != -1) {
|
||||
index = DebugManager.flags.OverrideDrmRegion.get();
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(index >= localMemoryRegions.size());
|
||||
|
||||
return localMemoryRegions[index].region;
|
||||
}
|
||||
|
||||
size_t getMemoryRegionSize(uint32_t memoryBank) override {
|
||||
auto index = (memoryBank > 0) ? Math::log2(memoryBank) + 1 : 0;
|
||||
if (index < regions.size()) {
|
||||
return regions[index].probed_size;
|
||||
if (DebugManager.flags.PrintMemoryRegionSizes.get()) {
|
||||
printRegionSizes();
|
||||
}
|
||||
if (memoryBank == 0) {
|
||||
return systemMemoryRegion.probed_size;
|
||||
}
|
||||
|
||||
auto index = Math::log2(memoryBank);
|
||||
|
||||
if (index < localMemoryRegions.size()) {
|
||||
return localMemoryRegions[index].probed_size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static constexpr uint16_t invalidMemoryRegion() {
|
||||
return static_cast<uint16_t>(-1);
|
||||
void printRegionSizes() {
|
||||
for (auto region : drmQueryRegions) {
|
||||
std::cout << "Memory type: " << region.region.memory_class
|
||||
<< ", memory instance: " << region.region.memory_instance
|
||||
<< ", region size: " << region.probed_size << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<drm_i915_memory_region_info> regions;
|
||||
const RegionContainer &getDrmRegionInfos() const { return drmQueryRegions; }
|
||||
|
||||
protected:
|
||||
const RegionContainer drmQueryRegions;
|
||||
|
||||
const drm_i915_memory_region_info &systemMemoryRegion;
|
||||
|
||||
RegionContainer localMemoryRegions;
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user