Revert "Move storage of mapped operations to OpenCL context"

This reverts commit 8c9dd3085b.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation
2021-10-19 15:25:35 +02:00
committed by Compute-Runtime-Automation
parent e199097acd
commit 116dac90de
13 changed files with 82 additions and 227 deletions

View File

@@ -16,7 +16,6 @@
#include "opencl/source/gtpin/gtpin_notify.h"
#include "opencl/source/helpers/base_object.h"
#include "opencl/source/helpers/destructor_callbacks.h"
#include "opencl/source/mem_obj/map_operations_handler.h"
#include <list>
#include <map>
@@ -94,8 +93,6 @@ class Context : public BaseObject<_cl_context> {
return svmAllocsManager;
}
auto &getMapOperationsStorage() { return mapOperationsStorage; }
const std::set<uint32_t> &getRootDeviceIndices() const;
uint32_t getMaxRootDeviceIndex() const;
@@ -202,7 +199,6 @@ class Context : public BaseObject<_cl_context> {
void *userData = nullptr;
MemoryManager *memoryManager = nullptr;
SVMAllocsManager *svmAllocsManager = nullptr;
MapOperationsStorage mapOperationsStorage = {};
StackVec<CommandQueue *, 1> specialQueues;
DeviceQueue *defaultDeviceQueue = nullptr;
DriverDiagnostics *driverDiagnostics = nullptr;

View File

@@ -72,21 +72,3 @@ void MapOperationsHandler::remove(void *mappedPtr) {
}
}
}
MapOperationsHandler &NEO::MapOperationsStorage::getHandler(cl_mem memObj) {
return handlers[memObj];
}
MapOperationsHandler *NEO::MapOperationsStorage::getHandlerIfExists(cl_mem memObj) {
auto iterator = handlers.find(memObj);
if (iterator == handlers.end()) {
return nullptr;
}
return &iterator->second;
}
void NEO::MapOperationsStorage::removeHandler(cl_mem memObj) {
auto iterator = handlers.find(memObj);
handlers.erase(iterator);
}

View File

@@ -9,7 +9,6 @@
#include "opencl/source/helpers/properties_helper.h"
#include <mutex>
#include <unordered_map>
#include <vector>
namespace NEO {
@@ -29,16 +28,4 @@ class MapOperationsHandler {
mutable std::mutex mtx;
};
class MapOperationsStorage {
public:
using HandlersMap = std::unordered_map<cl_mem, MapOperationsHandler>;
MapOperationsHandler &getHandler(cl_mem memObj);
MapOperationsHandler *getHandlerIfExists(cl_mem memObj);
void removeHandler(cl_mem memObj);
protected:
HandlersMap handlers{};
};
} // namespace NEO

View File

