mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Make small buffer allocations lockable
Allocations of buffers <= 64KB will be lockable, to allow copying through locked pointer. Related-To: NEO-7332 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
3b97ca8709
commit
9b9b0f10ef
@ -50,6 +50,8 @@ class Context : public BaseObject<_cl_context> {
|
||||
static constexpr auto startingOffset = chunkAlignment;
|
||||
|
||||
static_assert(aggregatedSmallBuffersPoolSize > smallBufferThreshold, "Largest allowed buffer needs to fit in pool");
|
||||
static_assert(aggregatedSmallBuffersPoolSize <= GraphicsAllocation::largestLockableBufferSize, "Pool buffer should be lockable");
|
||||
|
||||
Buffer *allocateBufferFromPool(const MemoryProperties &memoryProperties,
|
||||
cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel,
|
||||
|
@ -84,6 +84,12 @@ TEST_F(aggregatedSmallBuffersDisabledTest, givenAggregatedSmallBuffersDisabledWh
|
||||
|
||||
using aggregatedSmallBuffersEnabledTest = AggregatedSmallBuffersTestTemplate<1>;
|
||||
|
||||
TEST_F(aggregatedSmallBuffersEnabledTest, givenAggregatedSmallBuffersEnabledWhenCheckingMainStorageAllocationStorageInfoThenItIsLockable) {
|
||||
ASSERT_TRUE(poolAllocator->isAggregatedSmallBuffersEnabled());
|
||||
ASSERT_NE(poolAllocator->mainStorage, nullptr);
|
||||
EXPECT_TRUE(poolAllocator->mainStorage->getGraphicsAllocation(mockRootDeviceIndex)->isAllocationLockable());
|
||||
}
|
||||
|
||||
TEST_F(aggregatedSmallBuffersEnabledTest, givenAggregatedSmallBuffersEnabledAndSizeLargerThanThresholdWhenBufferCreateCalledThenDoNotUsePool) {
|
||||
ASSERT_TRUE(poolAllocator->isAggregatedSmallBuffersEnabled());
|
||||
ASSERT_NE(poolAllocator->mainStorage, nullptr);
|
||||
|
@ -35,7 +35,7 @@ StorageInfo MemoryManager::createStorageInfoFromProperties(const AllocationPrope
|
||||
|
||||
StorageInfo storageInfo{preferredTile, allTilesValue};
|
||||
storageInfo.subDeviceBitfield = properties.subDevicesBitfield;
|
||||
storageInfo.isLockable = GraphicsAllocation::isLockable(properties.allocationType);
|
||||
storageInfo.isLockable = GraphicsAllocation::isLockable(properties.allocationType) || GraphicsAllocation::isSmallBuffer(properties.allocationType, properties.size);
|
||||
storageInfo.cpuVisibleSegment = GraphicsAllocation::isCpuAccessRequired(properties.allocationType);
|
||||
|
||||
AppResourceHelper::copyResourceTagStr(storageInfo.resourceTag, properties.allocationType,
|
||||
|
@ -57,6 +57,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
GPU
|
||||
};
|
||||
|
||||
static constexpr auto largestLockableBufferSize = 64 * KB;
|
||||
|
||||
~GraphicsAllocation() override;
|
||||
GraphicsAllocation &operator=(const GraphicsAllocation &) = delete;
|
||||
GraphicsAllocation(const GraphicsAllocation &) = delete;
|
||||
@ -212,6 +214,10 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
type == AllocationType::DEBUG_MODULE_AREA;
|
||||
}
|
||||
|
||||
static bool isSmallBuffer(AllocationType type, size_t size) {
|
||||
return type == AllocationType::BUFFER && size <= largestLockableBufferSize;
|
||||
}
|
||||
|
||||
static bool isDebugSurfaceAllocationType(AllocationType type) {
|
||||
return type == AllocationType::DEBUG_CONTEXT_SAVE_AREA ||
|
||||
type == AllocationType::DEBUG_SBA_TRACKING_BUFFER;
|
||||
|
@ -198,6 +198,18 @@ TEST(GraphicsAllocationTest, whenAllocationTypeIsImageThenAllocationIsNotLockabl
|
||||
EXPECT_FALSE(GraphicsAllocation::isLockable(AllocationType::IMAGE));
|
||||
}
|
||||
|
||||
TEST(GraphicsAllocationTest, whenAllocationTypeIsNotBufferThenAllocationIsNotSmallBuffer) {
|
||||
EXPECT_FALSE(GraphicsAllocation::isSmallBuffer(AllocationType::IMAGE, GraphicsAllocation::largestLockableBufferSize));
|
||||
}
|
||||
|
||||
TEST(GraphicsAllocationTest, whenAllocationSizeIsAboveThresholdThenAllocationIsNotSmallBuffer) {
|
||||
EXPECT_FALSE(GraphicsAllocation::isSmallBuffer(AllocationType::BUFFER, GraphicsAllocation::largestLockableBufferSize + 1));
|
||||
}
|
||||
|
||||
TEST(GraphicsAllocationTest, whenAllocationTypeIsBufferAndSizeIsAtMostThresholdThenAllocationIsSmallBuffer) {
|
||||
EXPECT_TRUE(GraphicsAllocation::isSmallBuffer(AllocationType::BUFFER, GraphicsAllocation::largestLockableBufferSize));
|
||||
}
|
||||
|
||||
TEST(GraphicsAllocationTest, givenNumMemoryBanksWhenGettingNumHandlesForKmdSharedAllocationThenReturnCorrectValue) {
|
||||
DebugManagerStateRestore restore;
|
||||
|
||||
|
@ -459,15 +459,19 @@ TEST_F(MultiDeviceStorageInfoTest, givenGraphicsAllocationWithCpuAccessRequiredW
|
||||
TEST_F(MultiDeviceStorageInfoTest, givenGraphicsAllocationThatIsLockableWhenCreatingStorageInfoThenIsLockableFlagIsEnabled) {
|
||||
auto firstAllocationIdx = static_cast<int>(AllocationType::UNKNOWN);
|
||||
auto lastAllocationIdx = static_cast<int>(AllocationType::COUNT);
|
||||
std::array<size_t, 2> allocationSizes = {1u, GraphicsAllocation::largestLockableBufferSize + 1};
|
||||
|
||||
for (int allocationIdx = firstAllocationIdx; allocationIdx != lastAllocationIdx; allocationIdx++) {
|
||||
auto allocationType = static_cast<AllocationType>(allocationIdx);
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, 1u, allocationType, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
if (GraphicsAllocation::isLockable(properties.allocationType)) {
|
||||
EXPECT_TRUE(storageInfo.isLockable);
|
||||
} else {
|
||||
EXPECT_FALSE(storageInfo.isLockable);
|
||||
for (auto allocationSize : allocationSizes) {
|
||||
for (int allocationIdx = firstAllocationIdx; allocationIdx != lastAllocationIdx; allocationIdx++) {
|
||||
auto allocationType = static_cast<AllocationType>(allocationIdx);
|
||||
AllocationProperties properties{mockRootDeviceIndex, false, allocationSize, allocationType, false, singleTileMask};
|
||||
auto storageInfo = memoryManager->createStorageInfoFromProperties(properties);
|
||||
if (GraphicsAllocation::isLockable(properties.allocationType) ||
|
||||
GraphicsAllocation::isSmallBuffer(properties.allocationType, allocationSize)) {
|
||||
EXPECT_TRUE(storageInfo.isLockable);
|
||||
} else {
|
||||
EXPECT_FALSE(storageInfo.isLockable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user