Skip to content

Commit 6f4a56d

Browse files
refactor: pass product helper to isFenceAllocationRequired
Related-To: NEO-14642 Signed-off-by: Lukasz Jobczyk <[email protected]>
1 parent f5301ac commit 6f4a56d

File tree

11 files changed

+41
-37
lines changed

11 files changed

+41
-37
lines changed

opencl/test/unit_test/xe_hpc_core/gfx_core_helper_tests_xe_hpc_core.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -593,44 +593,45 @@ XE_HPC_CORETEST_F(GfxCoreHelperTestsXeHpcCore, whenPipecontrolWaIsProgrammedThen
593593
XE_HPC_CORETEST_F(GfxCoreHelperTestsXeHpcCore, givenGfxCoreHelperWhenAskedIfFenceAllocationRequiredThenReturnCorrectValue) {
594594
DebugManagerStateRestore dbgRestore;
595595

596-
auto hwInfo = *defaultHwInfo;
597-
auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
596+
const auto hwInfo = *defaultHwInfo;
597+
const auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
598+
const auto &productHelper = getHelper<ProductHelper>();
598599

599600
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(-1);
600601
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(-1);
601602
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(-1);
602603
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(-1);
603-
EXPECT_EQ(gfxCoreHelper.isFenceAllocationRequired(hwInfo), !hwInfo.capabilityTable.isIntegratedDevice);
604+
EXPECT_EQ(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper), !hwInfo.capabilityTable.isIntegratedDevice);
604605

605606
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0);
606607
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
607608
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
608609
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(0);
609-
EXPECT_FALSE(gfxCoreHelper.isFenceAllocationRequired(hwInfo));
610+
EXPECT_FALSE(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper));
610611

611612
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(1);
612613
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
613614
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
614615
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(0);
615-
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo));
616+
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper));
616617

617618
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0);
618619
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(1);
619620
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
620621
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(0);
621-
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo));
622+
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper));
622623

623624
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0);
624625
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
625626
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(1);
626627
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(0);
627-
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo));
628+
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper));
628629

629630
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0);
630631
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
631632
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
632633
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(1);
633-
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo));
634+
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper));
634635
}
635636

636637
XE_HPC_CORETEST_F(GfxCoreHelperTestsXeHpcCore, givenDontProgramGlobalFenceAsMiMemFenceCommandInCommandStreamWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) {

shared/source/command_stream/command_stream_receiver.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,10 @@ bool CommandStreamReceiver::createWorkPartitionAllocation(const Device &device)
884884
}
885885

