mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
fix: configure ISA Pool params based on productHelper
When is2MBLocalMemAlignmentEnabled returns true, increase pool size for builtins from 64k to 2MB. Additionally, set appropriate alignment for kernel ISA heap allocations. Additionally, configure isaAllocationPageSize based on productHelper Related-To: NEO-12287 Signed-off-by: Fabian Zwoliński <fabian.zwolinski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
e815da1e4f
commit
bf20ae7ae8
@@ -7423,6 +7423,39 @@ TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenEnabled2MBSizeAlignmentWhe
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerLocalMemoryAlignmentTest, givenEnabled2MBSizeAlignmentWhenAllocatingLargeKernelIsaThenAllocationIsAlignedTo2MB) {
|
||||
auto mockProductHelper = new MockProductHelper;
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->productHelper.reset(mockProductHelper);
|
||||
mockProductHelper->is2MBLocalMemAlignmentEnabledResult = true;
|
||||
|
||||
ASSERT_TRUE(executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->productHelper->is2MBLocalMemAlignmentEnabled());
|
||||
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
allocData.allFlags = 0;
|
||||
allocData.size = MemoryConstants::pageSize2M + 1;
|
||||
allocData.flags.allocateMemory = true;
|
||||
allocData.type = AllocationType::kernelIsa;
|
||||
allocData.rootDeviceIndex = rootDeviceIndex;
|
||||
|
||||
auto memoryManager = createMemoryManager();
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
|
||||
EXPECT_EQ(MemoryPool::localMemory, allocation->getMemoryPool());
|
||||
EXPECT_TRUE(isAligned(allocation->getGpuAddress(), MemoryConstants::pageSize2M));
|
||||
EXPECT_TRUE(isAligned(allocation->getUnderlyingBufferSize(), MemoryConstants::pageSize2M));
|
||||
|
||||
auto drmAllocation = static_cast<DrmAllocation *>(allocation);
|
||||
auto bo = drmAllocation->getBO();
|
||||
EXPECT_NE(nullptr, bo);
|
||||
EXPECT_EQ(allocation->getGpuAddress(), bo->peekAddress());
|
||||
EXPECT_TRUE(isAligned(bo->peekAddress(), MemoryConstants::pageSize2M));
|
||||
EXPECT_TRUE(isAligned(bo->peekSize(), MemoryConstants::pageSize2M));
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenNotSetUseSystemMemoryWhenGraphicsAllocationInDevicePoolIsAllocatedForBufferThenLocalMemoryAllocationIsReturnedFromStandard64KbHeap) {
|
||||
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
|
||||
AllocationData allocData;
|
||||
|
||||
@@ -1,18 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
* Copyright (C) 2023-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/utilities/heap_allocator.h"
|
||||
#include "shared/test/common/fixtures/device_fixture.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_product_helper.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
class MockISAPool : public ISAPool {
|
||||
public:
|
||||
using ISAPool::chunkAllocator;
|
||||
};
|
||||
|
||||
class MockISAPoolAllocator : public ISAPoolAllocator {
|
||||
public:
|
||||
using ISAPoolAllocator::bufferPools;
|
||||
|
||||
MockISAPoolAllocator(Device *device) : ISAPoolAllocator(device) {}
|
||||
};
|
||||
|
||||
using IsaPoolAllocatorTest = Test<DeviceFixture>;
|
||||
|
||||
void verifySharedIsaAllocation(const SharedIsaAllocation *sharedAllocation, size_t expectedOffset, size_t expectedSize) {
|
||||
@@ -99,3 +113,24 @@ TEST_F(IsaPoolAllocatorTest, givenIsaPoolAllocatorWhenRequestForLargeAllocationT
|
||||
verifySharedIsaAllocation(allocation, 0, requestAllocationSize);
|
||||
isaAllocator.freeSharedIsaAllocation(allocation);
|
||||
}
|
||||
|
||||
TEST_F(IsaPoolAllocatorTest, Given2MBLocalMemAlignmentEnabledWhenAllocatingIsaThenISAPoolSizeIsAlignedTo2MB) {
|
||||
auto mockProductHelper = new MockProductHelper;
|
||||
pDevice->getRootDeviceEnvironmentRef().productHelper.reset(mockProductHelper);
|
||||
mockProductHelper->is2MBLocalMemAlignmentEnabledResult = true;
|
||||
|
||||
MockISAPoolAllocator mockIsaAllocator(pDevice);
|
||||
|
||||
constexpr size_t requestAllocationSize = MemoryConstants::pageSize + 1;
|
||||
auto allocation = mockIsaAllocator.requestGraphicsAllocationForIsa(true, requestAllocationSize);
|
||||
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
ASSERT_GE(mockIsaAllocator.bufferPools.size(), 1u);
|
||||
|
||||
auto *bufferPool = static_cast<MockISAPool *>(&mockIsaAllocator.bufferPools[0]);
|
||||
auto chunkAllocatorSize = bufferPool->chunkAllocator->getLeftSize() + bufferPool->chunkAllocator->getUsedSize();
|
||||
|
||||
EXPECT_TRUE(isAligned(chunkAllocatorSize, MemoryConstants::pageSize2M));
|
||||
|
||||
mockIsaAllocator.freeSharedIsaAllocation(allocation);
|
||||
}
|
||||
Reference in New Issue
Block a user