mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add allocation type for Write Combined memory
Related-To: NEO-3392 Change-Id: I8c61b2ca2a25325d47095568703888688a2eb069 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
931bd04a99
commit
09e87879db
@ -74,6 +74,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
||||
SVM_ZERO_COPY,
|
||||
TAG_BUFFER,
|
||||
TIMESTAMP_PACKET_TAG_BUFFER,
|
||||
WRITE_COMBINED
|
||||
};
|
||||
|
||||
virtual ~GraphicsAllocation();
|
||||
|
@ -224,6 +224,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
case GraphicsAllocation::AllocationType::PRINTF_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::PRIVATE_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::SCRATCH_SURFACE:
|
||||
case GraphicsAllocation::AllocationType::WRITE_COMBINED:
|
||||
allow64KbPages = true;
|
||||
allow32Bit = true;
|
||||
default:
|
||||
@ -242,6 +243,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
case GraphicsAllocation::AllocationType::BUFFER:
|
||||
case GraphicsAllocation::AllocationType::BUFFER_COMPRESSED:
|
||||
case GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY:
|
||||
case GraphicsAllocation::AllocationType::WRITE_COMBINED:
|
||||
forcePin = true;
|
||||
default:
|
||||
break;
|
||||
@ -261,6 +263,7 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
case GraphicsAllocation::AllocationType::SVM_CPU:
|
||||
case GraphicsAllocation::AllocationType::SVM_GPU:
|
||||
case GraphicsAllocation::AllocationType::SVM_ZERO_COPY:
|
||||
case GraphicsAllocation::AllocationType::WRITE_COMBINED:
|
||||
mayRequireL3Flush = true;
|
||||
default:
|
||||
break;
|
||||
|
@ -375,7 +375,8 @@ const char *DebugSettingsManager<DebugLevel>::getAllocationTypeString(GraphicsAl
|
||||
return "TIMESTAMP_PACKET_TAG_BUFFER";
|
||||
case GraphicsAllocation::AllocationType::UNKNOWN:
|
||||
return "UNKNOWN";
|
||||
|
||||
case GraphicsAllocation::AllocationType::WRITE_COMBINED:
|
||||
return "WRITE_COMBINED";
|
||||
default:
|
||||
return "ILLEGAL_VALUE";
|
||||
}
|
||||
|
@ -86,6 +86,16 @@ TEST(MemoryManagerGetAlloctionDataTest, givenBufferCompressedTypeWhenAllocationD
|
||||
EXPECT_TRUE(allocData.flags.forcePin);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerGetAlloctionDataTest, givenWriteCombinedTypeWhenAllocationDataIsQueriedThenForcePinFlagIsSet) {
|
||||
AllocationData allocData;
|
||||
AllocationProperties properties(true, 10, GraphicsAllocation::AllocationType::WRITE_COMBINED, false);
|
||||
|
||||
MockMemoryManager mockMemoryManager;
|
||||
MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties));
|
||||
|
||||
EXPECT_TRUE(allocData.flags.forcePin);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerGetAlloctionDataTest, givenDefaultAllocationFlagsWhenAllocationDataIsQueriedThenAllocateMemoryIsFalse) {
|
||||
AllocationData allocData;
|
||||
AllocationProperties properties(false, 0, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, false);
|
||||
@ -151,7 +161,8 @@ static const GraphicsAllocation::AllocationType allocationTypesWith32BitAnd64KbP
|
||||
GraphicsAllocation::AllocationType::PRIVATE_SURFACE,
|
||||
GraphicsAllocation::AllocationType::PRINTF_SURFACE,
|
||||
GraphicsAllocation::AllocationType::CONSTANT_SURFACE,
|
||||
GraphicsAllocation::AllocationType::GLOBAL_SURFACE};
|
||||
GraphicsAllocation::AllocationType::GLOBAL_SURFACE,
|
||||
GraphicsAllocation::AllocationType::WRITE_COMBINED};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Allow32BitAnd64kbPagesTypes,
|
||||
MemoryManagerGetAlloctionData32BitAnd64kbPagesAllowedTest,
|
||||
@ -417,6 +428,14 @@ TEST(MemoryManagerTest, givenGlobalSurfaceTypeWhenGetAllocationDataIsCalledThenS
|
||||
EXPECT_FALSE(allocData.flags.useSystemMemory);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenWriteCombinedTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsNotRequested) {
|
||||
AllocationData allocData;
|
||||
MockMemoryManager mockMemoryManager;
|
||||
AllocationProperties properties{1, GraphicsAllocation::AllocationType::WRITE_COMBINED};
|
||||
MockMemoryManager::getAllocationData(allocData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties));
|
||||
EXPECT_FALSE(allocData.flags.useSystemMemory);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenDeviceQueueBufferTypeWhenGetAllocationDataIsCalledThenSystemMemoryIsRequested) {
|
||||
AllocationData allocData;
|
||||
MockMemoryManager mockMemoryManager;
|
||||
|
@ -1681,7 +1681,7 @@ TEST(MemoryManagerTest, givenAllocationTypesThatMayNeedL3FlushWhenCallingGetAllo
|
||||
GraphicsAllocation::AllocationType::PIPE, GraphicsAllocation::AllocationType::SHARED_IMAGE,
|
||||
GraphicsAllocation::AllocationType::SHARED_BUFFER, GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY,
|
||||
GraphicsAllocation::AllocationType::SVM_ZERO_COPY, GraphicsAllocation::AllocationType::SVM_GPU,
|
||||
GraphicsAllocation::AllocationType::SVM_CPU};
|
||||
GraphicsAllocation::AllocationType::SVM_CPU, GraphicsAllocation::AllocationType::WRITE_COMBINED};
|
||||
|
||||
MockMemoryManager mockMemoryManager;
|
||||
for (auto allocationType : allocationTypesThatMayNeedL3Flush) {
|
||||
|
@ -933,7 +933,8 @@ AllocationTypeTestCase allocationTypeValues[] = {
|
||||
{GraphicsAllocation::AllocationType::SVM_ZERO_COPY, "SVM_ZERO_COPY"},
|
||||
{GraphicsAllocation::AllocationType::TAG_BUFFER, "TAG_BUFFER"},
|
||||
{GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER, "TIMESTAMP_PACKET_TAG_BUFFER"},
|
||||
{GraphicsAllocation::AllocationType::UNKNOWN, "UNKNOWN"}};
|
||||
{GraphicsAllocation::AllocationType::UNKNOWN, "UNKNOWN"},
|
||||
{GraphicsAllocation::AllocationType::WRITE_COMBINED, "WRITE_COMBINED"}};
|
||||
|
||||
class AllocationTypeLogging : public ::testing::TestWithParam<AllocationTypeTestCase> {};
|
||||
|
||||
|
@ -1692,6 +1692,25 @@ TEST_F(WddmMemoryManagerSimpleTest, givenSvmCpuAllocationWhenSizeAndAlignmentPro
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerSimpleTest, givenWriteCombinedAllocationThenCpuAddressIsEqualToGpuAddress) {
|
||||
if (is32bit) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
memoryManager.reset(new MockWddmMemoryManager(true, true, *executionEnvironment));
|
||||
size_t size = 2 * MemoryConstants::megaByte;
|
||||
auto allocation = static_cast<WddmAllocation *>(memoryManager->allocateGraphicsMemoryWithProperties({size, GraphicsAllocation::AllocationType::WRITE_COMBINED}));
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_EQ(size, allocation->getUnderlyingBufferSize());
|
||||
EXPECT_NE(nullptr, allocation->getUnderlyingBuffer());
|
||||
EXPECT_NE(nullptr, reinterpret_cast<void *>(allocation->getGpuAddress()));
|
||||
|
||||
if (executionEnvironment->isFullRangeSvm()) {
|
||||
EXPECT_EQ(allocation->getUnderlyingBuffer(), reinterpret_cast<void *>(allocation->getGpuAddress()));
|
||||
}
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerSimpleTest, whenCreatingWddmMemoryManagerThenSupportsMultiStorageResourcesFlagIsSetToFalse) {
|
||||
EXPECT_TRUE(memoryManager->supportsMultiStorageResources);
|
||||
}
|
||||
|
Reference in New Issue
Block a user