Move ProductHelper ownership to RootDeviceEnvironment

Related-To: NEO-6853
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk
2023-02-01 03:12:09 +00:00
committed by Compute-Runtime-Automation
parent d7a78db328
commit 104126ddd7
23 changed files with 230 additions and 181 deletions

View File

@@ -133,8 +133,7 @@ BindlessHeapsHelper *RootDeviceEnvironment::getBindlessHeapsHelper() const {
}
const ProductHelper &RootDeviceEnvironment::getProductHelper() const {
auto &productHelper = *ProductHelper::get(this->getHardwareInfo()->platform.eProductFamily);
return productHelper;
return *productHelper;
}
void RootDeviceEnvironment::createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield) {
@@ -153,6 +152,7 @@ CompilerInterface *RootDeviceEnvironment::getCompilerInterface() {
}
void RootDeviceEnvironment::initHelpers() {
initProductHelper();
initGfxCoreHelper();
initApiGfxCoreHelper();
}
@@ -162,6 +162,11 @@ void RootDeviceEnvironment::initGfxCoreHelper() {
gfxCoreHelper = GfxCoreHelper::create(this->getHardwareInfo()->platform.eRenderCoreFamily);
}
}
void RootDeviceEnvironment::initProductHelper() {
if (productHelper == nullptr) {
productHelper = ProductHelper::create(this->getHardwareInfo()->platform.eProductFamily);
}
}
BuiltIns *RootDeviceEnvironment::getBuiltIns() {
if (this->builtins.get() == nullptr) {
@@ -189,8 +194,8 @@ HelperType &RootDeviceEnvironment::getHelper() const {
auto &compilerProductHelper = *CompilerProductHelper::get(this->getHardwareInfo()->platform.eProductFamily);
return compilerProductHelper;
} else if constexpr (std::is_same_v<HelperType, ProductHelper>) {
auto &productHelper = *ProductHelper::get(this->getHardwareInfo()->platform.eProductFamily);
return productHelper;
UNRECOVERABLE_IF(productHelper == nullptr);
return *productHelper;
} else {
static_assert(std::is_same_v<HelperType, GfxCoreHelper>, "Only CompilerProductHelper, ProductHelper and GfxCoreHelper are supported");
UNRECOVERABLE_IF(gfxCoreHelper == nullptr);

View File

@@ -68,7 +68,7 @@ struct RootDeviceEnvironment {
void createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield);
void limitNumberOfCcs(uint32_t numberOfCcs);
bool isNumberOfCcsLimited() const;
void initProductHelper();
void initHelpers();
void initGfxCoreHelper();
void initApiGfxCoreHelper();
@@ -90,6 +90,7 @@ struct RootDeviceEnvironment {
std::unique_ptr<SWTagsManager> tagsManager;
std::unique_ptr<ApiGfxCoreHelper> apiGfxCoreHelper;
std::unique_ptr<GfxCoreHelper> gfxCoreHelper;
std::unique_ptr<ProductHelper> productHelper;
ExecutionEnvironment &executionEnvironment;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -9,6 +9,6 @@
namespace NEO {
ProductHelper *productHelperFactory[IGFX_MAX_PRODUCT] = {};
ProductHelperCreateFunctionType productHelperFactory[IGFX_MAX_PRODUCT] = {};
} // namespace NEO

View File

@@ -9,6 +9,7 @@
#include "shared/source/helpers/hw_info.h"
#include <memory>
#include <optional>
namespace AOT {
@@ -37,7 +38,8 @@ class OSInterface;
enum class DriverModelType;
enum class AllocationType;
extern ProductHelper *productHelperFactory[IGFX_MAX_PRODUCT];
using ProductHelperCreateFunctionType = std::unique_ptr<ProductHelper> (*)();
extern ProductHelperCreateFunctionType productHelperFactory[IGFX_MAX_PRODUCT];
enum class UsmAccessCapabilities {
Host = 0,
@@ -49,9 +51,12 @@ enum class UsmAccessCapabilities {
class ProductHelper {
public:
static ProductHelper *get(PRODUCT_FAMILY product) {
return productHelperFactory[product];
static std::unique_ptr<ProductHelper> create(PRODUCT_FAMILY product) {
auto productHelperCreateFunction = productHelperFactory[product];
auto productHelper = productHelperCreateFunction();
return productHelper;
}
static constexpr uint32_t uuidSize = 16u;
static constexpr uint32_t luidSize = 8u;
int configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, const RootDeviceEnvironment &rootDeviceEnvironment);
@@ -188,9 +193,11 @@ class ProductHelper {
virtual bool isMultiContextResourceDeferDeletionSupported() const = 0;
MOCKABLE_VIRTUAL ~ProductHelper() = default;
virtual ~ProductHelper() = default;
protected:
ProductHelper() = default;
virtual LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const = 0;
virtual void fillScmPropertiesSupportStructureBase(StateComputeModePropertiesSupport &propertiesSupport) const = 0;
@@ -201,10 +208,15 @@ class ProductHelper {
template <PRODUCT_FAMILY gfxProduct>
class ProductHelperHw : public ProductHelper {
public:
static ProductHelper *get() {
static ProductHelperHw<gfxProduct> instance;
return &instance;
static std::unique_ptr<ProductHelper> create() {
auto productHelper = std::unique_ptr<ProductHelper>(new ProductHelperHw());
using GfxProduct = typename HwMapper<gfxProduct>::GfxProduct;
productHelper->threadsPerEu = GfxProduct::threadsPerEu;
return productHelper;
}
int configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) const override;
void adjustPlatformForProductFamily(HardwareInfo *hwInfo) override;
void adjustSamplerState(void *sampler, const HardwareInfo &hwInfo) const override;
@@ -337,6 +349,8 @@ class ProductHelperHw : public ProductHelper {
bool isMultiContextResourceDeferDeletionSupported() const override;
~ProductHelperHw() override = default;
protected:
ProductHelperHw() = default;
@@ -351,12 +365,12 @@ class ProductHelperHw : public ProductHelper {
template <PRODUCT_FAMILY gfxProduct>
struct EnableProductProductHelper {
typedef typename HwMapper<gfxProduct>::GfxProduct GfxProduct;
using GfxProduct = typename HwMapper<gfxProduct>::GfxProduct;
EnableProductProductHelper() {
ProductHelper *pProductHelper = ProductHelperHw<gfxProduct>::get();
productHelperFactory[gfxProduct] = pProductHelper;
pProductHelper->threadsPerEu = GfxProduct::threadsPerEu;
auto productHelperCreateFunction = ProductHelperHw<gfxProduct>::create;
productHelperFactory[gfxProduct] = productHelperCreateFunction;
}
};

View File

@@ -101,9 +101,11 @@ bool Wddm::init() {
hardwareInfo->capabilityTable.instrumentationEnabled =
(hardwareInfo->capabilityTable.instrumentationEnabled && instrumentationEnabled);
rootDeviceEnvironment.initProductHelper();
auto &productHelper = rootDeviceEnvironment.getHelper<ProductHelper>();
productHelper.adjustPlatformForProductFamily(hardwareInfo);
rootDeviceEnvironment.initHelpers();
rootDeviceEnvironment.initApiGfxCoreHelper();
rootDeviceEnvironment.initGfxCoreHelper();
if (productHelper.configureHwInfoWddm(hardwareInfo, hardwareInfo, rootDeviceEnvironment)) {
return false;