From 2f9bfc77482d7053b44e5dbf6013dbbaf533ef16 Mon Sep 17 00:00:00 2001 From: Gibala Date: Tue, 24 Sep 2019 16:05:17 +0200 Subject: [PATCH] Remove OCL object from MemoryProperties 10/n Add cl_mem_flags, cl_mem_flags_intel and wire it in mem_obj. Refactor: - validateMemoryPropertiesForImage - validateExtraMemoryProperties Related-To: NEO-3132 Change-Id: I90fac5fc00e24fc67346109a1fe6f269ef51e1e0 Signed-off-by: Gibala --- runtime/api/api.cpp | 10 +-- runtime/command_queue/command_queue.cpp | 2 +- runtime/command_queue/enqueue_fill_buffer.h | 2 +- runtime/command_queue/enqueue_svm.h | 2 +- runtime/kernel/kernel.cpp | 2 +- runtime/mem_obj/buffer.cpp | 22 ++++--- runtime/mem_obj/buffer.h | 16 ++++- runtime/mem_obj/image.cpp | 16 ++++- runtime/mem_obj/image.h | 14 ++++- runtime/mem_obj/mem_obj.cpp | 10 ++- runtime/mem_obj/mem_obj.h | 9 ++- runtime/mem_obj/mem_obj_helper.cpp | 2 +- runtime/mem_obj/mem_obj_helper.h | 6 +- runtime/mem_obj/mem_obj_helper_common.inl | 62 +++++++++---------- runtime/mem_obj/pipe.cpp | 2 + .../os_interface/debug_settings_manager.cpp | 4 +- .../enqueue_fill_buffer_tests.cpp | 14 ++--- .../command_queue/enqueue_map_image_tests.cpp | 4 +- .../get_size_required_buffer_tests.cpp | 2 +- .../multiple_map_buffer_tests.cpp | 2 +- .../multiple_map_image_tests.cpp | 4 +- unit_tests/d3d_sharing/d3d9_tests.cpp | 4 +- unit_tests/d3d_sharing/d3d_tests_part1.cpp | 6 +- unit_tests/helpers/base_object_tests.cpp | 4 +- unit_tests/mem_obj/buffer_set_arg_tests.cpp | 2 +- unit_tests/mem_obj/buffer_tests.cpp | 2 + unit_tests/mem_obj/image_redescribe_tests.cpp | 2 +- unit_tests/mem_obj/image_tests.cpp | 2 +- unit_tests/mem_obj/image_validate_tests.cpp | 9 ++- .../mem_obj/mem_obj_destruction_tests.cpp | 4 +- unit_tests/mem_obj/mem_obj_helper_tests.cpp | 60 ++++++++++++------ unit_tests/mem_obj/mem_obj_tests.cpp | 58 ++++++++--------- unit_tests/mocks/mock_buffer.h | 12 ++-- unit_tests/mocks/mock_image.h | 7 ++- .../linux/drm_command_stream_tests.cpp | 2 +- unit_tests/sharings/gl/gl_sharing_tests.cpp | 2 +- unit_tests/sharings/sharing_tests.cpp | 6 +- unit_tests/sharings/va/va_sharing_tests.cpp | 2 +- 38 files changed, 233 insertions(+), 158 deletions(-) diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index 06354a5215..64b0508828 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -659,7 +659,7 @@ cl_mem CL_API_CALL clCreateSubBuffer(cl_mem buffer, break; } - cl_mem_flags parentFlags = parentBuffer->getFlags(); + cl_mem_flags parentFlags = parentBuffer->getMemoryPropertiesFlags(); if (parentBuffer->isSubBuffer() == true) { retVal = CL_INVALID_MEM_OBJECT; @@ -765,7 +765,7 @@ cl_mem CL_API_CALL clCreateImage(cl_context context, if (retVal == CL_SUCCESS) { MemoryProperties propertiesStruct(flags); if (isFieldValid(propertiesStruct.flags, MemObjHelper::validFlagsForImage)) { - image = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, imageDesc, hostPtr, retVal); + image = Image::validateAndCreateImage(pContext, propertiesStruct, flags, 0, imageFormat, imageDesc, hostPtr, retVal); } else { retVal = CL_INVALID_VALUE; } @@ -804,7 +804,7 @@ cl_mem CL_API_CALL clCreateImageWithPropertiesINTEL(cl_context context, if (retVal == CL_SUCCESS) { if (MemoryPropertiesParser::parseMemoryProperties(properties, propertiesStruct, MemoryPropertiesParser::MemoryPropertiesParser::ObjType::IMAGE)) { - image = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, imageDesc, hostPtr, retVal); + image = Image::validateAndCreateImage(pContext, propertiesStruct, propertiesStruct.flags, propertiesStruct.flags_intel, imageFormat, imageDesc, hostPtr, retVal); } else { retVal = CL_INVALID_VALUE; } @@ -851,7 +851,7 @@ cl_mem CL_API_CALL clCreateImage2D(cl_context context, if (retVal == CL_SUCCESS) { MemoryProperties propertiesStruct(flags); - image2D = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, &imageDesc, hostPtr, retVal); + image2D = Image::validateAndCreateImage(pContext, propertiesStruct, flags, 0, imageFormat, &imageDesc, hostPtr, retVal); } ErrorCodeHelper err(errcodeRet, retVal); @@ -902,7 +902,7 @@ cl_mem CL_API_CALL clCreateImage3D(cl_context context, if (retVal == CL_SUCCESS) { MemoryProperties propertiesStruct(flags); - image3D = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, &imageDesc, hostPtr, retVal); + image3D = Image::validateAndCreateImage(pContext, propertiesStruct, flags, 0, imageFormat, &imageDesc, hostPtr, retVal); } ErrorCodeHelper err(errcodeRet, retVal); diff --git a/runtime/command_queue/command_queue.cpp b/runtime/command_queue/command_queue.cpp index ae0f7a47b3..a62061d21b 100644 --- a/runtime/command_queue/command_queue.cpp +++ b/runtime/command_queue/command_queue.cpp @@ -341,7 +341,7 @@ cl_int CommandQueue::enqueueWriteMemObjForUnmap(MemObj *memObj, void *mappedPtr, image->getHostPtrRowPitch(), image->getHostPtrSlicePitch(), mappedPtr, memObj->getMapAllocation(), eventsRequest.numEventsInWaitList, eventsRequest.eventWaitList, eventsRequest.outEvent); bool mustCallFinish = true; - if (!(image->getFlags() & CL_MEM_USE_HOST_PTR)) { + if (!(image->getMemoryPropertiesFlags() & CL_MEM_USE_HOST_PTR)) { mustCallFinish = true; } else { mustCallFinish = (CommandQueue::getTaskLevelFromWaitList(this->taskLevel, eventsRequest.numEventsInWaitList, eventsRequest.eventWaitList) != Event::eventNotReady); diff --git a/runtime/command_queue/enqueue_fill_buffer.h b/runtime/command_queue/enqueue_fill_buffer.h index 49b1d283ab..f88a6695ad 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, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(this->context, 0, 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 ff08f0c2ae..e5485097bc 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, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(this->context, 0, 0, 0, 0, alignUp(patternSize, 4), patternAllocation->getUnderlyingBuffer(), patternAllocation->getUnderlyingBuffer(), patternAllocation, false, false, true); void *alignedDstPtr = alignDown(svmPtr, 4); diff --git a/runtime/kernel/kernel.cpp b/runtime/kernel/kernel.cpp index 16c121cf5e..64cad7b458 100644 --- a/runtime/kernel/kernel.cpp +++ b/runtime/kernel/kernel.cpp @@ -2190,7 +2190,7 @@ cl_int Kernel::checkCorrectImageAccessQualifier(cl_uint argIndex, WithCastToInternal(mem, &pMemObj); if (pMemObj) { cl_kernel_arg_access_qualifier accessQualifier = getKernelInfo().kernelArgInfo[argIndex].accessQualifier; - cl_mem_flags flags = pMemObj->getFlags(); + cl_mem_flags flags = pMemObj->getMemoryPropertiesFlags(); if ((accessQualifier == CL_KERNEL_ARG_ACCESS_READ_ONLY && ((flags | CL_MEM_WRITE_ONLY) == flags)) || (accessQualifier == CL_KERNEL_ARG_ACCESS_WRITE_ONLY && ((flags | CL_MEM_READ_ONLY) == flags))) { return CL_INVALID_ARG_VALUE; diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index 7498897491..ce06bea454 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -33,6 +33,8 @@ BufferFuncs bufferFactory[IGFX_MAX_CORE] = {}; Buffer::Buffer(Context *context, MemoryProperties properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *memoryStorage, void *hostPtr, @@ -43,6 +45,8 @@ Buffer::Buffer(Context *context, : MemObj(context, CL_MEM_OBJECT_BUFFER, properties, + flags, + flagsIntel, size, memoryStorage, hostPtr, @@ -54,7 +58,7 @@ Buffer::Buffer(Context *context, setHostPtrMinSize(size); } -Buffer::Buffer() : MemObj(nullptr, CL_MEM_OBJECT_BUFFER, 0, 0, nullptr, nullptr, nullptr, false, false, false) { +Buffer::Buffer() : MemObj(nullptr, CL_MEM_OBJECT_BUFFER, 0, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false) { } Buffer::~Buffer() = default; @@ -92,7 +96,7 @@ void Buffer::validateInputAndCreateBuffer(cl_context &context, return; } - if (!MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flagsIntel)) { + if (!MemObjHelper::validateMemoryPropertiesForBuffer(MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties), flags, flagsIntel)) { retVal = CL_INVALID_VALUE; return; } @@ -401,7 +405,7 @@ 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, region->size, + auto buffer = createFunction(this->context, flags, flags, 0, region->size, ptrOffset(this->memoryStorage, region->origin), this->hostPtr ? ptrOffset(this->hostPtr, region->origin) : nullptr, this->graphicsAllocation, @@ -506,7 +510,7 @@ Buffer *Buffer::createBufferHw(Context *context, auto funcCreate = bufferFactory[hwInfo.platform.eRenderCoreFamily].createBufferFunction; DEBUG_BREAK_IF(nullptr == funcCreate); - auto pBuffer = funcCreate(context, properties, size, memoryStorage, hostPtr, gfxAllocation, + auto pBuffer = funcCreate(context, properties, properties.flags, properties.flags_intel, size, memoryStorage, hostPtr, gfxAllocation, zeroCopy, isHostPtrSVM, isImageRedescribed); DEBUG_BREAK_IF(nullptr == pBuffer); if (pBuffer) { @@ -517,6 +521,7 @@ Buffer *Buffer::createBufferHw(Context *context, Buffer *Buffer::createBufferHwFromDevice(const Device *device, cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *memoryStorage, void *hostPtr, @@ -529,7 +534,7 @@ Buffer *Buffer::createBufferHwFromDevice(const Device *device, auto funcCreate = bufferFactory[hwInfo.platform.eRenderCoreFamily].createBufferFunction; DEBUG_BREAK_IF(nullptr == funcCreate); - auto pBuffer = funcCreate(nullptr, flags, size, memoryStorage, hostPtr, gfxAllocation, + auto pBuffer = funcCreate(nullptr, flags, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation, zeroCopy, isHostPtrSVM, isImageRedescribed); pBuffer->executionEnvironment = device->getExecutionEnvironment(); return pBuffer; @@ -547,7 +552,7 @@ uint32_t Buffer::getMocsValue(bool disableL3Cache, bool isReadOnlyArgument) cons } bufferAddress += this->offset; - bool readOnlyMemObj = isValueSet(getFlags(), CL_MEM_READ_ONLY) || isReadOnlyArgument; + bool readOnlyMemObj = isValueSet(getMemoryPropertiesFlags(), CL_MEM_READ_ONLY) || isReadOnlyArgument; bool alignedMemObj = isAligned(bufferAddress) && isAligned(bufferSize); @@ -564,8 +569,9 @@ void Buffer::setSurfaceState(const Device *device, size_t svmSize, void *svmPtr, GraphicsAllocation *gfxAlloc, - cl_mem_flags flags) { - auto buffer = Buffer::createBufferHwFromDevice(device, flags, svmSize, svmPtr, svmPtr, gfxAlloc, true, false, false); + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel) { + auto buffer = Buffer::createBufferHwFromDevice(device, flags, flagsIntel, svmSize, svmPtr, svmPtr, gfxAlloc, true, false, false); buffer->setArgStateful(surfaceState, false, false, false, false); buffer->graphicsAllocation = nullptr; delete buffer; diff --git a/runtime/mem_obj/buffer.h b/runtime/mem_obj/buffer.h index feed3d31cd..a78b656843 100644 --- a/runtime/mem_obj/buffer.h +++ b/runtime/mem_obj/buffer.h @@ -23,6 +23,8 @@ struct MemoryProperties; typedef Buffer *(*BufferCreatFunc)(Context *context, MemoryProperties properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *memoryStorage, void *hostPtr, @@ -84,6 +86,7 @@ class Buffer : public MemObj { static Buffer *createBufferHwFromDevice(const Device *device, cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *memoryStorage, void *hostPtr, @@ -101,7 +104,8 @@ class Buffer : public MemObj { size_t svmSize, void *svmPtr, GraphicsAllocation *gfxAlloc = nullptr, - cl_mem_flags flags = 0); + cl_mem_flags flags = 0, + cl_mem_flags_intel flagsIntel = 0); static void provideCompressionHint(GraphicsAllocation::AllocationType allocationType, Context *context, @@ -132,6 +136,8 @@ class Buffer : public MemObj { protected: Buffer(Context *context, MemoryProperties properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *memoryStorage, void *hostPtr, @@ -162,6 +168,8 @@ class BufferHw : public Buffer { public: BufferHw(Context *context, MemoryProperties properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *memoryStorage, void *hostPtr, @@ -169,7 +177,7 @@ class BufferHw : public Buffer { bool zeroCopy, bool isHostPtrSVM, bool isObjectRedescribed) - : Buffer(context, properties, size, memoryStorage, hostPtr, gfxAllocation, + : Buffer(context, properties, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation, zeroCopy, isHostPtrSVM, isObjectRedescribed) {} void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument) override; @@ -177,6 +185,8 @@ class BufferHw : public Buffer { static Buffer *create(Context *context, MemoryProperties properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *memoryStorage, void *hostPtr, @@ -186,6 +196,8 @@ class BufferHw : public Buffer { bool isObjectRedescribed) { auto buffer = new BufferHw(context, properties, + flags, + flagsIntel, size, memoryStorage, hostPtr, diff --git a/runtime/mem_obj/image.cpp b/runtime/mem_obj/image.cpp index fbce1cce38..52724ddbd9 100644 --- a/runtime/mem_obj/image.cpp +++ b/runtime/mem_obj/image.cpp @@ -39,6 +39,8 @@ ImageFuncs imageFactory[IGFX_MAX_CORE] = {}; Image::Image(Context *context, const MemoryProperties &properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *hostPtr, cl_image_format imageFormat, @@ -53,6 +55,8 @@ Image::Image(Context *context, : MemObj(context, imageDesc.image_type, properties, + flags, + flagsIntel, size, graphicsAllocation->getUnderlyingBuffer(), hostPtr, @@ -408,7 +412,7 @@ 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, size, hostPtr, imageFormat, imageDesc, + auto image = funcCreate(context, properties, properties.flags, properties.flags_intel, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, surfaceFormatInfo, nullptr); DEBUG_BREAK_IF(nullptr == image); image->createFunction = funcCreate; @@ -464,7 +468,7 @@ cl_int Image::validate(Context *context, const auto minimumBufferSize = imageDesc->image_height * rowSize; if ((imageDesc->image_row_pitch % (*pitchAlignment)) || - ((parentBuffer->getFlags() & CL_MEM_USE_HOST_PTR) && (reinterpret_cast(parentBuffer->getHostPtr()) % (*baseAddressAlignment))) || + ((parentBuffer->getMemoryPropertiesFlags() & CL_MEM_USE_HOST_PTR) && (reinterpret_cast(parentBuffer->getHostPtr()) % (*baseAddressAlignment))) || (minimumBufferSize > parentBuffer->getSize())) { return CL_INVALID_IMAGE_FORMAT_DESCRIPTOR; } else if (memoryProperties.flags.useHostPtr || memoryProperties.flags.copyHostPtr) { @@ -858,6 +862,8 @@ Image *Image::redescribeFillImage() { DEBUG_BREAK_IF(nullptr == createFunction); auto image = createFunction(context, properties.flags | CL_MEM_USE_HOST_PTR, + properties.flags | CL_MEM_USE_HOST_PTR, + properties.flags_intel, this->getSize(), this->getCpuAddress(), imageFormatNew, @@ -905,6 +911,8 @@ Image *Image::redescribe() { DEBUG_BREAK_IF(nullptr == createFunction); auto image = createFunction(context, properties.flags | CL_MEM_USE_HOST_PTR, + properties.flags | CL_MEM_USE_HOST_PTR, + properties.flags_intel, this->getSize(), this->getCpuAddress(), imageFormatNew, @@ -1027,12 +1035,14 @@ bool Image::isDepthFormat(const cl_image_format &imageFormat) { Image *Image::validateAndCreateImage(Context *context, const MemoryProperties &properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, const cl_image_format *imageFormat, const cl_image_desc *imageDesc, const void *hostPtr, cl_int &errcodeRet) { - if (!MemObjHelper::validateMemoryPropertiesForImage(properties, imageDesc->mem_object)) { + if (!MemObjHelper::validateMemoryPropertiesForImage(MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties), flags, flagsIntel, imageDesc->mem_object)) { errcodeRet = CL_INVALID_VALUE; return nullptr; } diff --git a/runtime/mem_obj/image.h b/runtime/mem_obj/image.h index 4af4e3ae96..7f4209d8bd 100644 --- a/runtime/mem_obj/image.h +++ b/runtime/mem_obj/image.h @@ -26,6 +26,8 @@ struct SurfaceOffsets { typedef Image *(*ImageCreatFunc)(Context *context, const MemoryProperties &properties, + uint64_t flags, + uint64_t flagsIntel, size_t size, void *hostPtr, const cl_image_format &imageFormat, @@ -58,6 +60,8 @@ class Image : public MemObj { static Image *validateAndCreateImage(Context *context, const MemoryProperties &properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, const cl_image_format *imageFormat, const cl_image_desc *imageDesc, const void *hostPtr, @@ -180,6 +184,8 @@ class Image : public MemObj { protected: Image(Context *context, const MemoryProperties &properties, + cl_mem_flags flags, + cl_mem_flags_intel flags_intel, size_t size, void *hostPtr, cl_image_format imageFormat, @@ -234,6 +240,8 @@ class ImageHw : public Image { public: ImageHw(Context *context, const MemoryProperties &properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *hostPtr, const cl_image_format &imageFormat, @@ -245,7 +253,7 @@ class ImageHw : public Image { uint32_t mipCount, const SurfaceFormatInfo &surfaceFormatInfo, const SurfaceOffsets *surfaceOffsets = nullptr) - : Image(context, properties, size, hostPtr, imageFormat, imageDesc, + : Image(context, properties, 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 || @@ -287,6 +295,8 @@ class ImageHw : public Image { void transformImage3dTo2dArray(void *memory) override; static Image *create(Context *context, const MemoryProperties &properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *hostPtr, const cl_image_format &imageFormat, @@ -301,6 +311,8 @@ class ImageHw : public Image { UNRECOVERABLE_IF(surfaceFormatInfo == nullptr); return new ImageHw(context, properties, + flags, + flagsIntel, size, hostPtr, imageFormat, diff --git a/runtime/mem_obj/mem_obj.cpp b/runtime/mem_obj/mem_obj.cpp index 330878ebec..f16cd5a245 100644 --- a/runtime/mem_obj/mem_obj.cpp +++ b/runtime/mem_obj/mem_obj.cpp @@ -28,6 +28,8 @@ namespace NEO { MemObj::MemObj(Context *context, cl_mem_object_type memObjectType, const MemoryProperties &properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *memoryStorage, void *hostPtr, @@ -35,7 +37,7 @@ MemObj::MemObj(Context *context, bool zeroCopy, bool isHostPtrSVM, bool isObjectRedescribed) - : context(context), memObjectType(memObjectType), properties(properties), size(size), + : context(context), memObjectType(memObjectType), properties(properties), flags(flags), flags_intel(flagsIntel), size(size), memoryStorage(memoryStorage), hostPtr(hostPtr), isZeroCopy(zeroCopy), isHostPtrSVM(isHostPtrSVM), isObjectRedescribed(isObjectRedescribed), graphicsAllocation(gfxAllocation) { @@ -220,10 +222,6 @@ void MemObj::setAllocatedMapPtr(void *allocatedMapPtr) { this->allocatedMapPtr = allocatedMapPtr; } -cl_mem_flags MemObj::getFlags() const { - return getProperties().flags; -} - bool MemObj::isMemObjZeroCopy() const { return isZeroCopy; } @@ -325,7 +323,7 @@ void *MemObj::getBasePtrForMap() { if (associatedMemObject) { return associatedMemObject->getBasePtrForMap(); } - if (getFlags() & CL_MEM_USE_HOST_PTR) { + if (getMemoryPropertiesFlags() & CL_MEM_USE_HOST_PTR) { return getHostPtr(); } else { TakeOwnershipWrapper memObjOwnership(*this); diff --git a/runtime/mem_obj/mem_obj.h b/runtime/mem_obj/mem_obj.h index ee0e0033da..5899915267 100644 --- a/runtime/mem_obj/mem_obj.h +++ b/runtime/mem_obj/mem_obj.h @@ -14,6 +14,7 @@ #include "runtime/sharings/sharing.h" #include "mem_obj_types.h" +#include "memory_properties_flags.h" #include #include @@ -39,6 +40,8 @@ class MemObj : public BaseObject<_cl_mem> { MemObj(Context *context, cl_mem_object_type memObjectType, const MemoryProperties &properties, + cl_mem_flags flags, + cl_mem_flags_intel flagsIntel, size_t size, void *memoryStorage, void *hostPtr, @@ -59,7 +62,6 @@ class MemObj : public BaseObject<_cl_mem> { void *getHostPtr() const; bool getIsObjectRedescribed() const { return isObjectRedescribed; }; size_t getSize() const; - cl_mem_flags getFlags() const; bool addMappedPtr(void *ptr, size_t ptrLength, cl_map_flags &mapFlags, MemObjSizeArray &size, MemObjOffsetArray &offset, uint32_t mipLevel); bool findMappedPtr(void *mappedPtr, MapInfo &outMapInfo) { return mapOperationsHandler.find(mappedPtr, outMapInfo); } @@ -121,7 +123,7 @@ class MemObj : public BaseObject<_cl_mem> { return mapAllocation; } - const MemoryProperties &getProperties() const { return properties; } + const cl_mem_flags &getMemoryPropertiesFlags() const { return flags; } protected: void getOsSpecificMemObjectInfo(const cl_mem_info ¶mName, size_t *srcParamSize, void **srcParam); @@ -129,6 +131,9 @@ 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 flags_intel = 0; size_t size; size_t hostPtrMinSize = 0; void *memoryStorage; diff --git a/runtime/mem_obj/mem_obj_helper.cpp b/runtime/mem_obj/mem_obj_helper.cpp index 1c0ca3e3c1..24654e4b59 100644 --- a/runtime/mem_obj/mem_obj_helper.cpp +++ b/runtime/mem_obj/mem_obj_helper.cpp @@ -15,7 +15,7 @@ bool MemObjHelper::isSuitableForRenderCompression(bool renderCompressed, const M return renderCompressed && preferCompression; } -bool MemObjHelper::validateExtraMemoryProperties(const MemoryProperties &properties) { +bool MemObjHelper::validateExtraMemoryProperties(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel) { return true; } diff --git a/runtime/mem_obj/mem_obj_helper.h b/runtime/mem_obj/mem_obj_helper.h index d3ef72599d..0ae37dc240 100644 --- a/runtime/mem_obj/mem_obj_helper.h +++ b/runtime/mem_obj/mem_obj_helper.h @@ -30,15 +30,15 @@ class MemObjHelper { static const uint64_t validFlagsForImage; static const uint64_t validFlagsForImageIntel; - static bool validateMemoryPropertiesForBuffer(const MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel); - static bool validateMemoryPropertiesForImage(const MemoryProperties &properties, cl_mem parent); static bool parseUnifiedMemoryProperties(cl_mem_properties_intel *properties, SVMAllocsManager::UnifiedMemoryProperties &unifiedMemoryProperties); + static bool validateMemoryPropertiesForBuffer(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel); + static bool validateMemoryPropertiesForImage(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, cl_mem parent); static AllocationProperties getAllocationPropertiesWithImageInfo(ImageInfo &imgInfo, bool allocateMemory, const MemoryPropertiesFlags &memoryProperties); 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); protected: - static bool validateExtraMemoryProperties(const MemoryProperties &properties); + static bool validateExtraMemoryProperties(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel); }; } // namespace NEO diff --git a/runtime/mem_obj/mem_obj_helper_common.inl b/runtime/mem_obj/mem_obj_helper_common.inl index 3135a11657..3e47ba69a7 100644 --- a/runtime/mem_obj/mem_obj_helper_common.inl +++ b/runtime/mem_obj/mem_obj_helper_common.inl @@ -9,7 +9,7 @@ namespace NEO { -bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel) { +bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel) { /* 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)) || @@ -22,49 +22,49 @@ bool MemObjHelper::validateMemoryPropertiesForBuffer(const MemoryProperties &pro return false; } - return validateExtraMemoryProperties(properties); + return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel); } -bool MemObjHelper::validateMemoryPropertiesForImage(const MemoryProperties &properties, cl_mem parent) { +bool MemObjHelper::validateMemoryPropertiesForImage(const MemoryPropertiesFlags &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, cl_mem parent) { /* Check all the invalid flags combination. */ - if ((!isValueSet(properties.flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && - (isValueSet(properties.flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY) || - isValueSet(properties.flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY) || - isValueSet(properties.flags, CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY) || - isValueSet(properties.flags, CL_MEM_ALLOC_HOST_PTR | CL_MEM_USE_HOST_PTR) || - isValueSet(properties.flags, CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR) || - isValueSet(properties.flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY) || - isValueSet(properties.flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS) || - isValueSet(properties.flags, CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS) || - isValueSet(properties.flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_WRITE) || - isValueSet(properties.flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_WRITE_ONLY) || - isValueSet(properties.flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_ONLY))) { + if ((!isValueSet(flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && + (isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_WRITE_ONLY) || + isValueSet(flags, CL_MEM_READ_WRITE | CL_MEM_READ_ONLY) || + isValueSet(flags, CL_MEM_WRITE_ONLY | CL_MEM_READ_ONLY) || + isValueSet(flags, CL_MEM_ALLOC_HOST_PTR | CL_MEM_USE_HOST_PTR) || + isValueSet(flags, CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR) || + isValueSet(flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_READ_ONLY) || + isValueSet(flags, CL_MEM_HOST_WRITE_ONLY | CL_MEM_HOST_NO_ACCESS) || + isValueSet(flags, CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS) || + isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_WRITE) || + isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_WRITE_ONLY) || + isValueSet(flags, CL_MEM_NO_ACCESS_INTEL | CL_MEM_READ_ONLY))) { return false; } auto parentMemObj = castToObject(parent); - if (parentMemObj != nullptr && properties.flags) { - auto parentFlags = parentMemObj->getFlags(); + if (parentMemObj != nullptr && flags) { + auto parentFlags = parentMemObj->getMemoryPropertiesFlags(); /* Check whether flags are compatible with parent. */ - if (isValueSet(properties.flags, CL_MEM_ALLOC_HOST_PTR) || - isValueSet(properties.flags, CL_MEM_COPY_HOST_PTR) || - isValueSet(properties.flags, CL_MEM_USE_HOST_PTR) || + if (isValueSet(flags, CL_MEM_ALLOC_HOST_PTR) || + isValueSet(flags, CL_MEM_COPY_HOST_PTR) || + isValueSet(flags, CL_MEM_USE_HOST_PTR) || ((!isValueSet(parentFlags, 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(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_WRITE_ONLY)) || - (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(properties.flags, CL_MEM_READ_WRITE)) || - (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(properties.flags, CL_MEM_WRITE_ONLY)) || - (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(properties.flags, CL_MEM_READ_ONLY)) || - (isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(properties.flags, CL_MEM_HOST_WRITE_ONLY)) || - (isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(properties.flags, CL_MEM_HOST_READ_ONLY))))) { + (!isValueSet(flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) && + ((isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(flags, CL_MEM_READ_WRITE)) || + (isValueSet(parentFlags, CL_MEM_WRITE_ONLY) && isValueSet(flags, CL_MEM_READ_ONLY)) || + (isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(flags, CL_MEM_READ_WRITE)) || + (isValueSet(parentFlags, CL_MEM_READ_ONLY) && isValueSet(flags, CL_MEM_WRITE_ONLY)) || + (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_READ_WRITE)) || + (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_WRITE_ONLY)) || + (isValueSet(parentFlags, CL_MEM_NO_ACCESS_INTEL) && isValueSet(flags, CL_MEM_READ_ONLY)) || + (isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(flags, CL_MEM_HOST_WRITE_ONLY)) || + (isValueSet(parentFlags, CL_MEM_HOST_NO_ACCESS) && isValueSet(flags, CL_MEM_HOST_READ_ONLY))))) { return false; } } - return validateExtraMemoryProperties(properties); + return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel); } bool MemObjHelper::parseUnifiedMemoryProperties(cl_mem_properties_intel *properties, SVMAllocsManager::UnifiedMemoryProperties &unifiedMemoryProperties) { diff --git a/runtime/mem_obj/pipe.cpp b/runtime/mem_obj/pipe.cpp index 1ffaee520e..21187ecda5 100644 --- a/runtime/mem_obj/pipe.cpp +++ b/runtime/mem_obj/pipe.cpp @@ -25,6 +25,8 @@ Pipe::Pipe(Context *context, : MemObj(context, CL_MEM_OBJECT_PIPE, flags, + flags, + 0, static_cast(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace), memoryStorage, nullptr, diff --git a/runtime/os_interface/debug_settings_manager.cpp b/runtime/os_interface/debug_settings_manager.cpp index 729c5726fd..1f5755026a 100644 --- a/runtime/os_interface/debug_settings_manager.cpp +++ b/runtime/os_interface/debug_settings_manager.cpp @@ -234,7 +234,7 @@ void DebugSettingsManager::dumpKernelArgs(const Kernel *kernel) { if (memObj != nullptr) { ptr = static_cast(memObj->getCpuAddress()); size = memObj->getSize(); - flags = memObj->getFlags(); + flags = memObj->getMemoryPropertiesFlags(); } } else if (argInfo.typeStr.find("sampler") != std::string::npos) { type = "sampler"; @@ -245,7 +245,7 @@ void DebugSettingsManager::dumpKernelArgs(const Kernel *kernel) { if (memObj != nullptr) { ptr = static_cast(memObj->getCpuAddress()); size = memObj->getSize(); - flags = memObj->getFlags(); + flags = memObj->getMemoryPropertiesFlags(); } } else { type = "immediate"; diff --git a/unit_tests/command_queue/enqueue_fill_buffer_tests.cpp b/unit_tests/command_queue/enqueue_fill_buffer_tests.cpp index 2a4f74a1f4..90e31a28dc 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, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, 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, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, 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, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, 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, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, 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, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, 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, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, 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, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(&this->context, 0, 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 10bd4f2975..e88b033928 100644 --- a/unit_tests/command_queue/enqueue_map_image_tests.cpp +++ b/unit_tests/command_queue/enqueue_map_image_tests.cpp @@ -194,6 +194,8 @@ HWTEST_F(EnqueueMapImageTest, givenTiledImageWhenMapImageIsCalledThenStorageIsSe auto surfaceFormatInfo = image->getSurfaceFormatInfo(); mockedImage mockImage(context, + 0, + 0, 0, 4096u, nullptr, @@ -916,7 +918,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, + const cl_image_format &imageFormat, const cl_image_desc &imageDesc) : Image(context, 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 1491410f80..b72d3be53e 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, alignUp(EnqueueFillBufferTraits::patternSize, 4), patternAllocation->getUnderlyingBuffer(), + MemObj patternMemObj(this->context, 0, 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 ea50d04a93..3b7e0a6bf6 100644 --- a/unit_tests/command_queue/multiple_map_buffer_tests.cpp +++ b/unit_tests/command_queue/multiple_map_buffer_tests.cpp @@ -90,7 +90,7 @@ struct MultipleMapBufferTest : public DeviceFixture, public ::testing::Test { template std::unique_ptr> createMockBuffer(bool mapOnGpu) { auto mockAlloc = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - auto buffer = new MockBuffer(context, 0, 1024, mockAlloc->getUnderlyingBuffer(), mockAlloc->getUnderlyingBuffer(), + auto buffer = new MockBuffer(context, 0, 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 88ce55a2d3..a82dd3b179 100644 --- a/unit_tests/command_queue/multiple_map_image_tests.cpp +++ b/unit_tests/command_queue/multiple_map_image_tests.cpp @@ -27,6 +27,8 @@ struct MultipleMapImageTest : public DeviceFixture, public ::testing::Test { static Image *createMockImage(Context *context, const MemoryProperties &properties, + uint64_t flags, + uint64_t flagsIntel, size_t size, void *hostPtr, const cl_image_format &imageFormat, @@ -38,7 +40,7 @@ struct MultipleMapImageTest : public DeviceFixture, public ::testing::Test { uint32_t mipCount, const SurfaceFormatInfo *surfaceFormatInfo, const SurfaceOffsets *surfaceOffsets) { - return new MockImage(context, properties, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation, + return new MockImage(context, properties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation, isObjectRedescribed, baseMipLevel, mipCount, *surfaceFormatInfo, surfaceOffsets); }; diff --git a/unit_tests/d3d_sharing/d3d9_tests.cpp b/unit_tests/d3d_sharing/d3d9_tests.cpp index 24552e2b98..de2940a9d4 100644 --- a/unit_tests/d3d_sharing/d3d9_tests.cpp +++ b/unit_tests/d3d_sharing/d3d9_tests.cpp @@ -189,7 +189,7 @@ TEST_F(D3D9Tests, createSurface) { auto image = castToObject(memObj); EXPECT_NE(nullptr, image->getSharingHandler()); - EXPECT_TRUE(CL_MEM_READ_WRITE == image->getFlags()); + EXPECT_TRUE(CL_MEM_READ_WRITE == image->getMemoryPropertiesFlags()); EXPECT_TRUE(expectedImgFormat.image_channel_data_type == image->getImageFormat().image_channel_data_type); EXPECT_TRUE(expectedImgFormat.image_channel_order == image->getImageFormat().image_channel_order); @@ -223,7 +223,7 @@ TEST_F(D3D9Tests, createSurfaceIntel) { auto image = castToObject(memObj); EXPECT_NE(nullptr, image->getSharingHandler()); - EXPECT_TRUE(CL_MEM_READ_WRITE == image->getFlags()); + EXPECT_TRUE(CL_MEM_READ_WRITE == image->getMemoryPropertiesFlags()); EXPECT_TRUE(expectedImgFormat.image_channel_data_type == image->getImageFormat().image_channel_data_type); EXPECT_TRUE(expectedImgFormat.image_channel_order == image->getImageFormat().image_channel_order); diff --git a/unit_tests/d3d_sharing/d3d_tests_part1.cpp b/unit_tests/d3d_sharing/d3d_tests_part1.cpp index d91b9ee28f..10650395e1 100644 --- a/unit_tests/d3d_sharing/d3d_tests_part1.cpp +++ b/unit_tests/d3d_sharing/d3d_tests_part1.cpp @@ -135,7 +135,7 @@ TYPED_TEST_P(D3DTests, createFromD3DBufferKHRApi) { auto bufferObj = static_cast *>(buffer->getSharingHandler().get()); EXPECT_EQ((D3DResource *)&this->dummyD3DBuffer, *bufferObj->getResourceHandler()); - EXPECT_TRUE(buffer->getFlags() == CL_MEM_READ_WRITE); + EXPECT_TRUE(buffer->getMemoryPropertiesFlags() == CL_MEM_READ_WRITE); clReleaseMemObject(memObj); } @@ -255,7 +255,7 @@ TYPED_TEST_P(D3DTests, createFromD3D2dTextureKHRApi) { auto textureObj = static_cast *>(image->getSharingHandler().get()); EXPECT_EQ((D3DResource *)&this->dummyD3DTexture, *textureObj->getResourceHandler()); - EXPECT_TRUE(image->getFlags() == CL_MEM_READ_WRITE); + EXPECT_TRUE(image->getMemoryPropertiesFlags() == CL_MEM_READ_WRITE); EXPECT_TRUE(image->getImageDesc().image_type == CL_MEM_OBJECT_IMAGE2D); EXPECT_EQ(1u, textureObj->getSubresource()); @@ -287,7 +287,7 @@ TYPED_TEST_P(D3DTests, createFromD3D3dTextureKHRApi) { auto textureObj = static_cast *>(image->getSharingHandler().get()); EXPECT_EQ((D3DResource *)&this->dummyD3DTexture, *textureObj->getResourceHandler()); - EXPECT_TRUE(image->getFlags() == CL_MEM_READ_WRITE); + EXPECT_TRUE(image->getMemoryPropertiesFlags() == CL_MEM_READ_WRITE); EXPECT_TRUE(image->getImageDesc().image_type == CL_MEM_OBJECT_IMAGE3D); EXPECT_EQ(1u, textureObj->getSubresource()); diff --git a/unit_tests/helpers/base_object_tests.cpp b/unit_tests/helpers/base_object_tests.cpp index d034abe488..4254a2a034 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, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) { + MockBuffer() : MockBufferStorage(), Buffer(nullptr, 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, 0u, nullptr, nullptr, nullptr, false, false, false) { + ObjectForTest() : MemObj(nullptr, 0, 0, 0, 0, 0u, nullptr, nullptr, nullptr, false, false, false) { } void convertToInternalObject(void) { diff --git a/unit_tests/mem_obj/buffer_set_arg_tests.cpp b/unit_tests/mem_obj/buffer_set_arg_tests.cpp index 8a5ee87056..4f239665d2 100644 --- a/unit_tests/mem_obj/buffer_set_arg_tests.cpp +++ b/unit_tests/mem_obj/buffer_set_arg_tests.cpp @@ -221,7 +221,7 @@ TEST_F(BufferSetArgTest, givenBufferWhenOffsetedSubbufferIsPassedToSetKernelArgT region.origin = 0xc0; region.size = 32; cl_int error = 0; - auto subBuffer = buffer->createSubBuffer(buffer->getFlags(), ®ion, error); + auto subBuffer = buffer->createSubBuffer(buffer->getMemoryPropertiesFlags(), ®ion, error); ASSERT_NE(nullptr, subBuffer); diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index fd47b7e785..6b0ef213ca 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -1238,6 +1238,8 @@ TEST_P(NoHostPtr, GivenNoHostPtrWhenHwBufferCreationFailsThenReturnNullptr) { bufferFactory[i].createBufferFunction = [](Context *, MemoryProperties, + cl_mem_flags, + cl_mem_flags_intel, size_t, void *, void *, diff --git a/unit_tests/mem_obj/image_redescribe_tests.cpp b/unit_tests/mem_obj/image_redescribe_tests.cpp index 2e57bca55e..d9d5cf1952 100644 --- a/unit_tests/mem_obj/image_redescribe_tests.cpp +++ b/unit_tests/mem_obj/image_redescribe_tests.cpp @@ -72,7 +72,7 @@ TEST_P(ImageRedescribeTest, givenImageWhenItIsRedescribedThenItContainsProperFor ASSERT_NE(nullptr, imageNew); ASSERT_NE(image, imageNew); - EXPECT_EQ(static_cast(CL_MEM_USE_HOST_PTR), imageNew->getFlags() & CL_MEM_USE_HOST_PTR); + EXPECT_EQ(static_cast(CL_MEM_USE_HOST_PTR), imageNew->getMemoryPropertiesFlags() & CL_MEM_USE_HOST_PTR); EXPECT_EQ(image->getCpuAddress(), imageNew->getCpuAddress()); EXPECT_NE(static_cast(CL_FLOAT), imageNew->getSurfaceFormatInfo().OCLImageFormat.image_channel_data_type); EXPECT_NE(static_cast(CL_HALF_FLOAT), imageNew->getSurfaceFormatInfo().OCLImageFormat.image_channel_data_type); diff --git a/unit_tests/mem_obj/image_tests.cpp b/unit_tests/mem_obj/image_tests.cpp index db6e46f46d..f7c22d099f 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, 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, 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 44b4d3b15b..aa6e92438d 100644 --- a/unit_tests/mem_obj/image_validate_tests.cpp +++ b/unit_tests/mem_obj/image_validate_tests.cpp @@ -669,7 +669,7 @@ TEST(validateAndCreateImage, givenInvalidImageFormatWhenValidateAndCreateImageIs Image *image; imageFormat.image_channel_order = 0; imageFormat.image_channel_data_type = 0; - image = Image::validateAndCreateImage(&context, 0, &imageFormat, &Image1dDefaults::imageDesc, nullptr, retVal); + image = Image::validateAndCreateImage(&context, 0, 0, 0, &imageFormat, &Image1dDefaults::imageDesc, nullptr, retVal); EXPECT_EQ(nullptr, image); EXPECT_EQ(CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, retVal); } @@ -679,7 +679,8 @@ TEST(validateAndCreateImage, givenNotSupportedImageFormatWhenValidateAndCreateIm cl_image_format imageFormat = {CL_INTENSITY, CL_UNORM_INT8}; cl_int retVal = CL_SUCCESS; Image *image; - image = Image::validateAndCreateImage(&context, CL_MEM_READ_WRITE, &imageFormat, &Image1dDefaults::imageDesc, nullptr, retVal); + cl_mem_flags flags = CL_MEM_READ_WRITE; + image = Image::validateAndCreateImage(&context, CL_MEM_READ_WRITE, flags, 0, &imageFormat, &Image1dDefaults::imageDesc, nullptr, retVal); EXPECT_EQ(nullptr, image); EXPECT_EQ(CL_IMAGE_FORMAT_NOT_SUPPORTED, retVal); } @@ -708,6 +709,8 @@ TEST(validateAndCreateImage, givenValidImageParamsWhenValidateAndCreateImageIsCa image.reset(Image::validateAndCreateImage( &context, flags, + flags, + 0, &imageFormat, &imageDesc, nullptr, @@ -757,7 +760,7 @@ struct NullImage : public Image { using Image::imageDesc; using Image::imageFormat; - NullImage() : Image(nullptr, cl_mem_flags{}, 0, nullptr, cl_image_format{}, + NullImage() : Image(nullptr, cl_mem_flags{}, 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 7c76a6ea20..32e85e761b 100644 --- a/unit_tests/mem_obj/mem_obj_destruction_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_destruction_tests.cpp @@ -38,7 +38,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, CL_MEM_READ_WRITE, 0, size, nullptr, nullptr, allocation, true, false, false); *device->getDefaultEngine().commandStreamReceiver->getTagAddress() = 0; @@ -215,7 +215,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, 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_helper_tests.cpp b/unit_tests/mem_obj/mem_obj_helper_tests.cpp index 0e7df2db9f..fe688edad0 100644 --- a/unit_tests/mem_obj/mem_obj_helper_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_helper_tests.cpp @@ -54,52 +54,65 @@ TEST(MemObjHelper, givenClMemForceLinearStorageFlagWhenCheckForLinearStorageForc TEST(MemObjHelper, givenValidPropertiesWhenValidatingMemoryPropertiesThenTrueIsReturned) { MemoryProperties properties; + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); cl_mem_flags flags = 0; cl_mem_flags_intel flags_intel = 0; - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr)); properties.flags = CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL | CL_MEM_NO_ACCESS_INTEL; - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); + memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); + flags = CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL | CL_MEM_NO_ACCESS_INTEL; + flags_intel = 0; + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr)); properties.flags = CL_MEM_NO_ACCESS_INTEL; - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); + memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); + flags = CL_MEM_NO_ACCESS_INTEL; + flags_intel = 0; + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr)); properties.flags = CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR | CL_MEM_HOST_NO_ACCESS; + memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); flags = CL_MEM_READ_WRITE | CL_MEM_ALLOC_HOST_PTR | CL_MEM_HOST_NO_ACCESS; flags_intel = 0; - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr)); properties.flags = CL_MEM_WRITE_ONLY | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_WRITE_ONLY; + memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); flags = CL_MEM_WRITE_ONLY | CL_MEM_COPY_HOST_PTR | CL_MEM_HOST_WRITE_ONLY; flags_intel = 0; - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr)); properties.flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS; + memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); flags = CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR | CL_MEM_HOST_NO_ACCESS; flags_intel = 0; - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr)); properties.flags_intel = CL_MEM_LOCALLY_UNCACHED_RESOURCE; + memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); flags = 0; flags_intel = CL_MEM_LOCALLY_UNCACHED_RESOURCE; - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr)); properties.flags_intel = CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE; + memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); flags = 0; flags_intel = CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE; - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr)); properties.flags = 0; + memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); flags = 0; flags_intel = 0; - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(properties, flags, flags_intel)); - EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(properties, nullptr)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForBuffer(memoryProperties, flags, flags_intel)); + EXPECT_TRUE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, flags_intel, nullptr)); } struct Image1dWithAccessFlagsUnrestricted : public Image1dDefaults { @@ -108,19 +121,26 @@ struct Image1dWithAccessFlagsUnrestricted : public Image1dDefaults { TEST(MemObjHelper, givenParentMemObjAndHostPtrFlagsWhenValidatingMemoryPropertiesForImageThenFalseIsReturned) { MemoryProperties properties; + MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); + MockContext context; auto image = clUniquePtr(Image1dHelper<>::create(&context)); auto imageWithAccessFlagsUnrestricted = clUniquePtr(ImageHelper::create(&context)); cl_mem_flags hostPtrFlags[] = {CL_MEM_USE_HOST_PTR, CL_MEM_ALLOC_HOST_PTR, CL_MEM_COPY_HOST_PTR}; + cl_mem_flags flags = 0; for (auto hostPtrFlag : hostPtrFlags) { properties.flags = hostPtrFlag; - EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get())); - EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, imageWithAccessFlagsUnrestricted.get())); + memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); + flags = hostPtrFlag; + EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, 0, image.get())); + EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, 0, imageWithAccessFlagsUnrestricted.get())); properties.flags |= CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL; - EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, image.get())); - EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(properties, imageWithAccessFlagsUnrestricted.get())); + memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(properties); + flags |= CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL; + EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, 0, image.get())); + EXPECT_FALSE(MemObjHelper::validateMemoryPropertiesForImage(memoryProperties, flags, 0, imageWithAccessFlagsUnrestricted.get())); } } diff --git a/unit_tests/mem_obj/mem_obj_tests.cpp b/unit_tests/mem_obj/mem_obj_tests.cpp index e764c0f8b7..a57fdeb938 100644 --- a/unit_tests/mem_obj/mem_obj_tests.cpp +++ b/unit_tests/mem_obj/mem_obj_tests.cpp @@ -61,13 +61,13 @@ TEST(MemObj, GivenMemObjWhenInititalizedFromHostPtrThenInitializeFields) { MockContext context; MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer)); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(buffer), buffer, buffer, mockAllocation, true, false, false); EXPECT_EQ(&buffer, memObj.getCpuAddress()); EXPECT_EQ(&buffer, memObj.getHostPtr()); EXPECT_EQ(size, memObj.getSize()); - EXPECT_EQ(static_cast(CL_MEM_USE_HOST_PTR), memObj.getFlags()); + EXPECT_EQ(static_cast(CL_MEM_USE_HOST_PTR), memObj.getMemoryPropertiesFlags()); } TEST(MemObj, givenMemObjectWhenAskedForTransferToHostPtrThenDoNothing) { @@ -76,7 +76,7 @@ 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, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, size, hostPtr, hostPtr, mockAllocation, true, false, false); memset(memObj.getCpuAddress(), 123, size); @@ -95,7 +95,7 @@ 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, + MemObj memObj(&context, CL_MEM_OBJECT_PIPE, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, size, hostPtr, hostPtr, mockAllocation, true, false, false); memset(memObj.getCpuAddress(), 123, size); @@ -112,7 +112,7 @@ TEST(MemObj, givenHostPtrAndUseHostPtrFlagWhenAskingForBaseMapPtrThenReturnHostP uint8_t hostPtr = 0; MockContext context; - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, &hostPtr, nullptr, true, false, false); EXPECT_EQ(&hostPtr, memObj.getBasePtrForMap()); @@ -122,7 +122,7 @@ TEST(MemObj, givenHostPtrWithoutUseHostPtrFlagWhenAskingForBaseMapPtrThenReturnA uint8_t hostPtr = 0; MockContext context; - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, 1, nullptr, &hostPtr, nullptr, true, false, false); EXPECT_NE(&hostPtr, memObj.getBasePtrForMap()); @@ -134,7 +134,7 @@ TEST(MemObj, givenMemObjWhenReleaseAllocatedPtrIsCalledTwiceThenItDoesntCrash) { MockContext context; - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, nullptr, true, false, false); memObj.setAllocatedMapPtr(allocatedPtr); @@ -152,7 +152,7 @@ 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, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, 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 +170,7 @@ 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, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); auto &allocationList = device->getDefaultEngine().commandStreamReceiver->getTemporaryAllocations(); @@ -187,7 +187,7 @@ TEST(MemObj, givenNotUsedGraphicsAllocationWhenMemObjDestroysAllocationAsyncThen context.setMemoryManager(&memoryManager); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); auto &allocationList = memoryManager.getDefaultCommandStreamReceiver(0)->getTemporaryAllocations(); @@ -205,7 +205,7 @@ TEST(MemObj, givenMemoryManagerWithoutDeviceWhenMemObjDestroysAllocationAsyncThe auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); auto &allocationList = memoryManager.getDefaultCommandStreamReceiver(0)->getTemporaryAllocations(); @@ -221,7 +221,7 @@ TEST(MemObj, givenMemObjAndPointerToObjStorageWithProperCommandWhenCheckIfMemTra context.setMemoryManager(&memoryManager); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, 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); @@ -248,7 +248,7 @@ TEST(MemObj, givenMemObjAndPointerToObjStorageBadCommandWhenCheckIfMemTransferRe context.setMemoryManager(&memoryManager); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, 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); @@ -260,7 +260,7 @@ TEST(MemObj, givenMemObjAndPointerToDiffrentStorageAndProperCommandWhenCheckIfMe context.setMemoryManager(&memoryManager); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, 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); @@ -272,7 +272,7 @@ TEST(MemObj, givenSharingHandlerWhenAskedForCpuMappingThenReturnFalse) { 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, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, allocation, true, false, false); memObj.setSharingHandler(new SharingHandler()); EXPECT_FALSE(memObj.mappingOnCpuAllowed()); @@ -283,7 +283,7 @@ TEST(MemObj, givenTiledObjectWhenAskedForCpuMappingThenReturnFalse) { using MemObj::MemObj; bool isTiledAllocation() const override { return true; } }; - MyMemObj memObj(nullptr, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, + MyMemObj memObj(nullptr, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, MemoryConstants::pageSize, nullptr, nullptr, nullptr, true, false, false); EXPECT_FALSE(memObj.mappingOnCpuAllowed()); @@ -298,7 +298,7 @@ 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, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0, 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); allocation->getDefaultGmm()->isRenderCompressed = false; @@ -315,7 +315,7 @@ TEST(MemObj, givenDefaultWhenAskedForCpuMappingThenReturnTrue) { auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR, CL_MEM_COPY_HOST_PTR, 0, 64, allocation->getUnderlyingBuffer(), nullptr, allocation, true, false, false); EXPECT_FALSE(memObj.isTiledAllocation()); @@ -332,7 +332,7 @@ 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, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, CL_MEM_READ_WRITE, 0, 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); EXPECT_TRUE(memObj.mappingOnCpuAllowed()); @@ -347,13 +347,13 @@ TEST(MemObj, givenMultipleMemObjectsWithReusedGraphicsAllocationWhenDestroyedThe auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - std::unique_ptr memObj1(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 1, nullptr, nullptr, allocation, true, false, false)); + std::unique_ptr memObj1(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 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, 1, nullptr, nullptr, allocation, true, false, false)); + std::unique_ptr memObj2(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 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, 1, nullptr, nullptr, allocation, true, false, false)); + std::unique_ptr memObj3(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 0, 0, 1, nullptr, nullptr, allocation, true, false, false)); memObj3->setSharingHandler(new MySharingHandler(allocation)); EXPECT_EQ(3u, allocation->peekReuseCount()); @@ -370,7 +370,7 @@ TEST(MemObj, givenMemObjectWhenContextIsNotNullThenContextOutlivesMemobjects) { MockContext context; EXPECT_EQ(1, context.getRefInternalCount()); { - MemObj memObj(&context, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false); + MemObj memObj(&context, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, false, false, false); EXPECT_EQ(2, context.getRefInternalCount()); } EXPECT_EQ(1, context.getRefInternalCount()); @@ -382,7 +382,7 @@ TEST(MemObj, givenSharedMemObjectWithNullGfxAllocationWhenSettingGfxAllocationTh context.setMemoryManager(&memoryManager); MockGraphicsAllocation *gfxAllocation = new MockGraphicsAllocation(nullptr, 0); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, nullptr, true, false, false); memObj.setSharingHandler(new MySharingHandler(&memObj)); @@ -399,7 +399,7 @@ TEST(MemObj, givenSharedMemObjectAndNullGfxAllocationProvidedWhenSettingGfxAlloc context.setMemoryManager(&memoryManager); MockGraphicsAllocation *graphicsAllocation = new MockGraphicsAllocation(nullptr, 0); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, graphicsAllocation, true, false, false); memObj.setSharingHandler(new MySharingHandler(&memObj)); @@ -416,7 +416,7 @@ TEST(MemObj, givenSharedMemObjectAndZeroReuseCountWhenChangingGfxAllocationThenO MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, oldGfxAllocation, true, false, false); memObj.setSharingHandler(new MySharingHandler(&memObj)); @@ -435,7 +435,7 @@ TEST(MemObj, givenSharedMemObjectAndNonZeroReuseCountWhenChangingGfxAllocationTh MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, oldGfxAllocation, true, false, false); memObj.setSharingHandler(new MySharingHandler(&memObj)); @@ -454,7 +454,7 @@ TEST(MemObj, givenNotSharedMemObjectWhenChangingGfxAllocationThenOldAllocationIs MockGraphicsAllocation *oldGfxAllocation = new MockGraphicsAllocation(nullptr, 0); MockGraphicsAllocation *newGfxAllocation = new MockGraphicsAllocation(nullptr, 0); - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, oldGfxAllocation, true, false, false); memObj.resetGraphicsAllocation(newGfxAllocation); @@ -472,7 +472,7 @@ TEST(MemObj, givenGraphicsAllocationWhenCallingIsAllocDumpableThenItReturnsTheCo TEST(MemObj, givenMemObjNotUsingHostPtrWhenGettingBasePtrTwiceReturnSameMapPtr) { MockContext context; - MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE, 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 979b26f290..c5f1b98320 100644 --- a/unit_tests/mocks/mock_buffer.h +++ b/unit_tests/mocks/mock_buffer.h @@ -33,10 +33,10 @@ class MockBuffer : public MockBufferStorage, public Buffer { using MockBufferStorage::device; MockBuffer(GraphicsAllocation &alloc) - : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, alloc.getUnderlyingBufferSize(), alloc.getUnderlyingBuffer(), alloc.getUnderlyingBuffer(), &alloc, true, false, false), + : MockBufferStorage(), Buffer(nullptr, 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, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) { + MockBuffer() : MockBufferStorage(), Buffer(nullptr, 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 +54,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, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), &mockGfxAllocation, true, false, false) { + 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(GraphicsAllocation *gfxAllocation) : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), gfxAllocation, 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) { } void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override { Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation); @@ -66,9 +66,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, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), &mockGfxAllocation, false, false, false) { + 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(GraphicsAllocation *gfxAllocation) : MockBufferStorage(true), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), gfxAllocation, 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) { } 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 becc1931ab..af36827b82 100644 --- a/unit_tests/mocks/mock_image.h +++ b/unit_tests/mocks/mock_image.h @@ -14,9 +14,10 @@ struct MockImageBase : public NEO::Image { using Image::graphicsAllocation; using Image::imageDesc; - MockImageBase() : Image(nullptr, cl_mem_flags{}, 0, nullptr, cl_image_format{}, - cl_image_desc{}, false, new NEO::MockGraphicsAllocation(nullptr, 0), false, - 0, 0, NEO::SurfaceFormatInfo{}, nullptr) { + MockImageBase() : Image( + nullptr, cl_mem_flags{}, cl_mem_flags{}, 0, 0, nullptr, cl_image_format{}, + cl_image_desc{}, false, new NEO::MockGraphicsAllocation(nullptr, 0), false, + 0, 0, NEO::SurfaceFormatInfo{}, nullptr) { } ~MockImageBase() override { delete this->graphicsAllocation; 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 e1b64627d1..c318ba00b6 100644 --- a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp +++ b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp @@ -1330,7 +1330,7 @@ class DrmMockBuffer : public Buffer { delete gfxAllocation; } - DrmMockBuffer(char *data, size_t size, DrmAllocation *alloc) : Buffer(nullptr, CL_MEM_USE_HOST_PTR, size, data, data, alloc, true, false, false), + 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), data(data), gfxAllocation(alloc) { } diff --git a/unit_tests/sharings/gl/gl_sharing_tests.cpp b/unit_tests/sharings/gl/gl_sharing_tests.cpp index 273cd36948..a9d27254b2 100644 --- a/unit_tests/sharings/gl/gl_sharing_tests.cpp +++ b/unit_tests/sharings/gl/gl_sharing_tests.cpp @@ -80,7 +80,7 @@ TEST_F(glSharingTests, givenMockGlWhenGlBufferIsCreatedThenMemObjectHasGlHandler EXPECT_EQ(bufferId, mockGlSharing->dllParam->getBufferInfo().bufferName); EXPECT_EQ(4096u, glBuffer->getSize()); size_t flagsExpected = CL_MEM_READ_WRITE; - EXPECT_EQ(flagsExpected, glBuffer->getFlags()); + EXPECT_EQ(flagsExpected, glBuffer->getMemoryPropertiesFlags()); auto handler = glBuffer->peekSharingHandler(); ASSERT_NE(nullptr, handler); diff --git a/unit_tests/sharings/sharing_tests.cpp b/unit_tests/sharings/sharing_tests.cpp index 104d69c443..16386d6fbc 100644 --- a/unit_tests/sharings/sharing_tests.cpp +++ b/unit_tests/sharings/sharing_tests.cpp @@ -36,7 +36,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, + std::unique_ptr memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(buffer), buffer, buffer, mockAllocation, true, false, false)); struct MockSharingHandler : SharingHandler { @@ -61,7 +61,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, + std::unique_ptr memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, sizeof(buffer), buffer, buffer, mockAllocation, true, false, false)); struct MockSharingHandler : SharingHandler { @@ -106,7 +106,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, + MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR, CL_MEM_USE_HOST_PTR, 0, 1, nullptr, nullptr, graphicsAllocation, true, false, false); auto result = sharingHandler.acquire(&memObj); diff --git a/unit_tests/sharings/va/va_sharing_tests.cpp b/unit_tests/sharings/va/va_sharing_tests.cpp index ba6d2a2271..8686e4bc92 100644 --- a/unit_tests/sharings/va/va_sharing_tests.cpp +++ b/unit_tests/sharings/va/va_sharing_tests.cpp @@ -398,7 +398,7 @@ TEST_F(VaSharingTests, givenSimpleParamsWhenCreateSurfaceIsCalledThenSetImgObjec EXPECT_NE(0u, sharedImg->getImageDesc().image_row_pitch); EXPECT_EQ(0u, sharedImg->getHostPtrSlicePitch()); EXPECT_NE(0u, sharedImg->getHostPtrRowPitch()); - EXPECT_TRUE(sharedImg->getFlags() == CL_MEM_READ_WRITE); + EXPECT_TRUE(sharedImg->getMemoryPropertiesFlags() == CL_MEM_READ_WRITE); EXPECT_TRUE(sharedImg->getCubeFaceIndex() == __GMM_NO_CUBE_MAP); EXPECT_EQ(vaSharing->sharingHandle, sharedImg->getGraphicsAllocation()->peekSharedHandle());