performance: change buffer type for new coherency model

Related-To: NEO-11882

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2024-07-08 18:31:02 +00:00
committed by Compute-Runtime-Automation
parent 457cb005de
commit 7d25965a78
27 changed files with 440 additions and 161 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -57,7 +57,7 @@ TEST_F(ClEnqueueMapBufferTests, GivenValidParametersWhenMappingBufferThenSuccess
unsigned int bufferSize = 16; unsigned int bufferSize = 16;
auto pHostMem = new unsigned char[bufferSize]; auto pHostMem = new unsigned char[bufferSize];
memset(pHostMem, 0xaa, bufferSize); memset(pHostMem, 0xaa, bufferSize);
cl_event eventReturned = nullptr;
cl_mem_flags flags = CL_MEM_USE_HOST_PTR; cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
auto buffer = clCreateBuffer( auto buffer = clCreateBuffer(
pContext, pContext,
@@ -68,7 +68,6 @@ TEST_F(ClEnqueueMapBufferTests, GivenValidParametersWhenMappingBufferThenSuccess
EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, buffer); EXPECT_NE(nullptr, buffer);
cl_event eventReturned = nullptr;
auto ptrResult = clEnqueueMapBuffer( auto ptrResult = clEnqueueMapBuffer(
pCommandQueue, pCommandQueue,
buffer, buffer,
@@ -114,6 +113,12 @@ TEST_F(ClEnqueueMapBufferTests, GivenMappedPointerWhenCreatingBufferFromThisPoin
unsigned int bufferSize = 16; unsigned int bufferSize = 16;
cl_mem buffer = clCreateBuffer(pContext, CL_MEM_READ_WRITE, bufferSize, nullptr, &retVal); 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_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, buffer); EXPECT_NE(nullptr, buffer);

View File

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

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2023 Intel Corporation * Copyright (C) 2018-2024 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -393,7 +393,9 @@ HWTEST_F(CommandQueueHwTest, GivenNonEmptyQueueOnBlockingWhenMappingBufferThenWi
bool finishWasCalled; bool finishWasCalled;
}; };
if (context->getDevice(0)->getProductHelper().isNewCoherencyModelSupported()) {
GTEST_SKIP();
}
MockCmdQ cmdQ(context, pCmdQ->getDevice().getSpecializedDevice<ClDevice>()); MockCmdQ cmdQ(context, pCmdQ->getDevice().getSpecializedDevice<ClDevice>());
auto b1 = clCreateBuffer(context, CL_MEM_READ_WRITE, 20, nullptr, nullptr); auto b1 = clCreateBuffer(context, CL_MEM_READ_WRITE, 20, nullptr, nullptr);
@@ -439,7 +441,9 @@ HWTEST_F(CommandQueueHwTest, GivenEventsWaitlistOnBlockingWhenMappingBufferThenW
uint32_t updateCount = 0; uint32_t updateCount = 0;
uint32_t updateCountBeforeCompleted; uint32_t updateCountBeforeCompleted;
}; };
if (context->getDevice(0)->getProductHelper().isNewCoherencyModelSupported()) {
GTEST_SKIP();
}
MockEvent *me = new MockEvent(context, 1024); MockEvent *me = new MockEvent(context, 1024);
auto b1 = clCreateBuffer(context, CL_MEM_READ_WRITE, 20, nullptr, nullptr); auto b1 = clCreateBuffer(context, CL_MEM_READ_WRITE, 20, nullptr, nullptr);
cl_event meAsClEv = me; cl_event meAsClEv = me;

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2023 Intel Corporation * Copyright (C) 2018-2024 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -101,8 +101,23 @@ TEST_F(EnqueueReadBuffer, WhenReadingBufferThenEventReturnedShouldBeMaxOfInputEv
delete pEvent; delete pEvent;
} }
TEST_F(EnqueueReadBuffer, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) { struct EnqueueReadBufferOnCpuTest : public EnqueueReadBuffer {
void SetUp() override {
EnqueueReadBuffer::setUp();
auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper();
if (productHelper.isNewCoherencyModelSupported()) {
// These tests verify cpu transfer logic
GTEST_SKIP();
}
}
void TearDown() override {
EnqueueReadBuffer::tearDown();
}
DebugManagerStateRestore dbgRestore; DebugManagerStateRestore dbgRestore;
};
TEST_F(EnqueueReadBufferOnCpuTest, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
debugManager.flags.DoCpuCopyOnReadBuffer.set(1); debugManager.flags.DoCpuCopyOnReadBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode)); debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;
@@ -144,8 +159,7 @@ TEST_F(EnqueueReadBuffer, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtr
pEvent->release(); pEvent->release();
} }
TEST_F(EnqueueReadBuffer, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) { TEST_F(EnqueueReadBufferOnCpuTest, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnReadBuffer.set(1); debugManager.flags.DoCpuCopyOnReadBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode)); debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;
@@ -178,8 +192,7 @@ TEST_F(EnqueueReadBuffer, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtr
pEvent->release(); pEvent->release();
} }
TEST_F(EnqueueReadBuffer, givenOutOfOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) { TEST_F(EnqueueReadBufferOnCpuTest, givenOutOfOrderQueueAndForcedCpuCopyOnReadBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnReadBuffer.set(1); debugManager.flags.DoCpuCopyOnReadBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode)); 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)); std::unique_ptr<CommandQueue> pCmdOOQ(createCommandQueue(pClDevice, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE));
@@ -262,8 +275,7 @@ TEST_F(EnqueueReadBuffer, givenInOrderQueueAndForcedCpuCopyOnReadBufferAndEventN
pEvent->release(); pEvent->release();
} }
TEST_F(EnqueueReadBuffer, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) { TEST_F(EnqueueReadBufferOnCpuTest, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnReadBuffer.set(0); debugManager.flags.DoCpuCopyOnReadBuffer.set(0);
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;
uint32_t taskLevelCmdQ = 17; uint32_t taskLevelCmdQ = 17;
@@ -303,8 +315,7 @@ TEST_F(EnqueueReadBuffer, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrE
pEvent->release(); pEvent->release();
} }
TEST_F(EnqueueReadBuffer, givenOutOfOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) { TEST_F(EnqueueReadBufferOnCpuTest, givenOutOfOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenReadBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnReadBuffer.set(0); debugManager.flags.DoCpuCopyOnReadBuffer.set(0);
std::unique_ptr<CommandQueue> pCmdOOQ(createCommandQueue(pClDevice, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)); std::unique_ptr<CommandQueue> pCmdOOQ(createCommandQueue(pClDevice, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE));
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2023 Intel Corporation * Copyright (C) 2018-2024 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -135,7 +135,6 @@ HWTEST_F(EnqueueUnmapMemObjTest, WhenUnmappingMemoryObjectThenEventIsUpdated) {
EXPECT_NE(nullptr, eventReturned); EXPECT_NE(nullptr, eventReturned);
auto eventObject = castToObject<Event>(eventReturned); auto eventObject = castToObject<Event>(eventReturned);
EXPECT_EQ(0u, eventObject->peekTaskCount());
EXPECT_TRUE(eventObject->updateStatusAndCheckCompletion()); EXPECT_TRUE(eventObject->updateStatusAndCheckCompletion());
clReleaseEvent(eventReturned); clReleaseEvent(eventReturned);
@@ -182,11 +181,20 @@ TEST_F(EnqueueUnmapMemObjTest, WhenUnmappingMemoryObjectThenWaitEventIsUpdated)
EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_NE(nullptr, retEvent); EXPECT_NE(nullptr, retEvent);
EXPECT_EQ(CL_COMPLETE, wEvent->peekExecutionStatus());
Event *rEvent = castToObject<Event>(retEvent); Event *rEvent = castToObject<Event>(retEvent);
auto &productHelper = pCmdQ->getClDevice().getProductHelper();
if (productHelper.isNewCoherencyModelSupported()) {
// 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());
}
EXPECT_EQ(CL_QUEUED, rEvent->peekExecutionStatus()); EXPECT_EQ(CL_QUEUED, rEvent->peekExecutionStatus());
retVal = clWaitForEvents(1, &retEvent); retVal = clWaitForEvents(1, &retEvent);
EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_EQ(CL_SUCCESS, retVal);
@@ -216,12 +224,20 @@ HWTEST_F(EnqueueUnmapMemObjTest, givenEnqueueUnmapMemObjectWhenNonAubWritableBuf
nullptr, nullptr,
nullptr); nullptr);
ASSERT_EQ(CL_SUCCESS, retVal); ASSERT_EQ(CL_SUCCESS, retVal);
if (buffer->mappingOnCpuAllowed()) {
EXPECT_TRUE(graphicsAllocation->isAubWritable(GraphicsAllocation::defaultBank)); EXPECT_TRUE(graphicsAllocation->isAubWritable(GraphicsAllocation::defaultBank));
EXPECT_TRUE(graphicsAllocation->isTbxWritable(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) { HWTEST_F(EnqueueUnmapMemObjTest, givenWriteBufferIsServicedOnCPUWhenBufferIsNonAubTbxWriteableThenFlagsChange) {
if (pClDevice->getProductHelper().isNewCoherencyModelSupported()) {
// This test assumes that write buffer will be serviced on cpu
GTEST_SKIP();
}
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(1); debugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode)); debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2023 Intel Corporation * Copyright (C) 2018-2024 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -101,8 +101,28 @@ TEST_F(EnqueueWriteBufferTypeTest, WhenWritingBufferThenReturnedEventShouldBeMax
delete pEvent; delete pEvent;
} }
TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) { struct EnqueueWriteBufferOnCpuTypeTest : public EnqueueWriteBufferTypeTest {
void SetUp() override {
EnqueueWriteBufferTypeTest::SetUp();
auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper();
if (productHelper.isNewCoherencyModelSupported()) {
// These tests verify cpu transfer logic
GTEST_SKIP();
}
}
void TearDown() override {
auto &productHelper = BufferDefaults::context->getDevice(0)->getProductHelper();
if (productHelper.isNewCoherencyModelSupported()) {
// These tests verify cpu transfer logic
GTEST_SKIP();
}
EnqueueWriteBufferTypeTest::TearDown();
}
DebugManagerStateRestore dbgRestore; DebugManagerStateRestore dbgRestore;
};
TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWithEventsNotBlockedWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
debugManager.flags.DoCpuCopyOnWriteBuffer.set(1); debugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode)); debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;
@@ -144,8 +164,7 @@ TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBuffe
pEvent->release(); pEvent->release();
} }
TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndEventNotReadyWhenWriteBufferIsExecutedThenTaskLevelShouldBeIncreased) { TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndEventNotReadyWhenWriteBufferIsExecutedThenTaskLevelShouldBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(1); debugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;
uint32_t taskLevelCmdQ = 17; uint32_t taskLevelCmdQ = 17;
@@ -184,8 +203,7 @@ TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBuffe
pEvent->release(); pEvent->release();
} }
TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) { TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(1); debugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;
uint32_t taskLevelCmdQ = 17; uint32_t taskLevelCmdQ = 17;
@@ -216,8 +234,7 @@ TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndForcedCpuCopyOnWriteBuffe
pEvent->release(); pEvent->release();
} }
TEST_F(EnqueueWriteBufferTypeTest, givenOutOfOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) { TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenOutOfOrderQueueAndForcedCpuCopyOnWriteBufferAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(1); debugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode)); 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)); std::unique_ptr<CommandQueue> pCmdOOQ(createCommandQueue(pClDevice, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE));
@@ -259,8 +276,7 @@ TEST_F(EnqueueWriteBufferTypeTest, givenOutOfOrderQueueAndForcedCpuCopyOnWriteBu
pEvent->release(); pEvent->release();
} }
TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) { TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenInOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(0); debugManager.flags.DoCpuCopyOnWriteBuffer.set(0);
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;
uint32_t taskLevelCmdQ = 17; uint32_t taskLevelCmdQ = 17;
@@ -300,8 +316,7 @@ TEST_F(EnqueueWriteBufferTypeTest, givenInOrderQueueAndDisabledSupportCpuCopiesA
pEvent->release(); pEvent->release();
} }
TEST_F(EnqueueWriteBufferTypeTest, givenOutOfOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) { TEST_F(EnqueueWriteBufferOnCpuTypeTest, givenOutOfOrderQueueAndDisabledSupportCpuCopiesAndDstPtrEqualSrcPtrWithEventsWhenWriteBufferIsExecutedThenTaskLevelShouldNotBeIncreased) {
DebugManagerStateRestore dbgRestore;
debugManager.flags.DoCpuCopyOnWriteBuffer.set(0); debugManager.flags.DoCpuCopyOnWriteBuffer.set(0);
std::unique_ptr<CommandQueue> pCmdOOQ(createCommandQueue(pClDevice, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE)); std::unique_ptr<CommandQueue> pCmdOOQ(createCommandQueue(pClDevice, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE));
cl_int retVal = CL_SUCCESS; cl_int retVal = CL_SUCCESS;

View File

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

View File

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

View File

@@ -37,7 +37,8 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, givenCompressedGmmWhenAskingForCpuOperation
auto alignedPtr = alignedMalloc(2, MemoryConstants::cacheLineSize); auto alignedPtr = alignedMalloc(2, MemoryConstants::cacheLineSize);
auto unalignedPtr = ptrOffset(alignedPtr, 1); auto unalignedPtr = ptrOffset(alignedPtr, 1);
EXPECT_EQ(1u, allocation->storageInfo.getNumBanks()); EXPECT_EQ(1u, allocation->storageInfo.getNumBanks());
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(*pDevice)); auto isNewCoherencyModel = pDevice->getProductHelper().isNewCoherencyModelSupported();
EXPECT_EQ(!isNewCoherencyModel, buffer->isReadWriteOnCpuAllowed(*pDevice));
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(unalignedPtr, 1, *pDevice)); EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(unalignedPtr, 1, *pDevice));
gmm->setCompressionEnabled(true); gmm->setCompressionEnabled(true);
@@ -48,6 +49,10 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, givenCompressedGmmWhenAskingForCpuOperation
} }
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenUnalignedReadPtrWhenReadingBufferThenMemoryIsReadCorrectly) { 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; DebugManagerStateRestore restorer;
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode)); debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal; cl_int retVal;
@@ -89,6 +94,10 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenUnalignedReadPtrWhenReadingBufferThenM
} }
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenUnalignedSrcPtrWhenWritingBufferThenMemoryIsWrittenCorrectly) { 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; DebugManagerStateRestore restorer;
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode)); debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal; cl_int retVal;
@@ -136,7 +145,7 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenUnalignedSrcPtrWhenWritingBufferThenMe
delete[] bufferPtrBase; delete[] bufferPtrBase;
} }
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresWhenReadingWritingMemoryThenCpuReadWriteIsAllowed) { HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndOldCoherencyModelWhenReadingWritingMemoryThenCpuReadWriteIsAllowed) {
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode)); debugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::defaultMode));
cl_int retVal; cl_int retVal;
@@ -152,13 +161,14 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresWhenReadingWri
auto mockContext = std::unique_ptr<MockContext>(new MockContext(mockDevice.get())); auto mockContext = std::unique_ptr<MockContext>(new MockContext(mockDevice.get()));
auto memoryManager = static_cast<OsAgnosticMemoryManager *>(mockDevice->getMemoryManager()); auto memoryManager = static_cast<OsAgnosticMemoryManager *>(mockDevice->getMemoryManager());
memoryManager->turnOnFakingBigAllocations(); memoryManager->turnOnFakingBigAllocations();
auto &productHelper = mockDevice->getProductHelper();
auto isZeroCopyAllowed = !productHelper.isNewCoherencyModelSupported();
std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, alignedBufferPtr, retVal)); std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, alignedBufferPtr, retVal));
EXPECT_EQ(retVal, CL_SUCCESS); EXPECT_EQ(retVal, CL_SUCCESS);
EXPECT_TRUE(buffer->isMemObjZeroCopy()); EXPECT_EQ(isZeroCopyAllowed, buffer->isMemObjZeroCopy());
// zeroCopy == true && aligned/unaligned hostPtr // zeroCopy == true && aligned/unaligned hostPtr
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(alignedHostPtr, MemoryConstants::cacheLineSize + 1, mockDevice->getDevice())); EXPECT_EQ(isZeroCopyAllowed, buffer->isReadWriteOnCpuPreferred(alignedHostPtr, MemoryConstants::cacheLineSize + 1, mockDevice->getDevice()));
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(unalignedHostPtr, MemoryConstants::cacheLineSize, mockDevice->getDevice())); EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(unalignedHostPtr, MemoryConstants::cacheLineSize, mockDevice->getDevice()));
buffer.reset(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, unalignedBufferPtr, retVal)); buffer.reset(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, unalignedBufferPtr, retVal));
@@ -172,24 +182,24 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresWhenReadingWri
// platform LP == true && size <= 10 MB // platform LP == true && size <= 10 MB
mockDevice->deviceInfo.platformLP = true; mockDevice->deviceInfo.platformLP = true;
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(smallBufferPtr, 1 * MemoryConstants::megaByte, mockDevice->getDevice())); EXPECT_EQ(isZeroCopyAllowed, buffer->isReadWriteOnCpuPreferred(smallBufferPtr, 1 * MemoryConstants::megaByte, mockDevice->getDevice()));
// platform LP == false && size <= 10 MB // platform LP == false && size <= 10 MB
mockDevice->deviceInfo.platformLP = false; mockDevice->deviceInfo.platformLP = false;
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(smallBufferPtr, 1 * MemoryConstants::megaByte, mockDevice->getDevice())); EXPECT_EQ(isZeroCopyAllowed, buffer->isReadWriteOnCpuPreferred(smallBufferPtr, 1 * MemoryConstants::megaByte, mockDevice->getDevice()));
buffer.reset(Buffer::create(mockContext.get(), CL_MEM_ALLOC_HOST_PTR, largeBufferSize, nullptr, retVal)); buffer.reset(Buffer::create(mockContext.get(), CL_MEM_ALLOC_HOST_PTR, largeBufferSize, nullptr, retVal));
// platform LP == false && size > 10 MB // platform LP == false && size > 10 MB
mockDevice->deviceInfo.platformLP = false; mockDevice->deviceInfo.platformLP = false;
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(buffer->getCpuAddress(), largeBufferSize, mockDevice->getDevice())); EXPECT_EQ(isZeroCopyAllowed, buffer->isReadWriteOnCpuPreferred(buffer->getCpuAddress(), largeBufferSize, mockDevice->getDevice()));
alignedFree(smallBufferPtr); alignedFree(smallBufferPtr);
alignedFree(alignedHostPtr); alignedFree(alignedHostPtr);
alignedFree(alignedBufferPtr); alignedFree(alignedBufferPtr);
} }
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresWhenReadingWritingMemoryThenCpuReadWriteIsNotAllowed) { HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresAndOldCoherencyModelWhenReadingWritingMemoryThenCpuReadWriteIsNotAllowed) {
cl_int retVal; cl_int retVal;
size_t size = MemoryConstants::cacheLineSize; size_t size = MemoryConstants::cacheLineSize;
auto alignedBufferPtr = alignedMalloc(MemoryConstants::cacheLineSize + 1, MemoryConstants::cacheLineSize); auto alignedBufferPtr = alignedMalloc(MemoryConstants::cacheLineSize + 1, MemoryConstants::cacheLineSize);
@@ -204,10 +214,11 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, GivenSpecificMemoryStructuresWhenReadingWri
auto memoryManager = static_cast<OsAgnosticMemoryManager *>(mockDevice->getMemoryManager()); auto memoryManager = static_cast<OsAgnosticMemoryManager *>(mockDevice->getMemoryManager());
memoryManager->turnOnFakingBigAllocations(); memoryManager->turnOnFakingBigAllocations();
auto &productHelper = mockDevice->getProductHelper();
auto isZeroCopyAllowed = !productHelper.isNewCoherencyModelSupported();
std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, alignedBufferPtr, retVal)); std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_USE_HOST_PTR, size, alignedBufferPtr, retVal));
EXPECT_EQ(retVal, CL_SUCCESS); EXPECT_EQ(retVal, CL_SUCCESS);
EXPECT_TRUE(buffer->isMemObjZeroCopy()); EXPECT_EQ(isZeroCopyAllowed, buffer->isMemObjZeroCopy());
// non blocking // non blocking
EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_NDRANGE_KERNEL, false, size, unalignedHostPtr, 0u, nullptr)); EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_NDRANGE_KERNEL, false, size, unalignedHostPtr, 0u, nullptr));
@@ -242,14 +253,14 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, givenDebugVariableToDisableCpuCopiesWhenBuf
std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_ALLOC_HOST_PTR, MemoryConstants::pageSize, nullptr, retVal)); std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_ALLOC_HOST_PTR, MemoryConstants::pageSize, nullptr, retVal));
EXPECT_EQ(retVal, CL_SUCCESS); EXPECT_EQ(retVal, CL_SUCCESS);
EXPECT_TRUE(buffer->isMemObjZeroCopy()); auto mappingAllowed = buffer->mappingOnCpuAllowed();
EXPECT_TRUE(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_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)); EXPECT_EQ(mappingAllowed, mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_WRITE_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
debugManager.flags.DoCpuCopyOnReadBuffer.set(0); 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_FALSE(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)); EXPECT_EQ(mappingAllowed, mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_WRITE_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
debugManager.flags.DoCpuCopyOnWriteBuffer.set(0); debugManager.flags.DoCpuCopyOnWriteBuffer.set(0);
EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr)); EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, true, MemoryConstants::pageSize, reinterpret_cast<void *>(0x1000), 0u, nullptr));
@@ -271,9 +282,9 @@ TEST(ReadWriteBufferOnCpu, givenNoHostPtrAndAlignedSizeWhenMemoryAllocationIsInN
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, nullptr, retVal)); std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, flags, MemoryConstants::pageSize, nullptr, retVal));
ASSERT_NE(nullptr, buffer.get()); ASSERT_NE(nullptr, buffer.get());
auto isNewCoherencyModelSupported = device->getProductHelper().isNewCoherencyModelSupported();
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(device->getDevice())); EXPECT_EQ(!isNewCoherencyModelSupported, buffer->isReadWriteOnCpuAllowed(device->getDevice()));
EXPECT_TRUE(buffer->isReadWriteOnCpuPreferred(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize, device->getDevice())); EXPECT_EQ(!isNewCoherencyModelSupported, buffer->isReadWriteOnCpuPreferred(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize, device->getDevice()));
reinterpret_cast<MemoryAllocation *>(buffer->getGraphicsAllocation(device->getRootDeviceIndex()))->overrideMemoryPool(MemoryPool::systemCpuInaccessible); 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. // read write on CPU is allowed, but not preferred. We can access this memory via Lock.
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(device->getDevice())); EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(device->getDevice()));
@@ -300,7 +311,9 @@ TEST(ReadWriteBufferOnCpu, givenPointerThatRequiresCpuCopyWhenCpuCopyIsEvaluated
EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, false, MemoryConstants::pageSize, nullptr, 0u, nullptr)); EXPECT_FALSE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, false, MemoryConstants::pageSize, nullptr, 0u, nullptr));
memoryManager->cpuCopyRequired = true; memoryManager->cpuCopyRequired = true;
EXPECT_TRUE(mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, false, MemoryConstants::pageSize, nullptr, 0u, nullptr)); // cpu copy is never allowed with new coherency model
auto isNewCoherencyModelSupported = device->getProductHelper().isNewCoherencyModelSupported();
EXPECT_EQ(!isNewCoherencyModelSupported, mockCommandQueue->bufferCpuCopyAllowed(buffer.get(), CL_COMMAND_READ_BUFFER, false, MemoryConstants::pageSize, nullptr, 0u, nullptr));
} }
TEST(ReadWriteBufferOnCpu, givenPointerThatRequiresCpuCopyButItIsNotPossibleWhenCpuCopyIsEvaluatedThenFalseIsReturned) { TEST(ReadWriteBufferOnCpu, givenPointerThatRequiresCpuCopyButItIsNotPossibleWhenCpuCopyIsEvaluatedThenFalseIsReturned) {

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2023 Intel Corporation * Copyright (C) 2018-2024 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -327,7 +327,9 @@ TEST_F(Image2dFromBufferTest, givenBufferWhenImageFromBufferThenIsImageFromBuffe
EXPECT_TRUE(imageFromBuffer->isImageFromBuffer()); EXPECT_TRUE(imageFromBuffer->isImageFromBuffer());
auto graphicsAllocation = imageFromBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex()); auto graphicsAllocation = imageFromBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
EXPECT_TRUE(AllocationType::bufferHostMemory == graphicsAllocation->getAllocationType()); auto isHostMemory = AllocationType::bufferHostMemory == graphicsAllocation->getAllocationType();
auto isDevMemory = AllocationType::buffer == graphicsAllocation->getAllocationType();
EXPECT_TRUE(isHostMemory || isDevMemory);
buffer->release(); buffer->release();
imageDesc.mem_object = memObj; imageDesc.mem_object = memObj;

View File

@@ -431,7 +431,7 @@ TEST(MemObjHelper, givenDifferentCapabilityAndDebugFlagValuesWhenCheckingBufferC
bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*defaultHwInfo), memoryProperties, context, true); bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*defaultHwInfo), memoryProperties, context, true);
MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference( MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(
memoryProperties, compressionEnabled, false); memoryProperties, compressionEnabled, false, false);
bool expectBufferCompressed = ftrRenderCompressedBuffers && (enableMultiTileCompressionValue == 1); bool expectBufferCompressed = ftrRenderCompressedBuffers && (enableMultiTileCompressionValue == 1);
if (expectBufferCompressed) { if (expectBufferCompressed) {
@@ -483,7 +483,7 @@ TEST(MemObjHelper, givenDifferentValuesWhenCheckingBufferCompressionSupportThenC
bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*defaultHwInfo), memoryProperties, context, true); bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*defaultHwInfo), memoryProperties, context, true);
MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference( MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(
memoryProperties, compressionEnabled, false); memoryProperties, compressionEnabled, false, false);
bool isCompressionDisabled = isValueSet(flags, CL_MEM_UNCOMPRESSED_HINT_INTEL) || bool isCompressionDisabled = isValueSet(flags, CL_MEM_UNCOMPRESSED_HINT_INTEL) ||
isValueSet(flagsIntel, CL_MEM_UNCOMPRESSED_HINT_INTEL); isValueSet(flagsIntel, CL_MEM_UNCOMPRESSED_HINT_INTEL);

View File

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

View File

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

View File

@@ -12,6 +12,8 @@
#include "shared/test/common/libult/ult_command_stream_receiver.h" #include "shared/test/common/libult/ult_command_stream_receiver.h"
#include "opencl/source/command_queue/command_queue_hw.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> #include <optional>
@@ -180,7 +182,15 @@ class MockCommandQueue : public CommandQueue {
cl_int enqueueReadBuffer(Buffer *buffer, cl_bool blockingRead, size_t offset, size_t size, void *ptr, cl_int enqueueReadBuffer(Buffer *buffer, cl_bool blockingRead, size_t offset, size_t size, void *ptr,
GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList, GraphicsAllocation *mapAllocation, cl_uint numEventsInWaitList,
const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; } 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;
}
cl_int enqueueReadImage(Image *srcImage, cl_bool blockingRead, const size_t *origin, const size_t *region, cl_int enqueueReadImage(Image *srcImage, cl_bool blockingRead, const size_t *origin, const size_t *region,
size_t rowPitch, size_t slicePitch, void *ptr, size_t rowPitch, size_t slicePitch, void *ptr,

View File

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