mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
performance: improve pool handling
Signed-off-by: Mrozek, Michal <michal.mrozek@intel.com> Resolves: NEO-11731
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
aa3b13ce66
commit
5f0b9efd2b
@@ -89,7 +89,7 @@ TEST_F(AllocUsmHostDisabledMemoryTest, givenDriverHandleWhenCallingAllocHostMemT
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
using AllocUsmHostEnabledMemoryTest = AllocUsmPoolMemoryTest<1, -1>;
|
||||
using AllocUsmHostEnabledMemoryTest = AllocUsmPoolMemoryTest<16, -1>;
|
||||
|
||||
TEST_F(AllocUsmHostEnabledMemoryTest, givenDriverHandleWhenCallingAllocHostMemWithVariousParametersThenUsePoolIfAllowed) {
|
||||
auto mockHostMemAllocPool = reinterpret_cast<MockUsmMemAllocPool *>(&driverHandle->usmHostMemAllocPool);
|
||||
|
||||
@@ -498,7 +498,8 @@ void Context::initializeUsmAllocationPools() {
|
||||
}
|
||||
auto &productHelper = getDevices()[0]->getProductHelper();
|
||||
bool enabled = ApiSpecificConfig::isDeviceUsmPoolingEnabled() && productHelper.isUsmPoolAllocatorSupported();
|
||||
size_t poolSize = 2 * MemoryConstants::megaByte;
|
||||
|
||||
size_t poolSize = NEO::defaultPoolSize;
|
||||
if (debugManager.flags.EnableDeviceUsmAllocationPool.get() != -1) {
|
||||
enabled = debugManager.flags.EnableDeviceUsmAllocationPool.get() > 0;
|
||||
poolSize = debugManager.flags.EnableDeviceUsmAllocationPool.get() * MemoryConstants::megaByte;
|
||||
@@ -514,7 +515,7 @@ void Context::initializeUsmAllocationPools() {
|
||||
}
|
||||
|
||||
enabled = ApiSpecificConfig::isHostUsmPoolingEnabled() && productHelper.isUsmPoolAllocatorSupported();
|
||||
poolSize = 2 * MemoryConstants::megaByte;
|
||||
poolSize = NEO::defaultPoolSize;
|
||||
if (debugManager.flags.EnableHostUsmAllocationPool.get() != -1) {
|
||||
enabled = debugManager.flags.EnableHostUsmAllocationPool.get() > 0;
|
||||
poolSize = debugManager.flags.EnableHostUsmAllocationPool.get() * MemoryConstants::megaByte;
|
||||
|
||||
@@ -53,12 +53,12 @@ HWTEST2_F(ContextUsmPoolDefaultFlagsTest, givenDefaultDebugFlagsWhenCreatingCont
|
||||
|
||||
HWTEST2_F(ContextUsmPoolDefaultFlagsTest, givenDefaultDebugFlagsWhenCreatingContextThenPoolsAreInitialized, IsXeHpgCore) {
|
||||
EXPECT_TRUE(mockDeviceUsmMemAllocPool->isInitialized());
|
||||
EXPECT_EQ(2 * MemoryConstants::megaByte, mockDeviceUsmMemAllocPool->poolSize);
|
||||
EXPECT_EQ(1 * MemoryConstants::megaByte, mockDeviceUsmMemAllocPool->poolSize);
|
||||
EXPECT_NE(nullptr, mockDeviceUsmMemAllocPool->pool);
|
||||
EXPECT_EQ(InternalMemoryType::deviceUnifiedMemory, mockDeviceUsmMemAllocPool->poolMemoryType);
|
||||
|
||||
EXPECT_TRUE(mockHostUsmMemAllocPool->isInitialized());
|
||||
EXPECT_EQ(2 * MemoryConstants::megaByte, mockHostUsmMemAllocPool->poolSize);
|
||||
EXPECT_EQ(1 * MemoryConstants::megaByte, mockHostUsmMemAllocPool->poolSize);
|
||||
EXPECT_NE(nullptr, mockHostUsmMemAllocPool->pool);
|
||||
EXPECT_EQ(InternalMemoryType::hostUnifiedMemory, mockHostUsmMemAllocPool->poolMemoryType);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace NEO {
|
||||
// AUB file folder location
|
||||
@@ -13,4 +14,7 @@ const char *folderAUB = ".";
|
||||
|
||||
// Initial value for HW tag
|
||||
uint32_t initialHardwareTag = 0;
|
||||
|
||||
size_t defaultPoolSize = 16777216u;
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace NEO {
|
||||
enum class CommandStreamReceiverType {
|
||||
@@ -38,4 +39,7 @@ extern const char *folderAUB;
|
||||
// Initial value for HW tag
|
||||
// Set to 0 if using HW or simulator, otherwise 0xFFFFFF00, needs to be lower then CompletionStamp::notReady.
|
||||
extern uint32_t initialHardwareTag;
|
||||
|
||||
// default size of memory pools
|
||||
extern size_t defaultPoolSize;
|
||||
} // namespace NEO
|
||||
|
||||
@@ -24,7 +24,7 @@ bool UsmMemAllocPool::initialize(SVMAllocsManager *svmMemoryManager, const Unifi
|
||||
this->chunkAllocator.reset(new HeapAllocator(castToUint64(this->pool),
|
||||
poolSize,
|
||||
chunkAlignment,
|
||||
allocationThreshold / 2));
|
||||
2 * MemoryConstants::megaByte));
|
||||
this->poolSize = poolSize;
|
||||
this->poolMemoryType = memoryProperties.memoryType;
|
||||
return true;
|
||||
|
||||
@@ -35,9 +35,9 @@ class UsmMemAllocPool {
|
||||
void *getPooledAllocationBasePtr(const void *ptr);
|
||||
size_t getOffsetInPool(const void *ptr);
|
||||
|
||||
static constexpr auto allocationThreshold = 1 * MemoryConstants::megaByte;
|
||||
static constexpr auto allocationThreshold = 2 * MemoryConstants::megaByte;
|
||||
static constexpr auto chunkAlignment = 512u;
|
||||
static constexpr auto startingOffset = 2 * allocationThreshold;
|
||||
static constexpr auto startingOffset = chunkAlignment;
|
||||
|
||||
protected:
|
||||
size_t poolSize{};
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
* Copyright (C) 2019-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace NEO {
|
||||
const char *folderAUB = "aub_out";
|
||||
|
||||
uint32_t initialHardwareTag = static_cast<uint32_t>(0xFFFFFF00);
|
||||
|
||||
size_t defaultPoolSize = 1048576u;
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user