From d2576c95aabdbcf37bf05681f4aef31e2ef20d0f Mon Sep 17 00:00:00 2001 From: Gibala Date: Wed, 9 Oct 2019 17:29:00 +0200 Subject: [PATCH] Remove OCL object from MemoryProperties 11/n Remove MemoryProperties from MemObj class and replaced it with MemoryPropertiesFlags Related-To: NEO-3132 Change-Id: Iff8633c49225b6a1f18103281825b36bf179701f Signed-off-by: Gibala --- runtime/command_queue/enqueue_fill_buffer.h | 2 +- runtime/command_queue/enqueue_svm.h | 2 +- runtime/mem_obj/buffer.cpp | 15 +-- runtime/mem_obj/buffer.h | 12 +-- runtime/mem_obj/image.cpp | 21 ++-- runtime/mem_obj/image.h | 12 +-- runtime/mem_obj/mem_obj.cpp | 24 ++--- runtime/mem_obj/mem_obj.h | 3 +- runtime/mem_obj/pipe.cpp | 2 +- .../enqueue_fill_buffer_tests.cpp | 14 +-- .../command_queue/enqueue_map_image_tests.cpp | 5 +- .../get_size_required_buffer_tests.cpp | 2 +- .../multiple_map_buffer_tests.cpp | 3 +- .../multiple_map_image_tests.cpp | 4 +- unit_tests/helpers/base_object_tests.cpp | 4 +- unit_tests/mem_obj/buffer_tests.cpp | 2 +- unit_tests/mem_obj/image_tests.cpp | 2 +- unit_tests/mem_obj/image_validate_tests.cpp | 2 +- .../mem_obj/mem_obj_destruction_tests.cpp | 5 +- unit_tests/mem_obj/mem_obj_tests.cpp | 99 ++++++++++--------- unit_tests/mocks/mock_buffer.h | 13 +-- unit_tests/mocks/mock_image.h | 2 +- .../linux/drm_command_stream_tests.cpp | 3 +- unit_tests/sharings/sharing_tests.cpp | 7 +- 24 files changed, 139 insertions(+), 121 deletions(-) diff --git a/runtime/command_queue/enqueue_fill_buffer.h b/runtime/command_queue/enqueue_fill_buffer.h index f88a6695ad..6aacd2fc7c 100644 --- a/runtime/command_queue/enqueue_fill_buffer.h +++ b/runtime/command_queue/enqueue_fill_buffer.h @@ -54,7 +54,7 @@ cl_int CommandQueueHw::enqueueFillBuffer( BuiltInOwnershipWrapper builtInLock(builder, this->context); BuiltinOpParams dc; - MemObj patternMemObj(this->context, 0, 0, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(this->context, 0, {}, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); dc.srcMemObj = &patternMemObj; dc.dstMemObj = buffer; diff --git a/runtime/command_queue/enqueue_svm.h b/runtime/command_queue/enqueue_svm.h index e5485097bc..c8f68a5129 100644 --- a/runtime/command_queue/enqueue_svm.h +++ b/runtime/command_queue/enqueue_svm.h @@ -469,7 +469,7 @@ cl_int CommandQueueHw::enqueueSVMMemFill(void *svmPtr, BuiltInOwnershipWrapper builtInLock(builder, this->context); BuiltinOpParams operationParams; - MemObj patternMemObj(this->context, 0, 0, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(this->context, 0, {}, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); void *alignedDstPtr = alignDown(svmPtr, 4); diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index 80febfdc71..e0a9ac8208 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -32,7 +32,7 @@ namespace NEO { BufferFuncs bufferFactory[IGFX_MAX_CORE] = {}; Buffer::Buffer(Context *context, - MemoryProperties properties, + MemoryPropertiesFlags memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -44,7 +44,7 @@ Buffer::Buffer(Context *context, bool isObjectRedescribed) : MemObj(context, CL_MEM_OBJECT_BUFFER, - properties, + memoryProperties, flags, flagsIntel, size, @@ -58,7 +58,7 @@ Buffer::Buffer(Context *context, setHostPtrMinSize(size); } -Buffer::Buffer() : MemObj(nullptr, CL_MEM_OBJECT_BUFFER, 0, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false) { +Buffer::Buffer() : MemObj(nullptr, CL_MEM_OBJECT_BUFFER, {}, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false) { } Buffer::~Buffer() = default; @@ -405,7 +405,8 @@ Buffer *Buffer::createSubBuffer(cl_mem_flags flags, const cl_buffer_region *region, cl_int &errcodeRet) { DEBUG_BREAK_IF(nullptr == createFunction); - auto buffer = createFunction(this->context, flags, flags, 0, region->size, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({flags}); + auto buffer = createFunction(this->context, memoryProperties, flags, 0, region->size, ptrOffset(this->memoryStorage, region->origin), this->hostPtr ? ptrOffset(this->hostPtr, region->origin) : nullptr, this->graphicsAllocation, @@ -510,7 +511,8 @@ Buffer *Buffer::createBufferHw(Context *context, auto funcCreate = bufferFactory[hwInfo.platform.eRenderCoreFamily].createBufferFunction; DEBUG_BREAK_IF(nullptr == funcCreate); - auto pBuffer = funcCreate(context, properties, properties.flags, properties.flagsIntel, size, memoryStorage, hostPtr, gfxAllocation, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); + auto pBuffer = funcCreate(context, memoryProperties, properties.flags, properties.flagsIntel, size, memoryStorage, hostPtr, gfxAllocation, zeroCopy, isHostPtrSVM, isImageRedescribed); DEBUG_BREAK_IF(nullptr == pBuffer); if (pBuffer) { @@ -534,7 +536,8 @@ Buffer *Buffer::createBufferHwFromDevice(const Device *device, auto funcCreate = bufferFactory[hwInfo.platform.eRenderCoreFamily].createBufferFunction; DEBUG_BREAK_IF(nullptr == funcCreate); - auto pBuffer = funcCreate(nullptr, flags, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({flags}); + auto pBuffer = funcCreate(nullptr, memoryProperties, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation, zeroCopy, isHostPtrSVM, isImageRedescribed); pBuffer->executionEnvironment = device->getExecutionEnvironment(); return pBuffer; diff --git a/runtime/mem_obj/buffer.h b/runtime/mem_obj/buffer.h index 791779bc5a..b67a0d30ca 100644 --- a/runtime/mem_obj/buffer.h +++ b/runtime/mem_obj/buffer.h @@ -22,7 +22,7 @@ class MemoryManager; struct MemoryProperties; typedef Buffer *(*BufferCreatFunc)(Context *context, - MemoryProperties properties, + MemoryPropertiesFlags memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -135,7 +135,7 @@ class Buffer : public MemObj { protected: Buffer(Context *context, - MemoryProperties properties, + MemoryPropertiesFlags memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -167,7 +167,7 @@ template class BufferHw : public Buffer { public: BufferHw(Context *context, - MemoryProperties properties, + MemoryPropertiesFlags memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -177,7 +177,7 @@ class BufferHw : public Buffer { bool zeroCopy, bool isHostPtrSVM, bool isObjectRedescribed) - : Buffer(context, properties, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation, + : Buffer(context, memoryProperties, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation, zeroCopy, isHostPtrSVM, isObjectRedescribed) {} void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument) override; @@ -185,7 +185,7 @@ class BufferHw : public Buffer { void appendSurfaceStateExt(void *memory); static Buffer *create(Context *context, - MemoryProperties properties, + MemoryPropertiesFlags memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -196,7 +196,7 @@ class BufferHw : public Buffer { bool isHostPtrSVM, bool isObjectRedescribed) { auto buffer = new BufferHw(context, - properties, + memoryProperties, flags, flagsIntel, size, diff --git a/runtime/mem_obj/image.cpp b/runtime/mem_obj/image.cpp index c4bc7a0b38..7c3fef4e86 100644 --- a/runtime/mem_obj/image.cpp +++ b/runtime/mem_obj/image.cpp @@ -38,7 +38,7 @@ namespace NEO { ImageFuncs imageFactory[IGFX_MAX_CORE] = {}; Image::Image(Context *context, - const MemoryProperties &properties, + const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -54,7 +54,7 @@ Image::Image(Context *context, const SurfaceOffsets *surfaceOffsets) : MemObj(context, imageDesc.image_type, - properties, + memoryProperties, flags, flagsIntel, size, @@ -412,7 +412,8 @@ Image *Image::createImageHw(Context *context, const MemoryProperties &properties auto funcCreate = imageFactory[hwInfo.platform.eRenderCoreFamily].createImageFunction; DEBUG_BREAK_IF(nullptr == funcCreate); - auto image = funcCreate(context, properties, properties.flags, properties.flagsIntel, size, hostPtr, imageFormat, imageDesc, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); + auto image = funcCreate(context, memoryProperties, properties.flags, properties.flagsIntel, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, nullptr); DEBUG_BREAK_IF(nullptr == image); image->createFunction = funcCreate; @@ -860,10 +861,11 @@ Image *Image::redescribeFillImage() { imageFormatNew.image_channel_data_type = surfaceFormat->OCLImageFormat.image_channel_data_type; DEBUG_BREAK_IF(nullptr == createFunction); + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({flags | CL_MEM_USE_HOST_PTR}); auto image = createFunction(context, - properties.flags | CL_MEM_USE_HOST_PTR, - properties.flags | CL_MEM_USE_HOST_PTR, - properties.flagsIntel, + memoryProperties, + flags | CL_MEM_USE_HOST_PTR, + flagsIntel, this->getSize(), this->getCpuAddress(), imageFormatNew, @@ -909,10 +911,11 @@ Image *Image::redescribe() { imageFormatNew.image_channel_data_type = surfaceFormat->OCLImageFormat.image_channel_data_type; DEBUG_BREAK_IF(nullptr == createFunction); + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({flags | CL_MEM_USE_HOST_PTR}); auto image = createFunction(context, - properties.flags | CL_MEM_USE_HOST_PTR, - properties.flags | CL_MEM_USE_HOST_PTR, - properties.flagsIntel, + memoryProperties, + flags | CL_MEM_USE_HOST_PTR, + flagsIntel, this->getSize(), this->getCpuAddress(), imageFormatNew, diff --git a/runtime/mem_obj/image.h b/runtime/mem_obj/image.h index b91bf98612..b06c45eab4 100644 --- a/runtime/mem_obj/image.h +++ b/runtime/mem_obj/image.h @@ -25,7 +25,7 @@ struct SurfaceOffsets { }; typedef Image *(*ImageCreatFunc)(Context *context, - const MemoryProperties &properties, + const MemoryPropertiesFlags &memoryProperties, uint64_t flags, uint64_t flagsIntel, size_t size, @@ -183,7 +183,7 @@ class Image : public MemObj { protected: Image(Context *context, - const MemoryProperties &properties, + const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -239,7 +239,7 @@ class ImageHw : public Image { public: ImageHw(Context *context, - const MemoryProperties &properties, + const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -253,7 +253,7 @@ class ImageHw : public Image { uint32_t mipCount, const SurfaceFormatInfo &surfaceFormatInfo, const SurfaceOffsets *surfaceOffsets = nullptr) - : Image(context, properties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc, + : Image(context, memoryProperties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, surfaceOffsets) { if (getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D || getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER || @@ -295,7 +295,7 @@ class ImageHw : public Image { void transformImage2dArrayTo3d(void *memory) override; void transformImage3dTo2dArray(void *memory) override; static Image *create(Context *context, - const MemoryProperties &properties, + const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -311,7 +311,7 @@ class ImageHw : public Image { const SurfaceOffsets *surfaceOffsets) { UNRECOVERABLE_IF(surfaceFormatInfo == nullptr); return new ImageHw(context, - properties, + memoryProperties, flags, flagsIntel, size, diff --git a/runtime/mem_obj/mem_obj.cpp b/runtime/mem_obj/mem_obj.cpp index 262abad49a..d15af6f22e 100644 --- a/runtime/mem_obj/mem_obj.cpp +++ b/runtime/mem_obj/mem_obj.cpp @@ -27,7 +27,7 @@ namespace NEO { MemObj::MemObj(Context *context, cl_mem_object_type memObjectType, - const MemoryProperties &properties, + const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -37,7 +37,7 @@ MemObj::MemObj(Context *context, bool zeroCopy, bool isHostPtrSVM, bool isObjectRedescribed) - : context(context), memObjectType(memObjectType), properties(properties), flags(flags), flagsIntel(flagsIntel), size(size), + : context(context), memObjectType(memObjectType), memoryProperties(memoryProperties), flags(flags), flagsIntel(flagsIntel), size(size), memoryStorage(memoryStorage), hostPtr(hostPtr), isZeroCopy(zeroCopy), isHostPtrSVM(isHostPtrSVM), isObjectRedescribed(isObjectRedescribed), graphicsAllocation(gfxAllocation) { @@ -130,8 +130,8 @@ cl_int MemObj::getMemObjectInfo(cl_mem_info paramName, break; case CL_MEM_FLAGS: - srcParamSize = sizeof(properties.flags); - srcParam = &properties.flags; + srcParamSize = sizeof(flags); + srcParam = &flags; break; case CL_MEM_SIZE: @@ -151,7 +151,7 @@ cl_int MemObj::getMemObjectInfo(cl_mem_info paramName, break; case CL_MEM_USES_SVM_POINTER: - usesSVMPointer = isHostPtrSVM && isValueSet(properties.flags, CL_MEM_USE_HOST_PTR); + usesSVMPointer = isHostPtrSVM && isValueSet(flags, CL_MEM_USE_HOST_PTR); srcParamSize = sizeof(cl_bool); srcParam = &usesSVMPointer; break; @@ -231,11 +231,11 @@ bool MemObj::isMemObjWithHostPtrSVM() const { } bool MemObj::isMemObjUncacheable() const { - return isValueSet(properties.flagsIntel, CL_MEM_LOCALLY_UNCACHED_RESOURCE); + return isValueSet(flagsIntel, CL_MEM_LOCALLY_UNCACHED_RESOURCE); } bool MemObj::isMemObjUncacheableForSurfaceState() const { - return isAnyBitSet(properties.flagsIntel, CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE | CL_MEM_LOCALLY_UNCACHED_RESOURCE); + return isAnyBitSet(flagsIntel, CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE | CL_MEM_LOCALLY_UNCACHED_RESOURCE); } GraphicsAllocation *MemObj::getGraphicsAllocation() const { @@ -253,11 +253,11 @@ void MemObj::resetGraphicsAllocation(GraphicsAllocation *newGraphicsAllocation) } bool MemObj::readMemObjFlagsInvalid() { - return isValueSet(properties.flags, CL_MEM_HOST_WRITE_ONLY) || isValueSet(properties.flags, CL_MEM_HOST_NO_ACCESS); + return isValueSet(flags, CL_MEM_HOST_WRITE_ONLY) || isValueSet(flags, CL_MEM_HOST_NO_ACCESS); } bool MemObj::writeMemObjFlagsInvalid() { - return isValueSet(properties.flags, CL_MEM_HOST_READ_ONLY) || isValueSet(properties.flags, CL_MEM_HOST_NO_ACCESS); + return isValueSet(flags, CL_MEM_HOST_READ_ONLY) || isValueSet(flags, CL_MEM_HOST_NO_ACCESS); } bool MemObj::mapMemObjFlagsInvalid(cl_map_flags mapFlags) { @@ -271,7 +271,7 @@ void MemObj::setHostPtrMinSize(size_t size) { void *MemObj::getCpuAddressForMapping() { void *ptrToReturn = nullptr; - if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR)) { + if (isValueSet(flags, CL_MEM_USE_HOST_PTR)) { ptrToReturn = this->hostPtr; } else { ptrToReturn = this->memoryStorage; @@ -280,7 +280,7 @@ void *MemObj::getCpuAddressForMapping() { } void *MemObj::getCpuAddressForMemoryTransfer() { void *ptrToReturn = nullptr; - if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR) && this->isMemObjZeroCopy()) { + if (isValueSet(flags, CL_MEM_USE_HOST_PTR) && this->isMemObjZeroCopy()) { ptrToReturn = this->hostPtr; } else { ptrToReturn = this->memoryStorage; @@ -289,7 +289,7 @@ void *MemObj::getCpuAddressForMemoryTransfer() { } void MemObj::releaseAllocatedMapPtr() { if (allocatedMapPtr) { - DEBUG_BREAK_IF(isValueSet(properties.flags, CL_MEM_USE_HOST_PTR)); + DEBUG_BREAK_IF(isValueSet(flags, CL_MEM_USE_HOST_PTR)); memoryManager->freeSystemMemory(allocatedMapPtr); } allocatedMapPtr = nullptr; diff --git a/runtime/mem_obj/mem_obj.h b/runtime/mem_obj/mem_obj.h index be5166ae7f..20dd205d9e 100644 --- a/runtime/mem_obj/mem_obj.h +++ b/runtime/mem_obj/mem_obj.h @@ -39,7 +39,7 @@ class MemObj : public BaseObject<_cl_mem> { MemObj(Context *context, cl_mem_object_type memObjectType, - const MemoryProperties &properties, + const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, size_t size, @@ -130,7 +130,6 @@ class MemObj : public BaseObject<_cl_mem> { Context *context; cl_mem_object_type memObjectType; - MemoryProperties properties; MemoryPropertiesFlags memoryProperties; cl_mem_flags flags = 0; cl_mem_flags_intel flagsIntel = 0; diff --git a/runtime/mem_obj/pipe.cpp b/runtime/mem_obj/pipe.cpp index 21187ecda5..90a3391c5f 100644 --- a/runtime/mem_obj/pipe.cpp +++ b/runtime/mem_obj/pipe.cpp @@ -24,7 +24,7 @@ Pipe::Pipe(Context *context, GraphicsAllocation *gfxAllocation) : MemObj(context, CL_MEM_OBJECT_PIPE, - flags, + MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({flags}), flags, 0, static_cast(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace), diff --git a/unit_tests/command_queue/enqueue_fill_buffer_tests.cpp b/unit_tests/command_queue/enqueue_fill_buffer_tests.cpp index 90e31a28dc..08e942f000 100644 --- a/unit_tests/command_queue/enqueue_fill_buffer_tests.cpp +++ b/unit_tests/command_queue/enqueue_fill_buffer_tests.cpp @@ -100,7 +100,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, WhenFillingBufferThenIndirectDataGetsAdded) ASSERT_NE(nullptr, &builder); BuiltinOpParams dc; - MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, {}, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); dc.srcMemObj = &patternMemObj; dc.dstMemObj = buffer; @@ -132,7 +132,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, FillBufferRightLeftover) { ASSERT_NE(nullptr, &builder); BuiltinOpParams dc; - MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, {}, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); dc.srcMemObj = &patternMemObj; dc.dstMemObj = buffer; @@ -159,7 +159,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, FillBufferMiddle) { ASSERT_NE(nullptr, &builder); BuiltinOpParams dc; - MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, {}, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); dc.srcMemObj = &patternMemObj; dc.dstMemObj = buffer; @@ -186,7 +186,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, FillBufferLeftLeftover) { ASSERT_NE(nullptr, &builder); BuiltinOpParams dc; - MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, {}, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); dc.srcMemObj = &patternMemObj; dc.dstMemObj = buffer; @@ -279,7 +279,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, WhenFillingBufferThenArgumentZeroShouldMatch ASSERT_NE(nullptr, &builder); BuiltinOpParams dc; - MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, {}, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); dc.srcMemObj = &patternMemObj; dc.dstMemObj = buffer; @@ -315,7 +315,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, DISABLED_WhenFillingBufferThenArgumentOneSho ASSERT_NE(nullptr, &builder); BuiltinOpParams dc; - MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, {}, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); dc.srcMemObj = &patternMemObj; dc.dstMemObj = buffer; @@ -348,7 +348,7 @@ HWTEST_F(EnqueueFillBufferCmdTests, WhenFillingBufferThenArgumentTwoShouldMatchP ASSERT_NE(nullptr, &builder); BuiltinOpParams dc; - MemObj patternMemObj(&this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, {}, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); dc.srcMemObj = &patternMemObj; dc.dstMemObj = buffer; diff --git a/unit_tests/command_queue/enqueue_map_image_tests.cpp b/unit_tests/command_queue/enqueue_map_image_tests.cpp index e88b033928..ec96952e6b 100644 --- a/unit_tests/command_queue/enqueue_map_image_tests.cpp +++ b/unit_tests/command_queue/enqueue_map_image_tests.cpp @@ -8,6 +8,7 @@ #include "core/unit_tests/helpers/debug_manager_state_restore.h" #include "runtime/command_stream/command_stream_receiver.h" #include "runtime/event/user_event.h" +#include "runtime/helpers/memory_properties_flags_helpers.h" #include "runtime/os_interface/os_context.h" #include "test.h" #include "unit_tests/command_queue/command_enqueue_fixture.h" @@ -194,7 +195,7 @@ HWTEST_F(EnqueueMapImageTest, givenTiledImageWhenMapImageIsCalledThenStorageIsSe auto surfaceFormatInfo = image->getSurfaceFormatInfo(); mockedImage mockImage(context, - 0, + {}, 0, 0, 4096u, @@ -918,7 +919,7 @@ TEST_F(EnqueueMapImageTest, givenImage1DArrayWhenEnqueueMapImageIsCalledThenRetu class MockImage : public Image { public: MockImage(Context *context, cl_mem_flags flags, GraphicsAllocation *allocation, const SurfaceFormatInfo &surfaceFormat, - const cl_image_format &imageFormat, const cl_image_desc &imageDesc) : Image(context, flags, flags, 0, + const cl_image_format &imageFormat, const cl_image_desc &imageDesc) : Image(context, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({flags}), flags, 0, 0, nullptr, imageFormat, imageDesc, true, diff --git a/unit_tests/command_queue/get_size_required_buffer_tests.cpp b/unit_tests/command_queue/get_size_required_buffer_tests.cpp index b72d3be53e..e0b3452dbc 100644 --- a/unit_tests/command_queue/get_size_required_buffer_tests.cpp +++ b/unit_tests/command_queue/get_size_required_buffer_tests.cpp @@ -81,7 +81,7 @@ HWTEST_F(GetSizeRequiredBufferTest, enqueueFillBuffer) { ASSERT_NE(nullptr, &builder); BuiltinOpParams dc; - MemObj patternMemObj(this->context, 0, 0, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(this->context, 0, {}, 0, 0, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); dc.srcMemObj = &patternMemObj; dc.dstMemObj = dstBuffer; diff --git a/unit_tests/command_queue/multiple_map_buffer_tests.cpp b/unit_tests/command_queue/multiple_map_buffer_tests.cpp index 3b7e0a6bf6..9daac9abd4 100644 --- a/unit_tests/command_queue/multiple_map_buffer_tests.cpp +++ b/unit_tests/command_queue/multiple_map_buffer_tests.cpp @@ -89,8 +89,9 @@ struct MultipleMapBufferTest : public DeviceFixture, public ::testing::Test { template std::unique_ptr> createMockBuffer(bool mapOnGpu) { + MemoryPropertiesFlags memoryProperties; auto mockAlloc = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - auto buffer = new MockBuffer(context, 0, 0, 0, 1024, mockAlloc->getUnderlyingBuffer(), mockAlloc->getUnderlyingBuffer(), + auto buffer = new MockBuffer(context, memoryProperties, 0, 0, 1024, mockAlloc->getUnderlyingBuffer(), mockAlloc->getUnderlyingBuffer(), mockAlloc, false, false, false); if (mapOnGpu) { buffer->setSharingHandler(new SharingHandler()); diff --git a/unit_tests/command_queue/multiple_map_image_tests.cpp b/unit_tests/command_queue/multiple_map_image_tests.cpp index a82dd3b179..e243576b81 100644 --- a/unit_tests/command_queue/multiple_map_image_tests.cpp +++ b/unit_tests/command_queue/multiple_map_image_tests.cpp @@ -26,7 +26,7 @@ struct MultipleMapImageTest : public DeviceFixture, public ::testing::Test { using ImageHw::ImageHw; static Image *createMockImage(Context *context, - const MemoryProperties &properties, + const MemoryPropertiesFlags &memoryProperties, uint64_t flags, uint64_t flagsIntel, size_t size, @@ -40,7 +40,7 @@ struct MultipleMapImageTest : public DeviceFixture, public ::testing::Test { uint32_t mipCount, const SurfaceFormatInfo *surfaceFormatInfo, const SurfaceOffsets *surfaceOffsets) { - return new MockImage(context, properties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation, + return new MockImage(context, memoryProperties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, *surfaceFormatInfo, surfaceOffsets); }; diff --git a/unit_tests/helpers/base_object_tests.cpp b/unit_tests/helpers/base_object_tests.cpp index 4254a2a034..bcdee5807a 100644 --- a/unit_tests/helpers/base_object_tests.cpp +++ b/unit_tests/helpers/base_object_tests.cpp @@ -275,7 +275,7 @@ TEST(CastToImage, fromMemObj) { extern std::thread::id tempThreadID; class MockBuffer : public MockBufferStorage, public Buffer { public: - MockBuffer() : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) { + MockBuffer() : MockBufferStorage(), Buffer(nullptr, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) { } void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override { @@ -306,7 +306,7 @@ TYPED_TEST(BaseObjectTests, getCond) { TYPED_TEST(BaseObjectTests, convertToInternalObject) { class ObjectForTest : public NEO::MemObj { public: - ObjectForTest() : MemObj(nullptr, 0, 0, 0, 0, 0u, nullptr, nullptr, nullptr, false, false, false) { + ObjectForTest() : MemObj(nullptr, 0, {}, 0, 0, 0u, nullptr, nullptr, nullptr, false, false, false) { } void convertToInternalObject(void) { diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index 542e4349a3..ed2186a6eb 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -1237,7 +1237,7 @@ TEST_P(NoHostPtr, GivenNoHostPtrWhenHwBufferCreationFailsThenReturnNullptr) { BufferFuncsBackup[i] = bufferFactory[i]; bufferFactory[i].createBufferFunction = [](Context *, - MemoryProperties, + MemoryPropertiesFlags, cl_mem_flags, cl_mem_flags_intel, size_t, diff --git a/unit_tests/mem_obj/image_tests.cpp b/unit_tests/mem_obj/image_tests.cpp index a4bcb91ea8..555e75f752 100644 --- a/unit_tests/mem_obj/image_tests.cpp +++ b/unit_tests/mem_obj/image_tests.cpp @@ -1463,7 +1463,7 @@ HWTEST_F(ImageTransformTest, givenSurfaceBaseAddressAndUnifiedSurfaceWhenSetUnif template class MockImageHw : public ImageHw { public: - MockImageHw(Context *context, const cl_image_format &format, const cl_image_desc &desc, SurfaceFormatInfo &surfaceFormatInfo, GraphicsAllocation *graphicsAllocation) : ImageHw(context, 0, 0, 0, 0, nullptr, format, desc, false, graphicsAllocation, false, 0, 0, surfaceFormatInfo) { + MockImageHw(Context *context, const cl_image_format &format, const cl_image_desc &desc, SurfaceFormatInfo &surfaceFormatInfo, GraphicsAllocation *graphicsAllocation) : ImageHw(context, {}, 0, 0, 0, nullptr, format, desc, false, graphicsAllocation, false, 0, 0, surfaceFormatInfo) { } void setClearColorParams(typename FamilyName::RENDER_SURFACE_STATE *surfaceState, const Gmm *gmm) override; diff --git a/unit_tests/mem_obj/image_validate_tests.cpp b/unit_tests/mem_obj/image_validate_tests.cpp index aa6e92438d..821125b984 100644 --- a/unit_tests/mem_obj/image_validate_tests.cpp +++ b/unit_tests/mem_obj/image_validate_tests.cpp @@ -760,7 +760,7 @@ struct NullImage : public Image { using Image::imageDesc; using Image::imageFormat; - NullImage() : Image(nullptr, cl_mem_flags{}, cl_mem_flags{}, 0, 0, nullptr, cl_image_format{}, + NullImage() : Image(nullptr, MemoryPropertiesFlags(), cl_mem_flags{}, 0, 0, nullptr, cl_image_format{}, cl_image_desc{}, false, new MockGraphicsAllocation(nullptr, 0), false, 0, 0, SurfaceFormatInfo{}, nullptr) { } diff --git a/unit_tests/mem_obj/mem_obj_destruction_tests.cpp b/unit_tests/mem_obj/mem_obj_destruction_tests.cpp index 32e85e761b..22019f0dcc 100644 --- a/unit_tests/mem_obj/mem_obj_destruction_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_destruction_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/helpers/memory_properties_flags_helpers.h" #include "runtime/mem_obj/mem_obj.h" #include "runtime/memory_manager/allocations_list.h" #include "runtime/os_interface/os_context.h" @@ -38,7 +39,7 @@ class MemObjDestructionTest : public ::testing::TestWithParam { allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{size}); memObj = new MemObj(context.get(), CL_MEM_OBJECT_BUFFER, - CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0, + MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_READ_WRITE}), CL_MEM_READ_WRITE, 0, size, nullptr, nullptr, allocation, true, false, false); *device->getDefaultEngine().commandStreamReceiver->getTagAddress() = 0; @@ -215,7 +216,7 @@ HWTEST_P(MemObjAsyncDestructionTest, givenUsedMemObjWithAsyncDestructionsEnabled MemObjSizeArray region = {{1, 1, 1}}; cl_map_flags mapFlags = CL_MAP_READ; memObj = new MemObj(context.get(), CL_MEM_OBJECT_BUFFER, - CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0, + MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_READ_WRITE}), CL_MEM_READ_WRITE, 0, size, storage, nullptr, allocation, true, false, false); memObj->addMappedPtr(storage, 1, mapFlags, region, origin, 0); diff --git a/unit_tests/mem_obj/mem_obj_tests.cpp b/unit_tests/mem_obj/mem_obj_tests.cpp index de41af331d..9148cf169d 100644 --- a/unit_tests/mem_obj/mem_obj_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_tests.cpp @@ -8,6 +8,7 @@ #include "runtime/command_stream/command_stream_receiver.h" #include "runtime/device/device.h" #include "runtime/gmm_helper/gmm.h" +#include "runtime/helpers/memory_properties_flags_helpers.h" #include "runtime/helpers/properties_helper.h" #include "runtime/mem_obj/mem_obj.h" #include "runtime/memory_manager/allocations_list.h" @@ -60,8 +61,8 @@ TEST(MemObj, GivenMemObjWhenInititalizedFromHostPtrThenInitializeFields) { char buffer[size]; MockContext context; MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer)); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0, sizeof(buffer), buffer, buffer, mockAllocation, true, false, false); EXPECT_EQ(&buffer, memObj.getCpuAddress()); @@ -76,7 +77,8 @@ TEST(MemObj, givenMemObjectWhenAskedForTransferToHostPtrThenDoNothing) { uint8_t expectedHostPtr[size] = {}; MockContext context; MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(hostPtr, sizeof(hostPtr)); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0, size, hostPtr, hostPtr, mockAllocation, true, false, false); memset(memObj.getCpuAddress(), 123, size); @@ -95,7 +97,8 @@ TEST(MemObj, givenMemObjectWhenAskedForTransferFromHostPtrThenDoNothing) { uint8_t expectedBufferPtr[size] = {}; MockContext context; MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(hostPtr, sizeof(hostPtr)); - MemObj memObj(&context, CL_MEM_OBJECT_PIPE, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_PIPE, memoryProperties, CL_MEM_USE_HOST_PTR, 0, size, hostPtr, hostPtr, mockAllocation, true, false, false); memset(memObj.getCpuAddress(), 123, size); @@ -111,8 +114,8 @@ TEST(MemObj, givenMemObjectWhenAskedForTransferFromHostPtrThenDoNothing) { TEST(MemObj, givenHostPtrAndUseHostPtrFlagWhenAskingForBaseMapPtrThenReturnHostPtr) { uint8_t hostPtr = 0; MockContext context; - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, &hostPtr, nullptr, true, false, false); EXPECT_EQ(&hostPtr, memObj.getBasePtrForMap()); @@ -121,8 +124,8 @@ TEST(MemObj, givenHostPtrAndUseHostPtrFlagWhenAskingForBaseMapPtrThenReturnHostP TEST(MemObj, givenHostPtrWithoutUseHostPtrFlagWhenAskingForBaseMapPtrThenReturnAllocatedPtr) { uint8_t hostPtr = 0; MockContext context; - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_COPY_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, 1, nullptr, &hostPtr, nullptr, true, false, false); EXPECT_NE(&hostPtr, memObj.getBasePtrForMap()); @@ -133,8 +136,8 @@ TEST(MemObj, givenMemObjWhenReleaseAllocatedPtrIsCalledTwiceThenItDoesntCrash) { void *allocatedPtr = alignedMalloc(MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize); MockContext context; - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, nullptr, true, false, false); memObj.setAllocatedMapPtr(allocatedPtr); @@ -152,7 +155,8 @@ TEST(MemObj, givenNotReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThe auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); allocation->updateTaskCount(2, context.getDevice(0)->getDefaultEngine().osContext->getContextId()); *(memoryManager->getDefaultCommandStreamReceiver(0)->getTagAddress()) = 1; - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_COPY_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); auto &allocationList = memoryManager->getDefaultCommandStreamReceiver(0)->getTemporaryAllocations(); EXPECT_TRUE(allocationList.peekIsEmpty()); @@ -170,7 +174,8 @@ TEST(MemObj, givenReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThenAl auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); allocation->updateTaskCount(1, device->getDefaultEngine().osContext->getContextId()); *device->getDefaultEngine().commandStreamReceiver->getTagAddress() = 1; - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); auto &allocationList = device->getDefaultEngine().commandStreamReceiver->getTemporaryAllocations(); @@ -187,7 +192,8 @@ TEST(MemObj, givenNotUsedGraphicsAllocationWhenMemObjDestroysAllocationAsyncThen context.memoryManager = &memoryManager; auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_COPY_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); auto &allocationList = memoryManager.getDefaultCommandStreamReceiver(0)->getTemporaryAllocations(); @@ -204,8 +210,8 @@ TEST(MemObj, givenMemoryManagerWithoutDeviceWhenMemObjDestroysAllocationAsyncThe context.memoryManager = &memoryManager; auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_COPY_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); auto &allocationList = memoryManager.getDefaultCommandStreamReceiver(0)->getTemporaryAllocations(); @@ -220,8 +226,8 @@ TEST(MemObj, givenMemObjAndPointerToObjStorageWithProperCommandWhenCheckIfMemTra MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment()); context.memoryManager = &memoryManager; - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_COPY_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); void *ptr = memObj.getCpuAddressForMemoryTransfer(); bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_WRITE_BUFFER); @@ -247,8 +253,8 @@ TEST(MemObj, givenMemObjAndPointerToObjStorageBadCommandWhenCheckIfMemTransferRe MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment()); context.memoryManager = &memoryManager; - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_COPY_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); void *ptr = memObj.getCpuAddressForMemoryTransfer(); bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_FILL_BUFFER); @@ -259,8 +265,8 @@ TEST(MemObj, givenMemObjAndPointerToDiffrentStorageAndProperCommandWhenCheckIfMe MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment()); context.memoryManager = &memoryManager; - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_COPY_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); void *ptr = (void *)0x1234; bool isMemTransferNeeded = memObj.checkIfMemoryTransferIsRequired(0, 0, ptr, CL_COMMAND_WRITE_BUFFER); @@ -271,8 +277,8 @@ TEST(MemObj, givenSharingHandlerWhenAskedForCpuMappingThenReturnFalse) { MockContext context; MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment()); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_COPY_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, allocation, true, false, false); memObj.setSharingHandler(new SharingHandler()); EXPECT_FALSE(memObj.mappingOnCpuAllowed()); @@ -283,7 +289,8 @@ TEST(MemObj, givenTiledObjectWhenAskedForCpuMappingThenReturnFalse) { using MemObj::MemObj; bool isTiledAllocation() const override { return true; } }; - MyMemObj memObj(nullptr, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_COPY_HOST_PTR}); + MyMemObj memObj(nullptr, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); EXPECT_FALSE(memObj.mappingOnCpuAllowed()); @@ -297,8 +304,8 @@ TEST(MemObj, givenRenderCompressedGmmWhenAskingForMappingOnCpuThenDisallow) { auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); allocation->setDefaultGmm(new Gmm(nullptr, 1, false)); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_READ_WRITE}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); allocation->getDefaultGmm()->isRenderCompressed = false; @@ -314,8 +321,8 @@ TEST(MemObj, givenDefaultWhenAskedForCpuMappingThenReturnTrue) { context.memoryManager = &memoryManager; auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_COPY_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_COPY_HOST_PTR, 0, 64, allocation->getUnderlyingBuffer(), nullptr, allocation, true, false, false); EXPECT_FALSE(memObj.isTiledAllocation()); @@ -331,8 +338,8 @@ TEST(MemObj, givenNonCpuAccessibleMemoryWhenAskingForMappingOnCpuThenDisallow) { auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); allocation->setDefaultGmm(new Gmm(nullptr, 1, false)); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_READ_WRITE}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); EXPECT_TRUE(memObj.mappingOnCpuAllowed()); @@ -347,13 +354,13 @@ TEST(MemObj, givenMultipleMemObjectsWithReusedGraphicsAllocationWhenDestroyedThe auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - std::unique_ptr memObj1(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 0, 0, 1, nullptr, nullptr, allocation, true, false, false)); + std::unique_ptr memObj1(new MemObj(&context, CL_MEM_OBJECT_BUFFER, {}, 0, 0, 1, nullptr, nullptr, allocation, true, false, false)); memObj1->setSharingHandler(new MySharingHandler(allocation)); - std::unique_ptr memObj2(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 0, 0, 1, nullptr, nullptr, allocation, true, false, false)); + std::unique_ptr memObj2(new MemObj(&context, CL_MEM_OBJECT_BUFFER, {}, 0, 0, 1, nullptr, nullptr, allocation, true, false, false)); memObj2->setSharingHandler(new MySharingHandler(allocation)); - std::unique_ptr memObj3(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 0, 0, 1, nullptr, nullptr, allocation, true, false, false)); + std::unique_ptr memObj3(new MemObj(&context, CL_MEM_OBJECT_BUFFER, {}, 0, 0, 1, nullptr, nullptr, allocation, true, false, false)); memObj3->setSharingHandler(new MySharingHandler(allocation)); EXPECT_EQ(3u, allocation->peekReuseCount()); @@ -370,7 +377,7 @@ TEST(MemObj, givenMemObjectWhenContextIsNotNullThenContextOutlivesMemobjects) { MockContext context; EXPECT_EQ(1, context.getRefInternalCount()); { - MemObj memObj(&context, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false); + MemObj memObj(&context, 0, {}, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false); EXPECT_EQ(2, context.getRefInternalCount()); } EXPECT_EQ(1, context.getRefInternalCount()); @@ -381,8 +388,8 @@ TEST(MemObj, givenSharedMemObjectWithNullGfxAllocationWhenSettingGfxAllocationTh MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment()); context.memoryManager = &memoryManager; MockGraphicsAllocation *gfxAllocation = new MockGraphicsAllocation(nullptr, 0); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, nullptr, true, false, false); memObj.setSharingHandler(new MySharingHandler(&memObj)); @@ -398,8 +405,8 @@ TEST(MemObj, givenSharedMemObjectAndNullGfxAllocationProvidedWhenSettingGfxAlloc MockMemoryManager memoryManager(*context.getDevice(0)->getExecutionEnvironment()); context.memoryManager = &memoryManager; MockGraphicsAllocation *graphicsAllocation = new MockGraphicsAllocation(nullptr, 0); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, graphicsAllocation, true, false, false); memObj.setSharingHandler(new MySharingHandler(&memObj)); @@ -415,8 +422,8 @@ TEST(MemObj, givenSharedMemObjectAndZeroReuseCountWhenChangingGfxAllocationThenO context.memoryManager = &memoryManager; MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, oldGfxAllocation, true, false, false); memObj.setSharingHandler(new MySharingHandler(&memObj)); @@ -434,8 +441,8 @@ TEST(MemObj, givenSharedMemObjectAndNonZeroReuseCountWhenChangingGfxAllocationTh context.memoryManager = &memoryManager; MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, oldGfxAllocation, true, false, false); memObj.setSharingHandler(new MySharingHandler(&memObj)); @@ -453,8 +460,8 @@ TEST(MemObj, givenNotSharedMemObjectWhenChangingGfxAllocationThenOldAllocationIs context.memoryManager = &memoryManager; MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0); - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, oldGfxAllocation, true, false, false); memObj.resetGraphicsAllocation(newGfxAllocation); @@ -471,8 +478,8 @@ TEST(MemObj, givenGraphicsAllocationWhenCallingIsAllocDumpableThenItReturnsTheCo TEST(MemObj, givenMemObjNotUsingHostPtrWhenGettingBasePtrTwiceReturnSameMapPtr) { MockContext context; - - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0, + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_READ_WRITE}); + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, 1, nullptr, nullptr, nullptr, true, false, false); void *mapPtr = memObj.getBasePtrForMap(); diff --git a/unit_tests/mocks/mock_buffer.h b/unit_tests/mocks/mock_buffer.h index c5f1b98320..3e844fba00 100644 --- a/unit_tests/mocks/mock_buffer.h +++ b/unit_tests/mocks/mock_buffer.h @@ -7,6 +7,7 @@ #pragma once #include "core/helpers/aligned_memory.h" +#include "runtime/helpers/memory_properties_flags_helpers.h" #include "runtime/mem_obj/buffer.h" #include "unit_tests/mocks/mock_context.h" #include "unit_tests/mocks/mock_device.h" @@ -33,10 +34,10 @@ class MockBuffer : public MockBufferStorage, public Buffer { using MockBufferStorage::device; MockBuffer(GraphicsAllocation &alloc) - : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, alloc.getUnderlyingBufferSize(), alloc.getUnderlyingBuffer(), alloc.getUnderlyingBuffer(), &alloc, true, false, false), + : MockBufferStorage(), Buffer(nullptr, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, alloc.getUnderlyingBufferSize(), alloc.getUnderlyingBuffer(), alloc.getUnderlyingBuffer(), &alloc, true, false, false), externalAlloc(&alloc) { } - MockBuffer() : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) { + MockBuffer() : MockBufferStorage(), Buffer(nullptr, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) { } ~MockBuffer() override { if (externalAlloc != nullptr) { @@ -54,9 +55,9 @@ class MockBuffer : public MockBufferStorage, public Buffer { class AlignedBuffer : public MockBufferStorage, public Buffer { public: using MockBufferStorage::device; - AlignedBuffer() : MockBufferStorage(false), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), &mockGfxAllocation, true, false, false) { + AlignedBuffer() : MockBufferStorage(false), Buffer(nullptr, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), &mockGfxAllocation, true, false, false) { } - AlignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), gfxAllocation, true, false, false) { + AlignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(), Buffer(nullptr, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), gfxAllocation, true, false, false) { } void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override { Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation); @@ -66,9 +67,9 @@ class AlignedBuffer : public MockBufferStorage, public Buffer { class UnalignedBuffer : public MockBufferStorage, public Buffer { public: using MockBufferStorage::device; - UnalignedBuffer() : MockBufferStorage(true), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), &mockGfxAllocation, false, false, false) { + UnalignedBuffer() : MockBufferStorage(true), Buffer(nullptr, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), &mockGfxAllocation, false, false, false) { } - UnalignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(true), Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), gfxAllocation, false, false, false) { + UnalignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(true), Buffer(nullptr, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), gfxAllocation, false, false, false) { } void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override { Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation); diff --git a/unit_tests/mocks/mock_image.h b/unit_tests/mocks/mock_image.h index af36827b82..fe46d1230b 100644 --- a/unit_tests/mocks/mock_image.h +++ b/unit_tests/mocks/mock_image.h @@ -15,7 +15,7 @@ struct MockImageBase : public NEO::Image { using Image::imageDesc; MockImageBase() : Image( - nullptr, cl_mem_flags{}, cl_mem_flags{}, 0, 0, nullptr, cl_image_format{}, + nullptr, MemoryPropertiesFlags(), cl_mem_flags{}, 0, 0, nullptr, cl_image_format{}, cl_image_desc{}, false, new NEO::MockGraphicsAllocation(nullptr, 0), false, 0, 0, NEO::SurfaceFormatInfo{}, nullptr) { } diff --git a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp index c318ba00b6..524030ffd1 100644 --- a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp +++ b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp @@ -9,6 +9,7 @@ #include "runtime/command_stream/preemption.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/helpers/flush_stamp.h" +#include "runtime/helpers/memory_properties_flags_helpers.h" #include "runtime/mem_obj/buffer.h" #include "runtime/memory_manager/internal_allocation_storage.h" #include "runtime/os_interface/linux/drm_buffer_object.h" @@ -1330,7 +1331,7 @@ class DrmMockBuffer : public Buffer { delete gfxAllocation; } - DrmMockBuffer(char *data, size_t size, DrmAllocation *alloc) : Buffer(nullptr, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, size, data, data, alloc, true, false, false), + DrmMockBuffer(char *data, size_t size, DrmAllocation *alloc) : Buffer(nullptr, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, size, data, data, alloc, true, false, false), data(data), gfxAllocation(alloc) { } diff --git a/unit_tests/sharings/sharing_tests.cpp b/unit_tests/sharings/sharing_tests.cpp index 16386d6fbc..6e16f2cefc 100644 --- a/unit_tests/sharings/sharing_tests.cpp +++ b/unit_tests/sharings/sharing_tests.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/helpers/memory_properties_flags_helpers.h" #include "runtime/mem_obj/mem_obj.h" #include "runtime/sharings/sharing.h" #include "unit_tests/mocks/mock_context.h" @@ -36,7 +37,7 @@ TEST(sharingHandler, givenMemObjWhenAcquireIncrementCounterThenReleaseShouldDecr char buffer[64]; MockContext context; MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer)); - std::unique_ptr memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + std::unique_ptr memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, sizeof(buffer), buffer, buffer, mockAllocation, true, false, false)); struct MockSharingHandler : SharingHandler { @@ -61,7 +62,7 @@ TEST(sharingHandler, givenMemObjWhenAcquireTwoTimesThenReleaseShouldBeCalledTwoT char buffer[64]; MockContext context; MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer)); - std::unique_ptr memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + std::unique_ptr memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, sizeof(buffer), buffer, buffer, mockAllocation, true, false, false)); struct MockSharingHandler : SharingHandler { @@ -106,7 +107,7 @@ TEST(sharingHandler, givenSharingHandlerWhenAcquiringThenReturnErrorCode) { SharingHandler sharingHandler; MockContext context; MockGraphicsAllocation *graphicsAllocation = new MockGraphicsAllocation(nullptr, 0); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags({CL_MEM_USE_HOST_PTR}), CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, graphicsAllocation, true, false, false); auto result = sharingHandler.acquire(&memObj);