Pass Context to parseMemoryProperties function

Change-Id: I74ff9fdb9292e281a1a6491387163db0de2ccea2
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2020-03-30 11:42:07 +02:00
committed by sys_ocldev
parent 9022912a6d
commit 64575cd589
9 changed files with 109 additions and 111 deletions

View File

@@ -177,6 +177,9 @@ TEST_F(clCreateBufferTests, GivenNullContextWhenCreatingBufferThenInvalidContext
clCreateBuffer(nullptr, flags, bufferSize, pHostMem, &retVal);
ASSERT_EQ(CL_INVALID_CONTEXT, retVal);
clCreateBufferWithPropertiesINTEL(nullptr, nullptr, bufferSize, pHostMem, &retVal);
ASSERT_EQ(CL_INVALID_CONTEXT, retVal);
}
TEST_F(clCreateBufferTests, GivenBufferSizeZeroWhenCreatingBufferThenInvalidBufferSizeErrorIsReturned) {

View File

@@ -7,35 +7,38 @@
#include "opencl/source/helpers/mem_properties_parser_helper.h"
#include "opencl/source/mem_obj/mem_obj_helper.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "CL/cl_ext_intel.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(MemoryPropertiesParser, givenNullPropertiesWhenParsingMemoryPropertiesThenTrueIsReturned) {
struct MemoryPropertiesParserTests : ::testing::Test {
MockContext context;
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
};
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(nullptr, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN));
TEST_F(MemoryPropertiesParserTests, givenNullPropertiesWhenParsingMemoryPropertiesThenTrueIsReturned) {
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(nullptr, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN, context));
}
TEST(MemoryPropertiesParser, givenEmptyPropertiesWhenParsingMemoryPropertiesThenTrueIsReturned) {
TEST_F(MemoryPropertiesParserTests, givenEmptyPropertiesWhenParsingMemoryPropertiesThenTrueIsReturned) {
cl_mem_properties_intel properties[] = {0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN));
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::BUFFER));
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::IMAGE));
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN, context));
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::MemoryPropertiesParser::ObjType::BUFFER, context));
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::MemoryPropertiesParser::ObjType::IMAGE, context));
}
TEST(MemoryPropertiesParser, givenValidPropertiesWhenParsingMemoryPropertiesThenTrueIsReturned) {
TEST_F(MemoryPropertiesParserTests, 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 |
@@ -46,15 +49,11 @@ TEST(MemoryPropertiesParser, givenValidPropertiesWhenParsingMemoryPropertiesThen
CL_MEM_ALLOC_WRITE_COMBINED_INTEL, CL_MEM_ALLOC_DEFAULT_INTEL,
0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::UNKNOWN));
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::UNKNOWN, context));
}
TEST(MemoryPropertiesParser, givenValidPropertiesWhenParsingMemoryPropertiesForBufferThenTrueIsReturned) {
TEST_F(MemoryPropertiesParserTests, givenValidPropertiesWhenParsingMemoryPropertiesForBufferThenTrueIsReturned) {
cl_mem_properties_intel properties[] = {
CL_MEM_FLAGS,
MemObjHelper::validFlagsForBuffer,
@@ -62,15 +61,11 @@ TEST(MemoryPropertiesParser, givenValidPropertiesWhenParsingMemoryPropertiesForB
MemObjHelper::validFlagsForBufferIntel,
0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::BUFFER));
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::BUFFER, context));
}
TEST(MemoryPropertiesParser, givenValidPropertiesWhenParsingMemoryPropertiesForImageThenTrueIsReturned) {
TEST_F(MemoryPropertiesParserTests, givenValidPropertiesWhenParsingMemoryPropertiesForImageThenTrueIsReturned) {
cl_mem_properties_intel properties[] = {
CL_MEM_FLAGS,
MemObjHelper::validFlagsForImage,
@@ -78,30 +73,24 @@ TEST(MemoryPropertiesParser, givenValidPropertiesWhenParsingMemoryPropertiesForI
MemObjHelper::validFlagsForImageIntel,
0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::IMAGE));
EXPECT_TRUE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::IMAGE, context));
}
TEST(MemoryPropertiesParser, givenInvalidPropertiesWhenParsingMemoryPropertiesThenFalseIsReturned) {
TEST_F(MemoryPropertiesParserTests, givenInvalidPropertiesWhenParsingMemoryPropertiesThenFalseIsReturned) {
cl_mem_properties_intel properties[] = {
(1 << 30), CL_MEM_ALLOC_HOST_PTR | CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR,
0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::UNKNOWN));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::BUFFER));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::IMAGE));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::UNKNOWN, context));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::BUFFER, context));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::IMAGE, context));
}
TEST(MemoryPropertiesParser, givenInvalidPropertiesWhenParsingMemoryPropertiesForImageThenFalseIsReturned) {
TEST_F(MemoryPropertiesParserTests, givenInvalidPropertiesWhenParsingMemoryPropertiesForImageThenFalseIsReturned) {
cl_mem_properties_intel properties[] = {
CL_MEM_FLAGS,
MemObjHelper::validFlagsForBuffer,
@@ -109,15 +98,11 @@ TEST(MemoryPropertiesParser, givenInvalidPropertiesWhenParsingMemoryPropertiesFo
MemObjHelper::validFlagsForBufferIntel,
0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::IMAGE));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::IMAGE, context));
}
TEST(MemoryPropertiesParser, givenInvalidFlagsWhenParsingMemoryPropertiesForImageThenFalseIsReturned) {
TEST_F(MemoryPropertiesParserTests, givenInvalidFlagsWhenParsingMemoryPropertiesForImageThenFalseIsReturned) {
cl_mem_properties_intel properties[] = {
CL_MEM_FLAGS,
(1 << 30),
@@ -125,15 +110,11 @@ TEST(MemoryPropertiesParser, givenInvalidFlagsWhenParsingMemoryPropertiesForImag
MemObjHelper::validFlagsForImageIntel,
0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::IMAGE));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::IMAGE, context));
}
TEST(MemoryPropertiesParser, givenInvalidFlagsIntelWhenParsingMemoryPropertiesForImageThenFalseIsReturned) {
TEST_F(MemoryPropertiesParserTests, givenInvalidFlagsIntelWhenParsingMemoryPropertiesForImageThenFalseIsReturned) {
cl_mem_properties_intel properties[] = {
CL_MEM_FLAGS,
MemObjHelper::validFlagsForImage,
@@ -141,15 +122,11 @@ TEST(MemoryPropertiesParser, givenInvalidFlagsIntelWhenParsingMemoryPropertiesFo
(1 << 30),
0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::IMAGE));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::IMAGE, context));
}
TEST(MemoryPropertiesParser, givenInvalidPropertiesWhenParsingMemoryPropertiesForBufferThenFalseIsReturned) {
TEST_F(MemoryPropertiesParserTests, givenInvalidPropertiesWhenParsingMemoryPropertiesForBufferThenFalseIsReturned) {
cl_mem_properties_intel properties[] = {
CL_MEM_FLAGS,
MemObjHelper::validFlagsForImage,
@@ -157,15 +134,11 @@ TEST(MemoryPropertiesParser, givenInvalidPropertiesWhenParsingMemoryPropertiesFo
MemObjHelper::validFlagsForImageIntel,
0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::BUFFER));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::BUFFER, context));
}
TEST(MemoryPropertiesParser, givenInvalidFlagsWhenParsingMemoryPropertiesForBufferThenFalseIsReturned) {
TEST_F(MemoryPropertiesParserTests, givenInvalidFlagsWhenParsingMemoryPropertiesForBufferThenFalseIsReturned) {
cl_mem_properties_intel properties[] = {
CL_MEM_FLAGS,
(1 << 30),
@@ -173,15 +146,11 @@ TEST(MemoryPropertiesParser, givenInvalidFlagsWhenParsingMemoryPropertiesForBuff
MemObjHelper::validFlagsForBufferIntel,
0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::BUFFER));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::BUFFER, context));
}
TEST(MemoryPropertiesParser, givenInvalidFlagsIntelWhenParsingMemoryPropertiesForBufferThenFalseIsReturned) {
TEST_F(MemoryPropertiesParserTests, givenInvalidFlagsIntelWhenParsingMemoryPropertiesForBufferThenFalseIsReturned) {
cl_mem_properties_intel properties[] = {
CL_MEM_FLAGS,
MemObjHelper::validFlagsForBuffer,
@@ -189,15 +158,11 @@ TEST(MemoryPropertiesParser, givenInvalidFlagsIntelWhenParsingMemoryPropertiesFo
(1 << 30),
0};
MemoryPropertiesFlags memoryProperties;
cl_mem_flags flags = 0;
cl_mem_flags_intel flagsIntel = 0;
cl_mem_alloc_flags_intel allocflags = 0;
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::ObjType::BUFFER));
EXPECT_FALSE(MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
MemoryPropertiesParser::ObjType::BUFFER, context));
}
TEST(MemoryPropertiesParser, givenDifferentParametersWhenCallingFillCachePolicyInPropertiesThenFlushL3FlagsAreCorrectlySet) {
TEST_F(MemoryPropertiesParserTests, givenDifferentParametersWhenCallingFillCachePolicyInPropertiesThenFlushL3FlagsAreCorrectlySet) {
AllocationProperties allocationProperties{0, 0, GraphicsAllocation::AllocationType::BUFFER};
for (auto uncached : ::testing::Bool()) {