fix: revert changes around zero-copy

Related-To: NEO-12018

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2024-07-19 10:42:58 +00:00
committed by Compute-Runtime-Automation
parent b6299b8a21
commit 6a11e8a077
40 changed files with 166 additions and 466 deletions

View File

@@ -338,14 +338,12 @@ Buffer *Buffer::create(Context *context,
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex];
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*hwInfo), memoryProperties, *context,
gfxCoreHelper.isBufferSizeSuitableForCompression(size));
auto isZeroCopyCpuAccessPreferred = productHelper.isZeroCopyCpuAccessPreferred();
allocationInfo.allocationType = getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled,
memoryManager->isLocalMemorySupported(rootDeviceIndex),
isZeroCopyCpuAccessPreferred);
memoryManager->isLocalMemorySupported(rootDeviceIndex));
if (allocationCpuPtr) {
forceCopyHostPtr = !useHostPtr && !copyHostPtr;
@@ -373,9 +371,6 @@ Buffer *Buffer::create(Context *context,
allocationInfo.zeroCopyAllowed = false;
allocationInfo.allocateMemory = true;
}
} else if (!isZeroCopyCpuAccessPreferred) {
allocationInfo.zeroCopyAllowed = false;
allocationInfo.allocateMemory = true;
}
if (debugManager.flags.DisableZeroCopyForUseHostPtr.get()) {
@@ -470,7 +465,7 @@ Buffer *Buffer::create(Context *context,
return nullptr;
}
if (!isSystemMemory || (!isZeroCopyCpuAccessPreferred && !memoryProperties.flags.forceHostMemory)) {
if (!isSystemMemory) {
allocationInfo.zeroCopyAllowed = false;
if (hostPtr) {
if (!allocationInfo.isHostPtrSVM) {
@@ -642,14 +637,13 @@ void Buffer::checkMemory(const MemoryProperties &memoryProperties,
}
AllocationType Buffer::getGraphicsAllocationTypeAndCompressionPreference(const MemoryProperties &properties,
bool &compressionEnabled, bool isLocalMemoryEnabled,
bool isZeroCopyCpuAccessPreferred) {
bool &compressionEnabled, bool isLocalMemoryEnabled) {
if (properties.flags.forceHostMemory) {
compressionEnabled = false;
return AllocationType::bufferHostMemory;
}
if (properties.flags.useHostPtr && (!isLocalMemoryEnabled && isZeroCopyCpuAccessPreferred)) {
if (properties.flags.useHostPtr && !isLocalMemoryEnabled) {
compressionEnabled = false;
return AllocationType::bufferHostMemory;
}

View File

@@ -208,8 +208,7 @@ class Buffer : public MemObj {
uint32_t rootDeviceIndex,
bool forceCopyHostPtr);
static AllocationType getGraphicsAllocationTypeAndCompressionPreference(const MemoryProperties &properties,
bool &compressionEnabled, bool localMemoryEnabled,
bool isZeroCopyCpuAccessPreferred);
bool &compressionEnabled, bool localMemoryEnabled);
static bool isReadOnlyMemoryPermittedByFlags(const MemoryProperties &properties);
void transferData(void *dst, void *src, size_t copySize, size_t copyOffset);

View File

@@ -448,10 +448,8 @@ bool MemObj::mappingOnCpuAllowed() const {
bool MemObj::allowCpuAccess() const {
auto graphicsAllocation = this->multiGraphicsAllocation.getDefaultGraphicsAllocation();
auto allocType = graphicsAllocation->getAllocationType();
auto isNonCoherentSystemAllocation = MemoryPoolHelper::isSystemMemoryPool(graphicsAllocation->getMemoryPool()) && (allocType == AllocationType::buffer);
if (graphicsAllocation->getDefaultGmm() == nullptr) {
return !(isNonCoherentSystemAllocation);
return true;
}
return !graphicsAllocation->getDefaultGmm()->getPreferNoCpuAccess();

View File

@@ -145,7 +145,7 @@ bool MemObjHelper::isSuitableForCompression(bool compressionSupported, const Mem
return true;
}
return false;
return properties.flags.compressedHint;
}
bool MemObjHelper::validateExtraMemoryProperties(const MemoryProperties &memoryProperties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel, const Context &context) {

View File

@@ -30,6 +30,7 @@ struct ApiFixture {
void setUp() {
debugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
debugManager.flags.EnableCpuCacheForResources.set(true);
executionEnvironment = new ClExecutionEnvironment();
prepareDeviceEnvironments(*executionEnvironment);
for (auto i = 0u; i < executionEnvironment->rootDeviceEnvironments.size(); i++) {

View File

@@ -470,7 +470,7 @@ TEST_F(ClCreateBufferTests, WhenCreatingBufferWithPropertiesThenPropertiesAreCor
using clCreateBufferTestsWithRestrictions = api_test_using_aligned_memory_manager;
TEST_F(clCreateBufferTestsWithRestrictions, GivenMemoryManagerRestrictionsAndOldCoherencyModelWhenMinIsLessThanHostPtrThenUseZeroCopy) {
TEST_F(clCreateBufferTestsWithRestrictions, GivenMemoryManagerRestrictionsWhenMinIsLessThanHostPtrThenUseZeroCopy) {
std::unique_ptr<unsigned char[]> hostMem(nullptr);
unsigned char *destMem = nullptr;
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
@@ -495,13 +495,7 @@ TEST_F(clCreateBufferTestsWithRestrictions, GivenMemoryManagerRestrictionsAndOld
EXPECT_NE(nullptr, buffer);
Buffer *bufferObj = NEO::castToObject<Buffer>(buffer);
auto &productHelper = device->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
EXPECT_FALSE(bufferObj->isMemObjZeroCopy());
} else {
EXPECT_TRUE(bufferObj->isMemObjZeroCopy());
}
retVal = clReleaseMemObject(buffer);
EXPECT_EQ(CL_SUCCESS, retVal);

View File

@@ -57,7 +57,7 @@ TEST_F(ClEnqueueMapBufferTests, GivenValidParametersWhenMappingBufferThenSuccess
unsigned int bufferSize = 16;
auto pHostMem = new unsigned char[bufferSize];
memset(pHostMem, 0xaa, bufferSize);
cl_event eventReturned = nullptr;
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
auto buffer = clCreateBuffer(
pContext,
@@ -68,6 +68,7 @@ TEST_F(ClEnqueueMapBufferTests, GivenValidParametersWhenMappingBufferThenSuccess
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, buffer);
cl_event eventReturned = nullptr;
auto ptrResult = clEnqueueMapBuffer(
pCommandQueue,
buffer,
@@ -113,12 +114,6 @@ TEST_F(ClEnqueueMapBufferTests, GivenMappedPointerWhenCreatingBufferFromThisPoin
unsigned int bufferSize = 16;
cl_mem buffer = clCreateBuffer(pContext, CL_MEM_READ_WRITE, bufferSize, nullptr, &retVal);
auto pBuffer = castToObject<Buffer>(buffer);
if (!pBuffer->mappingOnCpuAllowed()) {
retVal = clReleaseMemObject(buffer);
EXPECT_EQ(CL_SUCCESS, retVal);
GTEST_SKIP();
}
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, buffer);

View File

@@ -63,6 +63,7 @@ TEST_F(ClEnqueueUnmapMemObjTests, GivenQueueIncapableWhenUnmappingBufferThenInva
TEST_F(ClEnqueueUnmapMemObjTests, givenInvalidAddressWhenUnmappingOnCpuThenReturnError) {
auto buffer = std::unique_ptr<Buffer>(BufferHelper<BufferUseHostPtr<>>::create(pContext));
EXPECT_TRUE(buffer->mappingOnCpuAllowed());
cl_int retVal = CL_SUCCESS;
auto mappedPtr = clEnqueueMapBuffer(pCommandQueue, buffer.get(), CL_TRUE, CL_MAP_READ, 0, 1, 0, nullptr, nullptr, &retVal);
@@ -85,9 +86,8 @@ TEST_F(ClEnqueueUnmapMemObjTests, givenZeroCopyWithoutCoherencyAllowedWhenMapAnd
VariableBackup<uint32_t> backupWaitCount(&WaitUtils::waitCount, 1);
auto buffer = std::unique_ptr<Buffer>(BufferHelper<BufferAllocHostPtr<>>::create(pContext));
if (!buffer->isMemObjZeroCopy()) {
GTEST_SKIP();
}
EXPECT_TRUE(buffer->mappingOnCpuAllowed());
buffer->isMemObjZeroCopy();
cl_int retVal = CL_SUCCESS;
CpuIntrinsicsTests::clFlushCounter.store(0u);

View File

@@ -35,7 +35,6 @@ struct CompressionXeHPAndLater : public AUBFixture,
debugRestorer = std::make_unique<DebugManagerStateRestore>();
debugManager.flags.RenderCompressedBuffersEnabled.set(true);
debugManager.flags.RenderCompressedImagesEnabled.set(true);
debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true);
debugManager.flags.EnableLocalMemory.set(useLocalMemory);
debugManager.flags.NodeOrdinal.set(GetParam());

View File

@@ -178,7 +178,7 @@ void CopyEngineXeHPAndLater<numTiles, testLocalMemory>::givenNotCompressedBuffer
if (!compressionSupported()) {
GTEST_SKIP();
}
debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true);
auto srcNotCompressedBuffer = createBuffer(false, testLocalMemory, compressiblePattern.get());
auto dstNotCompressedBuffer = createBuffer(false, testLocalMemory, nullptr);
auto dstCompressedBuffer = createBuffer(true, testLocalMemory, nullptr);
@@ -219,7 +219,7 @@ void CopyEngineXeHPAndLater<numTiles, testLocalMemory>::givenHostPtrWhenBlitComm
if (!compressionSupported()) {
GTEST_SKIP();
}
debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true);
auto dstCompressedBuffer = createBuffer(true, testLocalMemory, nullptr);
// HostPtr to Buffer - System -> compressed HBM
@@ -248,7 +248,7 @@ void CopyEngineXeHPAndLater<numTiles, testLocalMemory>::givenDstHostPtrWhenBlitC
if (!compressionSupported()) {
GTEST_SKIP();
}
debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true);
auto srcCompressedBuffer = createBuffer(true, testLocalMemory, nullptr);
auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::hostPtrToBuffer,
*bcsCsr, srcCompressedBuffer->getGraphicsAllocation(rootDeviceIndex),
@@ -372,7 +372,7 @@ void CopyEngineXeHPAndLater<numTiles, testLocalMemory>::givenSrcCompressedBuffer
if (!compressionSupported()) {
GTEST_SKIP();
}
debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true);
auto srcBuffer = createBuffer(true, testLocalMemory, nullptr);
auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::hostPtrToBuffer,
*bcsCsr, srcBuffer->getGraphicsAllocation(rootDeviceIndex),
@@ -407,7 +407,7 @@ void CopyEngineXeHPAndLater<numTiles, testLocalMemory>::givenCompressedBufferWhe
// no support for scenarios where stateless is mixed with blitter compression
GTEST_SKIP();
}
debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true);
auto buffer = createBuffer(true, testLocalMemory, compressiblePattern.get());
{

View File

@@ -393,9 +393,7 @@ HWTEST_F(CommandQueueHwTest, GivenNonEmptyQueueOnBlockingWhenMappingBufferThenWi
bool finishWasCalled;
};
if (context->getDevice(0)->getProductHelper().isNewCoherencyModelSupported()) {
GTEST_SKIP();
}
MockCmdQ cmdQ(context, pCmdQ->getDevice().getSpecializedDevice<ClDevice>());
auto b1 = clCreateBuffer(context, CL_MEM_READ_WRITE, 20, nullptr, nullptr);
@@ -441,9 +439,7 @@ HWTEST_F(CommandQueueHwTest, GivenEventsWaitlistOnBlockingWhenMappingBufferThenW
uint32_t updateCount = 0;
uint32_t updateCountBeforeCompleted;
};
if (context->getDevice(0)->getProductHelper().isNewCoherencyModelSupported()) {
GTEST_SKIP();
}
MockEvent *me = new MockEvent(context, 1024);
auto b1 = clCreateBuffer(context, CL_MEM_READ_WRITE, 20, nullptr, nullptr);
cl_event meAsClEv = me;

View File

@@ -1133,6 +1133,7 @@ HWTEST_F(EnqueueKernelTest, givenCsrInBatchingModeWhenNonBlockingMapFollowsNdrCa
mockCsr->overrideDispatchPolicy(DispatchMode::batchedDispatch);
pDevice->resetCommandStreamReceiver(mockCsr);
EXPECT_TRUE(this->destBuffer->isMemObjZeroCopy());
MockKernelWithInternals mockKernel(*pClDevice);
size_t gws[3] = {1, 0, 0};
pCmdQ->enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr);

View File

@@ -109,9 +109,6 @@ TEST_F(EnqueueMapBufferTest, GivenCmdqAndValidArgsWhenMappingBufferThenSuccessIs
TEST_F(EnqueueMapBufferTest, GivenChangesInHostBufferWhenMappingBufferThenChangesArePropagatedToDeviceMemory) {
// size not aligned to cacheline size
if (!buffer->mappingOnCpuAllowed()) {
GTEST_SKIP();
}
int bufferSize = 20;
void *ptrHost = malloc(bufferSize);
char *charHostPtr = static_cast<char *>(ptrHost);
@@ -291,10 +288,7 @@ HWTEST_F(EnqueueMapBufferTest, givenNonBlockingReadOnlyMapBufferOnZeroCopyBuffer
&retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, buffer);
auto pBuffer = castToObject<Buffer>(buffer);
if (!pBuffer->isMemObjZeroCopy()) {
GTEST_SKIP();
}
MockCommandQueueHw<FamilyType> mockCmdQueue(context, pClDevice, nullptr);
auto &commandStreamReceiver = mockCmdQueue.getGpgpuCommandStreamReceiver();
@@ -513,26 +507,21 @@ TEST_F(EnqueueMapBufferTest, givenNonBlockingMapBufferAfterL3IsAlreadyFlushedThe
EXPECT_EQ(CL_SUCCESS, retVal);
taskCount = commandStreamReceiver.peekTaskCount();
auto expectedTaskCount = 1u;
auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskCount++;
}
EXPECT_EQ(expectedTaskCount, taskCount);
EXPECT_EQ(1u, taskCount);
auto neoEvent = castToObject<Event>(eventReturned);
// if task count of csr is higher then event task count with proper dc flushing then we are fine
EXPECT_EQ(expectedTaskCount, neoEvent->getCompletionStamp());
EXPECT_EQ(1u, neoEvent->getCompletionStamp());
EXPECT_TRUE(neoEvent->updateStatusAndCheckCompletion());
// flush task was not called
EXPECT_EQ(expectedTaskCount, commandStreamReceiver.peekLatestSentTaskCount());
EXPECT_EQ(1u, commandStreamReceiver.peekLatestSentTaskCount());
// wait for events shouldn't call flush task
retVal = clWaitForEvents(1, &eventReturned);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(expectedTaskCount, commandStreamReceiver.peekLatestSentTaskCount());
EXPECT_EQ(1u, commandStreamReceiver.peekLatestSentTaskCount());
retVal = clReleaseMemObject(buffer);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -587,16 +576,14 @@ HWTEST_F(EnqueueMapBufferTest, GivenBufferThatIsNotZeroCopyWhenNonBlockingMapIsC
nullptr,
nullptr,
&retVal);
clFlush(&mockCmdQueue);
EXPECT_NE(nullptr, ptrResult);
EXPECT_EQ(CL_SUCCESS, retVal);
commandStreamReceiver.peekTaskCount();
if (pBuffer->mappingOnCpuAllowed()) {
EXPECT_EQ(1u, commandStreamReceiver.peekLatestSentTaskCount());
EXPECT_EQ(1u, mockCmdQueue.latestTaskCountWaited);
}
retVal = clReleaseMemObject(buffer);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -654,12 +641,7 @@ HWTEST_F(EnqueueMapBufferTest, GivenPtrToReturnEventWhenMappingBufferThenEventIs
EXPECT_NE(nullptr, eventReturned);
auto eventObject = castToObject<Event>(eventReturned);
auto bufferObject = castToObject<Buffer>(buffer);
if (bufferObject->mappingOnCpuAllowed()) {
EXPECT_EQ(0u, eventObject->peekTaskCount());
} else {
EXPECT_EQ(101u, eventObject->peekTaskCount());
}
EXPECT_TRUE(eventObject->updateStatusAndCheckCompletion());
retVal = clEnqueueUnmapMemObject(
@@ -684,11 +666,7 @@ TEST_F(EnqueueMapBufferTest, GivenZeroCopyBufferWhenMapBufferWithoutEventsThenCo
20,
nullptr,
&retVal);
auto pBuffer = castToObject<Buffer>(buffer);
if (!pBuffer->isMemObjZeroCopy()) {
clReleaseMemObject(buffer);
GTEST_SKIP();
}
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, buffer);
@@ -715,8 +693,7 @@ TEST_F(EnqueueMapBufferTest, GivenZeroCopyBufferWhenMapBufferWithoutEventsThenCo
TEST_F(EnqueueMapBufferTest, givenBufferWithoutUseHostPtrFlagWhenMappedOnCpuThenSetAllMapParams) {
std::unique_ptr<Buffer> buffer(Buffer::create(BufferDefaults::context, CL_MEM_READ_WRITE, 10, nullptr, retVal));
EXPECT_NE(nullptr, buffer);
auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper();
EXPECT_EQ(productHelper.isZeroCopyCpuAccessPreferred(), buffer->mappingOnCpuAllowed());
EXPECT_TRUE(buffer->mappingOnCpuAllowed());
size_t mapSize = 3;
size_t mapOffset = 2;
@@ -738,17 +715,15 @@ TEST_F(EnqueueMapBufferTest, givenBufferWithoutUseHostPtrFlagWhenMappedOnCpuThen
EXPECT_EQ(0u, mappedInfo.size[2]);
auto expectedPtr = ptrOffset(buffer->getCpuAddressForMapping(), mapOffset);
if (productHelper.isZeroCopyCpuAccessPreferred()) {
EXPECT_EQ(mappedPtr, expectedPtr);
}
}
TEST_F(EnqueueMapBufferTest, givenBufferWithUseHostPtrFlagWhenMappedOnCpuThenSetAllMapParams) {
uint8_t hostPtr[10] = {};
std::unique_ptr<Buffer> buffer(Buffer::create(BufferDefaults::context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, 10, hostPtr, retVal));
EXPECT_NE(nullptr, buffer);
auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper();
EXPECT_EQ(productHelper.isZeroCopyCpuAccessPreferred(), buffer->mappingOnCpuAllowed());
EXPECT_TRUE(buffer->mappingOnCpuAllowed());
size_t mapSize = 3;
size_t mapOffset = 2;
@@ -778,12 +753,7 @@ HWTEST_F(EnqueueMapBufferTest, givenMapBufferOnGpuWhenMappingBufferThenStoreGrap
uint8_t hostPtr[10] = {};
std::unique_ptr<Buffer> bufferForCpuMap(Buffer::create(context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, 10, hostPtr, retVal));
ASSERT_NE(nullptr, bufferForCpuMap);
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
ASSERT_FALSE(bufferForCpuMap->mappingOnCpuAllowed());
} else {
ASSERT_TRUE(bufferForCpuMap->mappingOnCpuAllowed());
}
std::unique_ptr<Buffer> bufferForGpuMap(Buffer::create(context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, 10, hostPtr, retVal));
ASSERT_NE(nullptr, bufferForGpuMap);
@@ -798,11 +768,7 @@ HWTEST_F(EnqueueMapBufferTest, givenMapBufferOnGpuWhenMappingBufferThenStoreGrap
MapInfo mapInfo{};
EXPECT_TRUE(bufferForCpuMap->findMappedPtr(pointerMappedOnCpu, mapInfo));
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
EXPECT_NE(nullptr, mapInfo.graphicsAllocation);
} else {
EXPECT_EQ(nullptr, mapInfo.graphicsAllocation);
}
EXPECT_TRUE(bufferForGpuMap->findMappedPtr(pointerMappedOnGpu, mapInfo));
EXPECT_NE(nullptr, mapInfo.graphicsAllocation);
}

View File

@@ -101,23 +101,8 @@ TEST_F(EnqueueReadBuffer, WhenReadingBufferThenEventReturnedShouldBeMaxOfInputEv
delete pEvent;
}
struct EnqueueReadBufferOnCpuTest : public EnqueueReadBuffer {
void SetUp() override {
EnqueueReadBuffer::setUp();
auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
// These tests verify cpu transfer logic
GTEST_SKIP();
}
}
void TearDown() override {
EnqueueReadBuffer::tearDown();
}
TEST_F(EnqueueReadBuffer, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
};
TEST_F(EnqueueReadBufferOnCpuTest, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
debugManager.flags.DoCpuCopyOnReadBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal = CL_SUCCESS;
@@ -159,7 +144,8 @@ TEST_F(EnqueueReadBufferOnCpuTest, givenInOrderQueueAndForcedCpuCopyOnReadBuffer
pEvent->release();
}
TEST_F(EnqueueReadBufferOnCpuTest, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
TEST_F(EnqueueReadBuffer, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnReadBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal = CL_SUCCESS;
@@ -192,7 +178,8 @@ TEST_F(EnqueueReadBufferOnCpuTest, givenInOrderQueueAndForcedCpuCopyOnReadBuffer
pEvent->release();
}
TEST_F(EnqueueReadBufferOnCpuTest, givenOutOfOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
TEST_F(EnqueueReadBuffer, givenOutOfOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnReadBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
std::unique_ptr<CommandQueue> pCmdOOQ(createCommandQueue(pClDevice, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE));
@@ -275,7 +262,8 @@ TEST_F(EnqueueReadBuffer, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndEventN
pEvent->release();
}
TEST_F(EnqueueReadBufferOnCpuTest, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
TEST_F(EnqueueReadBuffer, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnReadBuffer.set(0);
cl_int retVal = CL_SUCCESS;
uint32_t taskLevelCmdQ = 17;
@@ -315,7 +303,8 @@ TEST_F(EnqueueReadBufferOnCpuTest, givenInOrderQueueAndDisabledSupportCpuCopiesA
pEvent->release();
}
TEST_F(EnqueueReadBufferOnCpuTest, givenOutOfOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
TEST_F(EnqueueReadBuffer, givenOutOfOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnReadBuffer.set(0);
std::unique_ptr<CommandQueue> pCmdOOQ(createCommandQueue(pClDevice, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE));
cl_int retVal = CL_SUCCESS;

View File

@@ -389,15 +389,10 @@ HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndDstPtrEqualSrcPtrWithEve
EXPECT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, event);
auto expectedTaskLevel = 19u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
auto pEvent = (Event *)event;
EXPECT_EQ(19u, pEvent->taskLevel);
EXPECT_EQ(19u, pCmdQ->taskLevel);
EXPECT_EQ(CL_COMMAND_READ_BUFFER_RECT, (const int)pEvent->getCommandType());
EXPECT_EQ(expectedTaskLevel, pEvent->taskLevel);
EXPECT_EQ(expectedTaskLevel, pCmdQ->taskLevel);
pEvent->release();
}
@@ -442,17 +437,14 @@ HWTEST_F(EnqueueReadBufferRectTest, givenOutOfOrderQueueAndDstPtrEqualSrcPtrWith
&event);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(CL_SUCCESS, pCmdOOQ->flush());
EXPECT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, event);
auto expectedTaskLevel = 19u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
auto pEvent = (Event *)event;
EXPECT_EQ(19u, pEvent->taskLevel);
EXPECT_EQ(19u, pCmdOOQ->taskLevel);
EXPECT_EQ(CL_COMMAND_READ_BUFFER_RECT, (const int)pEvent->getCommandType());
EXPECT_EQ(expectedTaskLevel, pEvent->taskLevel);
EXPECT_EQ(expectedTaskLevel, pCmdOOQ->taskLevel);
pEvent->release();
}
HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndRowPitchEqualZeroAndDstPtrEqualSrcPtrWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
@@ -478,12 +470,7 @@ HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndRowPitchEqualZeroAndDstP
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedTaskLevel = 0u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndSlicePitchEqualZeroAndDstPtrEqualSrcPtrWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
cl_int retVal = CL_SUCCESS;
@@ -508,12 +495,7 @@ HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndSlicePitchEqualZeroAndDs
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedTaskLevel = 0u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndMemObjWithOffsetPointTheSameStorageWithHostWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
cl_int retVal = CL_SUCCESS;
@@ -540,12 +522,7 @@ HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndMemObjWithOffsetPointThe
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedTaskLevel = 0u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueReadBufferRectTest, givenInOrderQueueAndMemObjWithOffsetPointDiffrentStorageWithHostWhenReadBufferIsExecutedThenTaskLevelShouldBeIncreased) {
cl_int retVal = CL_SUCCESS;

View File

@@ -406,7 +406,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenOOQWithEnabledSupportCpuCopiesAndDstPtr
0,
nullptr,
nullptr);
pCmdOOQ->flush();
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(pCmdOOQ->taskLevel, 0u);
}
@@ -427,7 +427,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenOOQWithDisabledSupportCpuCopiesAndDstPt
0,
nullptr,
nullptr);
pCmdOOQ->flush();
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(pCmdOOQ->taskLevel, 0u);
}
@@ -474,12 +474,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenInOrderQueueAndEnabledSupportCpuCopiesA
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedTaskLevel = 0u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueReadBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrAndZeroCopyBufferWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
@@ -498,12 +493,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopies
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedTaskLevel = 0u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueReadBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrAndNonZeroCopyBufferWhenReadBufferIsExecutedThenTaskLevelShouldBeIncreased) {
DebugManagerStateRestore dbgRestore;

View File

@@ -135,6 +135,7 @@ HWTEST_F(EnqueueUnmapMemObjTest, WhenUnmappingMemoryObjectThenEventIsUpdated) {
EXPECT_NE(nullptr, eventReturned);
auto eventObject = castToObject<Event>(eventReturned);
EXPECT_EQ(0u, eventObject->peekTaskCount());
EXPECT_TRUE(eventObject->updateStatusAndCheckCompletion());
clReleaseEvent(eventReturned);
@@ -181,20 +182,11 @@ TEST_F(EnqueueUnmapMemObjTest, WhenUnmappingMemoryObjectThenWaitEventIsUpdated)
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, retEvent);
Event *rEvent = castToObject<Event>(retEvent);
auto &productHelper = pCmdQ->getClDevice().getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
// In new coherency model wait event is not immediately updated as unmap is sent to GPU
// Instead, verify that timestamp packets were correctly assigned from waitEvent to retEvent
auto waitNodes = wEvent->getTimestampPacketNodes()->peekNodes();
auto &retNodes = rEvent->getTimestampPacketNodes()->peekNodes();
EXPECT_EQ(1u, waitNodes.size());
EXPECT_EQ(2u, retNodes.size());
EXPECT_EQ(waitNodes[0], retNodes[1]);
} else {
EXPECT_EQ(CL_COMPLETE, wEvent->peekExecutionStatus());
}
Event *rEvent = castToObject<Event>(retEvent);
EXPECT_EQ(CL_QUEUED, rEvent->peekExecutionStatus());
retVal = clWaitForEvents(1, &retEvent);
EXPECT_EQ(CL_SUCCESS, retVal);
@@ -224,20 +216,12 @@ HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBuf
nullptr,
nullptr);
ASSERT_EQ(CL_SUCCESS, retVal);
if (buffer->mappingOnCpuAllowed()) {
EXPECT_TRUE(graphicsAllocation->isAubWritable(GraphicsAllocation::defaultBank));
EXPECT_TRUE(graphicsAllocation->isTbxWritable(GraphicsAllocation::defaultBank));
} else {
EXPECT_FALSE(graphicsAllocation->isAubWritable(GraphicsAllocation::defaultBank));
EXPECT_FALSE(graphicsAllocation->isTbxWritable(GraphicsAllocation::defaultBank));
}
}
HWTEST_F(EnqueueUnmapMemObjTest, givenWriteBufferIsServicedOnCPUWhenBufferIsNonAubTbxWriteableThenFlagsChange) {
if (pClDevice->getProductHelper().isNewCoherencyModelSupported()) {
// This test assumes that write buffer will be serviced on cpu
GTEST_SKIP();
}
DebugManagerStateRestore restorer;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));

View File

@@ -101,28 +101,8 @@ TEST_F(EnqueueWriteBufferTypeTest, WhenWritingBufferThenReturnedEventShouldBeMax
delete pEvent;
}
struct EnqueueWriteBufferOnCpuTypeTest : public EnqueueWriteBufferTypeTest {
void SetUp() override {
EnqueueWriteBufferTypeTest::SetUp();
auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
// These tests verify cpu transfer logic
GTEST_SKIP();
}
}
void TearDown() override {
auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
// These tests verify cpu transfer logic
GTEST_SKIP();
}
EnqueueWriteBufferTypeTest::TearDown();
}
TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
};
TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
debugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal = CL_SUCCESS;
@@ -164,7 +144,8 @@ TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndForcedCpuCopyOnWrite
pEvent->release();
}
TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndEventNotReadyWhenWriteBufferIsExecutedThenTaskLevelShouldBeIncreased) {
TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndEventNotReadyWhenWriteBufferIsExecutedThenTaskLevelShouldBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
cl_int retVal = CL_SUCCESS;
uint32_t taskLevelCmdQ = 17;
@@ -203,7 +184,8 @@ TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndForcedCpuCopyOnWrite
pEvent->release();
}
TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
cl_int retVal = CL_SUCCESS;
uint32_t taskLevelCmdQ = 17;
@@ -234,7 +216,8 @@ TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndForcedCpuCopyOnWrite
pEvent->release();
}
TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenOutOfOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
TEST_F(EnqueueWriteBufferTypeTest, givenOutOfOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
std::unique_ptr<CommandQueue> pCmdOOQ(createCommandQueue(pClDevice, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE));
@@ -276,7 +259,8 @@ TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenOutOfOrderQueueAndForcedCpuCopyOnWr
pEvent->release();
}
TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(0);
cl_int retVal = CL_SUCCESS;
uint32_t taskLevelCmdQ = 17;
@@ -316,7 +300,8 @@ TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndDisabledSupportCpuCo
pEvent->release();
}
TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenOutOfOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
TEST_F(EnqueueWriteBufferTypeTest, givenOutOfOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(0);
std::unique_ptr<CommandQueue> pCmdOOQ(createCommandQueue(pClDevice, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE));
cl_int retVal = CL_SUCCESS;

View File

@@ -322,12 +322,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndDstPtrEqualSrcPtrWhenWr
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedTaskLevel = 0u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueWriteBufferRectTest, givenOutOfOrderQueueAndDstPtrEqualSrcPtrWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
cl_int retVal = CL_SUCCESS;
@@ -352,7 +347,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenOutOfOrderQueueAndDstPtrEqualSrcPtrWhe
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(CL_SUCCESS, pCmdOOQ->flush());
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(pCmdOOQ->taskLevel, 0u);
}
HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
@@ -393,15 +388,11 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndDstPtrEqualSrcPtrWithEv
EXPECT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, event);
auto expectedTaskLevel = 19u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
auto pEvent = (Event *)event;
EXPECT_EQ(19u, pEvent->taskLevel);
EXPECT_EQ(19u, pCmdQ->taskLevel);
EXPECT_EQ(CL_COMMAND_WRITE_BUFFER_RECT, (const int)pEvent->getCommandType());
EXPECT_EQ(expectedTaskLevel, pEvent->taskLevel);
EXPECT_EQ(expectedTaskLevel, pCmdQ->taskLevel);
pEvent->release();
}
HWTEST_F(EnqueueWriteBufferRectTest, givenOutOfOrderQueueAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
@@ -449,16 +440,11 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenOutOfOrderQueueAndDstPtrEqualSrcPtrWit
EXPECT_EQ(CL_SUCCESS, retVal);
ASSERT_NE(nullptr, event);
auto expectedTaskLevel = 19u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
auto pEvent = (Event *)event;
EXPECT_EQ(19u, pEvent->taskLevel);
EXPECT_EQ(19u, pCmdOOQ->taskLevel);
EXPECT_EQ(CL_COMMAND_WRITE_BUFFER_RECT, (const int)pEvent->getCommandType());
EXPECT_EQ(expectedTaskLevel, pEvent->taskLevel);
EXPECT_EQ(expectedTaskLevel, pCmdOOQ->taskLevel);
pCmdOOQ->flush();
pEvent->release();
}
HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndRowPitchEqualZeroAndDstPtrEqualSrcPtrWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
@@ -484,12 +470,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndRowPitchEqualZeroAndDst
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedTaskLevel = 0u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndSlicePitchEqualZeroAndDstPtrEqualSrcPtrWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
cl_int retVal = CL_SUCCESS;
@@ -514,12 +495,7 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndSlicePitchEqualZeroAndD
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto &productHelper = context->getDevice(0)->getProductHelper();
auto expectedTaskLevel = 0u;
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndMemObjWithOffsetPointTheSameStorageWithHostWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
cl_int retVal = CL_SUCCESS;
@@ -545,12 +521,8 @@ HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndMemObjWithOffsetPointTh
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedTaskLevel = 0u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueWriteBufferRectTest, givenInOrderQueueAndMemObjWithOffsetPointDiffrentStorageWithHostWhenWriteBufferIsExecutedThenTaskLevelShouldBeIncreased) {
cl_int retVal = CL_SUCCESS;

View File

@@ -338,12 +338,7 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndEnabledSupportCpuCopies
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedTaskLevel = 0u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrZeroCopyBufferEqualSrcPtrWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
@@ -362,12 +357,7 @@ HWTEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopie
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
auto expectedTaskLevel = 0u;
auto &productHelper = context->getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
expectedTaskLevel++;
}
EXPECT_EQ(pCmdQ->taskLevel, expectedTaskLevel);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrZeroCopyBufferEqualSrcPtrWhenWriteBufferIsExecutedThenTaskLevelShouldBeIncreased) {
DebugManagerStateRestore dbgRestore;

View File

@@ -48,10 +48,6 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, givenCompressedGmmWhenAskingForCpuOperation
}
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenUnalignedReadPtrWhenReadingBufferThenMemoryIsReadCorrectly) {
if (context->getDevice(0)->getProductHelper().isNewCoherencyModelSupported()) {
// This test assumes that write buffer will be serviced on cpu
GTEST_SKIP();
}
DebugManagerStateRestore restorer;
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal;
@@ -93,10 +89,6 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenUnalignedReadPtrWhenReadingBufferThenM
}
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenUnalignedSrcPtrWhenWritingBufferThenMemoryIsWrittenCorrectly) {
if (context->getDevice(0)->getProductHelper().isNewCoherencyModelSupported()) {
// This test assumes that write buffer will be serviced on cpu
GTEST_SKIP();
}
DebugManagerStateRestore restorer;
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal;
@@ -144,7 +136,7 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenUnalignedSrcPtrWhenWritingBufferThenMe
delete[] bufferPtrBase;
}
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndCpuCachingAvailableWhenReadingWritingMemoryThenCpuReadWriteIsAllowed) {
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresWhenReadingWritingMemoryThenCpuReadWriteIsAllowed) {
DebugManagerStateRestore restorer;
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal;
@@ -160,14 +152,13 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndCpuCachingA
auto mockContext = std::unique_ptr<MockContext>(new MockContext(mockDevice.get()));
auto memoryManager = static_cast<OsAgnosticMemoryManager *>(mockDevice->getMemoryManager());
memoryManager->turnOnFakingBigAllocations();
auto &productHelper = mockDevice->getProductHelper();
auto isZeroCopyAllowed = productHelper.isZeroCopyCpuAccessPreferred();
std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, alignedBufferPtr, retVal));
EXPECT_EQ(retVal, CL_SUCCESS);
EXPECT_EQ(isZeroCopyAllowed, buffer->isMemObjZeroCopy());
EXPECT_TRUE(buffer->isMemObjZeroCopy());
// zeroCopy == true && aligned/unaligned hostPtr
EXPECT_EQ(isZeroCopyAllowed, buffer->isReadWriteOnCpuPreferred(alignedHostPtr, MemoryConstants::cacheLineSize + 1, mockDevice->getDevice()));
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(alignedHostPtr, MemoryConstants::cacheLineSize + 1, mockDevice->getDevice()));
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(unalignedHostPtr, MemoryConstants::cacheLineSize, mockDevice->getDevice()));
buffer.reset(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, unalignedBufferPtr, retVal));
@@ -181,24 +172,24 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndCpuCachingA
// platform LP == true && size <= 10 MB
mockDevice->deviceInfo.platformLP = true;
EXPECT_EQ(isZeroCopyAllowed, buffer->isReadWriteOnCpuPreferred(smallBufferPtr, 1 * MemoryConstants::megaByte, mockDevice->getDevice()));
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(smallBufferPtr, 1 * MemoryConstants::megaByte, mockDevice->getDevice()));
// platform LP == false && size <= 10 MB
mockDevice->deviceInfo.platformLP = false;
EXPECT_EQ(isZeroCopyAllowed, buffer->isReadWriteOnCpuPreferred(smallBufferPtr, 1 * MemoryConstants::megaByte, mockDevice->getDevice()));
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(smallBufferPtr, 1 * MemoryConstants::megaByte, mockDevice->getDevice()));
buffer.reset(Buffer::create(mockContext.get(), CL_MEM_ALLOC_HOST_PTR, largeBufferSize, nullptr, retVal));
// platform LP == false && size > 10 MB
mockDevice->deviceInfo.platformLP = false;
EXPECT_EQ(isZeroCopyAllowed, buffer->isReadWriteOnCpuPreferred(buffer->getCpuAddress(), largeBufferSize, mockDevice->getDevice()));
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(buffer->getCpuAddress(), largeBufferSize, mockDevice->getDevice()));
alignedFree(smallBufferPtr);
alignedFree(alignedHostPtr);
alignedFree(alignedBufferPtr);
}
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndIsZeroCopyCpuAccessPreferredWhenReadingWritingMemoryThenCpuReadWriteIsNotAllowed) {
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresWhenReadingWritingMemoryThenCpuReadWriteIsNotAllowed) {
cl_int retVal;
size_t size = MemoryConstants::cacheLineSize;
auto alignedBufferPtr = alignedMalloc(MemoryConstants::cacheLineSize + 1, MemoryConstants::cacheLineSize);
@@ -213,11 +204,10 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndIsZeroCopyC
auto memoryManager = static_cast<OsAgnosticMemoryManager *>(mockDevice->getMemoryManager());
memoryManager->turnOnFakingBigAllocations();
auto &productHelper = mockDevice->getProductHelper();
auto isZeroCopyAllowed = productHelper.isZeroCopyCpuAccessPreferred();
std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, alignedBufferPtr, retVal));
EXPECT_EQ(retVal, CL_SUCCESS);
EXPECT_EQ(isZeroCopyAllowed, buffer->isMemObjZeroCopy());
EXPECT_TRUE(buffer->isMemObjZeroCopy());
// non blocking
EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_NDRANGE_KERNEL, false, size, unalignedHostPtr, 0u, nullptr));
@@ -252,14 +242,14 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, givenDebugVariableToDisableCpuCopiesWhenBuf
std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_ALLOC_HOST_PTR, MemoryConstants::pageSize, nullptr, retVal));
EXPECT_EQ(retVal, CL_SUCCESS);
auto mappingAllowed = buffer->mappingOnCpuAllowed();
EXPECT_TRUE(buffer->isMemObjZeroCopy());
EXPECT_EQ(mappingAllowed, mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
EXPECT_EQ(mappingAllowed, mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_WRITE_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
EXPECT_TRUE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
EXPECT_TRUE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_WRITE_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
debugManager.flags.DoCpuCopyOnReadBuffer.set(0);
EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
EXPECT_EQ(mappingAllowed, mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_WRITE_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
EXPECT_TRUE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_WRITE_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
debugManager.flags.DoCpuCopyOnWriteBuffer.set(0);
EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
@@ -281,9 +271,9 @@ TEST(ReadWriteBufferOnCpu, givenNoHostPtrAndAlignedSizeWhenMemoryAllocationIsInN
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, nullptr, retVal));
ASSERT_NE(nullptr, buffer.get());
auto isZeroCopyCpuAccessPreferred = device->getProductHelper().isZeroCopyCpuAccessPreferred();
EXPECT_EQ(isZeroCopyCpuAccessPreferred, buffer->isReadWriteOnCpuAllowed(device->getDevice()));
EXPECT_EQ(isZeroCopyCpuAccessPreferred, buffer->isReadWriteOnCpuPreferred(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize, device->getDevice()));
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(device->getDevice()));
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize, device->getDevice()));
reinterpret_cast<MemoryAllocation *>(buffer->getGraphicsAllocation(device->getRootDeviceIndex()))->overrideMemoryPool(MemoryPool::systemCpuInaccessible);
// read write on CPU is allowed, but not preferred. We can access this memory via Lock.
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(device->getDevice()));
@@ -310,9 +300,7 @@ TEST(ReadWriteBufferOnCpu, givenPointerThatRequiresCpuCopyWhenCpuCopyIsEvaluated
EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, false, MemoryConstants::pageSize, nullptr, 0u, nullptr));
memoryManager->cpuCopyRequired = true;
// cpu copy is never allowed with new coherency model
auto isZeroCopyCpuAccessPreferred = device->getProductHelper().isZeroCopyCpuAccessPreferred();
EXPECT_EQ(isZeroCopyCpuAccessPreferred, mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, false, MemoryConstants::pageSize, nullptr, 0u, nullptr));
EXPECT_TRUE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, false, MemoryConstants::pageSize, nullptr, 0u, nullptr));
}
TEST(ReadWriteBufferOnCpu, givenPointerThatRequiresCpuCopyButItIsNotPossibleWhenCpuCopyIsEvaluatedThenFalseIsReturned) {

View File

@@ -252,26 +252,24 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenDcFlushWhenFinishingThenTaskC
auto ptr = mockCmdQueue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, sizeof(tempBuffer), 0, nullptr, nullptr, retVal);
EXPECT_EQ(retVal, CL_SUCCESS);
auto &productHelper = pDevice->getProductHelper();
auto expectFlushForMapUnmap = !productHelper.isZeroCopyCpuAccessPreferred();
EXPECT_EQ(1u + expectFlushForMapUnmap, commandStreamReceiver.peekLatestSentTaskCount());
EXPECT_EQ(1u, commandStreamReceiver.peekLatestSentTaskCount());
// cmdQ task count = 2, finish again
mockCmdQueue.finish();
EXPECT_EQ(1u + expectFlushForMapUnmap, commandStreamReceiver.peekLatestSentTaskCount());
EXPECT_EQ(1u, commandStreamReceiver.peekLatestSentTaskCount());
// finish again - dont flush task again
mockCmdQueue.finish();
EXPECT_EQ(1u + expectFlushForMapUnmap, commandStreamReceiver.peekLatestSentTaskCount());
EXPECT_EQ(1u, commandStreamReceiver.peekLatestSentTaskCount());
// finish(dcFlush=true) from MapBuffer again - dont call FinishTask n finished queue
retVal = mockCmdQueue.enqueueUnmapMemObject(buffer, ptr, 0, nullptr, nullptr);
EXPECT_EQ(retVal, CL_SUCCESS);
ptr = mockCmdQueue.enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, sizeof(tempBuffer), 0, nullptr, nullptr, retVal);
EXPECT_EQ(retVal, CL_SUCCESS);
EXPECT_EQ(1u + expectFlushForMapUnmap * 2, commandStreamReceiver.peekLatestSentTaskCount());
EXPECT_EQ(1u, commandStreamReceiver.peekLatestSentTaskCount());
// cleanup
retVal = mockCmdQueue.enqueueUnmapMemObject(buffer, ptr, 0, nullptr, nullptr);

