From 0e6cc86821c85464d29882db49989b9f22737208 Mon Sep 17 00:00:00 2001 From: Kamil Kopryk Date: Tue, 20 Dec 2022 15:13:56 +0000 Subject: [PATCH] Don't use global ProductHelper getter in L0 1/n Related-To: NEO-6853 Signed-off-by: Kamil Kopryk --- .../cmdqueue/cmdqueue_xe_hp_core_and_later.inl | 2 +- level_zero/core/source/device/device.h | 1 + level_zero/core/source/device/device_imp.cpp | 6 +++++- level_zero/core/source/device/device_imp.h | 1 + level_zero/core/test/unit_tests/mocks/mock_device.h | 1 + shared/source/os_interface/hw_info_config.h | 12 ++++++------ shared/source/os_interface/hw_info_config.inl | 6 +++--- .../source/xe_hpc_core/linux/hw_info_config_pvc.cpp | 6 +++--- shared/test/common/helpers/mock_hw_info_config_hw.h | 4 ++-- .../test/common/helpers/mock_hw_info_config_hw.inl | 4 ++-- shared/test/common/mocks/mock_hw_info_config.cpp | 6 +++--- 11 files changed, 28 insertions(+), 21 deletions(-) diff --git a/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl b/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl index f2df2fe898..aad3535a7e 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl @@ -91,7 +91,7 @@ size_t CommandQueueHw::estimateStateBaseAddressCmdSize() { NEO::Device *neoDevice = device->getNEODevice(); auto &hwInfo = neoDevice->getHardwareInfo(); - auto &productHelper = *NEO::ProductHelper::get(hwInfo.platform.eProductFamily); + auto &productHelper = neoDevice->getProductHelper(); size_t size = 0; if (NEO::ApiSpecificConfig::getBindlessConfiguration()) { diff --git a/level_zero/core/source/device/device.h b/level_zero/core/source/device/device.h index 864082481c..242128c280 100644 --- a/level_zero/core/source/device/device.h +++ b/level_zero/core/source/device/device.h @@ -94,6 +94,7 @@ struct Device : _ze_device_handle_t { virtual uint32_t getMaxNumHwThreads() const = 0; virtual const NEO::GfxCoreHelper &getGfxCoreHelper() = 0; + virtual const NEO::ProductHelper &getProductHelper() = 0; bool isImplicitScalingCapable() const { return implicitScalingCapable; } diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index a442435a3a..c0f6b629c1 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -552,7 +552,7 @@ ze_result_t DeviceImp::getMemoryProperties(uint32_t *pCount, ze_device_memory_pr const auto &deviceInfo = this->neoDevice->getDeviceInfo(); auto &hwInfo = this->getHwInfo(); - auto &productHelper = *NEO::ProductHelper::get(hwInfo.platform.eProductFamily); + auto &productHelper = this->getProductHelper(); strcpy_s(pMemProperties->name, ZE_MAX_DEVICE_NAME, productHelper.getDeviceMemoryName().c_str()); auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get(); pMemProperties->maxClockRate = productHelper.getDeviceMemoryMaxClkRate(hwInfo, osInterface, 0); @@ -1053,6 +1053,10 @@ const NEO::GfxCoreHelper &DeviceImp::getGfxCoreHelper() { return this->neoDevice->getGfxCoreHelper(); } +const NEO::ProductHelper &DeviceImp::getProductHelper() { + return this->neoDevice->getProductHelper(); +} + NEO::OSInterface &DeviceImp::getOsInterface() { return *neoDevice->getRootDeviceEnvironment().osInterface; } uint32_t DeviceImp::getPlatformInfo() const { diff --git a/level_zero/core/source/device/device_imp.h b/level_zero/core/source/device/device_imp.h index fcc1f0ebdb..a03903280b 100644 --- a/level_zero/core/source/device/device_imp.h +++ b/level_zero/core/source/device/device_imp.h @@ -73,6 +73,7 @@ struct DeviceImp : public Device { BuiltinFunctionsLib *getBuiltinFunctionsLib() override; uint32_t getMOCS(bool l3enabled, bool l1enabled) override; const NEO::GfxCoreHelper &getGfxCoreHelper() override; + const NEO::ProductHelper &getProductHelper() override; const NEO::HardwareInfo &getHwInfo() const override; NEO::OSInterface &getOsInterface() override; uint32_t getPlatformInfo() const override; diff --git a/level_zero/core/test/unit_tests/mocks/mock_device.h b/level_zero/core/test/unit_tests/mocks/mock_device.h index 6fec80fe2d..3bed34adb1 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_device.h +++ b/level_zero/core/test/unit_tests/mocks/mock_device.h @@ -58,6 +58,7 @@ struct Mock : public Device { // Runtime internal methods ADDMETHOD_NOBASE(getExecEnvironment, void *, nullptr, ()); ADDMETHOD_NOBASE_REFRETURN(getGfxCoreHelper, NEO::GfxCoreHelper &, ()); + ADDMETHOD_NOBASE_REFRETURN(getProductHelper, NEO::ProductHelper &, ()); ADDMETHOD_NOBASE(getBuiltinFunctionsLib, BuiltinFunctionsLib *, nullptr, ()); ADDMETHOD_CONST_NOBASE(getMaxNumHwThreads, uint32_t, 16u, ()); ADDMETHOD_NOBASE(activateMetricGroupsDeferred, ze_result_t, ZE_RESULT_SUCCESS, (uint32_t count, zet_metric_group_handle_t *phMetricGroups)); diff --git a/shared/source/os_interface/hw_info_config.h b/shared/source/os_interface/hw_info_config.h index d5c4e688cd..316eb1252b 100644 --- a/shared/source/os_interface/hw_info_config.h +++ b/shared/source/os_interface/hw_info_config.h @@ -66,9 +66,9 @@ class ProductHelper { virtual uint64_t getSharedSystemMemCapabilities(const HardwareInfo *hwInfo) = 0; virtual void getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) = 0; virtual std::vector getKernelSupportedThreadArbitrationPolicies() = 0; - virtual uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) = 0; - virtual uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) = 0; - virtual uint64_t getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) = 0; + virtual uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const = 0; + virtual uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) const = 0; + virtual uint64_t getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const = 0; virtual bool isAdditionalStateBaseAddressWARequired(const HardwareInfo &hwInfo) const = 0; virtual bool isMaxThreadsForWorkgroupWARequired(const HardwareInfo &hwInfo) const = 0; virtual uint32_t getMaxThreadsForWorkgroupInDSSOrSS(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice, uint32_t maxNumEUsPerDualSubSlice) const = 0; @@ -211,9 +211,9 @@ class ProductHelperHw : public ProductHelper { uint64_t getSharedSystemMemCapabilities(const HardwareInfo *hwInfo) override; void getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) override; std::vector getKernelSupportedThreadArbitrationPolicies() override; - uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) override; - uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) override; - uint64_t getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) override; + uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const override; + uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) const override; + uint64_t getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const override; bool isAdditionalStateBaseAddressWARequired(const HardwareInfo &hwInfo) const override; bool isMaxThreadsForWorkgroupWARequired(const HardwareInfo &hwInfo) const override; uint32_t getMaxThreadsForWorkgroupInDSSOrSS(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice, uint32_t maxNumEUsPerDualSubSlice) const override; diff --git a/shared/source/os_interface/hw_info_config.inl b/shared/source/os_interface/hw_info_config.inl index 3e70bcf30d..5567b6ee0d 100644 --- a/shared/source/os_interface/hw_info_config.inl +++ b/shared/source/os_interface/hw_info_config.inl @@ -135,17 +135,17 @@ bool ProductHelperHw::getConcurrentAccessMemCapabilitiesSupported(Us } template -uint32_t ProductHelperHw::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) { +uint32_t ProductHelperHw::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const { return 0u; } template -uint64_t ProductHelperHw::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) { +uint64_t ProductHelperHw::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) const { return 0; } template -uint64_t ProductHelperHw::getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) { +uint64_t ProductHelperHw::getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const { return 0; } diff --git a/shared/source/xe_hpc_core/linux/hw_info_config_pvc.cpp b/shared/source/xe_hpc_core/linux/hw_info_config_pvc.cpp index 37aa8a86d0..f8f4ccd553 100644 --- a/shared/source/xe_hpc_core/linux/hw_info_config_pvc.cpp +++ b/shared/source/xe_hpc_core/linux/hw_info_config_pvc.cpp @@ -36,7 +36,7 @@ const std::map> guidUuidOffsetMap = { namespace NEO { template <> -uint64_t ProductHelperHw::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) { +uint64_t ProductHelperHw::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) const { if (osIface == nullptr) { return 0; @@ -51,7 +51,7 @@ uint64_t ProductHelperHw::getDeviceMemoryPhysicalSizeInBytes(const O } template <> -uint32_t ProductHelperHw::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) { +uint32_t ProductHelperHw::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const { if (osIface == nullptr) { return 0; @@ -67,7 +67,7 @@ uint32_t ProductHelperHw::getDeviceMemoryMaxClkRate(const HardwareIn } template <> -uint64_t ProductHelperHw::getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) { +uint64_t ProductHelperHw::getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const { uint64_t memoryMaxClkRateInMhz = getDeviceMemoryMaxClkRate(hwInfo, osIface, subDeviceIndex); const uint64_t numberOfHbmStacksPerTile = 4u; const uint64_t memoryBusWidth = 128u; diff --git a/shared/test/common/helpers/mock_hw_info_config_hw.h b/shared/test/common/helpers/mock_hw_info_config_hw.h index fb296328a6..104259228a 100644 --- a/shared/test/common/helpers/mock_hw_info_config_hw.h +++ b/shared/test/common/helpers/mock_hw_info_config_hw.h @@ -18,8 +18,8 @@ struct MockProductHelperHw : NEO::ProductHelperHw { bool getUuid(Device *device, std::array &uuid) const override; uint32_t getSteppingFromHwRevId(const HardwareInfo &hwInfo) const override; int configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) const override; - uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) override; - uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) override; + uint64_t getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) const override; + uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const override; uint32_t getL1CachePolicy(bool isDebuggerActive) const override; bool use128MbEdram = false; diff --git a/shared/test/common/helpers/mock_hw_info_config_hw.inl b/shared/test/common/helpers/mock_hw_info_config_hw.inl index e6e9340412..18967acdef 100644 --- a/shared/test/common/helpers/mock_hw_info_config_hw.inl +++ b/shared/test/common/helpers/mock_hw_info_config_hw.inl @@ -48,12 +48,12 @@ int MockProductHelperHw::configureHardwareCustom(HardwareInfo *hwInf } template <> -uint64_t MockProductHelperHw::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) { +uint64_t MockProductHelperHw::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) const { return 1024u; } template <> -uint32_t MockProductHelperHw::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) { +uint32_t MockProductHelperHw::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const { return 800u; } diff --git a/shared/test/common/mocks/mock_hw_info_config.cpp b/shared/test/common/mocks/mock_hw_info_config.cpp index 4d90c44f03..0cb5eb19f3 100644 --- a/shared/test/common/mocks/mock_hw_info_config.cpp +++ b/shared/test/common/mocks/mock_hw_info_config.cpp @@ -72,17 +72,17 @@ bool ProductHelperHw::overrideGfxPartitionLayoutForWsl() const { } template <> -uint32_t ProductHelperHw::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) { +uint32_t ProductHelperHw::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const { return 0; } template <> -uint64_t ProductHelperHw::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) { +uint64_t ProductHelperHw::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) const { return 0; } template <> -uint64_t ProductHelperHw::getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) { +uint64_t ProductHelperHw::getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) const { return 0; }