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:
Dominik Dabek
2022-11-18 14:29:50 +00:00
committed by Compute-Runtime-Automation
parent 3b97ca8709
commit 9b9b0f10ef
6 changed files with 39 additions and 9 deletions

View File

@@ -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;

View File

@@ -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);
}
}
}
}