886886
bool CommandStreamReceiver::createGlobalFenceAllocation() {
887-
auto &gfxCoreHelper = getGfxCoreHelper();
888-
auto &hwInfo = peekHwInfo();
889-
if (!gfxCoreHelper.isFenceAllocationRequired(hwInfo)) {
887+
const auto &gfxCoreHelper = this->getGfxCoreHelper();
888+
const auto &hwInfo = this->peekHwInfo();
889+
const auto &productHelper = this->getProductHelper();
890+
if (!gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper)) {
890891
return true;
891892
}
892893

shared/source/helpers/gfx_core_helper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class GfxCoreHelper {
6363
virtual SipKernelType getSipKernelType(bool debuggingActive) const = 0;
6464
virtual bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) const = 0;
6565
virtual bool is1MbAlignmentSupported(const HardwareInfo &hwInfo, bool isCompressionEnabled) const = 0;
66-
virtual bool isFenceAllocationRequired(const HardwareInfo &hwInfo) const = 0;
66+
virtual bool isFenceAllocationRequired(const HardwareInfo &hwInfo, const ProductHelper &productHelper) const = 0;
6767
virtual const AubMemDump::LrcaHelper &getCsTraits(aub_stream::EngineType engineType) const = 0;
6868
virtual bool hvAlign4Required() const = 0;
6969
virtual bool isBufferSizeSuitableForCompression(const size_t size) const = 0;
@@ -280,7 +280,7 @@ class GfxCoreHelperHw : public GfxCoreHelper {
280280

281281
bool is1MbAlignmentSupported(const HardwareInfo &hwInfo, bool isCompressionEnabled) const override;
282282

283-
bool isFenceAllocationRequired(const HardwareInfo &hwInfo) const override;
283+
bool isFenceAllocationRequired(const HardwareInfo &hwInfo, const ProductHelper &productHelper) const override;
284284

285285
bool makeResidentBeforeLockNeeded(bool precondition) const override;
286286

shared/source/helpers/gfx_core_helper_bdw_to_dg2.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace NEO {
1111
template <typename Family>
12-
bool GfxCoreHelperHw<Family>::isFenceAllocationRequired(const HardwareInfo &hwInfo) const {
12+
bool GfxCoreHelperHw<Family>::isFenceAllocationRequired(const HardwareInfo &hwInfo, const ProductHelper &productHelper) const {
1313
return false;
1414
}
1515

shared/source/helpers/gfx_core_helper_pvc_and_later.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace NEO {
1212

1313
template <typename Family>
14-
bool GfxCoreHelperHw<Family>::isFenceAllocationRequired(const HardwareInfo &hwInfo) const {
14+
bool GfxCoreHelperHw<Family>::isFenceAllocationRequired(const HardwareInfo &hwInfo, const ProductHelper &productHelper) const {
1515
if ((debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.get() == 1) ||
1616
(debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.get() == 1) ||
1717
(debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.get() == 1) ||

shared/test/common/mocks/mock_gfx_core_helper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2024 Intel Corporation
2+
* Copyright (C) 2020-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -15,7 +15,7 @@ namespace NEO {
1515
template <typename GfxFamily>
1616
class MockGfxCoreHelperHw : public GfxCoreHelperHw<GfxFamily> {
1717
public:
18-
bool isFenceAllocationRequired(const HardwareInfo &hwInfo) const override {
18+
bool isFenceAllocationRequired(const HardwareInfo &hwInfo, const ProductHelper &productHelper) const override {
1919
return true;
2020
}
2121
void setExtraAllocationData(AllocationData &allocationData, const AllocationProperties &properties, const RootDeviceEnvironment &rootDeviceEnvironment) const override {

shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6078,7 +6078,7 @@ HWTEST_F(CommandStreamReceiverContextGroupTest, givenSecondaryCsrWhenGettingInte
60786078
EXPECT_NE(primaryCsr->getTagAllocation(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getTagAllocation());
60796079
}
60806080

6081-
if (gfxCoreHelper.isFenceAllocationRequired(hwInfo)) {
6081+
if (gfxCoreHelper.isFenceAllocationRequired(hwInfo, device->getRootDeviceEnvironment().getHelper<ProductHelper>())) {
60826082
EXPECT_EQ(primaryCsr->getGlobalFenceAllocation(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getGlobalFenceAllocation());
60836083
}
60846084

@@ -6131,7 +6131,7 @@ HWTEST_F(CommandStreamReceiverContextGroupTest, givenSecondaryRootCsrWhenGetting
61316131
EXPECT_NE(primaryCsr->getTagAllocation(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getTagAllocation());
61326132
}
61336133

6134-
if (gfxCoreHelper.isFenceAllocationRequired(hwInfo)) {
6134+
if (gfxCoreHelper.isFenceAllocationRequired(hwInfo, device->getRootDeviceEnvironment().getHelper<ProductHelper>())) {
61356135
EXPECT_EQ(primaryCsr->getGlobalFenceAllocation(), secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getGlobalFenceAllocation());
61366136
}
61376137

shared/test/unit_test/device/neo_device_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@ HWTEST_F(DeviceTests, givenContextGroupEnabledWhenGettingSecondaryEngineThenReso
20172017

20182018
EXPECT_NE(nullptr, secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getTagAllocation());
20192019

2020-
if (gfxCoreHelper.isFenceAllocationRequired(hwInfo)) {
2020+
if (gfxCoreHelper.isFenceAllocationRequired(hwInfo, device->getRootDeviceEnvironment().getHelper<ProductHelper>())) {
20212021
EXPECT_NE(nullptr, secondaryEngines.engines[secondaryIndex].commandStreamReceiver->getGlobalFenceAllocation());
20222022
}
20232023
if (device->getPreemptionMode() == PreemptionMode::MidThread) {

shared/test/unit_test/direct_submission/windows/wddm_direct_submission_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ HWTEST_F(WddmDirectSubmissionGlobalFenceTest, givenWddmWhenDirectIsInitializedWi
139139
EXPECT_TRUE(ret);
140140
EXPECT_TRUE(wddmDirectSubmission->ringStart);
141141

142-
auto isFenceRequired = device->getGfxCoreHelper().isFenceAllocationRequired(device->getHardwareInfo());
142+
auto isFenceRequired = device->getGfxCoreHelper().isFenceAllocationRequired(device->getHardwareInfo(), device->getProductHelper());
143143
auto &compilerProductHelper = device->getCompilerProductHelper();
144144
auto isHeaplessStateInit = compilerProductHelper.isHeaplessStateInitEnabled(compilerProductHelper.isHeaplessModeEnabled(*defaultHwInfo));
145145
if (isFenceRequired && !isHeaplessStateInit) {

shared/test/unit_test/xe2_hpg_core/gfx_core_helper_tests_xe2_hpg_core.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -478,44 +478,45 @@ XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, whenPipecontrolWaIsProgrammedTh
478478
XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenGfxCoreHelperWhenAskedIfFenceAllocationRequiredThenReturnCorrectValue) {
479479
DebugManagerStateRestore dbgRestore;
480480

481-
auto hwInfo = *defaultHwInfo;
482-
auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
481+
const auto hwInfo = *defaultHwInfo;
482+
const auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
483+
const auto &productHelper = getHelper<ProductHelper>();
483484

484485
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(-1);
485486
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(-1);
486487
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(-1);
487488
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(-1);
488-
EXPECT_EQ(gfxCoreHelper.isFenceAllocationRequired(hwInfo), !hwInfo.capabilityTable.isIntegratedDevice);
489+
EXPECT_EQ(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper), !hwInfo.capabilityTable.isIntegratedDevice);
489490

490491
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0);
491492
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
492493
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
493494
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(0);
494-
EXPECT_FALSE(gfxCoreHelper.isFenceAllocationRequired(hwInfo));
495+
EXPECT_FALSE(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper));
495496

496497
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(1);
497498
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
498499
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
499500
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(0);
500-
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo));
501+
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper));
501502

502503
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0);
503504
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(1);
504505
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
505506
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(0);
506-
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo));
507+
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper));
507508

508509
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0);
509510
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
510511
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(1);
511512
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(0);
512-
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo));
513+
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper));
513514

514515
debugManager.flags.ProgramGlobalFenceAsMiMemFenceCommandInCommandStream.set(0);
515516
debugManager.flags.ProgramGlobalFenceAsPostSyncOperationInComputeWalker.set(0);
516517
debugManager.flags.ProgramGlobalFenceAsKernelInstructionInEUKernel.set(0);
517518
debugManager.flags.DirectSubmissionInsertExtraMiMemFenceCommands.set(1);
518-
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo));
519+
EXPECT_TRUE(gfxCoreHelper.isFenceAllocationRequired(hwInfo, productHelper));
519520
}
520521

521522
XE2_HPG_CORETEST_F(GfxCoreHelperTestsXe2HpgCore, givenDefaultMemorySynchronizationCommandsWhenGettingSizeForAdditionalSynchronizationThenCorrectValueIsReturned) {

0 commit comments

Comments
 (0)