mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
performance(ocl): enable usm pool allocator
Enable on xe hpg and lpg platforms Related-To: NEO-9700 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
af1620a308
commit
9b52d52062
@@ -494,8 +494,8 @@ void Context::initializeUsmAllocationPools() {
|
|||||||
if (!(svmMemoryManager && this->isSingleDeviceContext())) {
|
if (!(svmMemoryManager && this->isSingleDeviceContext())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto &productHelper = getDevices()[0]->getProductHelper();
|
||||||
bool enabled = false;
|
bool enabled = productHelper.isUsmPoolAllocatorSupported();
|
||||||
size_t poolSize = 2 * MemoryConstants::megaByte;
|
size_t poolSize = 2 * MemoryConstants::megaByte;
|
||||||
if (debugManager.flags.EnableDeviceUsmAllocationPool.get() != -1) {
|
if (debugManager.flags.EnableDeviceUsmAllocationPool.get() != -1) {
|
||||||
enabled = debugManager.flags.EnableDeviceUsmAllocationPool.get() > 0;
|
enabled = debugManager.flags.EnableDeviceUsmAllocationPool.get() > 0;
|
||||||
@@ -511,7 +511,7 @@ void Context::initializeUsmAllocationPools() {
|
|||||||
usmDeviceMemAllocPool.initialize(svmMemoryManager, memoryProperties, poolSize);
|
usmDeviceMemAllocPool.initialize(svmMemoryManager, memoryProperties, poolSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled = false;
|
enabled = productHelper.isUsmPoolAllocatorSupported();
|
||||||
poolSize = 2 * MemoryConstants::megaByte;
|
poolSize = 2 * MemoryConstants::megaByte;
|
||||||
if (debugManager.flags.EnableHostUsmAllocationPool.get() != -1) {
|
if (debugManager.flags.EnableHostUsmAllocationPool.get() != -1) {
|
||||||
enabled = debugManager.flags.EnableHostUsmAllocationPool.get() > 0;
|
enabled = debugManager.flags.EnableHostUsmAllocationPool.get() > 0;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2023 Intel Corporation
|
* Copyright (C) 2018-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -221,6 +221,7 @@ TEST_F(clSetKernelArgSVMPointerTests, givenSvmAndValidArgValueWhenSettingSameKer
|
|||||||
void *const ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
void *const ptrSvm = clSVMAlloc(pContext, CL_MEM_READ_WRITE, 256, 4);
|
||||||
EXPECT_NE(nullptr, ptrSvm);
|
EXPECT_NE(nullptr, ptrSvm);
|
||||||
auto callCounter = 0u;
|
auto callCounter = 0u;
|
||||||
|
auto svmData = mockSvmManager->getSVMAlloc(ptrSvm);
|
||||||
// first set arg - called
|
// first set arg - called
|
||||||
mockSvmManager->allocationsCounter = 0u;
|
mockSvmManager->allocationsCounter = 0u;
|
||||||
auto retVal = clSetKernelArgSVMPointer(
|
auto retVal = clSetKernelArgSVMPointer(
|
||||||
@@ -261,7 +262,7 @@ TEST_F(clSetKernelArgSVMPointerTests, givenSvmAndValidArgValueWhenSettingSameKer
|
|||||||
++mockSvmManager->allocationsCounter;
|
++mockSvmManager->allocationsCounter;
|
||||||
|
|
||||||
// different pointer - called
|
// different pointer - called
|
||||||
void *const nextPtrSvm = static_cast<char *>(ptrSvm) + 1;
|
void *const nextPtrSvm = ptrOffset(ptrSvm, 1);
|
||||||
retVal = clSetKernelArgSVMPointer(
|
retVal = clSetKernelArgSVMPointer(
|
||||||
pMockMultiDeviceKernel, // cl_kernel kernel
|
pMockMultiDeviceKernel, // cl_kernel kernel
|
||||||
0, // cl_uint arg_index
|
0, // cl_uint arg_index
|
||||||
@@ -272,18 +273,7 @@ TEST_F(clSetKernelArgSVMPointerTests, givenSvmAndValidArgValueWhenSettingSameKer
|
|||||||
++mockSvmManager->allocationsCounter;
|
++mockSvmManager->allocationsCounter;
|
||||||
|
|
||||||
// different allocId - called
|
// different allocId - called
|
||||||
pMockKernel->kernelArguments[0].allocId = 2;
|
pMockKernel->kernelArguments[0].allocId = svmData->getAllocId() + 1;
|
||||||
retVal = clSetKernelArgSVMPointer(
|
|
||||||
pMockMultiDeviceKernel, // cl_kernel kernel
|
|
||||||
0, // cl_uint arg_index
|
|
||||||
nextPtrSvm // const void *arg_value
|
|
||||||
);
|
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
|
||||||
EXPECT_EQ(++callCounter, pMockKernel->setArgSvmAllocCalls);
|
|
||||||
++mockSvmManager->allocationsCounter;
|
|
||||||
|
|
||||||
// allocId = 3 - called
|
|
||||||
pMockKernel->kernelArguments[0].allocId = 3;
|
|
||||||
retVal = clSetKernelArgSVMPointer(
|
retVal = clSetKernelArgSVMPointer(
|
||||||
pMockMultiDeviceKernel, // cl_kernel kernel
|
pMockMultiDeviceKernel, // cl_kernel kernel
|
||||||
0, // cl_uint arg_index
|
0, // cl_uint arg_index
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2023 Intel Corporation
|
* Copyright (C) 2018-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -32,6 +32,7 @@ TEST_F(ContextFailureInjection, GivenFailedAllocationInjectionWhenCreatingContex
|
|||||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(0); // failing to allocate pool buffer is non-critical
|
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(0); // failing to allocate pool buffer is non-critical
|
||||||
debugManager.flags.SetAmountOfReusableAllocationsPerCmdQueue.set(0); // same for preallocations
|
debugManager.flags.SetAmountOfReusableAllocationsPerCmdQueue.set(0); // same for preallocations
|
||||||
debugManager.flags.EnableDeviceUsmAllocationPool.set(0); // usm device allocation pooling
|
debugManager.flags.EnableDeviceUsmAllocationPool.set(0); // usm device allocation pooling
|
||||||
|
debugManager.flags.EnableHostUsmAllocationPool.set(0); // usm host allocation pooling
|
||||||
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||||
cl_device_id deviceID = device.get();
|
cl_device_id deviceID = device.get();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2023 Intel Corporation
|
* Copyright (C) 2023-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||||
#include "shared/test/common/mocks/mock_usm_memory_pool.h"
|
#include "shared/test/common/mocks/mock_usm_memory_pool.h"
|
||||||
|
#include "shared/test/common/test_macros/hw_test.h"
|
||||||
|
|
||||||
#include "opencl/source/cl_device/cl_device.h"
|
#include "opencl/source/cl_device/cl_device.h"
|
||||||
#include "opencl/test/unit_test/mocks/mock_context.h"
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
||||||
@@ -40,7 +41,7 @@ struct ContextUsmPoolFlagValuesTest : public ::testing::Test {
|
|||||||
|
|
||||||
using ContextUsmPoolDefaultFlagsTest = ContextUsmPoolFlagValuesTest<-1, -1>;
|
using ContextUsmPoolDefaultFlagsTest = ContextUsmPoolFlagValuesTest<-1, -1>;
|
||||||
|
|
||||||
TEST_F(ContextUsmPoolDefaultFlagsTest, givenDefaultDebugFlagsWhenCreatingContextThenPoolsAreNotInitialized) {
|
HWTEST2_F(ContextUsmPoolDefaultFlagsTest, givenDefaultDebugFlagsWhenCreatingContextThenPoolsAreNotInitialized, IsNotXeHpgCore) {
|
||||||
EXPECT_FALSE(mockDeviceUsmMemAllocPool->isInitialized());
|
EXPECT_FALSE(mockDeviceUsmMemAllocPool->isInitialized());
|
||||||
EXPECT_EQ(0u, mockDeviceUsmMemAllocPool->poolSize);
|
EXPECT_EQ(0u, mockDeviceUsmMemAllocPool->poolSize);
|
||||||
EXPECT_EQ(nullptr, mockDeviceUsmMemAllocPool->pool);
|
EXPECT_EQ(nullptr, mockDeviceUsmMemAllocPool->pool);
|
||||||
@@ -50,6 +51,18 @@ TEST_F(ContextUsmPoolDefaultFlagsTest, givenDefaultDebugFlagsWhenCreatingContext
|
|||||||
EXPECT_EQ(nullptr, mockHostUsmMemAllocPool->pool);
|
EXPECT_EQ(nullptr, mockHostUsmMemAllocPool->pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWTEST2_F(ContextUsmPoolDefaultFlagsTest, givenDefaultDebugFlagsWhenCreatingContextThenPoolsAreInitialized, IsXeHpgCore) {
|
||||||
|
EXPECT_TRUE(mockDeviceUsmMemAllocPool->isInitialized());
|
||||||
|
EXPECT_EQ(2 * 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_NE(nullptr, mockHostUsmMemAllocPool->pool);
|
||||||
|
EXPECT_EQ(InternalMemoryType::hostUnifiedMemory, mockHostUsmMemAllocPool->poolMemoryType);
|
||||||
|
}
|
||||||
|
|
||||||
using ContextUsmPoolEnabledFlagsTest = ContextUsmPoolFlagValuesTest<1, 3>;
|
using ContextUsmPoolEnabledFlagsTest = ContextUsmPoolFlagValuesTest<1, 3>;
|
||||||
TEST_F(ContextUsmPoolEnabledFlagsTest, givenEnabledDebugFlagsWhenCreatingContextThenPoolsAreInitialized) {
|
TEST_F(ContextUsmPoolEnabledFlagsTest, givenEnabledDebugFlagsWhenCreatingContextThenPoolsAreInitialized) {
|
||||||
EXPECT_TRUE(mockDeviceUsmMemAllocPool->isInitialized());
|
EXPECT_TRUE(mockDeviceUsmMemAllocPool->isInitialized());
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Intel Corporation
|
* Copyright (C) 2022-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -52,6 +52,7 @@ class AggregatedSmallBuffersTestTemplate : public ::testing::Test {
|
|||||||
void setUpImpl() {
|
void setUpImpl() {
|
||||||
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(poolBufferFlag);
|
debugManager.flags.ExperimentalSmallBufferPoolAllocator.set(poolBufferFlag);
|
||||||
debugManager.flags.EnableDeviceUsmAllocationPool.set(0);
|
debugManager.flags.EnableDeviceUsmAllocationPool.set(0);
|
||||||
|
debugManager.flags.EnableHostUsmAllocationPool.set(0);
|
||||||
this->deviceFactory = std::make_unique<UltClDeviceFactory>(2, 0);
|
this->deviceFactory = std::make_unique<UltClDeviceFactory>(2, 0);
|
||||||
this->device = deviceFactory->rootDevices[rootDeviceIndex];
|
this->device = deviceFactory->rootDevices[rootDeviceIndex];
|
||||||
this->mockMemoryManager = static_cast<MockMemoryManager *>(device->getMemoryManager());
|
this->mockMemoryManager = static_cast<MockMemoryManager *>(device->getMemoryManager());
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2018-2023 Intel Corporation
|
* Copyright (C) 2018-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -161,6 +161,7 @@ class ProductHelper {
|
|||||||
virtual bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const = 0;
|
virtual bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const = 0;
|
||||||
virtual bool isMidThreadPreemptionDisallowedForRayTracingKernels() const = 0;
|
virtual bool isMidThreadPreemptionDisallowedForRayTracingKernels() const = 0;
|
||||||
virtual bool isBufferPoolAllocatorSupported() const = 0;
|
virtual bool isBufferPoolAllocatorSupported() const = 0;
|
||||||
|
virtual bool isUsmPoolAllocatorSupported() const = 0;
|
||||||
virtual bool isTlbFlushRequired() const = 0;
|
virtual bool isTlbFlushRequired() const = 0;
|
||||||
virtual bool isDummyBlitWaRequired() const = 0;
|
virtual bool isDummyBlitWaRequired() const = 0;
|
||||||
virtual bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled) const = 0;
|
virtual bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled) const = 0;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2023 Intel Corporation
|
* Copyright (C) 2020-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -584,6 +584,11 @@ bool ProductHelperHw<gfxProduct>::isBufferPoolAllocatorSupported() const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <PRODUCT_FAMILY gfxProduct>
|
||||||
|
bool ProductHelperHw<gfxProduct>::isUsmPoolAllocatorSupported() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
template <PRODUCT_FAMILY gfxProduct>
|
template <PRODUCT_FAMILY gfxProduct>
|
||||||
void ProductHelperHw<gfxProduct>::fillScmPropertiesSupportStructureBase(StateComputeModePropertiesSupport &propertiesSupport) const {
|
void ProductHelperHw<gfxProduct>::fillScmPropertiesSupportStructureBase(StateComputeModePropertiesSupport &propertiesSupport) const {
|
||||||
propertiesSupport.coherencyRequired = getScmPropertyCoherencyRequiredSupport();
|
propertiesSupport.coherencyRequired = getScmPropertyCoherencyRequiredSupport();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2023 Intel Corporation
|
* Copyright (C) 2023-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -112,6 +112,7 @@ class ProductHelperHw : public ProductHelper {
|
|||||||
bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const override;
|
bool isResolveDependenciesByPipeControlsSupported(const HardwareInfo &hwInfo, bool isOOQ, TaskCountType queueTaskCount, const CommandStreamReceiver &queueCsr) const override;
|
||||||
bool isMidThreadPreemptionDisallowedForRayTracingKernels() const override;
|
bool isMidThreadPreemptionDisallowedForRayTracingKernels() const override;
|
||||||
bool isBufferPoolAllocatorSupported() const override;
|
bool isBufferPoolAllocatorSupported() const override;
|
||||||
|
bool isUsmPoolAllocatorSupported() const override;
|
||||||
bool isTlbFlushRequired() const override;
|
bool isTlbFlushRequired() const override;
|
||||||
bool isDummyBlitWaRequired() const override;
|
bool isDummyBlitWaRequired() const override;
|
||||||
bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled) const override;
|
bool isDetectIndirectAccessInKernelSupported(const KernelDescriptor &kernelDescriptor, const bool isPrecompiled) const override;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2021-2023 Intel Corporation
|
* Copyright (C) 2021-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -213,6 +213,11 @@ bool ProductHelperHw<gfxProduct>::isBufferPoolAllocatorSupported() const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
bool ProductHelperHw<gfxProduct>::isUsmPoolAllocatorSupported() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
std::optional<aub_stream::ProductFamily> ProductHelperHw<gfxProduct>::getAubStreamProductFamily() const {
|
std::optional<aub_stream::ProductFamily> ProductHelperHw<gfxProduct>::getAubStreamProductFamily() const {
|
||||||
return aub_stream::ProductFamily::Dg2;
|
return aub_stream::ProductFamily::Dg2;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Intel Corporation
|
* Copyright (C) 2022-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -73,6 +73,11 @@ bool ProductHelperHw<gfxProduct>::isBufferPoolAllocatorSupported() const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
bool ProductHelperHw<gfxProduct>::isUsmPoolAllocatorSupported() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
uint64_t ProductHelperHw<gfxProduct>::overridePatIndex(bool isUncachedType, uint64_t patIndex) const {
|
uint64_t ProductHelperHw<gfxProduct>::overridePatIndex(bool isUncachedType, uint64_t patIndex) const {
|
||||||
if (isUncachedType) {
|
if (isUncachedType) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2023 Intel Corporation
|
* Copyright (C) 2022-2024 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -772,6 +772,14 @@ HWTEST2_F(ProductHelperTest, givenProductHelperWhenCheckingIsBufferPoolAllocator
|
|||||||
EXPECT_TRUE(productHelper->isBufferPoolAllocatorSupported());
|
EXPECT_TRUE(productHelper->isBufferPoolAllocatorSupported());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWTEST2_F(ProductHelperTest, givenProductHelperWhenCheckingIsUsmPoolAllocatorSupportedThenCorrectValueIsReturned, IsNotXeHpgCore) {
|
||||||
|
EXPECT_FALSE(productHelper->isUsmPoolAllocatorSupported());
|
||||||
|
}
|
||||||
|
|
||||||
|
HWTEST2_F(ProductHelperTest, givenProductHelperWhenCheckingIsUsmPoolAllocatorSupportedThenCorrectValueIsReturned, IsXeHpgCore) {
|
||||||
|
EXPECT_TRUE(productHelper->isUsmPoolAllocatorSupported());
|
||||||
|
}
|
||||||
|
|
||||||
HWTEST_F(ProductHelperTest, givenProductHelperWhenCheckingIsUnlockingLockedPtrNecessaryThenReturnFalse) {
|
HWTEST_F(ProductHelperTest, givenProductHelperWhenCheckingIsUnlockingLockedPtrNecessaryThenReturnFalse) {
|
||||||
EXPECT_FALSE(productHelper->isUnlockingLockedPtrNecessary(pInHwInfo));
|
EXPECT_FALSE(productHelper->isUnlockingLockedPtrNecessary(pInHwInfo));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user