mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Disallow for copying local memory buffers on CPU
Related-To: NEO-5733 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
3a2281bf77
commit
52308244a6
@ -621,16 +621,10 @@ bool Buffer::isReadWriteOnCpuAllowed(const Device &device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (graphicsAllocation->storageInfo.getNumBanks() > 1) {
|
||||
if (graphicsAllocation->isAllocatedInLocalMemoryPool()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto &hardwareInfo = device.getHardwareInfo();
|
||||
auto &hwHelper = HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
|
||||
auto isCpuAccessDisallowed = LocalMemoryAccessMode::CpuAccessDisallowed == hwHelper.getLocalMemoryAccessMode(hardwareInfo);
|
||||
if (isCpuAccessDisallowed) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1375,8 +1375,6 @@ HWTEST_TEMPLATED_F(BlitEnqueueTaskCountTests, givenBlockedEnqueueWithoutKernelWh
|
||||
}
|
||||
|
||||
HWTEST_TEMPLATED_F(BlitEnqueueTaskCountTests, givenEventFromCpuCopyWhenWaitingForCompletionThenWaitForCurrentBcsTaskCount) {
|
||||
DebugManager.flags.DoCpuCopyOnWriteBuffer.set(1);
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::Default));
|
||||
auto buffer = createBuffer(1, false);
|
||||
int hostPtr = 0;
|
||||
|
||||
@ -1394,12 +1392,12 @@ HWTEST_TEMPLATED_F(BlitEnqueueTaskCountTests, givenEventFromCpuCopyWhenWaitingFo
|
||||
commandQueue->enqueueWriteBuffer(buffer.get(), false, 0, 1, &hostPtr, nullptr, 0, nullptr, &outEvent2);
|
||||
|
||||
clWaitForEvents(1, &outEvent2);
|
||||
EXPECT_EQ(1u, static_cast<UltCommandStreamReceiver<FamilyType> *>(gpgpuCsr)->latestWaitForCompletionWithTimeoutTaskCount.load());
|
||||
EXPECT_EQ(2u, static_cast<UltCommandStreamReceiver<FamilyType> *>(bcsCsr)->latestWaitForCompletionWithTimeoutTaskCount.load());
|
||||
EXPECT_EQ(3u, static_cast<UltCommandStreamReceiver<FamilyType> *>(gpgpuCsr)->latestWaitForCompletionWithTimeoutTaskCount.load());
|
||||
EXPECT_EQ(4u, static_cast<UltCommandStreamReceiver<FamilyType> *>(bcsCsr)->latestWaitForCompletionWithTimeoutTaskCount.load());
|
||||
|
||||
clWaitForEvents(1, &outEvent1);
|
||||
EXPECT_EQ(1u, static_cast<UltCommandStreamReceiver<FamilyType> *>(gpgpuCsr)->latestWaitForCompletionWithTimeoutTaskCount.load());
|
||||
EXPECT_EQ(2u, static_cast<UltCommandStreamReceiver<FamilyType> *>(bcsCsr)->latestWaitForCompletionWithTimeoutTaskCount.load());
|
||||
EXPECT_EQ(2u, static_cast<UltCommandStreamReceiver<FamilyType> *>(gpgpuCsr)->latestWaitForCompletionWithTimeoutTaskCount.load());
|
||||
EXPECT_EQ(3u, static_cast<UltCommandStreamReceiver<FamilyType> *>(bcsCsr)->latestWaitForCompletionWithTimeoutTaskCount.load());
|
||||
|
||||
clReleaseEvent(outEvent1);
|
||||
clReleaseEvent(outEvent2);
|
||||
|
@ -41,18 +41,6 @@ HWTEST_F(ReadWriteBufferCpuCopyTest, givenRenderCompressedGmmWhenAskingForCpuOpe
|
||||
alignedFree(alignedPtr);
|
||||
}
|
||||
|
||||
HWTEST_F(ReadWriteBufferCpuCopyTest, givenDisallowedCpuAccessWhenAskingForCpuOperationThenDisallow) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::Default));
|
||||
cl_int retVal;
|
||||
std::unique_ptr<Buffer> buffer(Buffer::create(context, CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
|
||||
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(*pDevice));
|
||||
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::CpuAccessDisallowed));
|
||||
EXPECT_FALSE(buffer->isReadWriteOnCpuAllowed(*pDevice));
|
||||
}
|
||||
|
||||
HWTEST_F(ReadWriteBufferCpuCopyTest, GivenUnalignedReadPtrWhenReadingBufferThenMemoryIsReadCorrectly) {
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.ForceLocalMemoryAccessMode.set(static_cast<int32_t>(LocalMemoryAccessMode::Default));
|
||||
@ -344,6 +332,6 @@ TEST(ReadWriteBufferOnCpu, whenLocalMemoryPoolAllocationIsAskedForPreferenceThen
|
||||
ASSERT_NE(nullptr, buffer.get());
|
||||
reinterpret_cast<MemoryAllocation *>(buffer->getGraphicsAllocation(device->getRootDeviceIndex()))->overrideMemoryPool(MemoryPool::LocalMemory);
|
||||
|
||||
EXPECT_TRUE(buffer->isReadWriteOnCpuAllowed(device->getDevice()));
|
||||
EXPECT_FALSE(buffer->isReadWriteOnCpuAllowed(device->getDevice()));
|
||||
EXPECT_FALSE(buffer->isReadWriteOnCpuPreferred(reinterpret_cast<void *>(0x1000), MemoryConstants::pageSize, device->getDevice()));
|
||||
}
|
||||
|
@ -62,6 +62,19 @@ TEST(Buffer, givenBufferWhenAskedForPtrLengthThenReturnCorrectValue) {
|
||||
EXPECT_EQ(size[0], retOffset);
|
||||
}
|
||||
|
||||
TEST(Buffer, whenBufferAllocatedInLocalMemoryThenCpuCopyIsDisallowed) {
|
||||
MockGraphicsAllocation allocation{};
|
||||
MockBuffer buffer(allocation);
|
||||
UltDeviceFactory factory{1, 0};
|
||||
auto &device = *factory.rootDevices[0];
|
||||
|
||||
allocation.memoryPool = MemoryPool::LocalMemory;
|
||||
EXPECT_FALSE(buffer.isReadWriteOnCpuAllowed(device));
|
||||
|
||||
allocation.memoryPool = MemoryPool::System4KBPages;
|
||||
EXPECT_TRUE(buffer.isReadWriteOnCpuAllowed(device));
|
||||
}
|
||||
|
||||
TEST(Buffer, givenReadOnlySetOfInputFlagsWhenPassedToisReadOnlyMemoryPermittedByFlagsThenTrueIsReturned) {
|
||||
class MockBuffer : public Buffer {
|
||||
public:
|
||||
|
Reference in New Issue
Block a user