/* * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once #include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/product_config_helper.h" #include "igfxfmid.h" #include namespace NEO { class CompilerProductHelper; struct HardwareInfo; using CompilerProductHelperCreateFunctionType = std::unique_ptr (*)(); extern CompilerProductHelperCreateFunctionType compilerProductHelperFactory[IGFX_MAX_PRODUCT]; class CompilerProductHelper { public: static std::unique_ptr create(PRODUCT_FAMILY product) { if (product == IGFX_UNKNOWN) { return nullptr; } auto createFunction = compilerProductHelperFactory[product]; auto compilerProductHelper = createFunction(); return compilerProductHelper; } virtual bool isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const = 0; virtual bool isForceEmuInt32DivRemSPRequired() const = 0; virtual bool isStatelessToStatefulBufferOffsetSupported() const = 0; virtual bool isForceToStatelessRequired() const = 0; virtual void setProductConfigForHwInfo(HardwareInfo &hwInfo, HardwareIpVersion config) const = 0; virtual const char *getCachingPolicyOptions(bool isDebuggerActive) const = 0; virtual ~CompilerProductHelper() = default; protected: CompilerProductHelper() = default; }; template class CompilerProductHelperHw : public CompilerProductHelper { public: static std::unique_ptr create() { auto compilerProductHelper = std::unique_ptr(new CompilerProductHelperHw()); return compilerProductHelper; } bool isMidThreadPreemptionSupported(const HardwareInfo &hwInfo) const override; bool isForceEmuInt32DivRemSPRequired() const override; bool isStatelessToStatefulBufferOffsetSupported() const override; bool isForceToStatelessRequired() const override; void setProductConfigForHwInfo(HardwareInfo &hwInfo, HardwareIpVersion config) const override; const char *getCachingPolicyOptions(bool isDebuggerActive) const override; ~CompilerProductHelperHw() override = default; protected: CompilerProductHelperHw() = default; }; template struct EnableCompilerProductHelper { using GfxProduct = typename HwMapper::GfxProduct; EnableCompilerProductHelper() { auto compilerProductHelperCreateFunction = CompilerProductHelperHw::create; compilerProductHelperFactory[gfxProduct] = compilerProductHelperCreateFunction; } }; } // namespace NEO