2019-10-24 13:34:25 +02:00
|
|
|
/*
|
2023-01-02 09:56:45 +00:00
|
|
|
* Copyright (C) 2019-2023 Intel Corporation
|
2019-10-24 13:34:25 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2019-10-24 13:34:25 +02:00
|
|
|
|
2021-07-21 08:47:43 +00:00
|
|
|
#include "shared/source/ail/ail_configuration.h"
|
2023-03-07 16:39:25 +00:00
|
|
|
#include "shared/source/assert_handler/assert_handler.h"
|
2020-10-16 12:10:52 +02:00
|
|
|
#include "shared/source/aub/aub_center.h"
|
2020-02-27 15:32:57 +01:00
|
|
|
#include "shared/source/built_ins/built_ins.h"
|
2023-01-02 09:56:45 +00:00
|
|
|
#include "shared/source/built_ins/sip.h"
|
2020-02-27 15:32:57 +01:00
|
|
|
#include "shared/source/compiler_interface/compiler_interface.h"
|
|
|
|
|
#include "shared/source/compiler_interface/default_cache_config.h"
|
2020-03-11 08:56:55 +01:00
|
|
|
#include "shared/source/debugger/debugger.h"
|
2022-07-07 12:01:53 +00:00
|
|
|
#include "shared/source/debugger/debugger_l0.h"
|
2023-01-03 10:27:35 +00:00
|
|
|
#include "shared/source/device/device.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2020-02-24 18:04:30 +01:00
|
|
|
#include "shared/source/gmm_helper/gmm_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/gmm_helper/page_table_mngr.h"
|
2023-01-03 10:27:35 +00:00
|
|
|
#include "shared/source/helpers/api_gfx_core_helper.h"
|
2022-08-30 16:12:04 +00:00
|
|
|
#include "shared/source/helpers/api_specific_config.h"
|
2022-12-01 19:42:57 +00:00
|
|
|
#include "shared/source/helpers/bindless_heaps_helper.h"
|
2023-02-02 14:25:08 +00:00
|
|
|
#include "shared/source/helpers/compiler_product_helper.h"
|
2023-02-01 16:23:01 +00:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2020-03-04 08:51:02 +01:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2023-02-28 21:08:09 +00:00
|
|
|
#include "shared/source/memory_manager/allocation_properties.h"
|
|
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
2021-01-27 14:31:29 +01:00
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/memory_manager/memory_operations_handler.h"
|
|
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2021-09-24 10:51:57 +00:00
|
|
|
#include "shared/source/os_interface/os_time.h"
|
2023-03-10 12:28:11 +00:00
|
|
|
#include "shared/source/os_interface/product_helper.h"
|
2023-04-13 14:16:49 +00:00
|
|
|
#include "shared/source/release_helper/release_helper.h"
|
2021-01-26 11:22:10 +00:00
|
|
|
#include "shared/source/utilities/software_tags_manager.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2019-10-24 13:34:25 +02:00
|
|
|
namespace NEO {
|
|
|
|
|
|
2020-03-04 08:51:02 +01:00
|
|
|
RootDeviceEnvironment::RootDeviceEnvironment(ExecutionEnvironment &executionEnvironment) : executionEnvironment(executionEnvironment) {
|
|
|
|
|
hwInfo = std::make_unique<HardwareInfo>();
|
2021-01-26 11:22:10 +00:00
|
|
|
|
|
|
|
|
if (DebugManager.flags.EnableSWTags.get()) {
|
|
|
|
|
tagsManager = std::make_unique<SWTagsManager>();
|
|
|
|
|
}
|
2020-03-04 08:51:02 +01:00
|
|
|
}
|
|
|
|
|
|
2019-10-24 13:34:25 +02:00
|
|
|
RootDeviceEnvironment::~RootDeviceEnvironment() = default;
|
2019-11-15 09:59:48 +01:00
|
|
|
|
|
|
|
|
void RootDeviceEnvironment::initAubCenter(bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType) {
|
|
|
|
|
if (!aubCenter) {
|
2021-03-05 11:14:21 +00:00
|
|
|
UNRECOVERABLE_IF(!getGmmHelper());
|
2022-11-25 07:58:15 +00:00
|
|
|
aubCenter.reset(new AubCenter(*this, localMemoryEnabled, aubFileName, csrType));
|
2019-11-15 09:59:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-03-11 08:56:55 +01:00
|
|
|
|
2022-07-07 12:01:53 +00:00
|
|
|
void RootDeviceEnvironment::initDebuggerL0(Device *neoDevice) {
|
|
|
|
|
if (this->debugger.get() != nullptr) {
|
|
|
|
|
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr,
|
|
|
|
|
"%s", "Source Level Debugger cannot be used with Environment Variable enabling program debugging.\n");
|
|
|
|
|
UNRECOVERABLE_IF(this->debugger.get() != nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->getMutableHardwareInfo()->capabilityTable.fusedEuEnabled = false;
|
|
|
|
|
this->getMutableHardwareInfo()->capabilityTable.ftrRenderCompressedBuffers = false;
|
|
|
|
|
this->getMutableHardwareInfo()->capabilityTable.ftrRenderCompressedImages = false;
|
|
|
|
|
|
|
|
|
|
this->debugger = DebuggerL0::create(neoDevice);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-30 15:04:19 +01:00
|
|
|
const HardwareInfo *RootDeviceEnvironment::getHardwareInfo() const {
|
2020-03-04 08:51:02 +01:00
|
|
|
return hwInfo.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HardwareInfo *RootDeviceEnvironment::getMutableHardwareInfo() const {
|
|
|
|
|
return hwInfo.get();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-03 10:27:35 +00:00
|
|
|
void RootDeviceEnvironment::setHwInfoAndInitHelpers(const HardwareInfo *hwInfo) {
|
2020-03-04 08:51:02 +01:00
|
|
|
*this->hwInfo = *hwInfo;
|
2023-01-03 10:27:35 +00:00
|
|
|
initHelpers();
|
2020-03-04 08:51:02 +01:00
|
|
|
}
|
|
|
|
|
|
2023-06-06 11:41:57 +00:00
|
|
|
void RootDeviceEnvironment::setHwInfo(const HardwareInfo *hwInfo) {
|
|
|
|
|
*this->hwInfo = *hwInfo;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-04 08:51:02 +01:00
|
|
|
bool RootDeviceEnvironment::isFullRangeSvm() const {
|
|
|
|
|
return hwInfo->capabilityTable.gpuAddressSpace >= maxNBitValue(47);
|
2020-01-30 15:04:19 +01:00
|
|
|
}
|
2020-02-24 18:04:30 +01:00
|
|
|
|
|
|
|
|
GmmHelper *RootDeviceEnvironment::getGmmHelper() const {
|
2020-02-25 16:38:47 +01:00
|
|
|
return gmmHelper.get();
|
2020-02-24 18:04:30 +01:00
|
|
|
}
|
|
|
|
|
GmmClientContext *RootDeviceEnvironment::getGmmClientContext() const {
|
2020-02-25 16:38:47 +01:00
|
|
|
return gmmHelper->getClientContext();
|
2020-02-24 18:04:30 +01:00
|
|
|
}
|
2020-02-25 16:38:47 +01:00
|
|
|
|
2022-05-17 15:23:15 +00:00
|
|
|
void RootDeviceEnvironment::prepareForCleanup() const {
|
|
|
|
|
if (osInterface && osInterface->getDriverModel()) {
|
2022-10-20 11:51:13 +02:00
|
|
|
osInterface->getDriverModel()->isDriverAvailable();
|
2022-05-17 15:23:15 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-21 08:47:43 +00:00
|
|
|
bool RootDeviceEnvironment::initAilConfiguration() {
|
2023-07-06 10:05:58 +00:00
|
|
|
if (!DebugManager.flags.EnableAIL.get()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2021-07-21 08:47:43 +00:00
|
|
|
auto ailConfiguration = AILConfiguration::get(hwInfo->platform.eProductFamily);
|
|
|
|
|
|
|
|
|
|
if (ailConfiguration == nullptr) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto result = ailConfiguration->initProcessExecutableName();
|
|
|
|
|
if (result != true) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ailConfiguration->apply(hwInfo->capabilityTable);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-25 16:38:47 +01:00
|
|
|
void RootDeviceEnvironment::initGmm() {
|
|
|
|
|
if (!gmmHelper) {
|
2022-11-25 07:53:05 +00:00
|
|
|
gmmHelper.reset(new GmmHelper(*this));
|
2020-02-25 16:38:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-24 10:51:57 +00:00
|
|
|
void RootDeviceEnvironment::initOsTime() {
|
|
|
|
|
if (!osTime) {
|
|
|
|
|
osTime = OSTime::create(osInterface.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-27 14:31:29 +01:00
|
|
|
BindlessHeapsHelper *RootDeviceEnvironment::getBindlessHeapsHelper() const {
|
|
|
|
|
return bindlessHeapsHelper.get();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-12 16:43:41 +00:00
|
|
|
const ProductHelper &RootDeviceEnvironment::getProductHelper() const {
|
2023-02-01 03:12:09 +00:00
|
|
|
return *productHelper;
|
2022-11-07 14:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-05 10:30:14 +00:00
|
|
|
void RootDeviceEnvironment::createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield) {
|
|
|
|
|
bindlessHeapsHelper = std::make_unique<BindlessHeapsHelper>(memoryManager, availableDevices, rootDeviceIndex, deviceBitfield);
|
2021-01-27 14:31:29 +01:00
|
|
|
}
|
|
|
|
|
|
2020-02-27 15:32:57 +01:00
|
|
|
CompilerInterface *RootDeviceEnvironment::getCompilerInterface() {
|
|
|
|
|
if (this->compilerInterface.get() == nullptr) {
|
|
|
|
|
std::lock_guard<std::mutex> autolock(this->mtx);
|
|
|
|
|
if (this->compilerInterface.get() == nullptr) {
|
|
|
|
|
auto cache = std::make_unique<CompilerCache>(getDefaultCompilerCacheConfig());
|
2022-08-30 16:12:04 +00:00
|
|
|
this->compilerInterface.reset(CompilerInterface::createInstance(std::move(cache), ApiSpecificConfig::getApiType() == ApiSpecificConfig::ApiType::OCL));
|
2020-02-27 15:32:57 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this->compilerInterface.get();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-03 10:27:35 +00:00
|
|
|
void RootDeviceEnvironment::initHelpers() {
|
2023-02-01 03:12:09 +00:00
|
|
|
initProductHelper();
|
2023-01-09 14:59:10 +00:00
|
|
|
initGfxCoreHelper();
|
2023-01-03 10:27:35 +00:00
|
|
|
initApiGfxCoreHelper();
|
2023-01-31 12:34:59 +00:00
|
|
|
initCompilerProductHelper();
|
2023-04-13 14:16:49 +00:00
|
|
|
initReleaseHelper();
|
2023-01-03 10:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
2023-01-09 14:59:10 +00:00
|
|
|
void RootDeviceEnvironment::initGfxCoreHelper() {
|
|
|
|
|
if (gfxCoreHelper == nullptr) {
|
|
|
|
|
gfxCoreHelper = GfxCoreHelper::create(this->getHardwareInfo()->platform.eRenderCoreFamily);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-31 12:34:59 +00:00
|
|
|
|
2023-02-01 03:12:09 +00:00
|
|
|
void RootDeviceEnvironment::initProductHelper() {
|
|
|
|
|
if (productHelper == nullptr) {
|
|
|
|
|
productHelper = ProductHelper::create(this->getHardwareInfo()->platform.eProductFamily);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-31 12:34:59 +00:00
|
|
|
void RootDeviceEnvironment::initCompilerProductHelper() {
|
|
|
|
|
if (compilerProductHelper == nullptr) {
|
|
|
|
|
compilerProductHelper = CompilerProductHelper::create(this->getHardwareInfo()->platform.eProductFamily);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-09 14:59:10 +00:00
|
|
|
|
2023-04-13 14:16:49 +00:00
|
|
|
void RootDeviceEnvironment::initReleaseHelper() {
|
|
|
|
|
if (releaseHelper == nullptr) {
|
|
|
|
|
releaseHelper = ReleaseHelper::create(this->getHardwareInfo()->ipVersion);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReleaseHelper *RootDeviceEnvironment::getReleaseHelper() const {
|
|
|
|
|
return releaseHelper.get();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-27 15:32:57 +01:00
|
|
|
BuiltIns *RootDeviceEnvironment::getBuiltIns() {
|
|
|
|
|
if (this->builtins.get() == nullptr) {
|
|
|
|
|
std::lock_guard<std::mutex> autolock(this->mtx);
|
|
|
|
|
if (this->builtins.get() == nullptr) {
|
|
|
|
|
this->builtins = std::make_unique<BuiltIns>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this->builtins.get();
|
|
|
|
|
}
|
2022-07-25 12:13:27 +00:00
|
|
|
|
|
|
|
|
void RootDeviceEnvironment::limitNumberOfCcs(uint32_t numberOfCcs) {
|
|
|
|
|
|
|
|
|
|
hwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled = std::min(hwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled, numberOfCcs);
|
|
|
|
|
limitedNumberOfCcs = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool RootDeviceEnvironment::isNumberOfCcsLimited() const {
|
|
|
|
|
return limitedNumberOfCcs;
|
|
|
|
|
}
|
2022-11-08 16:16:37 +00:00
|
|
|
|
2023-02-28 21:08:09 +00:00
|
|
|
void RootDeviceEnvironment::initDummyAllocation() {
|
|
|
|
|
std::call_once(isDummyAllocationInitialized, [this]() {
|
|
|
|
|
auto customDeleter = [this](GraphicsAllocation *dummyAllocation) {
|
|
|
|
|
this->executionEnvironment.memoryManager->freeGraphicsMemory(dummyAllocation);
|
|
|
|
|
};
|
|
|
|
|
auto dummyBlitAllocation = this->executionEnvironment.memoryManager->allocateGraphicsMemoryWithProperties(
|
|
|
|
|
*this->dummyBlitProperties.get());
|
|
|
|
|
this->dummyAllocation = GraphicsAllocationUniquePtrType(dummyBlitAllocation, customDeleter);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RootDeviceEnvironment::setDummyBlitProperties(uint32_t rootDeviceIndex) {
|
|
|
|
|
size_t size = 4 * 4096u;
|
|
|
|
|
this->dummyBlitProperties = std::make_unique<AllocationProperties>(
|
|
|
|
|
rootDeviceIndex,
|
|
|
|
|
true,
|
|
|
|
|
size,
|
|
|
|
|
NEO::AllocationType::BUFFER,
|
|
|
|
|
false,
|
|
|
|
|
false,
|
|
|
|
|
systemMemoryBitfield);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GraphicsAllocation *RootDeviceEnvironment::getDummyAllocation() const {
|
|
|
|
|
return dummyAllocation.get();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-07 16:39:25 +00:00
|
|
|
AssertHandler *RootDeviceEnvironment::getAssertHandler(Device *neoDevice) {
|
|
|
|
|
if (this->assertHandler.get() == nullptr) {
|
|
|
|
|
std::lock_guard<std::mutex> autolock(this->mtx);
|
|
|
|
|
if (this->assertHandler.get() == nullptr) {
|
|
|
|
|
this->assertHandler = std::make_unique<AssertHandler>(neoDevice);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this->assertHandler.get();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-29 11:11:44 +00:00
|
|
|
bool RootDeviceEnvironment::isWddmOnLinux() const {
|
|
|
|
|
return isWddmOnLinuxEnable;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-08 16:16:37 +00:00
|
|
|
template <typename HelperType>
|
|
|
|
|
HelperType &RootDeviceEnvironment::getHelper() const {
|
2023-01-03 09:01:43 +00:00
|
|
|
if constexpr (std::is_same_v<HelperType, CompilerProductHelper>) {
|
2023-01-31 12:34:59 +00:00
|
|
|
UNRECOVERABLE_IF(compilerProductHelper == nullptr);
|
|
|
|
|
return *compilerProductHelper;
|
2023-01-03 09:01:43 +00:00
|
|
|
} else if constexpr (std::is_same_v<HelperType, ProductHelper>) {
|
2023-02-01 03:12:09 +00:00
|
|
|
UNRECOVERABLE_IF(productHelper == nullptr);
|
|
|
|
|
return *productHelper;
|
2022-11-10 15:23:21 +00:00
|
|
|
} else {
|
2023-01-03 09:01:43 +00:00
|
|
|
static_assert(std::is_same_v<HelperType, GfxCoreHelper>, "Only CompilerProductHelper, ProductHelper and GfxCoreHelper are supported");
|
2023-01-09 14:59:10 +00:00
|
|
|
UNRECOVERABLE_IF(gfxCoreHelper == nullptr);
|
|
|
|
|
return *gfxCoreHelper;
|
2022-11-08 16:16:37 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template ProductHelper &RootDeviceEnvironment::getHelper() const;
|
2023-01-03 09:01:43 +00:00
|
|
|
template CompilerProductHelper &RootDeviceEnvironment::getHelper() const;
|
2022-12-08 12:22:35 +00:00
|
|
|
template GfxCoreHelper &RootDeviceEnvironment::getHelper() const;
|
2022-11-08 16:16:37 +00:00
|
|
|
|
2019-10-24 13:34:25 +02:00
|
|
|
} // namespace NEO
|