mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
fix: Adjust standard heaps when on 57 bit address space
Resolves: GSD-10871 Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b31c3bb3ca
commit
1b5519a880
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2024 Intel Corporation
|
||||
* Copyright (C) 2019-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -296,6 +296,14 @@ bool GfxPartition::init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToRe
|
||||
|
||||
gfxBase = alignUp(gfxBase, maxStandardHeapGranularity);
|
||||
uint64_t maxStandardHeapSize = alignDown((gfxTop - gfxBase) / numStandardHeaps, maxStandardHeapGranularity);
|
||||
uint64_t maxStandard64HeapSize = maxStandardHeapSize;
|
||||
uint64_t maxStandard2MBHeapSize = maxStandardHeapSize;
|
||||
|
||||
if (gpuAddressSpace == maxNBitValue(57)) {
|
||||
maxStandardHeapSize *= 2;
|
||||
maxStandard64HeapSize /= 2;
|
||||
maxStandard2MBHeapSize /= 2;
|
||||
}
|
||||
|
||||
auto gfxStandardSize = maxStandardHeapSize;
|
||||
heapInit(HeapIndex::heapStandard, gfxBase, gfxStandardSize);
|
||||
@@ -304,14 +312,14 @@ bool GfxPartition::init(uint64_t gpuAddressSpace, size_t cpuAddressRangeSizeToRe
|
||||
gfxBase += maxStandardHeapSize;
|
||||
|
||||
// Split HEAP_STANDARD64K among root devices
|
||||
auto gfxStandard64KBSize = alignDown(maxStandardHeapSize / numRootDevices, GfxPartition::heapGranularity);
|
||||
auto gfxStandard64KBSize = alignDown(maxStandard64HeapSize / numRootDevices, GfxPartition::heapGranularity);
|
||||
heapInitWithAllocationAlignment(HeapIndex::heapStandard64KB, gfxBase + rootDeviceIndex * gfxStandard64KBSize, gfxStandard64KBSize, MemoryConstants::pageSize64k);
|
||||
DEBUG_BREAK_IF(!isAligned<GfxPartition::heapGranularity>(getHeapBase(HeapIndex::heapStandard64KB)));
|
||||
|
||||
gfxBase += maxStandardHeapSize;
|
||||
gfxBase += maxStandard64HeapSize;
|
||||
|
||||
// Split HEAP_STANDARD2MB among root devices
|
||||
auto gfxStandard2MBSize = alignDown(maxStandardHeapSize / numRootDevices, GfxPartition::heapGranularity2MB);
|
||||
auto gfxStandard2MBSize = alignDown(maxStandard2MBHeapSize / numRootDevices, GfxPartition::heapGranularity2MB);
|
||||
heapInitWithAllocationAlignment(HeapIndex::heapStandard2MB, gfxBase + rootDeviceIndex * gfxStandard2MBSize, gfxStandard2MBSize, 2 * MemoryConstants::megaByte);
|
||||
DEBUG_BREAK_IF(!isAligned<GfxPartition::heapGranularity2MB>(getHeapBase(HeapIndex::heapStandard2MB)));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2024 Intel Corporation
|
||||
* Copyright (C) 2019-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -557,6 +557,12 @@ struct GfxPartitionOn57bTest : public ::testing::Test {
|
||||
|
||||
gfxBase = alignUp(gfxBase, maxStandardHeapGranularity);
|
||||
uint64_t maxStandardHeapSize = alignDown((gfxTop - gfxBase) / numStandardHeaps, maxStandardHeapGranularity);
|
||||
uint64_t maxStandard64HeapSize = maxStandardHeapSize;
|
||||
|
||||
if (expectHeapExtendedInitialized) {
|
||||
maxStandardHeapSize *= 2;
|
||||
maxStandard64HeapSize /= 2;
|
||||
}
|
||||
|
||||
EXPECT_EQ(gfxBase, gfxPartition->getHeapBase(HeapIndex::heapStandard));
|
||||
EXPECT_EQ(gfxBase + maxStandardHeapSize - 1, gfxPartition->getHeapLimit(HeapIndex::heapStandard));
|
||||
@@ -564,7 +570,7 @@ struct GfxPartitionOn57bTest : public ::testing::Test {
|
||||
gfxBase += maxStandardHeapSize;
|
||||
|
||||
EXPECT_EQ(gfxBase, gfxPartition->getHeapBase(HeapIndex::heapStandard64KB));
|
||||
EXPECT_EQ(gfxBase + maxStandardHeapSize - 1, gfxPartition->getHeapLimit(HeapIndex::heapStandard64KB));
|
||||
EXPECT_EQ(gfxBase + maxStandard64HeapSize - 1, gfxPartition->getHeapLimit(HeapIndex::heapStandard64KB));
|
||||
|
||||
if (expectHeapExtendedInitialized) {
|
||||
EXPECT_TRUE(gfxPartition->heapInitialized(HeapIndex::heapExtended));
|
||||
@@ -832,6 +838,23 @@ TEST_F(GfxPartitionOn57bTest, given57bitCpuAddressWidthAndLa57IsPresentWhenIniti
|
||||
EXPECT_FALSE(gfxPartition->init(maxNBitValue(gpuAddressSpace), 0, 0, 1, false, 0u, gfxTop));
|
||||
}
|
||||
|
||||
TEST_F(GfxPartitionOn57bTest, whenInitGfxPartitionThenDoubleHeapStandardAtTheCostOfStandard64AndStandard2MB) {
|
||||
if (is32bit) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
auto gpuAddressSpace = 57;
|
||||
uint64_t gfxTop = maxNBitValue(gpuAddressSpace) + 1;
|
||||
OSMemory::ReservedCpuAddressRange reservedCpuAddressRange;
|
||||
std::vector<std::unique_ptr<MockGfxPartition>> gfxPartitions;
|
||||
gfxPartitions.push_back(std::make_unique<MockGfxPartition>(reservedCpuAddressRange));
|
||||
gfxPartitions[0]->osMemory.reset(new MockOsMemory);
|
||||
EXPECT_TRUE(gfxPartitions[0]->init(maxNBitValue(gpuAddressSpace), 0, 0, 1, false, 0u, gfxTop));
|
||||
|
||||
EXPECT_EQ(gfxPartitions[0]->getHeapSize(HeapIndex::heapStandard), 4 * gfxPartitions[0]->getHeapSize(HeapIndex::heapStandard64KB));
|
||||
EXPECT_EQ(gfxPartitions[0]->getHeapSize(HeapIndex::heapStandard), 4 * gfxPartitions[0]->getHeapSize(HeapIndex::heapStandard2MB));
|
||||
}
|
||||
|
||||
TEST_F(GfxPartitionOn57bTest, given48bitGpuAddressSpaceAnd57bitCpuAddressWidthWhenInitializingMultipleGfxPartitionsThenReserveSpaceForSvmHeapOnlyOnce) {
|
||||
if (is32bit) {
|
||||
GTEST_SKIP();
|
||||
|
||||
Reference in New Issue
Block a user