mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Allow debug flag to apply allocation alignment for heaps
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
841e536bc2
commit
4809a2a9b3
@ -68,7 +68,7 @@ class GfxPartition {
|
||||
return getHeap(heapIndex).allocate(size);
|
||||
}
|
||||
|
||||
uint64_t heapAllocateWithCustomAlignment(HeapIndex heapIndex, size_t &size, size_t alignment) {
|
||||
MOCKABLE_VIRTUAL uint64_t heapAllocateWithCustomAlignment(HeapIndex heapIndex, size_t &size, size_t alignment) {
|
||||
return getHeap(heapIndex).allocateWithCustomAlignment(size, alignment);
|
||||
}
|
||||
|
||||
|
@ -1331,7 +1331,13 @@ uint64_t getGpuAddress(const AlignmentSelector &alignmentSelector, HeapAssigner
|
||||
case AllocationType::INTERNAL_HEAP:
|
||||
case AllocationType::DEBUG_MODULE_AREA: {
|
||||
auto heap = heapAssigner.get32BitHeapIndex(allocType, true, hwInfo, useFrontWindow);
|
||||
gpuAddress = gmmHelper.canonize(gfxPartition->heapAllocate(heap, sizeAllocated));
|
||||
size_t alignment = 0;
|
||||
|
||||
if (DebugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.get() != -1) {
|
||||
alignment = static_cast<size_t>(DebugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.get());
|
||||
}
|
||||
|
||||
gpuAddress = gmmHelper.canonize(gfxPartition->heapAllocateWithCustomAlignment(heap, sizeAllocated, alignment));
|
||||
} break;
|
||||
case AllocationType::WRITE_COMBINED:
|
||||
sizeAllocated = 0;
|
||||
@ -1744,12 +1750,12 @@ void createMemoryRegionsForSharedAllocation(const HardwareInfo &hwInfo, MemoryIn
|
||||
auto memoryBanks = allocationData.storageInfo.memoryBanks;
|
||||
|
||||
if (allocationData.usmInitialPlacement == GraphicsAllocation::UsmInitialPlacement::CPU) {
|
||||
//System memory region
|
||||
// System memory region
|
||||
auto regionClassAndInstance = memoryInfo.getMemoryRegionClassAndInstance(0u, hwInfo);
|
||||
memRegions.push_back(regionClassAndInstance);
|
||||
}
|
||||
|
||||
//All local memory regions
|
||||
// All local memory regions
|
||||
size_t currentBank = 0;
|
||||
size_t i = 0;
|
||||
|
||||
@ -1763,7 +1769,7 @@ void createMemoryRegionsForSharedAllocation(const HardwareInfo &hwInfo, MemoryIn
|
||||
}
|
||||
|
||||
if (allocationData.usmInitialPlacement == GraphicsAllocation::UsmInitialPlacement::GPU) {
|
||||
//System memory region
|
||||
// System memory region
|
||||
auto regionClassAndInstance = memoryInfo.getMemoryRegionClassAndInstance(0u, hwInfo);
|
||||
memRegions.push_back(regionClassAndInstance);
|
||||
}
|
||||
|
@ -42,6 +42,14 @@ class MockGfxPartition : public GfxPartition {
|
||||
return mockGpuVa;
|
||||
}
|
||||
|
||||
uint64_t heapAllocateWithCustomAlignment(HeapIndex heapIndex, size_t &size, size_t alignment) override {
|
||||
if (callHeapAllocate) {
|
||||
return getHeap(heapIndex).allocateWithCustomAlignment(size, alignment);
|
||||
}
|
||||
heapAllocateIndex = heapIndex;
|
||||
return mockGpuVa;
|
||||
}
|
||||
|
||||
void heapFree(HeapIndex heapIndex, uint64_t ptr, size_t size) override {
|
||||
if (callHeapAllocate) {
|
||||
getHeap(heapIndex).free(ptr, size);
|
||||
|
@ -1393,10 +1393,24 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenSipKernelTypeWhenAllocatingTh
|
||||
memoryManager->freeGraphicsMemory(sipAllocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenDebugVariableSetWhenAllocatingThenForceHeapAlignment) {
|
||||
DebugManager.flags.ExperimentalEnableCustomLocalMemoryAlignment.set(static_cast<int32_t>(MemoryConstants::megaByte * 2));
|
||||
|
||||
const auto allocType = AllocationType::KERNEL_ISA_INTERNAL;
|
||||
AllocationProperties properties = {rootDeviceIndex, 0x1000, allocType, device->getDeviceBitfield()};
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
|
||||
|
||||
EXPECT_TRUE(isAligned(allocation->getGpuAddress(), MemoryConstants::megaByte * 2));
|
||||
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
using DrmMemoryManagerFailInjectionPrelimTest = Test<DrmMemoryManagerFixturePrelim>;
|
||||
|
||||
TEST_F(DrmMemoryManagerFailInjectionPrelimTest, givenEnabledLocalMemoryWhenNewFailsThenAllocateInDevicePoolReturnsStatusErrorAndNullallocation) {
|
||||
mock->ioctl_expected.total = -1; //don't care
|
||||
mock->ioctl_expected.total = -1; // don't care
|
||||
class MockGfxPartition : public GfxPartition {
|
||||
public:
|
||||
MockGfxPartition() : GfxPartition(reservedCpuAddressRange) {
|
||||
|
Reference in New Issue
Block a user