2018-06-22 12:54:33 +02:00
|
|
|
/*
|
2019-01-10 13:57:40 +01:00
|
|
|
* Copyright (C) 2018-2019 Intel Corporation
|
2018-09-19 20:54:29 -07:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
2018-06-27 11:35:37 +02:00
|
|
|
|
|
|
|
|
#include "runtime/execution_environment/execution_environment.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2019-10-22 12:09:08 +02:00
|
|
|
#include "core/compiler_interface/compiler_interface.h"
|
2019-11-13 10:01:19 +01:00
|
|
|
#include "core/helpers/hw_helper.h"
|
2019-08-21 10:53:07 +02:00
|
|
|
#include "core/memory_manager/memory_operations_handler.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "runtime/aub/aub_center.h"
|
|
|
|
|
#include "runtime/built_ins/built_ins.h"
|
2018-07-16 17:11:43 +02:00
|
|
|
#include "runtime/command_stream/command_stream_receiver.h"
|
2019-02-19 08:55:11 +01:00
|
|
|
#include "runtime/command_stream/tbx_command_stream_receiver_hw.h"
|
2019-10-21 15:47:04 +02:00
|
|
|
#include "runtime/compiler_interface/default_cl_cache_config.h"
|
2018-07-03 10:00:12 +02:00
|
|
|
#include "runtime/gmm_helper/gmm_helper.h"
|
2018-07-16 17:11:43 +02:00
|
|
|
#include "runtime/memory_manager/memory_manager.h"
|
2018-08-10 11:07:17 +02:00
|
|
|
#include "runtime/os_interface/os_interface.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "runtime/source_level_debugger/source_level_debugger.h"
|
2018-06-27 11:35:37 +02:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2019-05-06 12:33:44 +02:00
|
|
|
ExecutionEnvironment::ExecutionEnvironment() {
|
|
|
|
|
hwInfo = std::make_unique<HardwareInfo>(*platformDevices[0]);
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-24 13:34:25 +02:00
|
|
|
ExecutionEnvironment::~ExecutionEnvironment() {
|
|
|
|
|
sourceLevelDebugger.reset();
|
|
|
|
|
compilerInterface.reset();
|
|
|
|
|
builtins.reset();
|
|
|
|
|
rootDeviceEnvironments.clear();
|
|
|
|
|
}
|
2018-07-16 17:11:43 +02:00
|
|
|
|
2019-01-23 11:59:54 +01:00
|
|
|
void ExecutionEnvironment::initAubCenter(bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType) {
|
2019-10-24 13:34:25 +02:00
|
|
|
if (!rootDeviceEnvironments[0].aubCenter) {
|
|
|
|
|
rootDeviceEnvironments[0].aubCenter.reset(new AubCenter(hwInfo.get(), localMemoryEnabled, aubFileName, csrType));
|
2018-09-20 00:36:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-01-23 11:59:54 +01:00
|
|
|
void ExecutionEnvironment::initGmm() {
|
2018-07-16 16:37:17 +02:00
|
|
|
if (!gmmHelper) {
|
2019-05-06 12:33:44 +02:00
|
|
|
gmmHelper.reset(new GmmHelper(hwInfo.get()));
|
2018-07-16 16:37:17 +02:00
|
|
|
}
|
2018-07-03 10:00:12 +02:00
|
|
|
}
|
2019-01-23 11:59:54 +01:00
|
|
|
void ExecutionEnvironment::setHwInfo(const HardwareInfo *hwInfo) {
|
2019-05-06 12:33:44 +02:00
|
|
|
*this->hwInfo = *hwInfo;
|
2019-01-23 11:59:54 +01:00
|
|
|
}
|
2019-03-15 10:22:35 +01:00
|
|
|
void ExecutionEnvironment::initializeMemoryManager() {
|
2018-07-17 11:11:48 +02:00
|
|
|
if (this->memoryManager) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-07-20 09:01:58 +02:00
|
|
|
|
2019-02-19 08:55:11 +01:00
|
|
|
int32_t setCommandStreamReceiverType = CommandStreamReceiverType::CSR_HW;
|
|
|
|
|
if (DebugManager.flags.SetCommandStreamReceiver.get() >= 0) {
|
|
|
|
|
setCommandStreamReceiverType = DebugManager.flags.SetCommandStreamReceiver.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (setCommandStreamReceiverType) {
|
|
|
|
|
case CommandStreamReceiverType::CSR_TBX:
|
|
|
|
|
case CommandStreamReceiverType::CSR_TBX_WITH_AUB:
|
2019-03-15 10:22:35 +01:00
|
|
|
memoryManager = std::make_unique<TbxMemoryManager>(*this);
|
2019-02-19 08:55:11 +01:00
|
|
|
break;
|
|
|
|
|
case CommandStreamReceiverType::CSR_AUB:
|
2019-03-15 10:22:35 +01:00
|
|
|
memoryManager = std::make_unique<OsAgnosticMemoryManager>(*this);
|
2019-02-19 08:55:11 +01:00
|
|
|
break;
|
|
|
|
|
case CommandStreamReceiverType::CSR_HW:
|
|
|
|
|
case CommandStreamReceiverType::CSR_HW_WITH_AUB:
|
|
|
|
|
default:
|
2019-03-15 10:22:35 +01:00
|
|
|
memoryManager = MemoryManager::createMemoryManager(*this);
|
2019-02-19 08:55:11 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2018-07-16 17:11:43 +02:00
|
|
|
DEBUG_BREAK_IF(!this->memoryManager);
|
|
|
|
|
}
|
2019-01-23 11:59:54 +01:00
|
|
|
void ExecutionEnvironment::initSourceLevelDebugger() {
|
2019-05-06 12:33:44 +02:00
|
|
|
if (hwInfo->capabilityTable.sourceLevelDebuggerSupported) {
|
2018-07-12 15:47:48 +02:00
|
|
|
sourceLevelDebugger.reset(SourceLevelDebugger::create());
|
|
|
|
|
}
|
|
|
|
|
if (sourceLevelDebugger) {
|
2019-05-08 16:00:24 +02:00
|
|
|
bool localMemorySipAvailable = (SipKernelType::DbgCsrLocal == SipKernel::getSipKernelType(hwInfo->platform.eRenderCoreFamily, true));
|
2018-07-12 15:47:48 +02:00
|
|
|
sourceLevelDebugger->initialize(localMemorySipAvailable);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-23 12:23:48 +02:00
|
|
|
GmmHelper *ExecutionEnvironment::getGmmHelper() const {
|
|
|
|
|
return gmmHelper.get();
|
|
|
|
|
}
|
2018-08-01 09:06:46 +02:00
|
|
|
CompilerInterface *ExecutionEnvironment::getCompilerInterface() {
|
|
|
|
|
if (this->compilerInterface.get() == nullptr) {
|
|
|
|
|
std::lock_guard<std::mutex> autolock(this->mtx);
|
|
|
|
|
if (this->compilerInterface.get() == nullptr) {
|
2019-10-21 15:47:04 +02:00
|
|
|
auto cache = std::make_unique<CompilerCache>(getDefaultClCompilerCacheConfig());
|
|
|
|
|
this->compilerInterface.reset(CompilerInterface::createInstance(std::move(cache), true));
|
2018-08-01 09:06:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this->compilerInterface.get();
|
|
|
|
|
}
|
2018-08-21 15:47:21 +02:00
|
|
|
BuiltIns *ExecutionEnvironment::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();
|
|
|
|
|
}
|
2019-02-26 17:52:31 +01:00
|
|
|
|
2019-09-03 14:20:32 +02:00
|
|
|
bool ExecutionEnvironment::isFullRangeSvm() const {
|
|
|
|
|
return hwInfo->capabilityTable.gpuAddressSpace >= maxNBitValue<47>;
|
|
|
|
|
}
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|