View File

@@ -148,11 +148,7 @@ TEST_F(PerformanceHintEnqueueBufferTest, GivenNonBlockingReadAndSharedMemWhenEnq
nullptr,
nullptr);
if (isZeroCopyAllowed) {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_READ_BUFFER_RECT_DOESNT_REQUIRES_COPY_DATA], static_cast<cl_mem>(buffer), address);
} else {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_BUFFER_DOESNT_MEET_ALIGNMENT_RESTRICTIONS], address, MemoryConstants::cacheLineSize, MemoryConstants::pageSize, MemoryConstants::pageSize);
}
EXPECT_TRUE(containsHint(expectedHint, userData));
}
@@ -188,11 +184,7 @@ TEST_F(PerformanceHintEnqueueBufferTest, GivenNonBlockingWriteAndBufferSharesMem
0,
nullptr,
nullptr);
if (isZeroCopyAllowed) {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_WRITE_BUFFER_DOESNT_REQUIRE_COPY_DATA], static_cast<cl_mem>(buffer), address);
} else {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_WRITE_BUFFER_REQUIRES_COPY_DATA], static_cast<cl_mem>(buffer), address);
}
EXPECT_TRUE(containsHint(expectedHint, userData));
}
@@ -228,11 +220,7 @@ TEST_F(PerformanceHintEnqueueBufferTest, GivenBlockingWriteAndBufferSharesMemWit
0,
nullptr,
nullptr);
if (isZeroCopyAllowed) {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_WRITE_BUFFER_DOESNT_REQUIRE_COPY_DATA], static_cast<cl_mem>(buffer), address);
} else {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_WRITE_BUFFER_REQUIRES_COPY_DATA], static_cast<cl_mem>(buffer), address);
}
EXPECT_TRUE(containsHint(expectedHint, userData));
}
@@ -268,11 +256,7 @@ TEST_F(PerformanceHintEnqueueBufferTest, GivenNonBlockingReadAndBufferSharesMemW
0,
nullptr,
nullptr);
if (isZeroCopyAllowed) {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_READ_BUFFER_DOESNT_REQUIRE_COPY_DATA], static_cast<cl_mem>(buffer), address);
} else {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_READ_BUFFER_REQUIRES_COPY_DATA], static_cast<cl_mem>(buffer), address);
}
EXPECT_TRUE(containsHint(expectedHint, userData));
}
@@ -308,11 +292,7 @@ TEST_F(PerformanceHintEnqueueBufferTest, GivenBlockingReadAndBufferSharesMemWith
0,
nullptr,
nullptr);
if (isZeroCopyAllowed) {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_READ_BUFFER_DOESNT_REQUIRE_COPY_DATA], static_cast<cl_mem>(buffer), address);
} else {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_READ_BUFFER_REQUIRES_COPY_DATA], static_cast<cl_mem>(buffer), address);
}
EXPECT_TRUE(containsHint(expectedHint, userData));
}
@@ -363,11 +343,8 @@ TEST_F(PerformanceHintEnqueueBufferTest, GivenNonBlockingWriteAndSharedMemWhenEn
0,
nullptr,
nullptr);
if (isZeroCopyAllowed) {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_WRITE_BUFFER_RECT_DOESNT_REQUIRE_COPY_DATA], static_cast<cl_mem>(buffer));
} else {
snprintf(expectedHint, DriverDiagnostics::maxHintStringSize, DriverDiagnostics::hintFormat[CL_ENQUEUE_WRITE_BUFFER_RECT_REQUIRES_COPY_DATA], static_cast<cl_mem>(buffer));
}
EXPECT_TRUE(containsHint(expectedHint, userData));
}

