refactor: don't use global ProductHelper getter 15/n

Related-To: NEO-6853
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk 2023-01-27 15:40:08 +00:00 committed by Compute-Runtime-Automation
parent 5e059d4b30
commit 68bfd49033
14 changed files with 52 additions and 39 deletions

View File

@ -135,7 +135,8 @@ CommandList *CommandList::createImmediate(uint32_t productFamily, Device *device
commandList->cmdListType = CommandListType::TYPE_IMMEDIATE;
commandList->isSyncModeQueue = (desc->mode == ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS);
if (!internalUsage) {
commandList->isFlushTaskSubmissionEnabled = gfxCoreHelper.isPlatformFlushTaskEnabled(hwInfo);
auto &productHelper = device->getProductHelper();
commandList->isFlushTaskSubmissionEnabled = gfxCoreHelper.isPlatformFlushTaskEnabled(productHelper);
if (NEO::DebugManager.flags.EnableFlushTaskSubmission.get() != -1) {
commandList->isFlushTaskSubmissionEnabled = !!NEO::DebugManager.flags.EnableFlushTaskSubmission.get();
}

View File

@ -402,7 +402,8 @@ ze_result_t KernelImp::suggestMaxCooperativeGroupCount(uint32_t *totalGroupCount
dssCount = hardwareInfo.gtSystemInfo.SubSliceCount;
}
auto &helper = module->getDevice()->getNEODevice()->getRootDeviceEnvironment().getHelper<NEO::GfxCoreHelper>();
auto &rootDeviceEnvironment = module->getDevice()->getNEODevice()->getRootDeviceEnvironment();
auto &helper = rootDeviceEnvironment.getHelper<NEO::GfxCoreHelper>();
auto &descriptor = kernelImmData->getDescriptor();
auto availableThreadCount = helper.calculateAvailableThreadCount(hardwareInfo, descriptor.kernelAttributes.numGrfRequired);
@ -422,7 +423,7 @@ ze_result_t KernelImp::suggestMaxCooperativeGroupCount(uint32_t *totalGroupCount
barrierCount,
workDim,
localWorkSize);
*totalGroupCount = helper.adjustMaxWorkGroupCount(*totalGroupCount, engineGroupType, hardwareInfo, isEngineInstanced);
*totalGroupCount = helper.adjustMaxWorkGroupCount(*totalGroupCount, engineGroupType, rootDeviceEnvironment, isEngineInstanced);
return ZE_RESULT_SUCCESS;
}

View File

@ -3579,7 +3579,7 @@ TEST_F(DeviceTest, givenValidDeviceWhenCallingReleaseResourcesThenResourcesRelea
HWTEST_F(DeviceTest, givenCooperativeDispatchSupportedWhenQueryingPropertiesFlagsThenCooperativeKernelsAreSupported) {
struct MockGfxCoreHelper : NEO::GfxCoreHelperHw<FamilyType> {
bool isCooperativeDispatchSupported(const EngineGroupType engineGroupType, const HardwareInfo &hwInfo) const override {
bool isCooperativeDispatchSupported(const EngineGroupType engineGroupType, const RootDeviceEnvironment &rootDeviceEnvironment) const override {
return isCooperativeDispatchSupportedValue;
}
bool isCooperativeDispatchSupportedValue = true;

View File

@ -6049,7 +6049,7 @@ cl_int CL_API_CALL clEnqueueNDCountKernelINTEL(cl_command_queue commandQueue,
auto &gfxCoreHelper = device.getGfxCoreHelper();
auto engineGroupType = gfxCoreHelper.getEngineGroupType(pCommandQueue->getGpgpuEngine().getEngineType(),
pCommandQueue->getGpgpuEngine().getEngineUsage(), hardwareInfo);
if (!gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, hardwareInfo)) {
if (!gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, device.getRootDeviceEnvironment())) {
retVal = CL_INVALID_COMMAND_QUEUE;
return retVal;
}

View File

@ -1110,7 +1110,8 @@ void Kernel::getSuggestedLocalWorkSize(const cl_uint workDim, const size_t *glob
uint32_t Kernel::getMaxWorkGroupCount(const cl_uint workDim, const size_t *localWorkSize, const CommandQueue *commandQueue) const {
auto &hardwareInfo = getHardwareInfo();
auto &helper = this->getDevice().getRootDeviceEnvironment().getHelper<GfxCoreHelper>();
auto &rootDeviceEnvironment = this->getDevice().getRootDeviceEnvironment();
auto &helper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
auto engineGroupType = helper.getEngineGroupType(commandQueue->getGpgpuEngine().getEngineType(),
commandQueue->getGpgpuEngine().getEngineUsage(), hardwareInfo);
@ -1136,7 +1137,7 @@ uint32_t Kernel::getMaxWorkGroupCount(const cl_uint workDim, const size_t *local
workDim,
localWorkSize);
auto isEngineInstanced = commandQueue->getGpgpuCommandStreamReceiver().getOsContext().isEngineInstanced();
maxWorkGroupCount = helper.adjustMaxWorkGroupCount(maxWorkGroupCount, engineGroupType, hardwareInfo, isEngineInstanced);
maxWorkGroupCount = helper.adjustMaxWorkGroupCount(maxWorkGroupCount, engineGroupType, rootDeviceEnvironment, isEngineInstanced);
return maxWorkGroupCount;
}

View File

@ -316,7 +316,7 @@ TEST_F(clEnqueueNDCountKernelTests, GivenQueueIncapableWhenEnqueuingNDCountKerne
auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto engineGroupType = gfxCoreHelper.getEngineGroupType(pCommandQueue->getGpgpuEngine().getEngineType(),
pCommandQueue->getGpgpuEngine().getEngineUsage(), *::defaultHwInfo);
if (!gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, *::defaultHwInfo)) {
if (!gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, pDevice->getRootDeviceEnvironment())) {
GTEST_SKIP();
}
@ -350,7 +350,7 @@ TEST_F(EnqueueKernelTest, givenKernelWhenAllArgsAreSetThenClEnqueueNDCountKernel
auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto engineGroupType = gfxCoreHelper.getEngineGroupType(pCmdQ2->getGpgpuEngine().getEngineType(),
pCmdQ2->getGpgpuEngine().getEngineUsage(), hardwareInfo);
if (!gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, hardwareInfo)) {
if (!gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, pDevice->getRootDeviceEnvironment())) {
pCmdQ2->getGpgpuEngine().osContext = pCmdQ2->getDevice().getEngine(aub_stream::ENGINE_CCS, EngineUsage::LowPriority).osContext;
}
@ -398,7 +398,7 @@ TEST_F(EnqueueKernelTest, givenKernelWhenNotAllArgsAreSetButSetKernelArgIsCalled
auto &gfxCoreHelper = pClDevice->getGfxCoreHelper();
auto engineGroupType = gfxCoreHelper.getEngineGroupType(pCmdQ2->getGpgpuEngine().getEngineType(),
pCmdQ2->getGpgpuEngine().getEngineUsage(), hardwareInfo);
if (!gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, hardwareInfo)) {
if (!gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, pDevice->getRootDeviceEnvironment())) {
pCmdQ2->getGpgpuEngine().osContext = pCmdQ2->getDevice().getEngine(aub_stream::ENGINE_CCS, EngineUsage::LowPriority).osContext;
}
@ -446,7 +446,7 @@ TEST_F(EnqueueKernelTest, givenKernelWhenSetKernelArgIsCalledForEachArgButAtLeas
auto &gfxCoreHelper = pClDevice->getGfxCoreHelper();
auto engineGroupType = gfxCoreHelper.getEngineGroupType(pCmdQ2->getGpgpuEngine().getEngineType(),
pCmdQ2->getGpgpuEngine().getEngineUsage(), hardwareInfo);
if (!gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, hardwareInfo)) {
if (!gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, pDevice->getRootDeviceEnvironment())) {
pCmdQ2->getGpgpuEngine().osContext = pCmdQ2->getDevice().getEngine(aub_stream::ENGINE_CCS, EngineUsage::LowPriority).osContext;
}

View File

@ -102,7 +102,7 @@ class SyncBufferHandlerTest : public SyncBufferEnqueueHandlerTest {
auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto engineGroupType = gfxCoreHelper.getEngineGroupType(commandQueue->getGpgpuEngine().getEngineType(),
commandQueue->getGpgpuEngine().getEngineUsage(), hardwareInfo);
return gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, pDevice->getHardwareInfo());
return gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, pDevice->getRootDeviceEnvironment());
}
const cl_uint workDim = 1;

View File

@ -204,7 +204,7 @@ void GfxCoreHelperHw<Family>::setExtraAllocationData(AllocationData &allocationD
allocationData.flags.useSystemMemory = true;
}
}
if (ProductHelper::get(hwInfo.platform.eProductFamily)->isStorageInfoAdjustmentRequired()) {
if (productHelper.isStorageInfoAdjustmentRequired()) {
if (properties.allocationType == AllocationType::BUFFER && !properties.flags.preferCompressed && !properties.flags.shareable) {
allocationData.storageInfo.isLockable = true;
}

View File

@ -115,9 +115,9 @@ class GfxCoreHelper {
virtual bool packedFormatsSupported() const = 0;
virtual bool isAssignEngineRoundRobinSupported(const HardwareInfo &hwInfo) const = 0;
virtual bool isRcsAvailable(const HardwareInfo &hwInfo) const = 0;
virtual bool isCooperativeDispatchSupported(const EngineGroupType engineGroupType, const HardwareInfo &hwInfo) const = 0;
virtual bool isCooperativeDispatchSupported(const EngineGroupType engineGroupType, const RootDeviceEnvironment &rootDeviceEnvironment) const = 0;
virtual uint32_t adjustMaxWorkGroupCount(uint32_t maxWorkGroupCount, const EngineGroupType engineGroupType,
const HardwareInfo &hwInfo, bool isEngineInstanced) const = 0;
const RootDeviceEnvironment &rootDeviceEnvironment, bool isEngineInstanced) const = 0;
virtual size_t getMaxFillPaternSizeForCopyEngine() const = 0;
virtual size_t getSipKernelMaxDbgSurfaceSize(const HardwareInfo &hwInfo) const = 0;
virtual bool isSipWANeeded(const HardwareInfo &hwInfo) const = 0;
@ -160,7 +160,7 @@ class GfxCoreHelper {
virtual bool platformSupportsImplicitScaling(const NEO::HardwareInfo &hwInfo) const = 0;
virtual size_t getBatchBufferEndSize() const = 0;
virtual const void *getBatchBufferEndReference() const = 0;
virtual bool isPlatformFlushTaskEnabled(const NEO::HardwareInfo &hwInfo) const = 0;
virtual bool isPlatformFlushTaskEnabled(const NEO::ProductHelper &productHelper) const = 0;
virtual uint32_t getMinimalScratchSpaceSize() const = 0;
virtual bool copyThroughLockedPtrEnabled(const HardwareInfo &hwInfo) const = 0;
virtual uint32_t getAmountOfAllocationsToFill() const = 0;
@ -313,10 +313,10 @@ class GfxCoreHelperHw : public GfxCoreHelper {
bool isRcsAvailable(const HardwareInfo &hwInfo) const override;
bool isCooperativeDispatchSupported(const EngineGroupType engineGroupType, const HardwareInfo &hwInfo) const override;
bool isCooperativeDispatchSupported(const EngineGroupType engineGroupType, const RootDeviceEnvironment &rootDeviceEnvironment) const override;
uint32_t adjustMaxWorkGroupCount(uint32_t maxWorkGroupCount, const EngineGroupType engineGroupType,
const HardwareInfo &hwInfo, bool isEngineInstanced) const override;
const RootDeviceEnvironment &rootDeviceEnvironment, bool isEngineInstanced) const override;
size_t getMaxFillPaternSizeForCopyEngine() const override;
@ -377,7 +377,7 @@ class GfxCoreHelperHw : public GfxCoreHelper {
bool platformSupportsImplicitScaling(const NEO::HardwareInfo &hwInfo) const override;
size_t getBatchBufferEndSize() const override;
const void *getBatchBufferEndReference() const override;
bool isPlatformFlushTaskEnabled(const NEO::HardwareInfo &hwInfo) const override;
bool isPlatformFlushTaskEnabled(const NEO::ProductHelper &productHelper) const override;
uint32_t getMinimalScratchSpaceSize() const override;
bool copyThroughLockedPtrEnabled(const HardwareInfo &hwInfo) const override;
uint32_t getAmountOfAllocationsToFill() const override;

View File

@ -587,13 +587,13 @@ bool GfxCoreHelperHw<GfxFamily>::isRcsAvailable(const HardwareInfo &hwInfo) cons
}
template <typename GfxFamily>
bool GfxCoreHelperHw<GfxFamily>::isCooperativeDispatchSupported(const EngineGroupType engineGroupType, const HardwareInfo &hwInfo) const {
bool GfxCoreHelperHw<GfxFamily>::isCooperativeDispatchSupported(const EngineGroupType engineGroupType, const RootDeviceEnvironment &rootDeviceEnvironment) const {
return true;
}
template <typename GfxFamily>
uint32_t GfxCoreHelperHw<GfxFamily>::adjustMaxWorkGroupCount(uint32_t maxWorkGroupCount, const EngineGroupType engineGroupType,
const HardwareInfo &hwInfo, bool isEngineInstanced) const {
const RootDeviceEnvironment &rootDeviceEnvironment, bool isEngineInstanced) const {
return maxWorkGroupCount;
}
@ -684,8 +684,7 @@ const void *GfxCoreHelperHw<GfxFamily>::getBatchBufferEndReference() const {
return reinterpret_cast<const void *>(&GfxFamily::cmdInitBatchBufferEnd);
}
template <typename GfxFamily>
bool GfxCoreHelperHw<GfxFamily>::isPlatformFlushTaskEnabled(const HardwareInfo &hwInfo) const {
const auto &productHelper = *NEO::ProductHelper::get(hwInfo.platform.eProductFamily);
bool GfxCoreHelperHw<GfxFamily>::isPlatformFlushTaskEnabled(const ProductHelper &productHelper) const {
return productHelper.isFlushTaskAllowed();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -33,8 +33,9 @@ bool GfxCoreHelperHw<Family>::isRcsAvailable(const HardwareInfo &hwInfo) const {
}
template <>
bool GfxCoreHelperHw<Family>::isCooperativeDispatchSupported(const EngineGroupType engineGroupType, const HardwareInfo &hwInfo) const {
auto &productHelper = *ProductHelper::get(hwInfo.platform.eProductFamily);
bool GfxCoreHelperHw<Family>::isCooperativeDispatchSupported(const EngineGroupType engineGroupType, const RootDeviceEnvironment &rootDeviceEnvironment) const {
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
if (productHelper.isCooperativeEngineSupported(hwInfo)) {
if (engineGroupType == EngineGroupType::RenderCompute) {
return false;
@ -49,19 +50,21 @@ bool GfxCoreHelperHw<Family>::isCooperativeDispatchSupported(const EngineGroupTy
template <>
uint32_t GfxCoreHelperHw<Family>::adjustMaxWorkGroupCount(uint32_t maxWorkGroupCount, const EngineGroupType engineGroupType,
const HardwareInfo &hwInfo, bool isEngineInstanced) const {
const RootDeviceEnvironment &rootDeviceEnvironment, bool isEngineInstanced) const {
if ((DebugManager.flags.ForceTheoreticalMaxWorkGroupCount.get()) ||
(DebugManager.flags.OverrideMaxWorkGroupCount.get() != -1)) {
return maxWorkGroupCount;
}
if (!isCooperativeDispatchSupported(engineGroupType, hwInfo)) {
if (!isCooperativeDispatchSupported(engineGroupType, rootDeviceEnvironment)) {
return 1u;
}
auto &productHelper = *ProductHelper::get(hwInfo.platform.eProductFamily);
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
bool requiresLimitation = productHelper.isCooperativeEngineSupported(hwInfo) &&
(engineGroupType != EngineGroupType::CooperativeCompute) &&
(!isEngineInstanced);
if (requiresLimitation) {
auto ccsCount = hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
UNRECOVERABLE_IF(ccsCount == 0);
return maxWorkGroupCount / ccsCount;

View File

@ -1278,17 +1278,20 @@ HWTEST_F(GfxCoreHelperTest, givenGfxCoreHelperWhenGettingIfRevisionSpecificBinar
HWTEST2_F(GfxCoreHelperTest, givenDG2GfxCoreHelperWhenGettingIsPlatformFlushTaskEnabledThenTrueIsReturned, IsDG2) {
const auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
EXPECT_TRUE(gfxCoreHelper.isPlatformFlushTaskEnabled(*defaultHwInfo));
auto &productHelper = getHelper<ProductHelper>();
EXPECT_TRUE(gfxCoreHelper.isPlatformFlushTaskEnabled(productHelper));
}
HWTEST2_F(GfxCoreHelperTest, givenPvcGfxCoreHelperWhenGettingIsPlatformFlushTaskEnabledThenTrueIsReturned, IsPVC) {
const auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
EXPECT_TRUE(gfxCoreHelper.isPlatformFlushTaskEnabled(*defaultHwInfo));
auto &productHelper = getHelper<ProductHelper>();
EXPECT_TRUE(gfxCoreHelper.isPlatformFlushTaskEnabled(productHelper));
}
HWTEST2_F(GfxCoreHelperTest, givenAtMostGen12lpGfxCoreHelperWhenGettingIsPlatformFlushTaskEnabledThenFalseIsReturned, IsAtMostGen12lp) {
const auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
EXPECT_TRUE(gfxCoreHelper.isPlatformFlushTaskEnabled(*defaultHwInfo));
auto &productHelper = getHelper<ProductHelper>();
EXPECT_TRUE(gfxCoreHelper.isPlatformFlushTaskEnabled(productHelper));
}
struct CoherentWANotNeeded {

View File

@ -138,7 +138,9 @@ HWTEST2_F(GfxCoreHelperTestPvcAndLater, WhenIsCooperativeDispatchSupportedThenCo
};
MockProductHelperHw<productFamily> productHelper;
auto hwInfo = *::defaultHwInfo;
MockExecutionEnvironment mockExecutionEnvironment{};
auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0];
auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo();
VariableBackup<ProductHelper *> productHelperFactoryBackup{&NEO::productHelperFactory[static_cast<size_t>(hwInfo.platform.eProductFamily)]};
productHelperFactoryBackup = &productHelper;
@ -151,7 +153,7 @@ HWTEST2_F(GfxCoreHelperTestPvcAndLater, WhenIsCooperativeDispatchSupportedThenCo
for (auto engineGroupType : {EngineGroupType::RenderCompute, EngineGroupType::Compute,
EngineGroupType::CooperativeCompute}) {
auto isCooperativeDispatchSupported = gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, hwInfo);
auto isCooperativeDispatchSupported = gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, rootDeviceEnvironment);
if (isCooperativeEngineSupported) {
switch (engineGroupType) {
case EngineGroupType::RenderCompute:

View File

@ -155,28 +155,31 @@ PVCTEST_F(EngineNodeHelperPvcTests, givenCccsDisabledWhenGetGpgpuEnginesCalledTh
PVCTEST_F(EngineNodeHelperPvcTests, givenCCSEngineWhenCallingIsCooperativeDispatchSupportedThenTrueIsReturned) {
const auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
auto hwInfo = *defaultHwInfo;
auto &rootDeviceEnvironment = *pDevice->executionEnvironment->rootDeviceEnvironments[0];
auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo();
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS;
auto engineGroupType = gfxCoreHelper.getEngineGroupType(pDevice->getDefaultEngine().getEngineType(),
pDevice->getDefaultEngine().getEngineUsage(), hwInfo);
auto retVal = gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, hwInfo);
auto retVal = gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, rootDeviceEnvironment);
EXPECT_TRUE(retVal);
}
PVCTEST_F(EngineNodeHelperPvcTests, givenCCCSEngineAndRevisionBWhenCallingIsCooperativeDispatchSupportedThenFalseIsReturned) {
const auto &productHelper = getHelper<ProductHelper>();
const auto &gfxCoreHelper = getHelper<GfxCoreHelper>();
auto hwInfo = *defaultHwInfo;
auto &rootDeviceEnvironment = *pDevice->executionEnvironment->rootDeviceEnvironments[0];
auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo();
hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCCS;
auto engineGroupType = gfxCoreHelper.getEngineGroupType(pDevice->getDefaultEngine().getEngineType(),
pDevice->getDefaultEngine().getEngineUsage(), hwInfo);
auto retVal = gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, hwInfo);
auto retVal = gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, rootDeviceEnvironment);
EXPECT_TRUE(retVal);
hwInfo.platform.usRevId = productHelper.getHwRevIdFromStepping(REVISION_B, hwInfo);
retVal = gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, hwInfo);
retVal = gfxCoreHelper.isCooperativeDispatchSupported(engineGroupType, rootDeviceEnvironment);
EXPECT_FALSE(retVal);
}