mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Update memory flags validation for Images
Change-Id: Ifc8b50301cd82bd7e9c83da626a02dbc1643e0b0 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
@@ -62,13 +62,16 @@ class MemObjHelper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemObj *parentMemObj = castToObject<MemObj>(parent);
|
auto parentMemObj = castToObject<MemObj>(parent);
|
||||||
if (parentMemObj != nullptr && properties.flags) {
|
if (parentMemObj != nullptr && properties.flags) {
|
||||||
auto parentFlags = parentMemObj->getFlags();
|
auto parentFlags = parentMemObj->getFlags();
|
||||||
/* Check whether flags are compatible with parent. */
|
/* Check whether flags are compatible with parent. */
|
||||||
if ((!isValueSet(parentFlags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) &&
|
if ((!isValueSet(parentFlags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) &&
|
||||||
(!isValueSet(properties.flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) &&
|
(!isValueSet(properties.flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) &&
|
||||||
((isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(properties.flags, CL_MEM_READ_WRITE)) ||
|
(isValueSet(properties.flags, CL_MEM_ALLOC_HOST_PTR) ||
|
||||||
|
isValueSet(properties.flags, CL_MEM_COPY_HOST_PTR) ||
|
||||||
|
isValueSet(properties.flags, CL_MEM_USE_HOST_PTR) ||
|
||||||
|
(isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(properties.flags, CL_MEM_READ_WRITE)) ||
|
||||||
(isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(properties.flags, CL_MEM_READ_ONLY)) ||
|
(isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(properties.flags, CL_MEM_READ_ONLY)) ||
|
||||||
(isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(properties.flags, CL_MEM_READ_WRITE)) ||
|
(isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(properties.flags, CL_MEM_READ_WRITE)) ||
|
||||||
(isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(properties.flags, CL_MEM_WRITE_ONLY)) ||
|
(isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(properties.flags, CL_MEM_WRITE_ONLY)) ||
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "runtime/mem_obj/mem_obj_helper.h"
|
#include "runtime/mem_obj/mem_obj_helper.h"
|
||||||
|
#include "unit_tests/fixtures/image_fixture.h"
|
||||||
|
#include "unit_tests/utilities/base_object_utils.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
@@ -110,3 +112,18 @@ TEST(MemObjHelper, givenInvalidPropertiesWhenValidatingMemoryPropertiesThenFalse
|
|||||||
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForBuffer(properties));
|
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForBuffer(properties));
|
||||||
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr));
|
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(MemObjHelper, givenParentMemObjAndHostPtrFlagsWhenValidatingMemoryPropertiesForImageThenFalseIsReturned) {
|
||||||
|
MemoryProperties properties;
|
||||||
|
MockContext context;
|
||||||
|
auto image = clUniquePtr(Image1dHelper<>::create(&context));
|
||||||
|
|
||||||
|
properties.flags = CL_MEM_USE_HOST_PTR;
|
||||||
|
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get()));
|
||||||
|
|
||||||
|
properties.flags = CL_MEM_ALLOC_HOST_PTR;
|
||||||
|
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get()));
|
||||||
|
|
||||||
|
properties.flags = CL_MEM_COPY_HOST_PTR;
|
||||||
|
EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get()));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user