View File

@@ -141,8 +141,6 @@ struct PerformanceHintEnqueueBufferTest : public PerformanceHintEnqueueTest {
MemoryConstants::cacheLineSize,
address,
retVal);
auto &productHelper = context->getDevice(0)->getProductHelper();
isZeroCopyAllowed = productHelper.isZeroCopyCpuAccessPreferred();
}
void TearDown() override {
@@ -152,7 +150,6 @@ struct PerformanceHintEnqueueBufferTest : public PerformanceHintEnqueueTest {
}
void *address = nullptr;
Buffer *buffer = nullptr;
bool isZeroCopyAllowed = true;
};
struct PerformanceHintEnqueueReadBufferTest : public PerformanceHintEnqueueBufferTest,
@@ -215,9 +212,6 @@ struct PerformanceHintEnqueueMapTest : public PerformanceHintEnqueueTest,
void SetUp() override {
PerformanceHintEnqueueTest::SetUp();
if (context->getDevice(0)->getRootDeviceEnvironment().getProductHelper().isNewCoherencyModelSupported()) {
GTEST_SKIP();
}
}
void TearDown() override {

View File

@@ -376,8 +376,7 @@ TEST(Buffer, givenNullptrPassedToBufferCreateWhenNoSharedContextOrCompressedBuff
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, nullptr, retVal));
ASSERT_NE(nullptr, buffer.get());
auto isZeroCopyCpuAccessPreferred = device->getProductHelper().isZeroCopyCpuAccessPreferred();
if (MemoryPoolHelper::isSystemMemoryPool(buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getMemoryPool()) && isZeroCopyCpuAccessPreferred) {
if (MemoryPoolHelper::isSystemMemoryPool(buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getMemoryPool())) {
EXPECT_EQ(AllocationType::bufferHostMemory, buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getAllocationType());
} else {
EXPECT_EQ(AllocationType::buffer, buffer->getGraphicsAllocation(device->getRootDeviceIndex())->getAllocationType());
@@ -412,17 +411,13 @@ TEST(Buffer, givenAlignedHostPtrPassedToBufferCreateWhenNoSharedContextOrCompres
cl_int retVal = 0;
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
unsigned char hostPtr[MemoryConstants::pageSize];
void *hostPtr = reinterpret_cast<void *>(0x3000);
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, hostPtr, retVal));
ASSERT_NE(nullptr, buffer.get());
if (!device->getProductHelper().isZeroCopyCpuAccessPreferred()) {
EXPECT_EQ(AllocationType::buffer, buffer->getMultiGraphicsAllocation().getAllocationType());
} else {
EXPECT_EQ(AllocationType::bufferHostMemory, buffer->getMultiGraphicsAllocation().getAllocationType());
}
}
TEST(Buffer, givenAllocHostPtrFlagPassedToBufferCreateWhenNoSharedContextOrCompressedBuffersThenBuffersAllocationTypeIsBufferHostMemory) {
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
@@ -434,12 +429,8 @@ TEST(Buffer, givenAllocHostPtrFlagPassedToBufferCreateWhenNoSharedContextOrCompr
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, nullptr, retVal));
ASSERT_NE(nullptr, buffer.get());
if (!device->getProductHelper().isZeroCopyCpuAccessPreferred()) {
EXPECT_EQ(AllocationType::buffer, buffer->getMultiGraphicsAllocation().getAllocationType());
} else {
EXPECT_EQ(AllocationType::bufferHostMemory, buffer->getMultiGraphicsAllocation().getAllocationType());
}
}
TEST(Buffer, givenCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferCompressedTypeIsReturnedIn64Bit) {
MockContext context;
@@ -449,7 +440,7 @@ TEST(Buffer, givenCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferC
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_TRUE(compressionEnabled);
EXPECT_EQ(AllocationType::buffer, type);
}
@@ -462,7 +453,7 @@ TEST(Buffer, givenCompressedBuffersDisabledLocalMemoryEnabledWhenAllocationTypeI
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::buffer, type);
}
@@ -476,7 +467,7 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledWhenAllocationTypeIsQuerie
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::bufferHostMemory, type);
}
@@ -490,7 +481,7 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledWhenAllocationTypeIsQueried
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::buffer, type);
}
@@ -504,7 +495,7 @@ TEST(Buffer, givenAllocHostPtrFlagWhenAllocationTypeIsQueriedThenBufferTypeIsRet
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::buffer, type);
}
@@ -518,7 +509,7 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledAndCompressedBuffersEnable
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::bufferHostMemory, type);
}
@@ -532,7 +523,7 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledAndCompressedBuffersEnabled
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true);
EXPECT_TRUE(compressionEnabled);
EXPECT_EQ(AllocationType::buffer, type);
}
@@ -546,7 +537,7 @@ TEST(Buffer, givenUseHostPointerFlagAndForceSharedPhysicalStorageWhenLocalMemory
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::bufferHostMemory, type);
}
@@ -560,7 +551,7 @@ TEST(Buffer, givenAllocHostPtrFlagAndCompressedBuffersEnabledWhenAllocationTypeI
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_TRUE(compressionEnabled);
EXPECT_EQ(AllocationType::buffer, type);
}
@@ -573,24 +564,11 @@ TEST(Buffer, givenZeroFlagsNoSharedContextAndCompressedBuffersDisabledWhenAlloca
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::buffer, type);
}
TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledAndCompressedBuffersEnabledAndCachingOnCpuNotAvailableWhenAllocationTypeIsQueriedThenBufferMemoryTypeIsReturned) {
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice());
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false, false);
EXPECT_TRUE(compressionEnabled);
EXPECT_EQ(AllocationType::buffer, type);
}
TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInSystemMemoryPoolAndCopyOnCpuDisabledThenAllocationIsWrittenByEnqueueWriteBuffer) {
DebugManagerStateRestore restorer;
debugManager.flags.CopyHostPtrOnCpu.set(0);
@@ -771,13 +749,11 @@ TEST_F(CompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHostPtrWhe
buffer.reset(Buffer::create(context.get(), 0, bufferSize, nullptr, retVal));
auto allocation = buffer->getGraphicsAllocation(device->getRootDeviceIndex());
auto &productHelper = context->getDevice(0)->getProductHelper();
if (MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool()) && productHelper.isZeroCopyCpuAccessPreferred()) {
EXPECT_EQ(allocation->getAllocationType(), AllocationType::bufferHostMemory);
EXPECT_TRUE(buffer->isMemObjZeroCopy());
if (MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool())) {
EXPECT_EQ(allocation->getAllocationType(), AllocationType::bufferHostMemory);
} else {
EXPECT_EQ(allocation->getAllocationType(), AllocationType::buffer);
EXPECT_FALSE(buffer->isMemObjZeroCopy());
}
auto memoryManager = static_cast<MockMemoryManager *>(device->getExecutionEnvironment()->memoryManager.get());
@@ -787,11 +763,11 @@ TEST_F(CompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHostPtrWhe
allocation = buffer->getGraphicsAllocation(device->getRootDeviceIndex());
auto &gfxCoreHelper = context->getDevice(0)->getGfxCoreHelper();
if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) {
EXPECT_FALSE(buffer->isMemObjZeroCopy());
EXPECT_EQ(allocation->getAllocationType(), AllocationType::buffer);
EXPECT_EQ(!memoryManager->allocate32BitGraphicsMemoryImplCalled, allocation->isCompressionEnabled());
} else if (!productHelper.isZeroCopyCpuAccessPreferred()) {
EXPECT_EQ(allocation->getAllocationType(), AllocationType::buffer);
} else {
EXPECT_TRUE(buffer->isMemObjZeroCopy());
EXPECT_EQ(allocation->getAllocationType(), AllocationType::bufferHostMemory);
}
}
@@ -807,12 +783,9 @@ TEST_F(CompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThenSelect
buffer.reset(Buffer::create(context.get(), 0, bufferSize, nullptr, retVal));
auto graphicsAllocation = buffer->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex());
auto &gfxCoreHelper = context->getDevice(0)->getGfxCoreHelper();
auto &productHelper = context->getDevice(0)->getProductHelper();
if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) {
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::buffer);
EXPECT_EQ(!memoryManager->allocate32BitGraphicsMemoryImplCalled, graphicsAllocation->isCompressionEnabled());
} else if (!productHelper.isZeroCopyCpuAccessPreferred()) {
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::buffer);
} else {
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::bufferHostMemory);
}
@@ -869,7 +842,6 @@ TEST_F(CompressedBuffersCopyHostMemoryTests, givenCompressedBufferWhenCopyFromHo
buffer.reset(Buffer::create(context.get(), CL_MEM_COPY_HOST_PTR, bufferSize, hostPtr, retVal));
auto graphicsAllocation = buffer->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex());
auto &gfxCoreHelper = context->getDevice(0)->getGfxCoreHelper();
auto &productHelper = context->getDevice(0)->getProductHelper();
if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) {
EXPECT_TRUE(graphicsAllocation->isCompressionEnabled());
EXPECT_EQ(1u, mockCmdQ->writeBufferCounter);
@@ -878,7 +850,7 @@ TEST_F(CompressedBuffersCopyHostMemoryTests, givenCompressedBufferWhenCopyFromHo
EXPECT_EQ(bufferSize, mockCmdQ->writeBufferSize);
EXPECT_EQ(hostPtr, mockCmdQ->writeBufferPtr);
} else {
EXPECT_EQ(!productHelper.isNewCoherencyModelSupported(), graphicsAllocation->getAllocationType() == AllocationType::bufferHostMemory);
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::bufferHostMemory);
EXPECT_EQ(0u, mockCmdQ->writeBufferCounter);
EXPECT_FALSE(mockCmdQ->writeBufferBlocking);
EXPECT_EQ(0u, mockCmdQ->writeBufferOffset);
@@ -1037,8 +1009,7 @@ TEST_P(NoHostPtr, WhenGettingAllocationTypeThenCorrectBufferTypeIsReturned) {
ASSERT_NE(nullptr, buffer);
auto allocation = buffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex());
auto &productHelper = context->getDevice(0)->getProductHelper();
if (MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool()) && productHelper.isZeroCopyCpuAccessPreferred()) {
if (MemoryPoolHelper::isSystemMemoryPool(allocation->getMemoryPool())) {
EXPECT_EQ(allocation->getAllocationType(), AllocationType::bufferHostMemory);
} else {
EXPECT_EQ(allocation->getAllocationType(), AllocationType::buffer);
@@ -1374,10 +1345,7 @@ TEST(Buffers64on32Tests, given32BitBufferCreatedWithUseHostPtrFlagThatIsZeroCopy
{
debugManager.flags.Force32bitAddressing.set(true);
MockContext context;
auto isNewCoherencyModelSupported = context.getDevice(0)->getProductHelper().isNewCoherencyModelSupported();
if (isNewCoherencyModelSupported) {
GTEST_SKIP();
}
auto size = MemoryConstants::pageSize;
void *ptr = (void *)0x1000;
auto ptrOffset = MemoryConstants::cacheLineSize;
@@ -1391,15 +1359,10 @@ TEST(Buffers64on32Tests, given32BitBufferCreatedWithUseHostPtrFlagThatIsZeroCopy
(void *)offsetedPtr,
retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ((void *)offsetedPtr, buffer->getCpuAddressForMapping());
auto &productHelper = context.getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
EXPECT_FALSE(buffer->isMemObjZeroCopy());
} else {
EXPECT_TRUE(buffer->isMemObjZeroCopy());
EXPECT_EQ((void *)offsetedPtr, buffer->getCpuAddressForMapping());
EXPECT_EQ((void *)offsetedPtr, buffer->getCpuAddressForMemoryTransfer());
}
delete buffer;
debugManager.flags.Force32bitAddressing.set(false);
@@ -1421,8 +1384,8 @@ TEST(Buffers64on32Tests, given32BitBufferCreatedWithAllocHostPtrFlagThatIsZeroCo
nullptr,
retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto &productHelper = context.getDevice(0)->getProductHelper();
EXPECT_EQ(productHelper.isZeroCopyCpuAccessPreferred(), buffer->isMemObjZeroCopy());
EXPECT_TRUE(buffer->isMemObjZeroCopy());
EXPECT_EQ(buffer->getCpuAddress(), buffer->getCpuAddressForMapping());
EXPECT_EQ(buffer->getCpuAddress(), buffer->getCpuAddressForMemoryTransfer());

View File

@@ -327,9 +327,7 @@ TEST_F(Image2dFromBufferTest, givenBufferWhenImageFromBufferThenIsImageFromBuffe
EXPECT_TRUE(imageFromBuffer->isImageFromBuffer());
auto graphicsAllocation = imageFromBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
auto isHostMemory = AllocationType::bufferHostMemory == graphicsAllocation->getAllocationType();
auto isDevMemory = AllocationType::buffer == graphicsAllocation->getAllocationType();
EXPECT_TRUE(isHostMemory || isDevMemory);
EXPECT_TRUE(AllocationType::bufferHostMemory == graphicsAllocation->getAllocationType());
buffer->release();
imageDesc.mem_object = memObj;

View File

@@ -170,22 +170,22 @@ TEST(MemObjHelper, givenContextWithMultipleRootDevicesWhenIsSuitableForCompressi
EXPECT_FALSE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true));
}
TEST(MemObjHelper, givenCompressionEnabledButNotPreferredWhenCompressionHintIsPassedThenCompressionIsNotUsed) {
TEST(MemObjHelper, givenCompressionEnabledButNotPreferredWhenCompressionHintIsPassedThenCompressionIsUsed) {
cl_mem_flags_intel flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL;
cl_mem_flags flags = CL_MEM_COMPRESSED_HINT_INTEL;
MockContext context;
MemoryProperties memoryProperties =
ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_DEFAULT;
EXPECT_FALSE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false));
EXPECT_TRUE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false));
flags = CL_MEM_COMPRESSED_HINT_INTEL;
flagsIntel = 0;
memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice());
EXPECT_FALSE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false));
EXPECT_TRUE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false));
flagsIntel = CL_MEM_COMPRESSED_HINT_INTEL;
flags = 0;
memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, &context.getDevice(0)->getDevice());
EXPECT_FALSE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false));
EXPECT_TRUE(MemObjHelper::isSuitableForCompression(true, memoryProperties, context, false));
}
TEST(MemObjHelper, givenCompressionEnabledAndPreferredWhenCompressionHintIsPassedThenCompressionIsUsed) {
@@ -431,7 +431,7 @@ TEST(MemObjHelper, givenDifferentCapabilityAndDebugFlagValuesWhenCheckingBufferC
bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*defaultHwInfo), memoryProperties, context, true);
MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(
memoryProperties, compressionEnabled, false, true);
memoryProperties, compressionEnabled, false);
bool expectBufferCompressed = ftrRenderCompressedBuffers && (enableMultiTileCompressionValue == 1);
if (expectBufferCompressed) {
@@ -483,7 +483,7 @@ TEST(MemObjHelper, givenDifferentValuesWhenCheckingBufferCompressionSupportThenC
bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*defaultHwInfo), memoryProperties, context, true);
MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(
memoryProperties, compressionEnabled, false, true);
memoryProperties, compressionEnabled, false);
bool isCompressionDisabled = isValueSet(flags, CL_MEM_UNCOMPRESSED_HINT_INTEL) ||
isValueSet(flagsIntel, CL_MEM_UNCOMPRESSED_HINT_INTEL);

