Create helper for memory properties

-Move logics from  mem_obj_helper

Related-To: NEO-3374
Change-Id: I167cdcc8fcb08cb1fa6d19640fd266f0004f4c6b
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2019-07-18 00:07:10 +02:00
committed by sys_ocldev
parent f21e5e85e0
commit b5020eac81
18 changed files with 176 additions and 129 deletions

View File

@@ -26,11 +26,6 @@ TEST(MemObjHelper, givenInvalidMemFlagsForSubBufferWhenFlagsAreCheckedThenTrueIs
EXPECT_FALSE(MemObjHelper::checkMemFlagsForSubBuffer(flags));
}
TEST(MemObjHelper, givenNullPropertiesWhenParsingMemoryPropertiesThenTrueIsReturned) {
MemoryProperties propertiesStruct;
EXPECT_TRUE(MemObjHelper::parseMemoryProperties(nullptr, propertiesStruct));
}
TEST(MemObjHelper, givenClMemForceLinearStorageFlagWhenCheckForLinearStorageForceThenReturnProperValue) {
MemoryProperties properties;
@@ -51,35 +46,6 @@ TEST(MemObjHelper, givenClMemForceLinearStorageFlagWhenCheckForLinearStorageForc
EXPECT_FALSE(MemObjHelper::isLinearStorageForced(properties));
}
TEST(MemObjHelper, givenEmptyPropertiesWhenParsingMemoryPropertiesThenTrueIsReturned) {
cl_mem_properties_intel properties[] = {0};
MemoryProperties propertiesStruct;
EXPECT_TRUE(MemObjHelper::parseMemoryProperties(properties, propertiesStruct));
}
TEST(MemObjHelper, givenValidPropertiesWhenParsingMemoryPropertiesThenTrueIsReturned) {
cl_mem_properties_intel properties[] = {
CL_MEM_FLAGS,
CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR |
CL_MEM_USE_HOST_PTR | CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS,
CL_MEM_FLAGS_INTEL,
CL_MEM_LOCALLY_UNCACHED_RESOURCE,
0};
MemoryProperties propertiesStruct;
EXPECT_TRUE(MemObjHelper::parseMemoryProperties(properties, propertiesStruct));
}
TEST(MemObjHelper, givenInvalidPropertiesWhenParsingMemoryPropertiesThenFalseIsReturned) {
cl_mem_properties_intel properties[] = {
(1 << 30), CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR,
0};
MemoryProperties propertiesStruct;
EXPECT_FALSE(MemObjHelper::parseMemoryProperties(properties, propertiesStruct));
}
TEST(MemObjHelper, givenValidPropertiesWhenValidatingMemoryPropertiesThenTrueIsReturned) {
MemoryProperties properties;
EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties));
@@ -155,27 +121,3 @@ TEST(MemObjHelper, givenParentMemObjAndHostPtrFlagsWhenValidatingMemoryPropertie
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, imageWithAccessFlagsUnrestricted.get()));
}
}
TEST(MemObjHelper, givenDifferentParametersWhenCallingFillCachePolicyInPropertiesThenFlushL3FlagsAreCorrectlySet) {
AllocationProperties allocationProperties{0, GraphicsAllocation::AllocationType::BUFFER};
for (auto uncached : ::testing::Bool()) {
for (auto readOnly : ::testing::Bool()) {
for (auto deviceOnlyVisibilty : ::testing::Bool()) {
if (uncached || readOnly || deviceOnlyVisibilty) {
allocationProperties.flags.flushL3RequiredForRead = true;
allocationProperties.flags.flushL3RequiredForWrite = true;
MemObjHelper::fillCachePolicyInProperties(allocationProperties, uncached, readOnly, deviceOnlyVisibilty);
EXPECT_FALSE(allocationProperties.flags.flushL3RequiredForRead);
EXPECT_FALSE(allocationProperties.flags.flushL3RequiredForWrite);
} else {
allocationProperties.flags.flushL3RequiredForRead = false;
allocationProperties.flags.flushL3RequiredForWrite = false;
MemObjHelper::fillCachePolicyInProperties(allocationProperties, uncached, readOnly, deviceOnlyVisibilty);
EXPECT_TRUE(allocationProperties.flags.flushL3RequiredForRead);
EXPECT_TRUE(allocationProperties.flags.flushL3RequiredForWrite);
}
}
}
}
}