Files
compute-runtime/shared/source/execution_environment/execution_environment.cpp
Mateusz Jablonski 7cf57e04f9 Move builtins and compiler interface to RootDeviceEnvironment
Resolves: NEO-4355
Change-Id: Id1a3365673165d775a60a7e0a3f463e1b8f5a496
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
2020-03-05 13:22:22 +01:00

96 lines
3.2 KiB
C++

/*
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/built_ins/built_ins.h"
#include "shared/source/compiler_interface/compiler_interface.h"
#include "shared/source/compiler_interface/default_cache_config.h"
#include "shared/source/debugger/debugger.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/hw_helper.h"
#include "opencl/source/memory_manager/os_agnostic_memory_manager.h"
namespace NEO {
ExecutionEnvironment::ExecutionEnvironment() {
hwInfo = std::make_unique<HardwareInfo>();
};
ExecutionEnvironment::~ExecutionEnvironment() {
debugger.reset();
for (auto &rootDeviceEnvironment : rootDeviceEnvironments) {
rootDeviceEnvironment->builtins.reset();
}
if (memoryManager) {
memoryManager->commonCleanup();
}
rootDeviceEnvironments.clear();
}
void ExecutionEnvironment::setHwInfo(const HardwareInfo *hwInfo) {
*this->hwInfo = *hwInfo;
}
void ExecutionEnvironment::initializeMemoryManager() {
if (this->memoryManager) {
return;
}
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:
case CommandStreamReceiverType::CSR_AUB:
memoryManager = std::make_unique<OsAgnosticMemoryManager>(*this);
break;
case CommandStreamReceiverType::CSR_HW:
case CommandStreamReceiverType::CSR_HW_WITH_AUB:
default:
memoryManager = MemoryManager::createMemoryManager(*this);
break;
}
DEBUG_BREAK_IF(!this->memoryManager);
}
void ExecutionEnvironment::initDebugger() {
debugger = Debugger::create(hwInfo.get());
}
void ExecutionEnvironment::calculateMaxOsContextCount() {
for (const auto &rootDeviceEnvironment : this->rootDeviceEnvironments) {
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily);
auto osContextCount = hwHelper.getGpgpuEngineInstances(*hwInfo).size();
auto subDevicesCount = HwHelper::getSubDevicesCount(hwInfo);
bool hasRootCsr = subDevicesCount > 1;
MemoryManager::maxOsContextCount += static_cast<uint32_t>(osContextCount * subDevicesCount + hasRootCsr);
}
}
bool ExecutionEnvironment::isFullRangeSvm() const {
return hwInfo->capabilityTable.gpuAddressSpace >= maxNBitValue(47);
}
void ExecutionEnvironment::prepareRootDeviceEnvironments(uint32_t numRootDevices) {
if (rootDeviceEnvironments.size() < numRootDevices) {
rootDeviceEnvironments.resize(numRootDevices);
}
for (auto rootDeviceIndex = 0u; rootDeviceIndex < numRootDevices; rootDeviceIndex++) {
if (!rootDeviceEnvironments[rootDeviceIndex]) {
rootDeviceEnvironments[rootDeviceIndex] = std::make_unique<RootDeviceEnvironment>(*this);
}
}
}
} // namespace NEO