2018-06-22 18:54:33 +08:00
|
|
|
/*
|
2020-01-07 14:42:40 +08:00
|
|
|
* Copyright (C) 2018-2020 Intel Corporation
|
2018-09-20 11:54:29 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
2018-06-27 17:35:37 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-03-19 21:26:08 +08:00
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2020-03-17 14:26:46 +08:00
|
|
|
#include "shared/source/os_interface/os_environment.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/memory_manager/os_agnostic_memory_manager.h"
|
2018-06-27 17:35:37 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2020-03-04 15:51:02 +08:00
|
|
|
ExecutionEnvironment::ExecutionEnvironment() = default;
|
2019-05-06 18:33:44 +08:00
|
|
|
|
2019-10-24 19:34:25 +08:00
|
|
|
ExecutionEnvironment::~ExecutionEnvironment() {
|
2020-02-12 00:48:40 +08:00
|
|
|
if (memoryManager) {
|
|
|
|
memoryManager->commonCleanup();
|
|
|
|
}
|
2019-10-24 19:34:25 +08:00
|
|
|
rootDeviceEnvironments.clear();
|
|
|
|
}
|
2018-07-16 23:11:43 +08:00
|
|
|
|
2020-09-18 22:19:41 +08:00
|
|
|
bool ExecutionEnvironment::initializeMemoryManager() {
|
2018-07-17 17:11:48 +08:00
|
|
|
if (this->memoryManager) {
|
2020-09-18 22:19:41 +08:00
|
|
|
return memoryManager->isInitialized();
|
2018-07-17 17:11:48 +08:00
|
|
|
}
|
2018-07-20 15:01:58 +08:00
|
|
|
|
2019-02-19 15:55:11 +08: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:
|
|
|
|
case CommandStreamReceiverType::CSR_AUB:
|
2019-03-15 17:22:35 +08:00
|
|
|
memoryManager = std::make_unique<OsAgnosticMemoryManager>(*this);
|
2019-02-19 15:55:11 +08:00
|
|
|
break;
|
|
|
|
case CommandStreamReceiverType::CSR_HW:
|
|
|
|
case CommandStreamReceiverType::CSR_HW_WITH_AUB:
|
|
|
|
default:
|
2019-03-15 17:22:35 +08:00
|
|
|
memoryManager = MemoryManager::createMemoryManager(*this);
|
2019-02-19 15:55:11 +08:00
|
|
|
break;
|
|
|
|
}
|
2020-09-18 22:19:41 +08:00
|
|
|
|
|
|
|
return memoryManager->isInitialized();
|
2018-07-16 23:11:43 +08:00
|
|
|
}
|
2019-12-17 15:11:16 +08:00
|
|
|
|
|
|
|
void ExecutionEnvironment::calculateMaxOsContextCount() {
|
2020-08-17 19:41:48 +08:00
|
|
|
MemoryManager::maxOsContextCount = 0u;
|
2020-02-12 18:27:28 +08:00
|
|
|
for (const auto &rootDeviceEnvironment : this->rootDeviceEnvironments) {
|
2020-02-21 22:25:04 +08:00
|
|
|
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
|
|
|
|
auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily);
|
|
|
|
auto osContextCount = hwHelper.getGpgpuEngineInstances(*hwInfo).size();
|
|
|
|
auto subDevicesCount = HwHelper::getSubDevicesCount(hwInfo);
|
2020-02-12 18:27:28 +08:00
|
|
|
bool hasRootCsr = subDevicesCount > 1;
|
2019-12-17 15:11:16 +08:00
|
|
|
|
2020-02-12 18:27:28 +08:00
|
|
|
MemoryManager::maxOsContextCount += static_cast<uint32_t>(osContextCount * subDevicesCount + hasRootCsr);
|
|
|
|
}
|
2019-12-17 15:11:16 +08:00
|
|
|
}
|
|
|
|
|
2019-11-15 16:59:48 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|