From 5e059d4b30dd920f77874d67fdc8b215f79a42c0 Mon Sep 17 00:00:00 2001 From: Kamil Kopryk Date: Fri, 27 Jan 2023 16:02:13 +0000 Subject: [PATCH] refactor: don't use global ProductHelper getter 16 Related-To: NEO-6853 Signed-off-by: Kamil Kopryk --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 2 +- opencl/source/command_queue/cl_local_work_size.cpp | 4 ++-- .../test/unit_test/helpers/test_preamble_xehp_and_later.cpp | 6 +++--- shared/source/helpers/hw_helper.h | 4 ++-- shared/source/helpers/hw_helper_bdw_and_later.inl | 2 +- shared/source/helpers/hw_helper_xehp_and_later.inl | 6 ++++-- shared/source/helpers/preamble.h | 2 +- shared/source/helpers/preamble_base.inl | 6 ++++-- .../unit_test/gen12lp/adlp/preamble_helper_tests_adlp.cpp | 4 ++-- shared/test/unit_test/helpers/hw_helper_tests.cpp | 4 ++-- shared/test/unit_test/preamble/preamble_tests.cpp | 6 ++++-- 11 files changed, 26 insertions(+), 20 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 649fb48cbd..32f0c0b52d 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -140,7 +140,7 @@ ze_result_t CommandListCoreFamily::initialize(Device *device, NEO auto &hwInfo = device->getHwInfo(); auto &rootDeviceEnvironment = device->getNEODevice()->getRootDeviceEnvironment(); this->dcFlushSupport = NEO::MemorySynchronizationCommands::getDcFlushEnable(true, rootDeviceEnvironment); - this->systolicModeSupport = NEO::PreambleHelper::isSystolicModeConfigurable(hwInfo); + this->systolicModeSupport = NEO::PreambleHelper::isSystolicModeConfigurable(rootDeviceEnvironment); this->stateComputeModeTracking = L0GfxCoreHelper::enableStateComputeModeTracking(rootDeviceEnvironment); this->frontEndStateTracking = L0GfxCoreHelper::enableFrontEndStateTracking(rootDeviceEnvironment); this->pipelineSelectStateTracking = L0GfxCoreHelper::enablePipelineSelectStateTracking(rootDeviceEnvironment); diff --git a/opencl/source/command_queue/cl_local_work_size.cpp b/opencl/source/command_queue/cl_local_work_size.cpp index 911328a2c9..1c30995109 100644 --- a/opencl/source/command_queue/cl_local_work_size.cpp +++ b/opencl/source/command_queue/cl_local_work_size.cpp @@ -27,11 +27,11 @@ Vec3 computeWorkgroupSize(const DispatchInfo &dispatchInfo) { if (kernel != nullptr) { auto &device = dispatchInfo.getClDevice(); - const auto &hwInfo = device.getHardwareInfo(); + const auto &rootDeviceEnvironment = device.getRootDeviceEnvironment(); auto &gfxCoreHelper = device.getGfxCoreHelper(); if (DebugManager.flags.EnableComputeWorkSizeND.get()) { WorkSizeInfo wsInfo = createWorkSizeInfoFromDispatchInfo(dispatchInfo); - if (wsInfo.slmTotalSize == 0 && !wsInfo.hasBarriers && !wsInfo.imgUsed && gfxCoreHelper.preferSmallWorkgroupSizeForKernel(kernel->getKernelInfo().heapInfo.KernelUnpaddedSize, hwInfo) && + if (wsInfo.slmTotalSize == 0 && !wsInfo.hasBarriers && !wsInfo.imgUsed && gfxCoreHelper.preferSmallWorkgroupSizeForKernel(kernel->getKernelInfo().heapInfo.KernelUnpaddedSize, rootDeviceEnvironment) && ((dispatchInfo.getDim() == 1) && (dispatchInfo.getGWS().x % wsInfo.simdSize * 2 == 0))) { wsInfo.maxWorkGroupSize = wsInfo.simdSize * 2; } diff --git a/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp b/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp index 278e843746..f430c33354 100644 --- a/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp +++ b/opencl/test/unit_test/helpers/test_preamble_xehp_and_later.cpp @@ -552,15 +552,15 @@ HWTEST2_F(PipelineSelectTest, WhenProgramPipelineSelectThenProperMaskIsSet, IsWi using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT; MockExecutionEnvironment mockExecutionEnvironment{}; - + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; PIPELINE_SELECT cmd = FamilyType::cmdInitPipelineSelect; LinearStream pipelineSelectStream(&cmd, sizeof(cmd)); PipelineSelectArgs pipelineArgs = {}; - pipelineArgs.systolicPipelineSelectSupport = PreambleHelper::isSystolicModeConfigurable(*defaultHwInfo); + pipelineArgs.systolicPipelineSelectSupport = PreambleHelper::isSystolicModeConfigurable(rootDeviceEnvironment); - PreambleHelper::programPipelineSelect(&pipelineSelectStream, pipelineArgs, *mockExecutionEnvironment.rootDeviceEnvironments[0]); + PreambleHelper::programPipelineSelect(&pipelineSelectStream, pipelineArgs, rootDeviceEnvironment); auto expectedMask = pipelineSelectEnablePipelineSelectMaskBits; if constexpr (FamilyType::isUsingMediaSamplerDopClockGate) { diff --git a/shared/source/helpers/hw_helper.h b/shared/source/helpers/hw_helper.h index aed7ec94c2..46970286ca 100644 --- a/shared/source/helpers/hw_helper.h +++ b/shared/source/helpers/hw_helper.h @@ -62,7 +62,7 @@ class GfxCoreHelper { virtual bool isFenceAllocationRequired(const HardwareInfo &hwInfo) const = 0; virtual const AubMemDump::LrcaHelper &getCsTraits(aub_stream::EngineType engineType) const = 0; virtual bool hvAlign4Required() const = 0; - virtual bool preferSmallWorkgroupSizeForKernel(const size_t size, const HardwareInfo &hwInfo) const = 0; + virtual bool preferSmallWorkgroupSizeForKernel(const size_t size, const RootDeviceEnvironment &rootDeviceEnvironment) const = 0; virtual bool isBufferSizeSuitableForCompression(const size_t size) const = 0; virtual bool checkResourceCompatibility(GraphicsAllocation &graphicsAllocation) const = 0; static bool compressedBuffersSupported(const HardwareInfo &hwInfo); @@ -348,7 +348,7 @@ class GfxCoreHelperHw : public GfxCoreHelper { void applyAdditionalCompressionSettings(Gmm &gmm, bool isNotCompressed) const override; - bool preferSmallWorkgroupSizeForKernel(const size_t size, const HardwareInfo &hwInfo) const override; + bool preferSmallWorkgroupSizeForKernel(const size_t size, const RootDeviceEnvironment &rootDeviceEnvironment) const override; void applyRenderCompressionFlag(Gmm &gmm, uint32_t isCompressed) const override; diff --git a/shared/source/helpers/hw_helper_bdw_and_later.inl b/shared/source/helpers/hw_helper_bdw_and_later.inl index 5f77f09bc3..1fa305a274 100644 --- a/shared/source/helpers/hw_helper_bdw_and_later.inl +++ b/shared/source/helpers/hw_helper_bdw_and_later.inl @@ -99,7 +99,7 @@ uint64_t GfxCoreHelperHw::getGpuTimeStampInNS(uint64_t timeStamp, dou } template -inline bool GfxCoreHelperHw::preferSmallWorkgroupSizeForKernel(const size_t size, const HardwareInfo &hwInfo) const { +inline bool GfxCoreHelperHw::preferSmallWorkgroupSizeForKernel(const size_t size, const RootDeviceEnvironment &rootDeviceEnvironment) const { return false; } diff --git a/shared/source/helpers/hw_helper_xehp_and_later.inl b/shared/source/helpers/hw_helper_xehp_and_later.inl index 37db44d0b1..4a44854c2b 100644 --- a/shared/source/helpers/hw_helper_xehp_and_later.inl +++ b/shared/source/helpers/hw_helper_xehp_and_later.inl @@ -184,8 +184,10 @@ bool MemorySynchronizationCommands::isBarrierWaRequired(const RootDev } template -inline bool GfxCoreHelperHw::preferSmallWorkgroupSizeForKernel(const size_t size, const HardwareInfo &hwInfo) const { - if (ProductHelper::get(hwInfo.platform.eProductFamily)->getSteppingFromHwRevId(hwInfo) >= REVISION_B) { +inline bool GfxCoreHelperHw::preferSmallWorkgroupSizeForKernel(const size_t size, const RootDeviceEnvironment &rootDeviceEnvironment) const { + auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); + if (productHelper.getSteppingFromHwRevId(hwInfo) >= REVISION_B) { return false; } diff --git a/shared/source/helpers/preamble.h b/shared/source/helpers/preamble.h index c420f22f90..26c4525a1d 100644 --- a/shared/source/helpers/preamble.h +++ b/shared/source/helpers/preamble.h @@ -53,7 +53,7 @@ struct PreambleHelper { static void programKernelDebugging(LinearStream *pCommandStream); static void programSemaphoreDelay(LinearStream *pCommandStream); static uint32_t getL3Config(const HardwareInfo &hwInfo, bool useSLM); - static bool isSystolicModeConfigurable(const HardwareInfo &hwInfo); + static bool isSystolicModeConfigurable(const RootDeviceEnvironment &rootDeviceEnvironment); static size_t getAdditionalCommandsSize(const Device &device); static std::vector getSupportedThreadArbitrationPolicies(); static size_t getVFECommandsSize(); diff --git a/shared/source/helpers/preamble_base.inl b/shared/source/helpers/preamble_base.inl index 0d92f21a3f..cb3f2c61ff 100644 --- a/shared/source/helpers/preamble_base.inl +++ b/shared/source/helpers/preamble_base.inl @@ -8,6 +8,7 @@ #include "shared/source/command_stream/linear_stream.h" #include "shared/source/command_stream/preemption.h" #include "shared/source/device/device.h" +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/aligned_memory.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/preamble.h" @@ -115,8 +116,9 @@ uint32_t PreambleHelper::getScratchSizeValueToProgramMediaVfeState(ui } template -bool PreambleHelper::isSystolicModeConfigurable(const HardwareInfo &hwInfo) { - const auto &productHelper = *NEO::ProductHelper::get(hwInfo.platform.eProductFamily); +bool PreambleHelper::isSystolicModeConfigurable(const RootDeviceEnvironment &rootDeviceEnvironment) { + const auto &productHelper = rootDeviceEnvironment.getHelper(); + auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); return productHelper.isSystolicModeConfigurable(hwInfo); } diff --git a/shared/test/unit_test/gen12lp/adlp/preamble_helper_tests_adlp.cpp b/shared/test/unit_test/gen12lp/adlp/preamble_helper_tests_adlp.cpp index 5cef9dff13..8592daa533 100644 --- a/shared/test/unit_test/gen12lp/adlp/preamble_helper_tests_adlp.cpp +++ b/shared/test/unit_test/gen12lp/adlp/preamble_helper_tests_adlp.cpp @@ -34,7 +34,7 @@ ADLPTEST_F(PreambleHelperTestsAdlp, givenSystolicPipelineSelectModeDisabledWhenP DispatchFlags flags = DispatchFlagsHelper::createDefaultDispatchFlags(); flags.pipelineSelectArgs.systolicPipelineSelectMode = false; - flags.pipelineSelectArgs.systolicPipelineSelectSupport = PreambleHelper::isSystolicModeConfigurable(ADLP::hwInfo); + flags.pipelineSelectArgs.systolicPipelineSelectSupport = PreambleHelper::isSystolicModeConfigurable(rootDeviceEnvironment); PreambleHelper::programPipelineSelect(&stream, flags.pipelineSelectArgs, rootDeviceEnvironment); HardwareParse hwParser; @@ -68,7 +68,7 @@ ADLPTEST_F(PreambleHelperTestsAdlp, givenSystolicPipelineSelectModeEnabledWhenPr DispatchFlags flags = DispatchFlagsHelper::createDefaultDispatchFlags(); flags.pipelineSelectArgs.systolicPipelineSelectMode = true; - flags.pipelineSelectArgs.systolicPipelineSelectSupport = PreambleHelper::isSystolicModeConfigurable(ADLP::hwInfo); + flags.pipelineSelectArgs.systolicPipelineSelectSupport = PreambleHelper::isSystolicModeConfigurable(rootDeviceEnvironment); PreambleHelper::programPipelineSelect(&stream, flags.pipelineSelectArgs, rootDeviceEnvironment); HardwareParse hwParser; diff --git a/shared/test/unit_test/helpers/hw_helper_tests.cpp b/shared/test/unit_test/helpers/hw_helper_tests.cpp index cf24f6c873..c8ddbbaf93 100644 --- a/shared/test/unit_test/helpers/hw_helper_tests.cpp +++ b/shared/test/unit_test/helpers/hw_helper_tests.cpp @@ -1167,8 +1167,8 @@ HWTEST_F(GfxCoreHelperTest, whenGettingNumberOfCacheRegionsThenReturnZero) { HWCMDTEST_F(IGFX_GEN8_CORE, GfxCoreHelperTest, whenCheckingForSmallKernelPreferenceThenFalseIsReturned) { auto &gfxCoreHelper = getHelper(); - EXPECT_FALSE(gfxCoreHelper.preferSmallWorkgroupSizeForKernel(0u, this->pDevice->getHardwareInfo())); - EXPECT_FALSE(gfxCoreHelper.preferSmallWorkgroupSizeForKernel(20000u, this->pDevice->getHardwareInfo())); + EXPECT_FALSE(gfxCoreHelper.preferSmallWorkgroupSizeForKernel(0u, this->pDevice->getRootDeviceEnvironment())); + EXPECT_FALSE(gfxCoreHelper.preferSmallWorkgroupSizeForKernel(20000u, this->pDevice->getRootDeviceEnvironment())); } HWTEST_F(GfxCoreHelperTest, whenSetCompressedFlagThenProperFlagSet) { diff --git a/shared/test/unit_test/preamble/preamble_tests.cpp b/shared/test/unit_test/preamble/preamble_tests.cpp index 1c07bb35a7..5ae7376049 100644 --- a/shared/test/unit_test/preamble/preamble_tests.cpp +++ b/shared/test/unit_test/preamble/preamble_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -259,7 +259,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, PreambleTest, WhenGetScratchSpaceAddressOffsetForVfe } HWCMDTEST_F(IGFX_GEN8_CORE, PreambleTest, WhenIsSystolicModeConfigurableThenReturnFalse) { - auto result = PreambleHelper::isSystolicModeConfigurable(*defaultHwInfo); + MockExecutionEnvironment mockExecutionEnvironment{}; + auto &rootDeviceEnvironment = *mockExecutionEnvironment.rootDeviceEnvironments[0]; + auto result = PreambleHelper::isSystolicModeConfigurable(rootDeviceEnvironment); EXPECT_FALSE(result); }