Add assignRegionsFromDistances logic

If prelim kernel is being used, use distances
logic to assign memory regions.

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2021-12-29 11:14:26 +00:00
committed by Compute-Runtime-Automation
parent 0c2f83579c
commit 5be9d2d584
7 changed files with 78 additions and 57 deletions

View File

@@ -42,7 +42,6 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_manager_local_memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_memory_operations_handler_create.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_query.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}memory_info_extended.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_drm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp

View File

@@ -25,12 +25,23 @@ struct MemoryClassInstance {
uint16_t memoryInstance;
};
struct EngineClassInstance {
uint16_t engineClass;
uint16_t engineInstance;
};
struct MemoryRegion {
MemoryClassInstance region;
uint64_t probedSize;
uint64_t unallocatedSize;
};
struct DistanceInfo {
MemoryClassInstance region;
EngineClassInstance engine;
int32_t distance;
};
class IoctlHelper {
public:
virtual ~IoctlHelper() {}

View File

@@ -15,6 +15,40 @@
namespace NEO {
MemoryInfo::MemoryInfo(const RegionContainer &regionInfo)
: drmQueryRegions(regionInfo), systemMemoryRegion(drmQueryRegions[0]) {
UNRECOVERABLE_IF(systemMemoryRegion.region.memoryClass != I915_MEMORY_CLASS_SYSTEM);
std::copy_if(drmQueryRegions.begin(), drmQueryRegions.end(), std::back_inserter(localMemoryRegions),
[](const MemoryRegion &memoryRegionInfo) {
return (memoryRegionInfo.region.memoryClass == I915_MEMORY_CLASS_DEVICE);
});
}
void MemoryInfo::assignRegionsFromDistances(const std::vector<DistanceInfo> &distances) {
localMemoryRegions.clear();
uint32_t memoryRegionCounter = 1;
uint32_t tile = 0;
for (size_t i = 0; i < distances.size(); i++) {
if (i > 0 && distances[i].region.memoryInstance != distances[i - 1].region.memoryInstance) {
UNRECOVERABLE_IF(distances[i].distance == 0);
memoryRegionCounter++;
tile++;
}
if ((distances[i].distance != 0) || (localMemoryRegions.size() == (tile + 1))) {
continue;
}
UNRECOVERABLE_IF((drmQueryRegions[memoryRegionCounter].region.memoryClass != distances[i].region.memoryClass) ||
(drmQueryRegions[memoryRegionCounter].region.memoryInstance != distances[i].region.memoryInstance));
localMemoryRegions.push_back(drmQueryRegions[memoryRegionCounter]);
}
}
uint32_t MemoryInfo::createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle) {
return IoctlHelper::get(drm)->createGemExt(drm, memClassInstances, allocSize, handle);
}

View File

@@ -24,7 +24,7 @@ class MemoryInfo {
MemoryInfo(const RegionContainer &regionInfo);
void assignRegionsFromDistances(const void *distanceInfosPtr, size_t size);
void assignRegionsFromDistances(const std::vector<DistanceInfo> &distances);
MOCKABLE_VIRTUAL uint32_t createGemExt(Drm *drm, const std::vector<MemoryClassInstance> &memClassInstances, size_t allocSize, uint32_t &handle);

View File

@@ -1,30 +0,0 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/linux/memory_info.h"
#include "drm/i915_drm.h"
#include <algorithm>
#include <iterator>
namespace NEO {
MemoryInfo::MemoryInfo(const RegionContainer &regionInfo)
: drmQueryRegions(regionInfo), systemMemoryRegion(drmQueryRegions[0]) {
UNRECOVERABLE_IF(systemMemoryRegion.region.memoryClass != I915_MEMORY_CLASS_SYSTEM);
std::copy_if(drmQueryRegions.begin(), drmQueryRegions.end(), std::back_inserter(localMemoryRegions),
[](const MemoryRegion &memoryRegionInfo) {
return (memoryRegionInfo.region.memoryClass == I915_MEMORY_CLASS_DEVICE);
});
}
void MemoryInfo::assignRegionsFromDistances(const void *distanceInfosPtr, size_t size) {
}
} // namespace NEO