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