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 <krzysztof.gibala@intel.com>
This commit is contained in:
Gibala
2019-09-24 16:05:17 +02:00
committed by sys_ocldev
parent fc652b2822
commit 2f9bfc7748
38 changed files with 233 additions and 158 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -54,7 +54,7 @@ cl_int CommandQueueHw<GfxFamily>::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;

View File

@@ -469,7 +469,7 @@ cl_int CommandQueueHw<GfxFamily>::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);

View File

@@ -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;

View File

@@ -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<MemoryConstants::cacheLineSize>(bufferAddress) &&
isAligned<MemoryConstants::cacheLineSize>(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;

View File

@@ -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<GfxFamily>(context,
properties,
flags,
flagsIntel,
size,
memoryStorage,
hostPtr,

View File

@@ -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<uint64_t>(parentBuffer->getHostPtr()) % (*baseAddressAlignment))) ||
((parentBuffer->getMemoryPropertiesFlags() & CL_MEM_USE_HOST_PTR) && (reinterpret_cast<uint64_t>(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;
}

View File

@@ -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<GfxFamily>(context,
properties,
flags,
flagsIntel,
size,
hostPtr,
imageFormat,

View File

@@ -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<MemObj> memObjOwnership(*this);

View File

@@ -14,6 +14,7 @@
#include "runtime/sharings/sharing.h"
#include "mem_obj_types.h"
#include "memory_properties_flags.h"
#include <atomic>
#include <cstdint>
@@ -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 &paramName, 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;

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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<MemObj>(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) {

View File

@@ -25,6 +25,8 @@ Pipe::Pipe(Context *context,
: MemObj(context,
CL_MEM_OBJECT_PIPE,
flags,
flags,
0,
static_cast<size_t>(packetSize * (maxPackets + 1) + intelPipeHeaderReservedSpace),
memoryStorage,
nullptr,

View File

@@ -234,7 +234,7 @@ void DebugSettingsManager<DebugLevel>::dumpKernelArgs(const Kernel *kernel) {
if (memObj != nullptr) {
ptr = static_cast<char *>(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<DebugLevel>::dumpKernelArgs(const Kernel *kernel) {
if (memObj != nullptr) {
ptr = static_cast<char *>(memObj->getCpuAddress());
size = memObj->getSize();
flags = memObj->getFlags();
flags = memObj->getMemoryPropertiesFlags();
}
} else {
type = "immediate";

View File

@@ -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;

View File

@@ -194,6 +194,8 @@ HWTEST_F(EnqueueMapImageTest, givenTiledImageWhenMapImageIsCalledThenStorageIsSe
auto surfaceFormatInfo = image->getSurfaceFormatInfo();
mockedImage<FamilyType> 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,

View File

@@ -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;

View File

@@ -90,7 +90,7 @@ struct MultipleMapBufferTest : public DeviceFixture, public ::testing::Test {
template <typename FamilyType>
std::unique_ptr<MockBuffer<FamilyType>> createMockBuffer(bool mapOnGpu) {
auto mockAlloc = pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
auto buffer = new MockBuffer<FamilyType>(context, 0, 1024, mockAlloc->getUnderlyingBuffer(), mockAlloc->getUnderlyingBuffer(),
auto buffer = new MockBuffer<FamilyType>(context, 0, 0, 0, 1024, mockAlloc->getUnderlyingBuffer(), mockAlloc->getUnderlyingBuffer(),
mockAlloc, false, false, false);
if (mapOnGpu) {
buffer->setSharingHandler(new SharingHandler());

View File

@@ -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<T>(context, properties, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation,
return new MockImage<T>(context, properties, flags, flagsIntel, size, hostPtr, imageFormat, imageDesc, zeroCopy, graphicsAllocation,
isObjectRedescribed, baseMipLevel, mipCount, *surfaceFormatInfo, surfaceOffsets);
};

View File

@@ -189,7 +189,7 @@ TEST_F(D3D9Tests, createSurface) {
auto image = castToObject<Image>(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<Image>(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);

View File

@@ -135,7 +135,7 @@ TYPED_TEST_P(D3DTests, createFromD3DBufferKHRApi) {
auto bufferObj = static_cast<D3DBuffer<TypeParam> *>(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<D3DTexture<TypeParam> *>(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<D3DTexture<TypeParam> *>(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());

View File

@@ -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) {

View File

@@ -221,7 +221,7 @@ TEST_F(BufferSetArgTest, givenBufferWhenOffsetedSubbufferIsPassedToSetKernelArgT
region.origin = 0xc0;
region.size = 32;
cl_int error = 0;
auto subBuffer = buffer->createSubBuffer(buffer->getFlags(), &region, error);
auto subBuffer = buffer->createSubBuffer(buffer->getMemoryPropertiesFlags(), &region, error);
ASSERT_NE(nullptr, subBuffer);

View File

@@ -1238,6 +1238,8 @@ TEST_P(NoHostPtr, GivenNoHostPtrWhenHwBufferCreationFailsThenReturnNullptr) {
bufferFactory[i].createBufferFunction =
[](Context *,
MemoryProperties,
cl_mem_flags,
cl_mem_flags_intel,
size_t,
void *,
void *,

View File

@@ -72,7 +72,7 @@ TEST_P(ImageRedescribeTest, givenImageWhenItIsRedescribedThenItContainsProperFor
ASSERT_NE(nullptr, imageNew);
ASSERT_NE(image, imageNew);
EXPECT_EQ(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), imageNew->getFlags() & CL_MEM_USE_HOST_PTR);
EXPECT_EQ(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), imageNew->getMemoryPropertiesFlags() & CL_MEM_USE_HOST_PTR);
EXPECT_EQ(image->getCpuAddress(), imageNew->getCpuAddress());
EXPECT_NE(static_cast<cl_channel_type>(CL_FLOAT), imageNew->getSurfaceFormatInfo().OCLImageFormat.image_channel_data_type);
EXPECT_NE(static_cast<cl_channel_type>(CL_HALF_FLOAT), imageNew->getSurfaceFormatInfo().OCLImageFormat.image_channel_data_type);

View File

@@ -1463,7 +1463,7 @@ HWTEST_F(ImageTransformTest, givenSurfaceBaseAddressAndUnifiedSurfaceWhenSetUnif
template <typename FamilyName>
class MockImageHw : public ImageHw<FamilyName> {
public:
MockImageHw(Context *context, const cl_image_format &format, const cl_image_desc &desc, SurfaceFormatInfo &surfaceFormatInfo, GraphicsAllocation *graphicsAllocation) : ImageHw<FamilyName>(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<FamilyName>(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;

View File

@@ -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) {
}

View File

@@ -38,7 +38,7 @@ class MemObjDestructionTest : public ::testing::TestWithParam<bool> {
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);

View File

@@ -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<Image1dWithAccessFlagsUnrestricted>::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()));
}
}

View File

@@ -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_flags>(CL_MEM_USE_HOST_PTR), memObj.getFlags());
EXPECT_EQ(static_cast<cl_mem_flags>(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<MemObj> memObj1(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 1, nullptr, nullptr, allocation, true, false, false));
std::unique_ptr<MemObj> 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<MemObj> memObj2(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 1, nullptr, nullptr, allocation, true, false, false));
std::unique_ptr<MemObj> 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<MemObj> memObj3(new MemObj(&context, CL_MEM_OBJECT_BUFFER, 0, 1, nullptr, nullptr, allocation, true, false, false));
std::unique_ptr<MemObj> 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();

View File

@@ -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);

View File

@@ -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;

View File

@@ -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) {
}

View File

@@ -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);

View File

@@ -36,7 +36,7 @@ TEST(sharingHandler, givenMemObjWhenAcquireIncrementCounterThenReleaseShouldDecr
char buffer[64];
MockContext context;
MockGraphicsAllocation *mockAllocation = new MockGraphicsAllocation(buffer, sizeof(buffer));
std::unique_ptr<MemObj> memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR,
std::unique_ptr<MemObj> 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> memObj(new MemObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_USE_HOST_PTR,
std::unique_ptr<MemObj> 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);

View File

@@ -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());