Skip to content

Commit f5c433c

Browse files
Revert "performance: Use lock pointer copy with sfence for dc flush mitigation"
This reverts commit 8c3c703. Signed-off-by: Compute-Runtime-Validation <[email protected]>
1 parent ebdded1 commit f5c433c

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

opencl/source/mem_obj/buffer.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "shared/source/memory_manager/memory_operations_handler.h"
2525
#include "shared/source/memory_manager/migration_sync_data.h"
2626
#include "shared/source/os_interface/os_interface.h"
27-
#include "shared/source/utilities/cpuintrinsics.h"
2827

2928
#include "opencl/source/cl_device/cl_device.h"
3029
#include "opencl/source/command_queue/command_queue.h"
@@ -213,7 +212,8 @@ bool inline copyHostPointer(Buffer *buffer,
213212
size <= Buffer::maxBufferSizeForCopyOnCpu &&
214213
isCompressionEnabled == false &&
215214
productHelper.getLocalMemoryAccessMode(hwInfo) != LocalMemoryAccessMode::cpuAccessDisallowed &&
216-
isLockable;
215+
isLockable &&
216+
!isGpuCopyRequiredForDcFlushMitigation;
217217

218218
if (debugManager.flags.CopyHostPtrOnCpu.get() != -1) {
219219
copyOnCpuAllowed = debugManager.flags.CopyHostPtrOnCpu.get() == 1;
@@ -222,11 +222,6 @@ bool inline copyHostPointer(Buffer *buffer,
222222
memory->setAubWritable(true, GraphicsAllocation::defaultBank);
223223
memory->setTbxWritable(true, GraphicsAllocation::defaultBank);
224224
memcpy_s(ptrOffset(lockedPointer, buffer->getOffset()), size, hostPtr, size);
225-
226-
if (isGpuCopyRequiredForDcFlushMitigation) {
227-
CpuIntrinsics::sfence();
228-
}
229-
230225
return true;
231226
} else {
232227
auto blitMemoryToAllocationResult = BlitOperationResult::unsupported;

opencl/test/unit_test/libult/command_queue_ult.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bool CommandQueue::isTimestampWaitEnabled() {
2020
}
2121

2222
bool checkIsGpuCopyRequiredForDcFlushMitigation(AllocationType type) {
23-
return ultHwConfig.useGpuCopyForDcFlushMitigation;
23+
return false;
2424
}
2525

2626
} // namespace NEO

opencl/test/unit_test/mem_obj/buffer_tests.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -599,30 +599,33 @@ TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInS
599599
}
600600
}
601601

602-
namespace CpuIntrinsicsTests {
603-
extern std::atomic<uint32_t> sfenceCounter;
604-
} // namespace CpuIntrinsicsTests
605-
606-
TEST(Buffer, givenDcFlushMitigationWhenCreateBufferCopyHostptrThenUseLockPointerCopyWithSfence) {
602+
TEST(Buffer, givenDcFlushMitigationWhenCreateBufferCopyHostptrThenUseBlitterCopy) {
603+
DebugManagerStateRestore restorer;
604+
debugManager.flags.AllowDcFlush.set(0);
607605
ExecutionEnvironment *executionEnvironment = MockClDevice::prepareExecutionEnvironment(defaultHwInfo.get(), 0u);
606+
executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.blitterOperationsSupported = true;
607+
608608
auto productHelper = executionEnvironment->rootDeviceEnvironments[0]->productHelper.get();
609-
if (!productHelper->isDcFlushMitigated()) {
609+
if (!(productHelper->isBlitterFullySupported(*defaultHwInfo) && productHelper->isDcFlushMitigated())) {
610610
GTEST_SKIP();
611611
}
612612

613-
VariableBackup<UltHwConfig> backup(&ultHwConfig);
614-
ultHwConfig.useGpuCopyForDcFlushMitigation = true;
615-
616-
DebugManagerStateRestore restorer;
617-
debugManager.flags.AllowDcFlush.set(0);
613+
auto blitterCalled = 0u;
614+
auto mockBlitMemoryToAllocation = [&](const NEO::Device &device, NEO::GraphicsAllocation *memory, size_t offset, const void *hostPtr,
615+
Vec3<size_t> size) -> NEO::BlitOperationResult {
616+
memcpy(memory->getUnderlyingBuffer(), hostPtr, size.x);
617+
blitterCalled++;
618+
return BlitOperationResult::success;
619+
};
620+
VariableBackup<NEO::BlitHelperFunctions::BlitMemoryToAllocationFunc> blitMemoryToAllocationFuncBackup(
621+
&NEO::BlitHelperFunctions::blitMemoryToAllocation, mockBlitMemoryToAllocation);
618622

619623
auto *memoryManager = new MockMemoryManagerFailFirstAllocation(*executionEnvironment);
620624
executionEnvironment->memoryManager.reset(memoryManager);
621625
memoryManager->returnBaseAllocateGraphicsMemoryInDevicePool = true;
622626
auto device = std::make_unique<MockClDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
623627

624628
MockContext ctx(device.get());
625-
CpuIntrinsicsTests::sfenceCounter.store(0u);
626629

627630
cl_int retVal = 0;
628631
cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR;
@@ -631,8 +634,7 @@ TEST(Buffer, givenDcFlushMitigationWhenCreateBufferCopyHostptrThenUseLockPointer
631634
std::unique_ptr<Buffer> buffer(Buffer::create(&ctx, flags, sizeof(memory), memory, retVal));
632635

633636
ASSERT_NE(nullptr, buffer.get());
634-
EXPECT_EQ(1u, CpuIntrinsicsTests::sfenceCounter.load());
635-
CpuIntrinsicsTests::sfenceCounter.store(0u);
637+
EXPECT_EQ(blitterCalled, 1u);
636638
}
637639

638640
TEST(Buffer, givenPropertiesWithClDeviceHandleListKHRWhenCreateBufferThenCorrectBufferIsSet) {

shared/test/common/base_ult_config_listener.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void BaseUltConfigListener::OnTestEnd(const ::testing::TestInfo &) {
5050

5151
// Ensure that global state is restored
5252
UltHwConfig expectedState{};
53-
static_assert(sizeof(UltHwConfig) == (17 * sizeof(bool) + sizeof(const char *)) + sizeof(UltHwConfig::padding), ""); // Ensure that there is no internal padding
53+
static_assert(sizeof(UltHwConfig) == (16 * sizeof(bool) + sizeof(const char *)), ""); // Ensure that there is no internal padding
5454
EXPECT_EQ(0, memcmp(&expectedState, &ultHwConfig, sizeof(UltHwConfig)));
5555

5656
EXPECT_EQ(0, memcmp(&referencedHwInfo.platform, &defaultHwInfo->platform, sizeof(PLATFORM)));

shared/test/common/helpers/ult_hw_config.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ struct UltHwConfig {
1616
bool useWaitForTimestamps = false;
1717
bool useBlitSplit = false;
1818
bool useFirstSubmissionInitDevice = false;
19-
bool useGpuCopyForDcFlushMitigation = false;
2019

2120
bool csrFailInitDirectSubmission = false;
2221
bool csrBaseCallDirectSubmissionAvailable = false;
@@ -29,8 +28,6 @@ struct UltHwConfig {
2928
bool csrCreatePreemptionReturnValue = true;
3029
bool reserved = false;
3130

32-
char padding[7];
33-
3431
const char *aubTestName = nullptr;
3532
};
3633

0 commit comments

Comments
 (0)