mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Pass Context to parseMemoryProperties function
Change-Id: I74ff9fdb9292e281a1a6491387163db0de2ccea2 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
9022912a6d
commit
64575cd589
@@ -652,9 +652,17 @@ cl_mem CL_API_CALL clCreateBuffer(cl_context context,
|
||||
cl_mem buffer = nullptr;
|
||||
ErrorCodeHelper err(errcodeRet, CL_SUCCESS);
|
||||
|
||||
Context *pContext = nullptr;
|
||||
retVal = validateObjects(WithCastToInternal(context, &pContext));
|
||||
if (retVal != CL_SUCCESS) {
|
||||
err.set(retVal);
|
||||
TRACING_EXIT(clCreateBuffer, &buffer);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(flags, 0, 0);
|
||||
if (isFieldValid(flags, MemObjHelper::validFlagsForBuffer)) {
|
||||
Buffer::validateInputAndCreateBuffer(context, memoryProperties, flags, 0, size, hostPtr, retVal, buffer);
|
||||
Buffer::validateInputAndCreateBuffer(*pContext, memoryProperties, flags, 0, size, hostPtr, retVal, buffer);
|
||||
} else {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
}
|
||||
@@ -681,12 +689,20 @@ cl_mem CL_API_CALL clCreateBufferWithPropertiesINTEL(cl_context context,
|
||||
cl_mem buffer = nullptr;
|
||||
ErrorCodeHelper err(errcodeRet, CL_SUCCESS);
|
||||
|
||||
Context *pContext = nullptr;
|
||||
retVal = validateObjects(WithCastToInternal(context, &pContext));
|
||||
if (retVal != CL_SUCCESS) {
|
||||
err.set(retVal);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MemoryPropertiesFlags memoryProperties;
|
||||
cl_mem_flags flags = 0;
|
||||
cl_mem_flags_intel flagsIntel = 0;
|
||||
cl_mem_alloc_flags_intel allocflags = 0;
|
||||
if (MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::BUFFER)) {
|
||||
Buffer::validateInputAndCreateBuffer(context, memoryProperties, flags, flagsIntel, size, hostPtr, retVal, buffer);
|
||||
if (MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
|
||||
MemoryPropertiesParser::MemoryPropertiesParser::ObjType::BUFFER, *pContext)) {
|
||||
Buffer::validateInputAndCreateBuffer(*pContext, memoryProperties, flags, flagsIntel, size, hostPtr, retVal, buffer);
|
||||
} else {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
}
|
||||
@@ -871,7 +887,8 @@ cl_mem CL_API_CALL clCreateImageWithPropertiesINTEL(cl_context context,
|
||||
retVal = validateObjects(WithCastToInternal(context, &pContext));
|
||||
|
||||
if (retVal == CL_SUCCESS) {
|
||||
if (MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::IMAGE)) {
|
||||
if (MemoryPropertiesParser::parseMemoryProperties(properties, memoryProperties, flags, flagsIntel, allocflags,
|
||||
MemoryPropertiesParser::MemoryPropertiesParser::ObjType::IMAGE, *pContext)) {
|
||||
image = Image::validateAndCreateImage(pContext, memoryProperties, flags, flagsIntel, imageFormat, imageDesc, hostPtr, retVal);
|
||||
} else {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
@@ -3484,7 +3501,9 @@ void *clHostMemAllocINTEL(
|
||||
cl_mem_flags flags = 0;
|
||||
cl_mem_flags_intel flagsIntel = 0;
|
||||
cl_mem_alloc_flags_intel allocflags = 0;
|
||||
if (!MemoryPropertiesParser::parseMemoryProperties(properties, unifiedMemoryProperties.allocationFlags, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN)) {
|
||||
if (!MemoryPropertiesParser::parseMemoryProperties(properties, unifiedMemoryProperties.allocationFlags, flags, flagsIntel,
|
||||
allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN,
|
||||
*neoContext)) {
|
||||
err.set(CL_INVALID_VALUE);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -3520,7 +3539,9 @@ void *clDeviceMemAllocINTEL(
|
||||
cl_mem_flags flags = 0;
|
||||
cl_mem_flags_intel flagsIntel = 0;
|
||||
cl_mem_alloc_flags_intel allocflags = 0;
|
||||
if (!MemoryPropertiesParser::parseMemoryProperties(properties, unifiedMemoryProperties.allocationFlags, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN)) {
|
||||
if (!MemoryPropertiesParser::parseMemoryProperties(properties, unifiedMemoryProperties.allocationFlags, flags, flagsIntel,
|
||||
allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN,
|
||||
*neoContext)) {
|
||||
err.set(CL_INVALID_VALUE);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -3559,7 +3580,9 @@ void *clSharedMemAllocINTEL(
|
||||
cl_mem_flags flags = 0;
|
||||
cl_mem_flags_intel flagsIntel = 0;
|
||||
cl_mem_alloc_flags_intel allocflags = 0;
|
||||
if (!MemoryPropertiesParser::parseMemoryProperties(properties, unifiedMemoryProperties.allocationFlags, flags, flagsIntel, allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN)) {
|
||||
if (!MemoryPropertiesParser::parseMemoryProperties(properties, unifiedMemoryProperties.allocationFlags, flags, flagsIntel,
|
||||
allocflags, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::UNKNOWN,
|
||||
*neoContext)) {
|
||||
err.set(CL_INVALID_VALUE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
bool NEO::MemoryPropertiesParser::parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryPropertiesFlags &memoryProperties,
|
||||
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, cl_mem_alloc_flags_intel &allocflags, ObjType objectType) {
|
||||
bool MemoryPropertiesParser::parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryPropertiesFlags &memoryProperties,
|
||||
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel,
|
||||
cl_mem_alloc_flags_intel &allocflags, ObjType objectType, Context &context) {
|
||||
if (properties == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class Context;
|
||||
|
||||
class MemoryPropertiesParser {
|
||||
public:
|
||||
enum class ObjType {
|
||||
@@ -24,7 +26,8 @@ class MemoryPropertiesParser {
|
||||
};
|
||||
|
||||
static bool parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryPropertiesFlags &memoryProperties,
|
||||
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, cl_mem_alloc_flags_intel &allocflags, ObjType objectType);
|
||||
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, cl_mem_alloc_flags_intel &allocflags,
|
||||
ObjType objectType, Context &context);
|
||||
|
||||
static AllocationProperties getAllocationProperties(uint32_t rootDeviceIndex, MemoryPropertiesFlags memoryProperties, bool allocateMemory,
|
||||
size_t size, GraphicsAllocation::AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo) {
|
||||
|
||||
@@ -85,7 +85,7 @@ bool Buffer::isValidSubBufferOffset(size_t offset) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Buffer::validateInputAndCreateBuffer(cl_context &context,
|
||||
void Buffer::validateInputAndCreateBuffer(Context &context,
|
||||
MemoryPropertiesFlags memoryProperties,
|
||||
cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel,
|
||||
@@ -93,18 +93,13 @@ void Buffer::validateInputAndCreateBuffer(cl_context &context,
|
||||
void *hostPtr,
|
||||
cl_int &retVal,
|
||||
cl_mem &buffer) {
|
||||
Context *pContext = nullptr;
|
||||
retVal = validateObjects(WithCastToInternal(context, &pContext));
|
||||
if (retVal != CL_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, *pContext)) {
|
||||
if (!MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flagsIntel, context)) {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
return;
|
||||
}
|
||||
|
||||
auto pDevice = pContext->getDevice(0);
|
||||
auto pDevice = context.getDevice(0);
|
||||
bool allowCreateBuffersWithUnrestrictedSize = isValueSet(flags, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL) ||
|
||||
isValueSet(flagsIntel, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL);
|
||||
|
||||
@@ -121,7 +116,7 @@ void Buffer::validateInputAndCreateBuffer(cl_context &context,
|
||||
}
|
||||
|
||||
// create the buffer
|
||||
buffer = create(pContext, memoryProperties, flags, flagsIntel, size, hostPtr, retVal);
|
||||
buffer = create(&context, memoryProperties, flags, flagsIntel, size, hostPtr, retVal);
|
||||
}
|
||||
|
||||
Buffer *Buffer::create(Context *context,
|
||||
|
||||
@@ -49,7 +49,7 @@ class Buffer : public MemObj {
|
||||
|
||||
~Buffer() override;
|
||||
|
||||
static void validateInputAndCreateBuffer(cl_context &context,
|
||||
static void validateInputAndCreateBuffer(Context &context,
|
||||
MemoryPropertiesFlags memoryProperties,
|
||||
cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel,
|
||||
|
||||
@@ -30,14 +30,20 @@ class MemObjHelper {
|
||||
static const uint64_t validFlagsForImage;
|
||||
static const uint64_t validFlagsForImageIntel;
|
||||
|
||||
static bool validateMemoryPropertiesForBuffer(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const Context &context);
|
||||
static bool validateMemoryPropertiesForImage(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, cl_mem parent, const Context &context);
|
||||
static AllocationProperties getAllocationPropertiesWithImageInfo(uint32_t rootDeviceIndex, ImageInfo &imgInfo, bool allocateMemory, const MemoryPropertiesFlags &memoryProperties, const HardwareInfo &hwInfo);
|
||||
static bool validateMemoryPropertiesForBuffer(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel, const Context &context);
|
||||
static bool validateMemoryPropertiesForImage(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel, cl_mem parent, const Context &context);
|
||||
static AllocationProperties getAllocationPropertiesWithImageInfo(uint32_t rootDeviceIndex, ImageInfo &imgInfo, bool allocateMemory,
|
||||
const MemoryPropertiesFlags &memoryProperties,
|
||||
const HardwareInfo &hwInfo);
|
||||
static bool checkMemFlagsForSubBuffer(cl_mem_flags flags);
|
||||
static SVMAllocsManager::SvmAllocationProperties getSvmAllocationProperties(cl_mem_flags flags);
|
||||
static bool isSuitableForRenderCompression(bool renderCompressed, const MemoryPropertiesFlags &properties, Context &context, bool preferCompression);
|
||||
static bool isSuitableForRenderCompression(bool renderCompressed, const MemoryPropertiesFlags &properties, Context &context,
|
||||
bool preferCompression);
|
||||
|
||||
protected:
|
||||
static bool validateExtraMemoryProperties(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const Context &context);
|
||||
static bool validateExtraMemoryProperties(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel, const Context &context);
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const Context &context) {
|
||||
bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel, const Context &context) {
|
||||
/* Check all the invalid flags combination. */
|
||||
if ((isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY)) ||
|
||||
(isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY)) ||
|
||||
@@ -25,7 +26,8 @@ bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryPropertiesFlags
|
||||
return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel, context);
|
||||
}
|
||||
|
||||
bool MemObjHelper::validateMemoryPropertiesForImage(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, cl_mem parent, const Context &context) {
|
||||
bool MemObjHelper::validateMemoryPropertiesForImage(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel, cl_mem parent, const Context &context) {
|
||||
/* Check all the invalid flags combination. */
|
||||
if ((!isValueSet(flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) &&
|
||||
(isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY) ||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user