View File

@@ -13,7 +13,6 @@
#include "opencl/source/cl_device/cl_device.h"
#include "opencl/source/mem_obj/buffer.h"
#include "opencl/test/unit_test/fixtures/cl_device_fixture.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "gtest/gtest.h"
@@ -63,6 +62,7 @@ std::tuple<uint64_t, size_t, size_t, int, bool, bool> inputs[] = {std::make_tupl
std::make_tuple(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), cacheLinedAlignedSize, MemoryConstants::preferredAlignment, cacheLinedAlignedSize, true, false),
std::make_tuple(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), cacheLinedMisAlignedSize, MemoryConstants::preferredAlignment, cacheLinedMisAlignedSize, false, false),
std::make_tuple(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), pageAlignSize, MemoryConstants::preferredAlignment, pageAlignSize, true, false),
std::make_tuple(static_cast<cl_mem_flags>(CL_MEM_USE_HOST_PTR), cacheLinedMisAlignedSize, MemoryConstants::cacheLineSize, cacheLinedAlignedSize, true, false),
std::make_tuple(static_cast<cl_mem_flags>(CL_MEM_COPY_HOST_PTR), cacheLinedMisAlignedSize, MemoryConstants::preferredAlignment, cacheLinedMisAlignedSize, true, true),
std::make_tuple(static_cast<cl_mem_flags>(CL_MEM_COPY_HOST_PTR), cacheLinedMisAlignedSize, MemoryConstants::preferredAlignment, cacheLinedMisAlignedSize, true, false),
std::make_tuple(0, 0, 0, cacheLinedMisAlignedSize, true, false),
@@ -74,7 +74,6 @@ TEST_P(ZeroCopyBufferTest, GivenCacheAlignedPointerWhenCreatingBufferThenZeroCop
// misalign the pointer
if (misalignPointer && passedPtr) {
passedPtr += 1;
size -= 1;
}
auto buffer = Buffer::create(
@@ -84,8 +83,6 @@ TEST_P(ZeroCopyBufferTest, GivenCacheAlignedPointerWhenCreatingBufferThenZeroCop
passedPtr,
retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto &productHelper = pClDevice->getProductHelper();
shouldBeZeroCopy = shouldBeZeroCopy && productHelper.isZeroCopyCpuAccessPreferred();
EXPECT_EQ(shouldBeZeroCopy, buffer->isMemObjZeroCopy()) << "Zero Copy not handled properly";
if (!shouldBeZeroCopy && flags & CL_MEM_USE_HOST_PTR) {
EXPECT_NE(buffer->getCpuAddress(), hostPtr);
@@ -151,7 +148,7 @@ TEST(ZeroCopyWithDebugFlag, GivenBufferInputsThatWouldResultInZeroCopyAndDisable
EXPECT_NE(mapAllocation, bufferAllocation);
}
TEST(ZeroCopyBufferWith32BitAddressing, GivenDeviceSupporting32BitAddressingAndOldCoherencyModelWhenAskedForBufferCreationFromHostPtrThenNonZeroCopyBufferIsReturned) {
TEST(ZeroCopyBufferWith32BitAddressing, GivenDeviceSupporting32BitAddressingWhenAskedForBufferCreationFromHostPtrThenNonZeroCopyBufferIsReturned) {
DebugManagerStateRestore dbgRestorer;
debugManager.flags.Force32bitAddressing.set(true);
MockContext context;
@@ -161,13 +158,8 @@ TEST(ZeroCopyBufferWith32BitAddressing, GivenDeviceSupporting32BitAddressingAndO
std::unique_ptr<Buffer> buffer(Buffer::create(&context, CL_MEM_USE_HOST_PTR, size, hostPtr, retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
auto &productHelper = context.getDevice(0)->getProductHelper();
if (!productHelper.isZeroCopyCpuAccessPreferred()) {
EXPECT_FALSE(buffer->isMemObjZeroCopy());
} else {
EXPECT_TRUE(buffer->isMemObjZeroCopy());
}
EXPECT_TRUE(buffer->isMemObjZeroCopy());
if constexpr (is64bit) {
EXPECT_TRUE(buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->is32BitAllocation());
}

View File

@@ -1032,9 +1032,7 @@ TEST(UnifiedSharedMemoryTransferCalls, givenHostUsmAllocationWhenPtrIsUsedForTra
if (mockContext.getDevice(0u)->getHardwareInfo().capabilityTable.supportsOcl21Features == false) {
GTEST_SKIP();
}
if (mockContext.getDevice(0u)->getProductHelper().isNewCoherencyModelSupported()) {
GTEST_SKIP();
}
auto status = CL_INVALID_PLATFORM;
cl_device_id clDevice = mockContext.getDevice(0u);

View File

@@ -12,8 +12,6 @@
#include "shared/test/common/libult/ult_command_stream_receiver.h"
#include "opencl/source/command_queue/command_queue_hw.h"
#include "opencl/source/event/event.h"
#include "opencl/source/event/event_builder.h"
#include <optional>
@@ -183,15 +181,7 @@ class MockCommandQueue : public CommandQueue {
cl_int enqueueReadBuffer(Buffer *buffer, cl_bool blockingRead, size_t offset, size_t size, void *ptr,
GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList,
const cl_event *eventWaitList, cl_event *event) override {
if (event != nullptr) {
EventBuilder eventBuilder;
eventBuilder.create<Event>(this, CL_COMMAND_READ_BUFFER, CompletionStamp::notReady, 0);
*event = eventBuilder.getEvent();
}
return CL_SUCCESS;
}
const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; }
cl_int enqueueReadImage(Image *srcImage, cl_bool blockingRead, const size_t *origin, const size_t *region,
size_t rowPitch, size_t slicePitch, void *ptr,

View File

@@ -85,6 +85,7 @@ TEST_F(ClDrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferAllocationTh
retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(buffer->isMemObjZeroCopy());
auto bufferAddress = buffer->getGraphicsAllocation(rootDeviceIndex)->getGpuAddress();
auto baseAddress = buffer->getGraphicsAllocation(rootDeviceIndex)->getGpuBaseAddress();
@@ -95,10 +96,6 @@ TEST_F(ClDrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferAllocationTh
TEST_F(ClDrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferCreatedFromHostPtrThen32BitBufferIsReturned) {
DebugManagerStateRestore dbgRestorer;
auto isNewCoherencyModelSupported = pClDevice->getProductHelper().isNewCoherencyModelSupported();
if (isNewCoherencyModelSupported) {
GTEST_SKIP();
}
mock->ioctlExpected.gemUserptr = 1;
mock->ioctlExpected.gemWait = 1;
mock->ioctlExpected.gemClose = 1;
@@ -155,10 +152,6 @@ TEST_F(ClDrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferCreatedFromH
TEST_F(ClDrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferCreatedFrom64BitHostPtrThen32BitBufferIsReturned) {
DebugManagerStateRestore dbgRestorer;
auto isNewCoherencyModelSupported = pClDevice->getProductHelper().isNewCoherencyModelSupported();
if (isNewCoherencyModelSupported) {
GTEST_SKIP();
}
{
if (is32bit) {
mock->ioctlExpected.total = -1;
@@ -198,6 +191,7 @@ TEST_F(ClDrmMemoryManagerTest, Given32bitAllocatorWhenAskedForBufferCreatedFrom6
auto allocationCpuPtr = drmAllocation->getUnderlyingBuffer();
auto allocationPageOffset = ptrDiff(allocationCpuPtr, alignDown(allocationCpuPtr, MemoryConstants::pageSize));
auto bufferObject = drmAllocation->getBO();
EXPECT_EQ(allocationPageOffset, ptrOffset);
auto boAddress = bufferObject->peekAddress();

View File

@@ -398,7 +398,7 @@ XE_HPG_CORETEST_F(BlitXeHpgCoreTests, givenCompressedBufferWhenProgrammingBltCom
auto csr = static_cast<UltCommandStreamReceiver<FamilyType> *>(clDevice->getEngine(aub_stream::EngineType::ENGINE_BCS, EngineUsage::regular).commandStreamReceiver);
MockContext context(clDevice.get());
debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true);
cl_int retVal = CL_SUCCESS;
auto bufferCompressed = clUniquePtr<Buffer>(Buffer::create(&context, CL_MEM_READ_WRITE | CL_MEM_COMPRESSED_HINT_INTEL, 2048, nullptr, retVal));
bufferCompressed->getGraphicsAllocation(clDevice->getRootDeviceIndex())->getDefaultGmm()->setCompressionEnabled(true);
@@ -460,7 +460,7 @@ XE_HPG_CORETEST_F(BlitXeHpgCoreTests, givenDebugFlagSetWhenCompressionEnabledThe
uint32_t compressionFormat = 3;
debugManager.flags.ForceBufferCompressionFormat.set(compressionFormat);
debugManager.flags.OverrideBufferSuitableForRenderCompression.set(true);
auto csr = static_cast<UltCommandStreamReceiver<FamilyType> *>(clDevice->getEngine(aub_stream::EngineType::ENGINE_BCS, EngineUsage::regular).commandStreamReceiver);
MockContext context(clDevice.get());

View File

@@ -231,7 +231,6 @@ class ProductHelper {
virtual std::optional<GfxMemoryAllocationMethod> getPreferredAllocationMethod(AllocationType allocationType) const = 0;
virtual bool isCachingOnCpuAvailable() const = 0;
virtual bool isNewCoherencyModelSupported() const = 0;
virtual bool isZeroCopyCpuAccessPreferred() const = 0;
virtual bool deferMOCSToPatIndex() const = 0;
virtual const std::vector<uint32_t> getSupportedLocalDispatchSizes(const HardwareInfo &hwInfo) const = 0;
virtual bool supportReadOnlyAllocations() const = 0;

View File

@@ -873,11 +873,6 @@ bool ProductHelperHw<gfxProduct>::isNewCoherencyModelSupported() const {
return false;
}
template <PRODUCT_FAMILY gfxProduct>
bool ProductHelperHw<gfxProduct>::isZeroCopyCpuAccessPreferred() const {
return true;
}
template <PRODUCT_FAMILY gfxProduct>
bool ProductHelperHw<gfxProduct>::supportReadOnlyAllocations() const {
return false;

View File

@@ -175,7 +175,6 @@ class ProductHelperHw : public ProductHelper {
std::optional<GfxMemoryAllocationMethod> getPreferredAllocationMethod(AllocationType allocationType) const override;
bool isCachingOnCpuAvailable() const override;
bool isNewCoherencyModelSupported() const override;
bool isZeroCopyCpuAccessPreferred() const override;
bool deferMOCSToPatIndex() const override;
bool supportReadOnlyAllocations() const override;
const std::vector<uint32_t> getSupportedLocalDispatchSizes(const HardwareInfo &hwInfo) const override;

View File

@@ -108,11 +108,6 @@ bool ProductHelperHw<gfxProduct>::isNewCoherencyModelSupported() const {
return true;
}
template <>
bool ProductHelperHw<gfxProduct>::isZeroCopyCpuAccessPreferred() const {
return false;
}
template <>
std::optional<bool> ProductHelperHw<gfxProduct>::isCoherentAllocation(uint64_t patIndex) const {
std::array<uint64_t, 2> listOfCoherentPatIndexes = {3, 4};

View File

@@ -953,10 +953,6 @@ HWTEST_F(ProductHelperTest, givenProductHelperWhenAskingForDeviceToHostCopySigna
EXPECT_FALSE(productHelper->isDeviceToHostCopySignalingFenceRequired());
}
HWTEST_F(ProductHelperTest, givenProductHelperWhenIsZeroCopyCpuAccessPreferredCalledThenReturnTrue) {
EXPECT_TRUE(productHelper->isZeroCopyCpuAccessPreferred());
}
HWTEST2_F(ProductHelperTest, givenPatIndexWhenCheckIsCoherentAllocationThenReturnNullopt, IsAtMostPVC) {
std::array<uint64_t, 5> listOfCoherentPatIndexes = {0, 1, 2, 3, 4};
for (auto patIndex : listOfCoherentPatIndexes) {

View File

@@ -23,4 +23,3 @@ HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckBlitEnqueue
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned, IGFX_ARROWLAKE);
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenBooleanUncachedWhenCallOverridePatIndexThenProperPatIndexIsReturned, IGFX_ARROWLAKE);
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckDummyBlitWaRequiredThenReturnFalse, IGFX_ARROWLAKE);
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenIsZeroCopyCpuAccessPreferredCalledThenReturnTrue, IGFX_ARROWLAKE);

View File

@@ -19,4 +19,3 @@ HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckBlitEnqueue
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, whenGettingPreferredAllocationMethodThenNoPreferenceIsReturned, IGFX_METEORLAKE);
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenBooleanUncachedWhenCallOverridePatIndexThenProperPatIndexIsReturned, IGFX_METEORLAKE);
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenCheckDummyBlitWaRequiredThenReturnFalse, IGFX_METEORLAKE);
HWTEST_EXCLUDE_PRODUCT(ProductHelperTest, givenProductHelperWhenIsZeroCopyCpuAccessPreferredCalledThenReturnTrue, IGFX_METEORLAKE);

View File

@@ -354,10 +354,6 @@ HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenCallIsNewCoherencyModel
EXPECT_TRUE(productHelper->isNewCoherencyModelSupported());
}
HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenIsZeroCopyCpuAccessPreferredCalledThenReturnFalse, IsXeLpg) {
EXPECT_FALSE(productHelper->isZeroCopyCpuAccessPreferred());
}
HWTEST2_F(XeLpgProductHelperTests, givenProductHelperWhenCallDeferMOCSToPatThenFalseIsReturned, IsXeLpg) {
const auto &productHelper = getHelper<ProductHelper>();
EXPECT_FALSE(productHelper.deferMOCSToPatIndex());