feature: Add debug keys for chunking allocation and size

Related-to: NEO-7695

New debug keys added:

EnableBOChunking is now a mask
0 = no chunking (default).
1 = shared allocations only
2 = device allocations only
3 = shared and device allocations

MinimalAllocationSizeForChunking sets the minimum allocation
size to apply chunking. Default is 2MB.

Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
Jaime Arteaga
2023-07-05 21:41:17 +00:00
committed by Compute-Runtime-Automation
parent aa0beb8191
commit 23eeaf816d
11 changed files with 304 additions and 11 deletions

View File

@@ -1869,20 +1869,23 @@ bool DrmMemoryManager::createDrmAllocation(Drm *drm, DrmAllocation *allocation,
size_t boTotalChunkSize = 0;
if (AllocationType::BUFFER == allocation->getAllocationType() &&
drm->getChunkingAvailable()) {
(drm->getChunkingMode() & 0x02)) {
boTotalChunkSize = allocation->getUnderlyingBufferSize();
uint32_t numOfChunks = DebugManager.flags.NumberOfBOChunks.get();
size_t chunkingSize = boTotalChunkSize / numOfChunks;
// Dont chunk for sizes less than chunkThreshold
if (!(chunkingSize & (MemoryConstants::chunkThreshold - 1))) {
if (boTotalChunkSize >= drm->getMinimalSizeForChunking() &&
!(chunkingSize & (MemoryConstants::chunkThreshold - 1))) {
handles = 1;
allocation->resizeBufferObjects(handles);
bos.resize(handles);
useChunking = true;
}
} else if (storageInfo.colouringPolicy == ColouringPolicy::ChunkSizeBased) {
handles = allocation->getNumGmms();
allocation->resizeBufferObjects(handles);
@@ -2219,7 +2222,9 @@ GraphicsAllocation *DrmMemoryManager::createSharedUnifiedMemoryAllocation(const
size_t chunkingSize = size / numOfChunks;
// Dont chunk for sizes less than chunkThreshold
if (drm.getChunkingAvailable() && !(chunkingSize & (MemoryConstants::chunkThreshold - 1))) {
if ((drm.getChunkingMode() & 0x01) &&
!(chunkingSize & (MemoryConstants::chunkThreshold - 1)) &&
size >= drm.getMinimalSizeForChunking()) {
numHandles = 1;
useChunking = true;
}

View File

@@ -1146,14 +1146,24 @@ bool Drm::isSetPairAvailable() {
}
bool Drm::isChunkingAvailable() {
if (DebugManager.flags.EnableBOChunking.get()) {
if (DebugManager.flags.EnableBOChunking.get() != 0) {
std::call_once(checkChunkingOnce, [this]() {
int ret = ioctlHelper->isChunkingAvailable();
if (ret) {
chunkingAvailable = true;
chunkingMode = DebugManager.flags.EnableBOChunking.get();
}
if (DebugManager.flags.MinimalAllocationSizeForChunking.get() != -1) {
minimalChunkingSize = DebugManager.flags.MinimalAllocationSizeForChunking.get();
}
printDebugString(DebugManager.flags.PrintBOChunkingLogs.get(), stdout,
"Chunking available: %d\n", chunkingAvailable);
"Chunking available: %d; enabled for: shared allocations %d, device allocations %d; minimalChunkingSize: %zd\n",
chunkingAvailable,
(chunkingMode & 0x01),
(chunkingMode & 0x02),
minimalChunkingSize);
});
}
return chunkingAvailable;

View File

@@ -7,6 +7,7 @@
#pragma once
#include "shared/source/gmm_helper/gmm_lib.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/driver_model_type.h"
#include "shared/source/memory_manager/definitions/engine_limits.h"
#include "shared/source/os_interface/linux/drm_debug.h"
@@ -151,6 +152,8 @@ class Drm : public DriverModel {
MOCKABLE_VIRTUAL bool getSetPairAvailable() { return setPairAvailable; }
MOCKABLE_VIRTUAL bool isChunkingAvailable();
MOCKABLE_VIRTUAL bool getChunkingAvailable() { return chunkingAvailable; }
MOCKABLE_VIRTUAL uint32_t getChunkingMode() { return chunkingMode; }
uint32_t getMinimalSizeForChunking() { return minimalChunkingSize; }
MOCKABLE_VIRTUAL bool useVMBindImmediate() const;
@@ -334,6 +337,8 @@ class Drm : public DriverModel {
bool directSubmissionActive = false;
bool setPairAvailable = false;
bool chunkingAvailable = false;
uint32_t chunkingMode = 0;
uint32_t minimalChunkingSize = MemoryConstants::pageSize2Mb;
bool contextDebugSupported = false;
bool pageFaultSupported = false;
bool completionFenceSupported = false;