Files
compute-runtime/shared/source/ail/ail_configuration.h
Kacper Nowak c504b497d7 refactor: Store AIL in root device environment
Instead of storing AIL configurations in global table, store it
in root device environment.
This also prevents potential scenario with accessing deleted memory due
to symbol collision when application uses both OCL/L0 libraries.
- AIL is now stored in root device environment, and gets initialized
with other helpers
- Minor: corrected naming in ULTs

Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
Related-To: NEO-9240
2023-11-17 15:18:27 +01:00

109 lines
3.3 KiB
C++

/*
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "igfxfmid.h"
#include <cstdint>
#include <memory>
#include <set>
#include <string>
/*
* AIL (Application Intelligence Layer) is a set of per-application controls that influence driver behavior.
* The primary goal is to improve user experience and/or performance.
*
* AIL provides application detection mechanism based on running processes in the system.
* Mechanism works on Windows and Linux, is flexible and easily extendable to new applications.
*
* E.g. AIL can detect running Blender application and enable fp64 emulation on hardware
* that does not support native fp64.
*
* Disclaimer: we should never use this for benchmarking or conformance purposes - this would be cheating.
*
*/
namespace NEO {
extern const char legacyPlatformName[];
struct RuntimeCapabilityTable;
enum class AILEnumeration : uint32_t {
DISABLE_BLITTER,
DISABLE_COMPRESSION,
ENABLE_FP64,
DISABLE_HOST_PTR_TRACKING,
ENABLE_LEGACY_PLATFORM_NAME,
DISABLE_DIRECT_SUBMISSION,
AIL_MAX_OPTIONS_COUNT
};
class AILConfiguration;
using AILConfigurationCreateFunctionType = std::unique_ptr<AILConfiguration> (*)();
extern AILConfigurationCreateFunctionType ailConfigurationFactory[IGFX_MAX_PRODUCT];
class AILConfiguration {
public:
static std::unique_ptr<AILConfiguration> create(PRODUCT_FAMILY product) {
auto ailConfigurationCreateFunction = ailConfigurationFactory[product];
if (ailConfigurationCreateFunction == nullptr) {
return nullptr;
}
auto ailConfiguration = ailConfigurationCreateFunction();
return ailConfiguration;
}
AILConfiguration() = default;
MOCKABLE_VIRTUAL bool initProcessExecutableName();
virtual void apply(RuntimeCapabilityTable &runtimeCapabilityTable);
virtual void modifyKernelIfRequired(std::string &kernel) = 0;
virtual bool isFallbackToPatchtokensRequired(const std::string &kernelSources) = 0;
virtual bool isContextSyncFlagRequired() = 0;
virtual ~AILConfiguration() = default;
protected:
virtual void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) = 0;
std::string processName;
bool sourcesContain(const std::string &sources, std::string_view contentToFind) const;
MOCKABLE_VIRTUAL bool isKernelHashCorrect(const std::string &kernelSources, uint64_t expectedHash) const;
};
extern const std::set<std::string_view> applicationsContextSyncFlag;
template <PRODUCT_FAMILY Product>
class AILConfigurationHw : public AILConfiguration {
public:
static std::unique_ptr<AILConfiguration> create() {
auto ailConfiguration = std::unique_ptr<AILConfiguration>(new AILConfigurationHw());
return ailConfiguration;
}
void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) override;
void modifyKernelIfRequired(std::string &kernel) override;
bool isFallbackToPatchtokensRequired(const std::string &kernelSources) override;
bool isContextSyncFlagRequired() override;
};
template <PRODUCT_FAMILY product>
struct EnableAIL {
EnableAIL() {
auto ailConfigurationCreateFunction = AILConfigurationHw<product>::create;
ailConfigurationFactory[product] = ailConfigurationCreateFunction;
}
};
} // namespace NEO