Create buffer object with multiple lmem regions for kmd-migrated buffers

This commit enables cross-tile kmd migration for buffers in local memory

Related-To: NEO-6977

Signed-off-by: Milczarek, Slawomir <slawomir.milczarek@intel.com>
This commit is contained in:
Milczarek, Slawomir
2022-06-28 12:36:40 +00:00
committed by Compute-Runtime-Automation
parent f2bbd63d37
commit 30071599df
6 changed files with 107 additions and 8 deletions

View File

@@ -1483,7 +1483,14 @@ BufferObject *DrmMemoryManager::createBufferObjectInMemoryRegion(Drm *drm, Gmm *
}
uint32_t handle = 0;
auto ret = memoryInfo->createGemExtWithSingleRegion(drm, memoryBanks, size, handle);
uint32_t ret = 0;
auto banks = std::bitset<32>(memoryBanks);
if (banks.count() > 1) {
ret = memoryInfo->createGemExtWithMultipleRegions(drm, memoryBanks, size, handle);
} else {
ret = memoryInfo->createGemExtWithSingleRegion(drm, memoryBanks, size, handle);
}
if (ret != 0) {
return nullptr;
@@ -1508,6 +1515,7 @@ bool DrmMemoryManager::createDrmAllocation(Drm *drm, DrmAllocation *allocation,
auto currentBank = 0u;
auto iterationOffset = 0u;
auto banksCnt = storageInfo.getTotalBanksCnt();
auto useKmdMigrationForBuffers = (AllocationType::BUFFER == allocation->getAllocationType() && (DebugManager.flags.UseKmdMigrationForBuffers.get() > 0));
auto handles = storageInfo.getNumBanks();
if (storageInfo.colouringPolicy == ColouringPolicy::ChunkSizeBased) {
@@ -1522,14 +1530,16 @@ bool DrmMemoryManager::createDrmAllocation(Drm *drm, DrmAllocation *allocation,
currentBank = 0;
iterationOffset += banksCnt;
}
uint32_t memoryBanks = static_cast<uint32_t>(storageInfo.memoryBanks.to_ulong());
if (storageInfo.getNumBanks() > 1) {
// check if we have this bank, if not move to next one
// we may have holes in memoryBanks that we need to skip i.e. memoryBanks 1101 and 3 handle allocation
while (!(memoryBanks & (1u << currentBank))) {
currentBank++;
auto memoryBanks = static_cast<uint32_t>(storageInfo.memoryBanks.to_ulong());
if (!useKmdMigrationForBuffers) {
if (storageInfo.getNumBanks() > 1) {
// check if we have this bank, if not move to next one
// we may have holes in memoryBanks that we need to skip i.e. memoryBanks 1101 and 3 handle allocation
while (!(memoryBanks & (1u << currentBank))) {
currentBank++;
}
memoryBanks &= 1u << currentBank;
}
memoryBanks &= 1u << currentBank;
}
auto gmm = allocation->getGmm(handleId);
auto boSize = alignUp(gmm->gmmResourceInfo->getSizeAllocation(), MemoryConstants::pageSize64k);

View File

@@ -122,4 +122,22 @@ uint32_t MemoryInfo::createGemExtWithSingleRegion(Drm *drm, uint32_t memoryBanks
return ret;
}
uint32_t MemoryInfo::createGemExtWithMultipleRegions(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle) {
auto pHwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
auto banks = std::bitset<32>(memoryBanks);
MemRegionsVec memRegions{};
size_t currentBank = 0;
size_t i = 0;
while (i < banks.count()) {
if (banks.test(currentBank)) {
auto regionClassAndInstance = getMemoryRegionClassAndInstance(1u << currentBank, *pHwInfo);
memRegions.push_back(regionClassAndInstance);
i++;
}
currentBank++;
}
auto ret = createGemExt(drm, memRegions, allocSize, handle, {});
return ret;
}
} // namespace NEO

View File

@@ -37,6 +37,7 @@ class MemoryInfo {
uint32_t getTileIndex(uint32_t memoryBank, const HardwareInfo &hwInfo);
MOCKABLE_VIRTUAL uint32_t createGemExtWithSingleRegion(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle);
MOCKABLE_VIRTUAL uint32_t createGemExtWithMultipleRegions(Drm *drm, uint32_t memoryBanks, size_t allocSize, uint32_t &handle);
const RegionContainer &getDrmRegionInfos() const { return drmQueryRegions; }