mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-18 22:08:53 +08:00
fix: Copy hostptr using BCS when mitigate dc flush
Related-To: NEO-10556 Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4c49a08017
commit
773da10099
@@ -191,13 +191,13 @@ bool inline copyHostPointer(Buffer *buffer,
|
||||
bool implicitScalingEnabled,
|
||||
cl_int &errcodeRet) {
|
||||
auto rootDeviceIndex = device.getRootDeviceIndex();
|
||||
auto &productHelper = device.getProductHelper();
|
||||
auto memory = buffer->getGraphicsAllocation(rootDeviceIndex);
|
||||
auto isCompressionEnabled = memory->isCompressionEnabled();
|
||||
const bool isLocalMemory = !MemoryPoolHelper::isSystemMemoryPool(memory->getMemoryPool());
|
||||
const bool gpuCopyRequired = isCompressionEnabled || isLocalMemory;
|
||||
const bool gpuCopyRequired = isCompressionEnabled || isLocalMemory || productHelper.isDcFlushMitigated();
|
||||
if (gpuCopyRequired) {
|
||||
auto &hwInfo = device.getHardwareInfo();
|
||||
auto &productHelper = device.getProductHelper();
|
||||
|
||||
auto &osInterface = device.getRootDeviceEnvironment().osInterface;
|
||||
bool isLockable = true;
|
||||
@@ -209,7 +209,9 @@ bool inline copyHostPointer(Buffer *buffer,
|
||||
size <= Buffer::maxBufferSizeForCopyOnCpu &&
|
||||
isCompressionEnabled == false &&
|
||||
productHelper.getLocalMemoryAccessMode(hwInfo) != LocalMemoryAccessMode::cpuAccessDisallowed &&
|
||||
isLockable;
|
||||
isLockable &&
|
||||
!productHelper.isDcFlushMitigated();
|
||||
|
||||
if (debugManager.flags.CopyHostPtrOnCpu.get() != -1) {
|
||||
copyOnCpuAllowed = debugManager.flags.CopyHostPtrOnCpu.get() == 1;
|
||||
}
|
||||
@@ -221,7 +223,7 @@ bool inline copyHostPointer(Buffer *buffer,
|
||||
} else {
|
||||
auto blitMemoryToAllocationResult = BlitOperationResult::unsupported;
|
||||
|
||||
if (productHelper.isBlitterFullySupported(hwInfo) && isLocalMemory) {
|
||||
if (productHelper.isBlitterFullySupported(hwInfo) && (isLocalMemory || productHelper.isDcFlushMitigated())) {
|
||||
blitMemoryToAllocationResult = BlitHelperFunctions::blitMemoryToAllocation(device, memory, buffer->getOffset(), hostPtr, {size, 1, 1});
|
||||
}
|
||||
|
||||
|
||||
@@ -594,6 +594,44 @@ TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInS
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Buffer, givenDcFlushMitigationWhenCreateBufferCopyHostptrThenUseBlitterCopy) {
|
||||
DebugManagerStateRestore restorer;
|
||||
debugManager.flags.AllowDcFlush.set(0);
|
||||
ExecutionEnvironment *executionEnvironment = MockClDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u);
|
||||
executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true;
|
||||
|
||||
auto productHelper = executionEnvironment->rootDeviceEnvironments[0]->productHelper.get();
|
||||
if (!(productHelper->isBlitterFullySupported(*defaultHwInfo) && productHelper->isDcFlushMitigated())) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
auto blitterCalled = 0u;
|
||||
auto mockBlitMemoryToAllocation = [&](const NEO::Device &device, NEO::GraphicsAllocation *memory, size_t offset, const void *hostPtr,
|
||||
Vec3<size_t> size) -> NEO::BlitOperationResult {
|
||||
memcpy(memory->getUnderlyingBuffer(), hostPtr, size.x);
|
||||
blitterCalled++;
|
||||
return BlitOperationResult::success;
|
||||
};
|
||||
VariableBackup<NEO::BlitHelperFunctions::BlitMemoryToAllocationFunc> blitMemoryToAllocationFuncBackup(
|
||||
&NEO::BlitHelperFunctions::blitMemoryToAllocation, mockBlitMemoryToAllocation);
|
||||
|
||||
auto *memoryManager = new MockMemoryManagerFailFirstAllocation(*executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
memoryManager->returnBaseAllocateGraphicsMemoryInDevicePool = true;
|
||||
auto device = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
|
||||
|
||||
MockContext ctx(device.get());
|
||||
|
||||
cl_int retVal = 0;
|
||||
cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR;
|
||||
char memory[] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
|
||||
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, flags, sizeof(memory), memory, retVal));
|
||||
|
||||
ASSERT_NE(nullptr, buffer.get());
|
||||
EXPECT_EQ(blitterCalled, 1u);
|
||||
}
|
||||
|
||||
TEST(Buffer, givenPropertiesWithClDeviceHandleListKHRWhenCreateBufferThenCorrectBufferIsSet) {
|
||||
MockDefaultContext context;
|
||||
auto clDevice = context.getDevice(1);
|
||||
|
||||
Reference in New Issue
Block a user