Revert "fix: set memoryBanks correctly for single memory bank"

This reverts commit ec5477e3ee.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation 2025-01-11 01:25:43 +01:00 committed by Compute-Runtime-Automation
parent a27c9200d3
commit dc49d09e64
2 changed files with 21 additions and 47 deletions

View File

@ -355,7 +355,6 @@ SubmissionStatus DrmMemoryManager::emitPinningRequestForBoContainer(BufferObject
}
StorageInfo DrmMemoryManager::createStorageInfoFromProperties(const AllocationProperties &properties) {
auto storageInfo{MemoryManager::createStorageInfoFromProperties(properties)};
auto *memoryInfo = getDrm(properties.rootDeviceIndex).getMemoryInfo();
@ -367,17 +366,9 @@ StorageInfo DrmMemoryManager::createStorageInfoFromProperties(const AllocationPr
DEBUG_BREAK_IF(localMemoryRegions.empty());
DeviceBitfield allMemoryBanks{0b0};
if (storageInfo.tileInstanced) {
const auto deviceCount = GfxCoreHelper::getSubDevicesCount(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getHardwareInfo());
const auto subDevicesMask = executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->deviceAffinityMask.getGenericSubDevicesMask().to_ulong();
const DeviceBitfield allTilesValue(properties.subDevicesBitfield.count() == 1 ? maxNBitValue(deviceCount) & subDevicesMask : properties.subDevicesBitfield);
allMemoryBanks = allTilesValue;
} else {
for (auto i = 0u; i < localMemoryRegions.size(); ++i) {
if ((properties.subDevicesBitfield & localMemoryRegions[i].tilesMask).any()) {
allMemoryBanks.set(i);
}
for (auto i = 0u; i < localMemoryRegions.size(); ++i) {
if ((properties.subDevicesBitfield & localMemoryRegions[i].tilesMask).any()) {
allMemoryBanks.set(i);
}
}
if (allMemoryBanks.none()) {
@ -1789,8 +1780,7 @@ void DrmMemoryManager::unlockBufferObject(BufferObject *bo) {
bo->setLockedAddress(nullptr);
}
void createColouredGmms(GmmHelper *gmmHelper, DrmAllocation &allocation, bool compression) {
const StorageInfo &storageInfo = allocation.storageInfo;
void createColouredGmms(GmmHelper *gmmHelper, DrmAllocation &allocation, const StorageInfo &storageInfo, bool compression) {
DEBUG_BREAK_IF(storageInfo.colouringPolicy == ColouringPolicy::deviceCountBased && storageInfo.colouringGranularity != MemoryConstants::pageSize64k);
auto remainingSize = alignUp(allocation.getUnderlyingBufferSize(), storageInfo.colouringGranularity);
@ -1834,14 +1824,12 @@ void createColouredGmms(GmmHelper *gmmHelper, DrmAllocation &allocation, bool co
}
}
void fillGmmsInAllocation(GmmHelper *gmmHelper, DrmAllocation *allocation) {
void fillGmmsInAllocation(GmmHelper *gmmHelper, DrmAllocation *allocation, const StorageInfo &storageInfo) {
auto alignedSize = alignUp(allocation->getUnderlyingBufferSize(), MemoryConstants::pageSize64k);
auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper<ProductHelper>();
GmmRequirements gmmRequirements{};
gmmRequirements.allowLargePages = true;
gmmRequirements.preferCompressed = false;
const StorageInfo &storageInfo = allocation->storageInfo;
for (auto handleId = 0u; handleId < storageInfo.getNumBanks(); handleId++) {
StorageInfo limitedStorageInfo = storageInfo;
limitedStorageInfo.memoryBanks &= 1u << handleId;
@ -1957,16 +1945,18 @@ inline std::unique_ptr<DrmAllocation> DrmMemoryManager::makeDrmAllocation(const
auto allocation = std::make_unique<DrmAllocation>(allocationData.rootDeviceIndex, allocationData.storageInfo.getNumBanks(),
allocationData.type, nullptr, nullptr, gmmHelper->canonize(gpuAddress),
sizeAligned, MemoryPool::localMemory);
allocation->storageInfo = allocationData.storageInfo;
if (createSingleHandle) {
allocation->setDefaultGmm(gmm.release());
} else if (allocationData.storageInfo.multiStorage) {
createColouredGmms(gmmHelper, *allocation, allocationData.flags.preferCompressed);
createColouredGmms(gmmHelper,
*allocation,
allocationData.storageInfo,
allocationData.flags.preferCompressed);
} else {
fillGmmsInAllocation(gmmHelper, allocation.get());
fillGmmsInAllocation(gmmHelper, allocation.get(), allocationData.storageInfo);
}
allocation->storageInfo = allocationData.storageInfo;
allocation->setFlushL3Required(allocationData.flags.flushL3);
allocation->setUncacheable(allocationData.flags.uncacheable);
if (debugManager.flags.EnableHostAllocationMemPolicy.get()) {
@ -2265,6 +2255,7 @@ bool DrmMemoryManager::createDrmAllocation(Drm *drm, DrmAllocation *allocation,
auto useKmdMigrationForBuffers = (AllocationType::buffer == allocation->getAllocationType() && (debugManager.flags.UseKmdMigrationForBuffers.get() > 0));
auto handles = storageInfo.getNumBanks();
bool useChunking = false;
size_t boTotalChunkSize = 0;
if (checkAllocationForChunking(allocation->getUnderlyingBufferSize(), drm->getMinimalSizeForChunking(),
@ -2274,19 +2265,21 @@ bool DrmMemoryManager::createDrmAllocation(Drm *drm, DrmAllocation *allocation,
handles = 1;
allocation->resizeBufferObjects(handles);
bos.resize(handles);
useChunking = true;
boTotalChunkSize = allocation->getUnderlyingBufferSize();
allocation->setNumHandles(handles);
return createDrmChunkedAllocation(drm, allocation, gpuAddress, boTotalChunkSize, maxOsContextCount);
}
if (storageInfo.colouringPolicy == ColouringPolicy::chunkSizeBased) {
} else if (storageInfo.colouringPolicy == ColouringPolicy::chunkSizeBased) {
handles = allocation->getNumGmms();
allocation->resizeBufferObjects(handles);
bos.resize(handles);
allocation->setNumHandles(handles);
}
allocation->setNumHandles(handles);
int32_t pairHandle = -1;
if (useChunking) {
return createDrmChunkedAllocation(drm, allocation, gpuAddress, boTotalChunkSize, maxOsContextCount);
}
for (auto handleId = 0u; handleId < handles; handleId++, currentBank++) {
if (currentBank == banksCnt) {
currentBank = 0;

View File

@ -5512,7 +5512,7 @@ TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenSingleLocalMemoryWhenParticular
EXPECT_EQ(memoryManager->computeStorageInfoMemoryBanksCalled, 2UL);
}
TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenSingleLocalMemoryAndClonedAllocationTypeWhenAllTilesIndicatedThenCorrectBankIsSelected) {
TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenSingleLocalMemoryWhenAllSubdevicesIndicatedThenCorrectBankIsSelected) {
auto *memoryInfo = static_cast<MockMemoryInfo *>(mock->memoryInfo.get());
auto &localMemoryRegions = memoryInfo->localMemoryRegions;
localMemoryRegions.resize(1U);
@ -5529,25 +5529,6 @@ TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenSingleLocalMemoryAndClonedAlloc
EXPECT_EQ(memoryManager->computeStorageInfoMemoryBanksCalled, 2UL);
}
TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenSingleLocalMemoryAndNonClonedAllocationTypeWhenAllTilesIndicatedThenCorrectBankIsSelected) {
auto *memoryInfo = static_cast<MockMemoryInfo *>(mock->memoryInfo.get());
auto &localMemoryRegions = memoryInfo->localMemoryRegions;
localMemoryRegions.resize(1U);
localMemoryRegions[0].tilesMask = 0b11;
AllocationProperties properties{1, true, 4096, AllocationType::workPartitionSurface, false, {}};
properties.subDevicesBitfield = 0b11;
memoryManager->computeStorageInfoMemoryBanksCalled = 0U;
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
constexpr auto defaultMemoryBanks = 0b01;
EXPECT_NE(storageInfo.memoryBanks, defaultMemoryBanks);
EXPECT_EQ(storageInfo.memoryBanks, storageInfo.pageTablesVisibility);
EXPECT_TRUE(storageInfo.tileInstanced);
EXPECT_EQ(memoryManager->computeStorageInfoMemoryBanksCalled, 2UL);
}
TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenMultipleLocalMemoryRegionsWhenParticularSubdeviceIndicatedThenItIsSelected) {
auto *memoryInfo = static_cast<MockMemoryInfo *>(mock->memoryInfo.get());
auto &localMemoryRegions = memoryInfo->localMemoryRegions;