@@ -62,14 +62,9 @@ MemObj::~MemObj() {
if (allocatedMapPtr != nullptr) {
needWait = true;
}
if (auto mapOperationsHandler = getMapOperationsHandlerIfExists(); mapOperationsHandler != nullptr) {
if (mapOperationsHandler->size() > 0 && !getCpuAddressForMapping()) {
needWait = true;
}
context->getMapOperationsStorage().removeHandler(this);
if (mapOperationsHandler.size() > 0 && !getCpuAddressForMapping()) {
needWait = true;
}
if (!destructorCallbacks.empty()) {
needWait = true;
}
@@ -177,7 +172,7 @@ cl_int MemObj::getMemObjectInfo(cl_mem_info paramName,
case CL_MEM_MAP_COUNT:
srcParamSize = sizeof(mapCount);
mapCount = static_cast<cl_uint>(getMapOperationsHandler().size());
mapCount = static_cast<cl_uint>(mapOperationsHandler.size());
srcParam = &mapCount;
break;
@@ -387,26 +382,11 @@ void *MemObj::getBasePtrForMap(uint32_t rootDeviceIndex) {
}
}
MapOperationsHandler &MemObj::getMapOperationsHandler() {
return context->getMapOperationsStorage().getHandler(this);
}
MapOperationsHandler *MemObj::getMapOperationsHandlerIfExists() {
return context->getMapOperationsStorage().getHandlerIfExists(this);
}
bool MemObj::addMappedPtr(void *ptr, size_t ptrLength, cl_map_flags &mapFlags,
MemObjSizeArray &size, MemObjOffsetArray &offset,
uint32_t mipLevel) {
return getMapOperationsHandler().add(ptr, ptrLength, mapFlags, size, offset, mipLevel);
}
bool MemObj::findMappedPtr(void *mappedPtr, MapInfo &outMapInfo) {
return getMapOperationsHandler().find(mappedPtr, outMapInfo);
}
void MemObj::removeMappedPtr(void *mappedPtr) {
getMapOperationsHandler().remove(mappedPtr);
return mapOperationsHandler.add(ptr, ptrLength, mapFlags, size, offset,
mipLevel);
}
bool MemObj::isTiledAllocation() const {

View File

@@ -86,11 +86,9 @@ class MemObj : public BaseObject<_cl_mem> {
bool getIsObjectRedescribed() const { return isObjectRedescribed; };
size_t getSize() const;
MapOperationsHandler &getMapOperationsHandler();
MapOperationsHandler *getMapOperationsHandlerIfExists();
bool addMappedPtr(void *ptr, size_t ptrLength, cl_map_flags &mapFlags, MemObjSizeArray &size, MemObjOffsetArray &offset, uint32_t mipLevel);
bool findMappedPtr(void *mappedPtr, MapInfo &outMapInfo);
void removeMappedPtr(void *mappedPtr);
bool findMappedPtr(void *mappedPtr, MapInfo &outMapInfo) { return mapOperationsHandler.find(mappedPtr, outMapInfo); }
void removeMappedPtr(void *mappedPtr) { mapOperationsHandler.remove(mappedPtr); }
void *getBasePtrForMap(uint32_t rootDeviceIndex);
MOCKABLE_VIRTUAL void setAllocatedMapPtr(void *allocatedMapPtr);
@@ -175,6 +173,7 @@ class MemObj : public BaseObject<_cl_mem> {
void *memoryStorage;
void *hostPtr;
void *allocatedMapPtr = nullptr;
MapOperationsHandler mapOperationsHandler;
size_t offset = 0;
MemObj *associatedMemObject = nullptr;
cl_uint refCount = 0;

View File

@@ -89,9 +89,7 @@ TEST_F(clEnqueueUnmapMemObjTests, givenInvalidAddressWhenUnmappingOnGpuThenRetur
}
TEST_F(clEnqueueUnmapMemObjTests, GivenInvalidMemObjectTypeWhenUnmappingImageThenInvalidMemObjectIsReturned) {
MockContext context{};
MockGraphicsAllocation allocation{};
MockBuffer buffer{&context, allocation};
MockBuffer buffer{};
cl_int retVal = CL_SUCCESS;
auto mappedPtr = clEnqueueMapBuffer(pCommandQueue, &buffer, CL_TRUE, CL_MAP_READ, 0, 1, 0, nullptr, nullptr, &retVal);

View File

@@ -59,7 +59,7 @@ struct EnqueueWaitlistTest : public EnqueueWaitlistFixture,
void SetUp() override {
EnqueueWaitlistFixture::SetUp();
buffer = BufferHelper<>::create();
bufferNonZeroCopy = new UnalignedBuffer(BufferDefaults::context, &bufferNonZeroCopyAlloc);
bufferNonZeroCopy = new UnalignedBuffer;
image = Image1dHelper<>::create(BufferDefaults::context);
imageNonZeroCopy = ImageHelper<ImageUseHostPtr<Image1dDefaults>>::create(BufferDefaults::context);
}
@@ -75,7 +75,6 @@ struct EnqueueWaitlistTest : public EnqueueWaitlistFixture,
cl_int retVal = CL_SUCCESS;
cl_int error = CL_SUCCESS;
MockGraphicsAllocation bufferNonZeroCopyAlloc{nullptr, MemoryConstants::pageSize};
Buffer *buffer;
Buffer *bufferNonZeroCopy;
Image *image;

View File

@@ -20,6 +20,8 @@ using namespace NEO;
struct MultipleMapBufferTest : public ClDeviceFixture, public ::testing::Test {
template <typename T>
struct MockBuffer : public BufferHw<T> {
using Buffer::mapOperationsHandler;
template <class... Params>
MockBuffer(Params... params) : BufferHw<T>(params...) {
this->createFunction = BufferHw<T>::create;
@@ -133,13 +135,13 @@ HWTEST_F(MultipleMapBufferTest, givenValidReadAndWriteBufferWhenMappedOnGpuThenA
size_t size = 3;
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_WRITE, offset, size, 0, nullptr, nullptr, nullptr);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->readBufferCalled, 1u);
EXPECT_EQ(cmdQ->enqueueSize, size);
EXPECT_EQ(cmdQ->enqueueOffset, offset);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->writeBufferCalled, 1u);
EXPECT_EQ(cmdQ->enqueueSize, size);
EXPECT_EQ(cmdQ->enqueueOffset, offset);
@@ -155,11 +157,11 @@ HWTEST_F(MultipleMapBufferTest, givenReadOnlyMapWhenUnmappedOnGpuThenEnqueueMark
size_t size = 3;
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_READ, offset, size, 0, nullptr, nullptr, nullptr);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->readBufferCalled, 1u);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->writeBufferCalled, 0u);
EXPECT_EQ(cmdQ->enqueueMarkerCalled, 1u);
}
@@ -173,12 +175,12 @@ HWTEST_F(MultipleMapBufferTest, givenWriteInvalidateMapWhenMappedOnGpuThenCallEn
size_t size = 3;
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_WRITE_INVALIDATE_REGION, offset, size, 0, nullptr, nullptr, nullptr);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->readBufferCalled, 0u);
EXPECT_EQ(cmdQ->enqueueMarkerCalled, 1u);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->writeBufferCalled, 1u);
EXPECT_EQ(cmdQ->enqueueMarkerCalled, 1u);
}
@@ -188,7 +190,7 @@ HWTEST_F(MultipleMapBufferTest, givenNotMappedPtrWhenUnmapedOnGpuThenReturnError
auto cmdQ = createMockCmdQ<FamilyType>();
EXPECT_FALSE(buffer->mappingOnCpuAllowed());
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
retVal = clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), buffer->getBasePtrForMap(cmdQ->getDevice().getRootDeviceIndex()), 0, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
}
@@ -204,7 +206,7 @@ HWTEST_F(MultipleMapBufferTest, givenErrorFromReadBufferWhenMappedOnGpuThenDontA
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_READ, offset, size, 0, nullptr, nullptr, &retVal);
EXPECT_EQ(nullptr, mappedPtr);
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
}
HWTEST_F(MultipleMapBufferTest, givenErrorFromWriteBufferWhenUnmappedOnGpuThenDontRemoveMappedPtr) {
@@ -217,12 +219,12 @@ HWTEST_F(MultipleMapBufferTest, givenErrorFromWriteBufferWhenUnmappedOnGpuThenDo
size_t size = 3;
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_WRITE, offset, size, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
retVal = clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(1u, cmdQ->writeBufferCalled);
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
}
HWTEST_F(MultipleMapBufferTest, givenUnblockedQueueWhenMappedOnCpuThenAddMappedPtrAndRemoveOnUnmap) {
@@ -234,13 +236,13 @@ HWTEST_F(MultipleMapBufferTest, givenUnblockedQueueWhenMappedOnCpuThenAddMappedP
size_t size = 3;
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_WRITE, offset, size, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
EXPECT_EQ(1u, buffer->transferToHostPtrCalled);
EXPECT_EQ(buffer->copySize, size);
EXPECT_EQ(buffer->copyOffset, offset);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
EXPECT_EQ(1u, buffer->transferFromHostPtrCalled);
EXPECT_EQ(buffer->copySize, size);
EXPECT_EQ(buffer->copyOffset, offset);
@@ -255,11 +257,11 @@ HWTEST_F(MultipleMapBufferTest, givenUnblockedQueueWhenReadOnlyMappedOnCpuThenDo
size_t size = 3;
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_READ, offset, size, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
EXPECT_EQ(1u, buffer->transferToHostPtrCalled);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
EXPECT_EQ(0u, buffer->transferFromHostPtrCalled);
}
@@ -272,11 +274,11 @@ HWTEST_F(MultipleMapBufferTest, givenUnblockedQueueWhenWriteInvalidateMappedOnCp
size_t size = 3;
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_WRITE_INVALIDATE_REGION, offset, size, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
EXPECT_EQ(0u, buffer->transferToHostPtrCalled);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
EXPECT_EQ(1u, buffer->transferFromHostPtrCalled);
}
@@ -294,14 +296,14 @@ HWTEST_F(MultipleMapBufferTest, givenBlockedQueueWhenMappedOnCpuThenAddMappedPtr
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_WRITE, offset, size, 1, &clMapEvent, nullptr, &retVal);
mapEvent.setStatus(CL_COMPLETE);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
EXPECT_EQ(buffer->copySize, size);
EXPECT_EQ(buffer->copyOffset, offset);
EXPECT_EQ(1u, buffer->transferToHostPtrCalled);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtr, 1, &clUnmapEvent, nullptr);
unmapEvent.setStatus(CL_COMPLETE);
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
EXPECT_EQ(buffer->copySize, size);
EXPECT_EQ(buffer->copyOffset, offset);
EXPECT_EQ(1u, buffer->transferFromHostPtrCalled);
@@ -322,11 +324,11 @@ HWTEST_F(MultipleMapBufferTest, givenBlockedQueueWhenMappedReadOnlyOnCpuThenDont
mapEvent.setStatus(CL_COMPLETE);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, buffer->transferToHostPtrCalled);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
retVal = clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtr, 1, &clUnmapEvent, nullptr);
unmapEvent.setStatus(CL_COMPLETE);
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
EXPECT_EQ(0u, buffer->transferFromHostPtrCalled);
}
@@ -353,26 +355,26 @@ HWTEST_F(MultipleMapBufferTest, givenMultimpleMapsWhenUnmappingThenRemoveCorrect
mappedPtrs[i].ptr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_WRITE,
mappedPtrs[i].offset[0], mappedPtrs[i].size[0], 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtrs[i].ptr);
EXPECT_EQ(i + 1, buffer->getMapOperationsHandler().size());
EXPECT_EQ(i + 1, buffer->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->enqueueSize, mappedPtrs[i].size[0]);
EXPECT_EQ(cmdQ->enqueueOffset, mappedPtrs[i].offset[0]);
}
// reordered unmap
clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtrs[1].ptr, 0, nullptr, nullptr);
EXPECT_EQ(2u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(2u, buffer->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->unmapPtr, mappedPtrs[1].ptr);
EXPECT_EQ(cmdQ->enqueueSize, mappedPtrs[1].size[0]);
EXPECT_EQ(cmdQ->enqueueOffset, mappedPtrs[1].offset[0]);
clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtrs[2].ptr, 0, nullptr, nullptr);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->unmapPtr, mappedPtrs[2].ptr);
EXPECT_EQ(cmdQ->enqueueSize, mappedPtrs[2].size[0]);
EXPECT_EQ(cmdQ->enqueueOffset, mappedPtrs[2].offset[0]);
clEnqueueUnmapMemObject(cmdQ.get(), buffer.get(), mappedPtrs[0].ptr, 0, nullptr, nullptr);
EXPECT_EQ(0u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(0u, buffer->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->unmapPtr, mappedPtrs[0].ptr);
EXPECT_EQ(cmdQ->enqueueSize, mappedPtrs[0].size[0]);
EXPECT_EQ(cmdQ->enqueueOffset, mappedPtrs[0].offset[0]);
@@ -388,13 +390,13 @@ HWTEST_F(MultipleMapBufferTest, givenOverlapingPtrWhenMappingOnGpuForWriteThenRe
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_READ, offset, size, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
offset++;
void *mappedPtr2 = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_WRITE, offset, size, 0, nullptr, nullptr, &retVal);
EXPECT_EQ(nullptr, mappedPtr2);
EXPECT_EQ(CL_INVALID_OPERATION, retVal);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
}
HWTEST_F(MultipleMapBufferTest, givenOverlapingPtrWhenMappingOnCpuForWriteThenReturnError) {
@@ -407,11 +409,11 @@ HWTEST_F(MultipleMapBufferTest, givenOverlapingPtrWhenMappingOnCpuForWriteThenRe
void *mappedPtr = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_READ, offset, size, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
offset++;
void *mappedPtr2 = clEnqueueMapBuffer(cmdQ.get(), buffer.get(), CL_FALSE, CL_MAP_WRITE, offset, size, 0, nullptr, nullptr, &retVal);
EXPECT_EQ(nullptr, mappedPtr2);
EXPECT_EQ(CL_INVALID_OPERATION, retVal);
EXPECT_EQ(1u, buffer->getMapOperationsHandler().size());
EXPECT_EQ(1u, buffer->mapOperationsHandler.size());
}

View File

@@ -21,6 +21,7 @@ extern ImageFactoryFuncs imageFactory[IGFX_MAX_CORE];
struct MultipleMapImageTest : public ClDeviceFixture, public ::testing::Test {
template <typename T>
struct MockImage : public ImageHw<T> {
using Image::mapOperationsHandler;
using ImageHw<T>::isZeroCopy;
using ImageHw<T>::ImageHw;
@@ -155,13 +156,13 @@ HWTEST_F(MultipleMapImageTest, givenValidReadAndWriteImageWhenMappedOnGpuThenAdd
MemObjSizeArray region = {{3, 4, 1}};
void *mappedPtr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_WRITE, &origin[0], &region[0], nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->enqueueRegion, region);
EXPECT_EQ(cmdQ->enqueueOrigin, origin);
EXPECT_EQ(cmdQ->readImageCalled, 1u);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->enqueueRegion, region);
EXPECT_EQ(cmdQ->enqueueOrigin, origin);
EXPECT_EQ(cmdQ->unmapPtr, mappedPtr);
@@ -180,13 +181,13 @@ HWTEST_F(MultipleMapImageTest, givenReadOnlyMapWhenUnmappedOnGpuThenEnqueueMarke
MemObjSizeArray region = {{3, 4, 1}};
void *mappedPtr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_READ, &origin[0], &region[0], nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->enqueueRegion, region);
EXPECT_EQ(cmdQ->enqueueOrigin, origin);
EXPECT_EQ(cmdQ->readImageCalled, 1u);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->writeImageCalled, 0u);
EXPECT_EQ(cmdQ->enqueueMarkerCalled, 1u);
}
@@ -203,12 +204,12 @@ HWTEST_F(MultipleMapImageTest, givenWriteInvalidateMapWhenMappedOnGpuThenEnqueue
MemObjSizeArray region = {{3, 4, 1}};
void *mappedPtr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_WRITE_INVALIDATE_REGION, &origin[0], &region[0], nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->readImageCalled, 0u);
EXPECT_EQ(cmdQ->enqueueMarkerCalled, 1u);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->writeImageCalled, 1u);
EXPECT_EQ(cmdQ->enqueueMarkerCalled, 1u);
EXPECT_EQ(cmdQ->enqueueRegion, region);
@@ -220,7 +221,7 @@ HWTEST_F(MultipleMapImageTest, givenNotMappedPtrWhenUnmapedThenReturnError) {
auto cmdQ = createMockCmdQ<FamilyType>();
EXPECT_EQ(!UnitTestHelper<FamilyType>::tiledImagesSupported, image->mappingOnCpuAllowed());
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
retVal = clEnqueueUnmapMemObject(cmdQ.get(), image.get(), image->getBasePtrForMap(cmdQ->getDevice().getRootDeviceIndex()), 0, nullptr, nullptr);
EXPECT_EQ(CL_INVALID_VALUE, retVal);
}
@@ -239,7 +240,7 @@ HWTEST_F(MultipleMapImageTest, givenErrorFromReadImageWhenMappedOnGpuThenDontAdd
void *mappedPtr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_READ, origin, region, nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_EQ(nullptr, mappedPtr);
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
}
HWTEST_F(MultipleMapImageTest, givenErrorFromWriteImageWhenUnmappedOnGpuThenDontRemoveMappedPtr) {
@@ -255,12 +256,12 @@ HWTEST_F(MultipleMapImageTest, givenErrorFromWriteImageWhenUnmappedOnGpuThenDont
size_t region[] = {2, 1, 1};
void *mappedPtr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_WRITE, origin, region, nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
retVal = clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
EXPECT_EQ(cmdQ->writeImageCalled, 1u);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
}
HWTEST_F(MultipleMapImageTest, givenUnblockedQueueWhenMappedOnCpuThenAddMappedPtrAndRemoveOnUnmap) {
@@ -273,13 +274,13 @@ HWTEST_F(MultipleMapImageTest, givenUnblockedQueueWhenMappedOnCpuThenAddMappedPt
MemObjSizeArray region = {{3, 1, 1}};
void *mappedPtr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_WRITE, &origin[0], &region[0], nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
EXPECT_EQ(1u, image->transferToHostPtrCalled);
EXPECT_EQ(image->copyRegion, region);
EXPECT_EQ(image->copyOrigin, origin);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
EXPECT_EQ(1u, image->transferFromHostPtrCalled);
EXPECT_EQ(image->copyRegion, region);
EXPECT_EQ(image->copyOrigin, origin);
@@ -296,13 +297,13 @@ HWTEST_F(MultipleMapImageTest, givenUnblockedQueueWhenReadOnlyUnmappedOnCpuThenD
MemObjSizeArray region = {{3, 1, 1}};
void *mappedPtr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_READ, &origin[0], &region[0], nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
EXPECT_EQ(1u, image->transferToHostPtrCalled);
EXPECT_EQ(image->copyRegion, region);
EXPECT_EQ(image->copyOrigin, origin);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
EXPECT_EQ(0u, image->transferFromHostPtrCalled);
}
@@ -317,11 +318,11 @@ HWTEST_F(MultipleMapImageTest, givenUnblockedQueueWhenWriteInvalidateMappedOnCpu
MemObjSizeArray region = {{3, 1, 1}};
void *mappedPtr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_WRITE_INVALIDATE_REGION, &origin[0], &region[0], nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
EXPECT_EQ(0u, image->transferToHostPtrCalled);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtr, 0, nullptr, nullptr);
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
EXPECT_EQ(1u, image->transferFromHostPtrCalled);
EXPECT_EQ(image->copyRegion, region);
EXPECT_EQ(image->copyOrigin, origin);
@@ -344,13 +345,13 @@ HWTEST_F(MultipleMapImageTest, givenBlockedQueueWhenMappedOnCpuThenAddMappedPtrA
mapEvent.setStatus(CL_COMPLETE);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, image->transferToHostPtrCalled);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
EXPECT_EQ(image->copyRegion, region);
EXPECT_EQ(image->copyOrigin, origin);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtr, 1, &clUnmapEvent, nullptr);
unmapEvent.setStatus(CL_COMPLETE);
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
EXPECT_EQ(1u, image->transferFromHostPtrCalled);
EXPECT_EQ(image->copyRegion, region);
EXPECT_EQ(image->copyOrigin, origin);
@@ -373,13 +374,13 @@ HWTEST_F(MultipleMapImageTest, givenBlockedQueueWhenMappedReadOnlyOnCpuThenDontM
mapEvent.setStatus(CL_COMPLETE);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(1u, image->transferToHostPtrCalled);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
EXPECT_EQ(image->copyRegion, region);
EXPECT_EQ(image->copyOrigin, origin);
retVal = clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtr, 1, &clUnmapEvent, nullptr);
unmapEvent.setStatus(CL_COMPLETE);
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
EXPECT_EQ(0u, image->transferFromHostPtrCalled);
}
@@ -407,26 +408,26 @@ HWTEST_F(MultipleMapImageTest, givenMultimpleMapsWhenUnmappingThenRemoveCorrectP
mappedPtrs[i].ptr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_WRITE, &mappedPtrs[i].offset[0], &mappedPtrs[i].size[0],
nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtrs[i].ptr);
EXPECT_EQ(i + 1, image->getMapOperationsHandler().size());
EXPECT_EQ(i + 1, image->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->enqueueRegion, mappedPtrs[i].size);
EXPECT_EQ(cmdQ->enqueueOrigin, mappedPtrs[i].offset);
}
// reordered unmap
clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtrs[1].ptr, 0, nullptr, nullptr);
EXPECT_EQ(2u, image->getMapOperationsHandler().size());
EXPECT_EQ(2u, image->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->unmapPtr, mappedPtrs[1].ptr);
EXPECT_EQ(cmdQ->enqueueRegion, mappedPtrs[1].size);
EXPECT_EQ(cmdQ->enqueueOrigin, mappedPtrs[1].offset);
clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtrs[2].ptr, 0, nullptr, nullptr);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->unmapPtr, mappedPtrs[2].ptr);
EXPECT_EQ(cmdQ->enqueueRegion, mappedPtrs[2].size);
EXPECT_EQ(cmdQ->enqueueOrigin, mappedPtrs[2].offset);
clEnqueueUnmapMemObject(cmdQ.get(), image.get(), mappedPtrs[0].ptr, 0, nullptr, nullptr);
EXPECT_EQ(0u, image->getMapOperationsHandler().size());
EXPECT_EQ(0u, image->mapOperationsHandler.size());
EXPECT_EQ(cmdQ->unmapPtr, mappedPtrs[0].ptr);
EXPECT_EQ(cmdQ->enqueueRegion, mappedPtrs[0].size);
EXPECT_EQ(cmdQ->enqueueOrigin, mappedPtrs[0].offset);
@@ -442,13 +443,13 @@ HWTEST_F(MultipleMapImageTest, givenOverlapingPtrWhenMappingForWriteThenReturnEr
void *mappedPtr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_READ, &origin[0], &region[0], nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
origin[0]++;
void *mappedPtr2 = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_WRITE, &origin[0], &region[0], nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_EQ(nullptr, mappedPtr2);
EXPECT_EQ(CL_INVALID_OPERATION, retVal);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
}
HWTEST_F(MultipleMapImageTest, givenOverlapingPtrWhenMappingOnCpuForWriteThenReturnError) {
@@ -461,12 +462,12 @@ HWTEST_F(MultipleMapImageTest, givenOverlapingPtrWhenMappingOnCpuForWriteThenRet
void *mappedPtr = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_READ, &origin[0], &region[0], nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_NE(nullptr, mappedPtr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
origin[0]++;
void *mappedPtr2 = clEnqueueMapImage(cmdQ.get(), image.get(), CL_TRUE, CL_MAP_WRITE, &origin[0], &region[0], nullptr, nullptr, 0, nullptr, nullptr, &retVal);
EXPECT_EQ(nullptr, mappedPtr2);
EXPECT_EQ(CL_INVALID_OPERATION, retVal);
EXPECT_EQ(1u, image->getMapOperationsHandler().size());
EXPECT_EQ(1u, image->mapOperationsHandler.size());
}
} // namespace NEO

View File

@@ -283,9 +283,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenNonBlockingMapEnqueueWhenFini
size_t tempBuffer[] = {0, 1, 2};
cl_int retVal;
auto cpuAllocation = std::make_unique<std::byte[]>(MemoryConstants::pageSize);
MockGraphicsAllocation allocation{cpuAllocation.get(), MemoryConstants::pageSize};
AlignedBuffer mockBuffer{&ctx, &allocation};
AlignedBuffer mockBuffer;
uint32_t taskCount = 0;
taskLevel = taskCount;

View File

@@ -8,7 +8,6 @@
#include "shared/source/helpers/ptr_math.h"
#include "opencl/source/mem_obj/map_operations_handler.h"
#include "opencl/test/unit_test/mocks/mock_buffer.h"
#include "test.h"
#include <tuple>
@@ -161,56 +160,3 @@ TEST_P(MapOperationsHandlerOverlapTests, givenAlreadyMappedPtrWhenAskingForOverl
INSTANTIATE_TEST_CASE_P(MapOperationsHandlerOverlapTests,
MapOperationsHandlerOverlapTests,
::testing::ValuesIn(overlappingCombinations));
struct MapOperationsStorageWhitebox : MapOperationsStorage {
using MapOperationsStorage::handlers;
};
TEST(MapOperationsStorageTest, givenMapOperationsStorageWhenGetHandlerIsUsedThenCreateHandler) {
MockBuffer buffer1{};
MockBuffer buffer2{};
MapOperationsStorageWhitebox storage{};
EXPECT_EQ(0u, storage.handlers.size());
storage.getHandler(&buffer1);
EXPECT_EQ(1u, storage.handlers.size());
storage.getHandler(&buffer2);
EXPECT_EQ(2u, storage.handlers.size());
storage.getHandler(&buffer1);
EXPECT_EQ(2u, storage.handlers.size());
}
TEST(MapOperationsStorageTest, givenMapOperationsStorageWhenGetHandlerIfExistsIsUsedThenDoNotCreateHandler) {
MockBuffer buffer1{};
MockBuffer buffer2{};
MapOperationsStorageWhitebox storage{};
EXPECT_EQ(0u, storage.handlers.size());
EXPECT_EQ(nullptr, storage.getHandlerIfExists(&buffer1));
EXPECT_EQ(nullptr, storage.getHandlerIfExists(&buffer2));
storage.getHandler(&buffer1);
EXPECT_EQ(1u, storage.handlers.size());
EXPECT_NE(nullptr, storage.getHandlerIfExists(&buffer1));
EXPECT_EQ(nullptr, storage.getHandlerIfExists(&buffer2));
storage.getHandler(&buffer2);
EXPECT_EQ(2u, storage.handlers.size());
EXPECT_NE(nullptr, storage.getHandlerIfExists(&buffer1));
EXPECT_NE(nullptr, storage.getHandlerIfExists(&buffer2));
EXPECT_NE(storage.getHandlerIfExists(&buffer1), storage.getHandlerIfExists(&buffer2));
}
TEST(MapOperationsStorageTest, givenMapOperationsStorageWhenRemoveHandlerIsUsedThenRemoveHandler) {
MockBuffer buffer{};
MapOperationsStorageWhitebox storage{};
storage.getHandler(&buffer);
ASSERT_EQ(1u, storage.handlers.size());
storage.removeHandler(&buffer);
EXPECT_EQ(0u, storage.handlers.size());
}

View File

@@ -35,21 +35,16 @@ class MockBuffer : public MockBufferStorage, public Buffer {
using Buffer::magic;
using Buffer::offset;
using Buffer::size;
using MemObj::context;
using MemObj::isZeroCopy;
using MemObj::memObjectType;
using MockBufferStorage::device;
MockBuffer(GraphicsAllocation &alloc) : MockBuffer(nullptr, alloc) {}
MockBuffer(Context *context, GraphicsAllocation &alloc)
MockBuffer(GraphicsAllocation &alloc)
: MockBufferStorage(), Buffer(
context, ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
nullptr, ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, alloc.getUnderlyingBufferSize(), alloc.getUnderlyingBuffer(), alloc.getUnderlyingBuffer(),
GraphicsAllocationHelper::toMultiGraphicsAllocation(&alloc), true, false, false),
externalAlloc(&alloc) {
}
MockBuffer()
: MockBufferStorage(), Buffer(
nullptr, ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
@@ -58,8 +53,9 @@ class MockBuffer : public MockBufferStorage, public Buffer {
}
~MockBuffer() override {
if (externalAlloc != nullptr) {
// no ownership over graphics allocation, do not release it
this->multiGraphicsAllocation.removeAllocation(0u);
// no ownership over graphics allocation
// return to mock allocations
this->multiGraphicsAllocation.addAllocation(&this->mockGfxAllocation);
}
}
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, const Device &device, bool useGlobalAtomics, bool areMultipleSubDevicesInContext) override {
@@ -77,29 +73,15 @@ class AlignedBuffer : public MockBufferStorage, public Buffer {
CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64),
GraphicsAllocationHelper::toMultiGraphicsAllocation(&mockGfxAllocation), true, false, false) {
}
AlignedBuffer(GraphicsAllocation *gfxAllocation) : AlignedBuffer(nullptr, gfxAllocation) {}
AlignedBuffer(Context *context, GraphicsAllocation *gfxAllocation)
AlignedBuffer(GraphicsAllocation *gfxAllocation)
: MockBufferStorage(), Buffer(
context, ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
nullptr, ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64),
GraphicsAllocationHelper::toMultiGraphicsAllocation(gfxAllocation), true, false, false),
externalAlloc(gfxAllocation) {
GraphicsAllocationHelper::toMultiGraphicsAllocation(gfxAllocation), true, false, false) {
}
~AlignedBuffer() override {
if (externalAlloc != nullptr) {
// no ownership over graphics allocation, do not release it
this->multiGraphicsAllocation.removeAllocation(0u);
}
}
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, const Device &device, bool useGlobalAtomics, bool areMultipleSubDevicesInContext) override {
Buffer::setSurfaceState(this->device.get(), memory, forceNonAuxMode, disableL3, getSize(), getCpuAddress(), 0, &mockGfxAllocation, 0, 0, false, false);
}
GraphicsAllocation *externalAlloc = nullptr;
};
class UnalignedBuffer : public MockBufferStorage, public Buffer {
@@ -111,29 +93,15 @@ class UnalignedBuffer : public MockBufferStorage, public Buffer {
CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4),
GraphicsAllocationHelper::toMultiGraphicsAllocation(&mockGfxAllocation), false, false, false) {
}
UnalignedBuffer(GraphicsAllocation *gfxAllocation) : UnalignedBuffer(nullptr, gfxAllocation) {}
UnalignedBuffer(Context *context, GraphicsAllocation *gfxAllocation)
UnalignedBuffer(GraphicsAllocation *gfxAllocation)
: MockBufferStorage(true), Buffer(
context, ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
nullptr, ClMemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4),
GraphicsAllocationHelper::toMultiGraphicsAllocation(gfxAllocation), false, false, false),
externalAlloc(gfxAllocation) {
GraphicsAllocationHelper::toMultiGraphicsAllocation(gfxAllocation), false, false, false) {
}
~UnalignedBuffer() override {
if (externalAlloc != nullptr) {
// no ownership over graphics allocation, do not release it
this->multiGraphicsAllocation.removeAllocation(0u);
}
}
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, const Device &device, bool useGlobalAtomics, bool areMultipleSubDevicesInContext) override {
Buffer::setSurfaceState(this->device.get(), memory, forceNonAuxMode, disableL3, getSize(), getCpuAddress(), 0, &mockGfxAllocation, 0, 0, false, false);
}
GraphicsAllocation *externalAlloc = nullptr;
};
class MockPublicAccessBuffer : public Buffer {

View File

@@ -86,8 +86,7 @@ TEST_F(IOQTaskTestsMt, GivenBlockedOnUserEventWhenEnqueingMarkerThenSuccessIsRet
}
TEST_F(IOQTaskTestsMt, GivenMultipleThreadsWhenMappingBufferThenEventsAreCompleted) {
MockGraphicsAllocation alignedBufferAlloc{nullptr, MemoryConstants::pageSize};
AlignedBuffer alignedBuffer{pContext, &alignedBufferAlloc};
AlignedBuffer alignedBuffer;
auto userEvent = clCreateUserEvent(pContext, &retVal);
EXPECT_EQ(CL_SUCCESS, retVal);