2018-06-22 12:54:33 +02:00
|
|
|
/*
|
2023-01-09 17:14:18 +00:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2018-09-19 20:54:29 -07:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
2018-06-27 11:35:37 +02:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-12-02 10:22:27 +00:00
|
|
|
#include "shared/source/built_ins/built_ins.h"
|
2021-04-16 12:52:30 +00:00
|
|
|
#include "shared/source/built_ins/sip.h"
|
2022-12-15 16:01:37 +00:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2021-07-30 09:56:58 +00:00
|
|
|
#include "shared/source/direct_submission/direct_submission_controller.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2021-05-05 08:07:53 +00:00
|
|
|
#include "shared/source/helpers/affinity_mask.h"
|
2023-01-09 17:14:18 +00:00
|
|
|
#include "shared/source/helpers/driver_model_type.h"
|
2023-02-01 16:23:01 +00:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2022-12-06 11:19:36 +00:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2021-05-05 16:00:12 +00:00
|
|
|
#include "shared/source/helpers/string_helpers.h"
|
2020-03-19 14:26:08 +01:00
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2020-11-02 15:54:01 +01:00
|
|
|
#include "shared/source/memory_manager/os_agnostic_memory_manager.h"
|
2023-07-12 02:14:09 +00:00
|
|
|
#include "shared/source/os_interface/debug_env_reader.h"
|
2023-06-13 15:19:02 +00:00
|
|
|
#include "shared/source/os_interface/driver_info.h"
|
2020-03-17 07:26:46 +01:00
|
|
|
#include "shared/source/os_interface/os_environment.h"
|
2021-05-21 01:17:57 +02:00
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2023-03-10 12:28:11 +00:00
|
|
|
#include "shared/source/os_interface/product_helper.h"
|
2021-03-30 18:11:00 +00:00
|
|
|
#include "shared/source/utilities/wait_util.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2021-03-30 18:11:00 +00:00
|
|
|
ExecutionEnvironment::ExecutionEnvironment() {
|
|
|
|
|
WaitUtils::init();
|
2022-10-26 12:41:36 +00:00
|
|
|
this->configureNeoEnvironment();
|
2021-03-30 18:11:00 +00:00
|
|
|
}
|
2019-05-06 12:33:44 +02:00
|
|
|
|
2021-10-11 15:34:03 +00:00
|
|
|
void ExecutionEnvironment::releaseRootDeviceEnvironmentResources(RootDeviceEnvironment *rootDeviceEnvironment) {
|
|
|
|
|
if (rootDeviceEnvironment == nullptr) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SipKernel::freeSipKernels(rootDeviceEnvironment, memoryManager.get());
|
|
|
|
|
if (rootDeviceEnvironment->builtins.get()) {
|
2022-05-09 16:21:21 +00:00
|
|
|
rootDeviceEnvironment->builtins->freeSipKernels(memoryManager.get());
|
2021-10-11 15:34:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-24 13:34:25 +02:00
|
|
|
ExecutionEnvironment::~ExecutionEnvironment() {
|
2020-02-11 17:48:40 +01:00
|
|
|
if (memoryManager) {
|
|
|
|
|
memoryManager->commonCleanup();
|
2020-12-02 10:22:27 +00:00
|
|
|
for (const auto &rootDeviceEnvironment : this->rootDeviceEnvironments) {
|
2021-10-11 15:34:03 +00:00
|
|
|
releaseRootDeviceEnvironmentResources(rootDeviceEnvironment.get());
|
2020-12-02 10:22:27 +00:00
|
|
|
}
|
2020-02-11 17:48:40 +01:00
|
|
|
}
|
2019-10-24 13:34:25 +02:00
|
|
|
rootDeviceEnvironments.clear();
|
2023-08-16 03:00:31 +00:00
|
|
|
mapOfSubDeviceIndices.clear();
|
2019-10-24 13:34:25 +02:00
|
|
|
}
|
2018-07-16 17:11:43 +02:00
|
|
|
|
2020-09-18 16:19:41 +02:00
|
|
|
bool ExecutionEnvironment::initializeMemoryManager() {
|
2018-07-17 11:11:48 +02:00
|
|
|
if (this->memoryManager) {
|
2020-09-18 16:19:41 +02:00
|
|
|
return memoryManager->isInitialized();
|
2018-07-17 11:11:48 +02:00
|
|
|
}
|
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:
|
|
|
|
|
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:
|
2021-05-25 15:37:44 +00:00
|
|
|
default: {
|
|
|
|
|
auto driverModelType = DriverModelType::UNKNOWN;
|
|
|
|
|
if (this->rootDeviceEnvironments[0]->osInterface && this->rootDeviceEnvironments[0]->osInterface->getDriverModel()) {
|
|
|
|
|
driverModelType = this->rootDeviceEnvironments[0]->osInterface->getDriverModel()->getDriverModelType();
|
|
|
|
|
}
|
|
|
|
|
memoryManager = MemoryManager::createMemoryManager(*this, driverModelType);
|
|
|
|
|
} break;
|
2019-02-19 08:55:11 +01:00
|
|
|
}
|
2020-09-18 16:19:41 +02:00
|
|
|
|
|
|
|
|
return memoryManager->isInitialized();
|
2018-07-16 17:11:43 +02:00
|
|
|
}
|
2019-12-17 08:11:16 +01:00
|
|
|
|
|
|
|
|
void ExecutionEnvironment::calculateMaxOsContextCount() {
|
2020-08-17 13:41:48 +02:00
|
|
|
MemoryManager::maxOsContextCount = 0u;
|
2020-02-12 11:27:28 +01:00
|
|
|
for (const auto &rootDeviceEnvironment : this->rootDeviceEnvironments) {
|
2020-02-21 15:25:04 +01:00
|
|
|
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
|
2022-12-08 12:22:35 +00:00
|
|
|
auto &gfxCoreHelper = rootDeviceEnvironment->getHelper<GfxCoreHelper>();
|
2023-01-25 16:13:28 +00:00
|
|
|
auto osContextCount = static_cast<uint32_t>(gfxCoreHelper.getGpgpuEngineInstances(*rootDeviceEnvironment).size());
|
2022-12-08 12:22:35 +00:00
|
|
|
auto subDevicesCount = GfxCoreHelper::getSubDevicesCount(hwInfo);
|
2021-08-30 17:05:59 +00:00
|
|
|
auto ccsCount = hwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
|
2020-02-12 11:27:28 +01:00
|
|
|
bool hasRootCsr = subDevicesCount > 1;
|
2019-12-17 08:11:16 +01:00
|
|
|
|
2021-08-30 17:05:59 +00:00
|
|
|
MemoryManager::maxOsContextCount += osContextCount * subDevicesCount + hasRootCsr;
|
|
|
|
|
|
|
|
|
|
if (ccsCount > 1 && DebugManager.flags.EngineInstancedSubDevices.get()) {
|
|
|
|
|
MemoryManager::maxOsContextCount += ccsCount * subDevicesCount;
|
|
|
|
|
}
|
2020-02-12 11:27:28 +01:00
|
|
|
}
|
2019-12-17 08:11:16 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-25 15:33:38 +00:00
|
|
|
DirectSubmissionController *ExecutionEnvironment::initializeDirectSubmissionController() {
|
2023-07-18 10:48:49 +00:00
|
|
|
std::lock_guard<std::mutex> lockForInit(initializeDirectSubmissionControllerMutex);
|
2021-10-25 15:33:38 +00:00
|
|
|
auto initializeDirectSubmissionController = DirectSubmissionController::isSupported();
|
2021-07-30 09:56:58 +00:00
|
|
|
|
2022-02-28 12:03:29 +00:00
|
|
|
if (DebugManager.flags.SetCommandStreamReceiver.get() > 0) {
|
|
|
|
|
initializeDirectSubmissionController = false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-30 09:56:58 +00:00
|
|
|
if (DebugManager.flags.EnableDirectSubmissionController.get() != -1) {
|
|
|
|
|
initializeDirectSubmissionController = DebugManager.flags.EnableDirectSubmissionController.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (initializeDirectSubmissionController && this->directSubmissionController == nullptr) {
|
|
|
|
|
this->directSubmissionController = std::make_unique<DirectSubmissionController>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return directSubmissionController.get();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 09:59:48 +01: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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-05 16:00:12 +00:00
|
|
|
|
2022-05-17 15:23:15 +00:00
|
|
|
void ExecutionEnvironment::prepareForCleanup() const {
|
|
|
|
|
for (auto &rootDeviceEnvironment : rootDeviceEnvironments) {
|
|
|
|
|
if (rootDeviceEnvironment) {
|
|
|
|
|
rootDeviceEnvironment->prepareForCleanup();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-11 15:34:03 +00:00
|
|
|
void ExecutionEnvironment::prepareRootDeviceEnvironment(const uint32_t rootDeviceIndexForReInit) {
|
|
|
|
|
rootDeviceEnvironments[rootDeviceIndexForReInit] = std::make_unique<RootDeviceEnvironment>(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-16 03:00:31 +00:00
|
|
|
bool ExecutionEnvironment::getSubDeviceHierarchy(uint32_t index, std::tuple<uint32_t, uint32_t, uint32_t> *subDeviceMap) {
|
|
|
|
|
if (mapOfSubDeviceIndices.find(index) != mapOfSubDeviceIndices.end()) {
|
|
|
|
|
*subDeviceMap = mapOfSubDeviceIndices.at(index);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 09:24:00 +00:00
|
|
|
void ExecutionEnvironment::parseAffinityMask() {
|
2023-08-16 03:00:31 +00:00
|
|
|
|
|
|
|
|
// If the device hierarchy is Combined, then skip the affinity mask parsing until level zero device get.
|
|
|
|
|
if (isCombinedDeviceHierarchy()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-05 16:00:12 +00:00
|
|
|
const auto &affinityMaskString = DebugManager.flags.ZE_AFFINITY_MASK.get();
|
2021-01-25 09:24:00 +00:00
|
|
|
|
|
|
|
|
if (affinityMaskString.compare("default") == 0 ||
|
|
|
|
|
affinityMaskString.empty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
feature: Affinity mask plus ReturnSubDevicesAsApiDevices
When using ReturnSubDevicesAsApiDevices=1 to have
sub-devices-as-root-devices, then the driver should read the values
passed in the mask as those corresponding to the physical
sub-devices.
For instance, in a dual system with multi-tile device, we would have:
card 0, tile 0
card 0, tile 1
card 1, tile 0
card 1, tile 1
With:
ReturnSubDevicesAsApiDevices=0
ZE_AFFINITY_MASK=0,1
Then all tiles in card 0 and card 1 need to be exposed.
With:
ReturnSubDevicesAsApiDevices=1
ZE_AFFINITY_MASK=0,3
Then card 0 tile 0, and card 1 tile 1 need to be exposed.
Related-To: NEO-7137
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
2023-02-02 02:54:47 +00:00
|
|
|
bool exposeSubDevicesAsApiDevices = false;
|
|
|
|
|
if (NEO::DebugManager.flags.ReturnSubDevicesAsApiDevices.get() != -1) {
|
|
|
|
|
exposeSubDevicesAsApiDevices = NEO::DebugManager.flags.ReturnSubDevicesAsApiDevices.get();
|
|
|
|
|
}
|
2023-07-12 02:14:09 +00:00
|
|
|
// If the user has requested FLAT device hierarchy models, then report all the sub devices as devices.
|
|
|
|
|
if (this->subDevicesAsDevices) {
|
|
|
|
|
exposeSubDevicesAsApiDevices = true;
|
|
|
|
|
}
|
feature: Affinity mask plus ReturnSubDevicesAsApiDevices
When using ReturnSubDevicesAsApiDevices=1 to have
sub-devices-as-root-devices, then the driver should read the values
passed in the mask as those corresponding to the physical
sub-devices.
For instance, in a dual system with multi-tile device, we would have:
card 0, tile 0
card 0, tile 1
card 1, tile 0
card 1, tile 1
With:
ReturnSubDevicesAsApiDevices=0
ZE_AFFINITY_MASK=0,1
Then all tiles in card 0 and card 1 need to be exposed.
With:
ReturnSubDevicesAsApiDevices=1
ZE_AFFINITY_MASK=0,3
Then card 0 tile 0, and card 1 tile 1 need to be exposed.
Related-To: NEO-7137
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
2023-02-02 02:54:47 +00:00
|
|
|
|
|
|
|
|
uint32_t numRootDevices = static_cast<uint32_t>(rootDeviceEnvironments.size());
|
|
|
|
|
|
|
|
|
|
RootDeviceIndicesMap mapOfIndexes;
|
|
|
|
|
// Reserve at least for a size equal to rootDeviceEnvironments.size() times four,
|
|
|
|
|
// which is enough for typical configurations
|
|
|
|
|
size_t reservedSizeForIndices = numRootDevices * 4;
|
|
|
|
|
mapOfIndexes.reserve(reservedSizeForIndices);
|
2023-08-16 03:00:31 +00:00
|
|
|
uint32_t hwSubDevicesCount = 0u;
|
feature: Affinity mask plus ReturnSubDevicesAsApiDevices
When using ReturnSubDevicesAsApiDevices=1 to have
sub-devices-as-root-devices, then the driver should read the values
passed in the mask as those corresponding to the physical
sub-devices.
For instance, in a dual system with multi-tile device, we would have:
card 0, tile 0
card 0, tile 1
card 1, tile 0
card 1, tile 1
With:
ReturnSubDevicesAsApiDevices=0
ZE_AFFINITY_MASK=0,1
Then all tiles in card 0 and card 1 need to be exposed.
With:
ReturnSubDevicesAsApiDevices=1
ZE_AFFINITY_MASK=0,3
Then card 0 tile 0, and card 1 tile 1 need to be exposed.
Related-To: NEO-7137
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
2023-02-02 02:54:47 +00:00
|
|
|
if (exposeSubDevicesAsApiDevices) {
|
|
|
|
|
uint32_t currentDeviceIndex = 0;
|
|
|
|
|
for (uint32_t currentRootDevice = 0u; currentRootDevice < static_cast<uint32_t>(rootDeviceEnvironments.size()); currentRootDevice++) {
|
|
|
|
|
auto hwInfo = rootDeviceEnvironments[currentRootDevice]->getHardwareInfo();
|
2023-08-16 03:00:31 +00:00
|
|
|
hwSubDevicesCount = GfxCoreHelper::getSubDevicesCount(hwInfo);
|
feature: Affinity mask plus ReturnSubDevicesAsApiDevices
When using ReturnSubDevicesAsApiDevices=1 to have
sub-devices-as-root-devices, then the driver should read the values
passed in the mask as those corresponding to the physical
sub-devices.
For instance, in a dual system with multi-tile device, we would have:
card 0, tile 0
card 0, tile 1
card 1, tile 0
card 1, tile 1
With:
ReturnSubDevicesAsApiDevices=0
ZE_AFFINITY_MASK=0,1
Then all tiles in card 0 and card 1 need to be exposed.
With:
ReturnSubDevicesAsApiDevices=1
ZE_AFFINITY_MASK=0,3
Then card 0 tile 0, and card 1 tile 1 need to be exposed.
Related-To: NEO-7137
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
2023-02-02 02:54:47 +00:00
|
|
|
uint32_t currentSubDevice = 0;
|
|
|
|
|
mapOfIndexes[currentDeviceIndex++] = std::make_tuple(currentRootDevice, currentSubDevice);
|
2023-08-16 03:00:31 +00:00
|
|
|
for (currentSubDevice = 1; currentSubDevice < hwSubDevicesCount; currentSubDevice++) {
|
feature: Affinity mask plus ReturnSubDevicesAsApiDevices
When using ReturnSubDevicesAsApiDevices=1 to have
sub-devices-as-root-devices, then the driver should read the values
passed in the mask as those corresponding to the physical
sub-devices.
For instance, in a dual system with multi-tile device, we would have:
card 0, tile 0
card 0, tile 1
card 1, tile 0
card 1, tile 1
With:
ReturnSubDevicesAsApiDevices=0
ZE_AFFINITY_MASK=0,1
Then all tiles in card 0 and card 1 need to be exposed.
With:
ReturnSubDevicesAsApiDevices=1
ZE_AFFINITY_MASK=0,3
Then card 0 tile 0, and card 1 tile 1 need to be exposed.
Related-To: NEO-7137
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
2023-02-02 02:54:47 +00:00
|
|
|
mapOfIndexes[currentDeviceIndex++] = std::make_tuple(currentRootDevice, currentSubDevice);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
numRootDevices = currentDeviceIndex;
|
|
|
|
|
UNRECOVERABLE_IF(numRootDevices > reservedSizeForIndices);
|
|
|
|
|
}
|
2021-05-05 08:07:53 +00:00
|
|
|
|
|
|
|
|
std::vector<AffinityMaskHelper> affinityMaskHelper(numRootDevices);
|
2021-01-25 09:24:00 +00:00
|
|
|
|
2021-05-05 16:00:12 +00:00
|
|
|
auto affinityMaskEntries = StringHelpers::split(affinityMaskString, ",");
|
|
|
|
|
|
2023-08-16 03:00:31 +00:00
|
|
|
// Index of the Device to be returned to the user, not the physcial device index.
|
|
|
|
|
uint32_t deviceIndex = 0;
|
2021-05-05 16:00:12 +00:00
|
|
|
for (const auto &entry : affinityMaskEntries) {
|
|
|
|
|
auto subEntries = StringHelpers::split(entry, ".");
|
|
|
|
|
uint32_t rootDeviceIndex = StringHelpers::toUint32t(subEntries[0]);
|
|
|
|
|
|
feature: Affinity mask plus ReturnSubDevicesAsApiDevices
When using ReturnSubDevicesAsApiDevices=1 to have
sub-devices-as-root-devices, then the driver should read the values
passed in the mask as those corresponding to the physical
sub-devices.
For instance, in a dual system with multi-tile device, we would have:
card 0, tile 0
card 0, tile 1
card 1, tile 0
card 1, tile 1
With:
ReturnSubDevicesAsApiDevices=0
ZE_AFFINITY_MASK=0,1
Then all tiles in card 0 and card 1 need to be exposed.
With:
ReturnSubDevicesAsApiDevices=1
ZE_AFFINITY_MASK=0,3
Then card 0 tile 0, and card 1 tile 1 need to be exposed.
Related-To: NEO-7137
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
2023-02-02 02:54:47 +00:00
|
|
|
// tiles as devices
|
|
|
|
|
if (exposeSubDevicesAsApiDevices) {
|
|
|
|
|
if (rootDeviceIndex > numRootDevices) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ReturnSubDevicesAsApiDevices not supported with AllowSingleTileEngineInstancedSubDevices
|
|
|
|
|
// so ignore X.Y
|
|
|
|
|
if (subEntries.size() > 1) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::tuple<uint32_t, uint32_t> indexKey = mapOfIndexes[rootDeviceIndex];
|
2023-08-16 03:00:31 +00:00
|
|
|
auto hwDeviceIndex = std::get<0>(indexKey);
|
feature: Affinity mask plus ReturnSubDevicesAsApiDevices
When using ReturnSubDevicesAsApiDevices=1 to have
sub-devices-as-root-devices, then the driver should read the values
passed in the mask as those corresponding to the physical
sub-devices.
For instance, in a dual system with multi-tile device, we would have:
card 0, tile 0
card 0, tile 1
card 1, tile 0
card 1, tile 1
With:
ReturnSubDevicesAsApiDevices=0
ZE_AFFINITY_MASK=0,1
Then all tiles in card 0 and card 1 need to be exposed.
With:
ReturnSubDevicesAsApiDevices=1
ZE_AFFINITY_MASK=0,3
Then card 0 tile 0, and card 1 tile 1 need to be exposed.
Related-To: NEO-7137
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
2023-02-02 02:54:47 +00:00
|
|
|
auto tileIndex = std::get<1>(indexKey);
|
2023-08-16 03:00:31 +00:00
|
|
|
affinityMaskHelper[hwDeviceIndex].enableGenericSubDevice(tileIndex);
|
|
|
|
|
// Store the Physical Hierarchy for this SubDevice mapped to the Device Index passed to the user.
|
|
|
|
|
mapOfSubDeviceIndices[deviceIndex++] = std::make_tuple(hwDeviceIndex, tileIndex, hwSubDevicesCount);
|
feature: Affinity mask plus ReturnSubDevicesAsApiDevices
When using ReturnSubDevicesAsApiDevices=1 to have
sub-devices-as-root-devices, then the driver should read the values
passed in the mask as those corresponding to the physical
sub-devices.
For instance, in a dual system with multi-tile device, we would have:
card 0, tile 0
card 0, tile 1
card 1, tile 0
card 1, tile 1
With:
ReturnSubDevicesAsApiDevices=0
ZE_AFFINITY_MASK=0,1
Then all tiles in card 0 and card 1 need to be exposed.
With:
ReturnSubDevicesAsApiDevices=1
ZE_AFFINITY_MASK=0,3
Then card 0 tile 0, and card 1 tile 1 need to be exposed.
Related-To: NEO-7137
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
2023-02-02 02:54:47 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// cards as devices
|
2021-05-05 08:07:53 +00:00
|
|
|
if (rootDeviceIndex < numRootDevices) {
|
|
|
|
|
auto hwInfo = rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
2022-12-08 12:22:35 +00:00
|
|
|
auto subDevicesCount = GfxCoreHelper::getSubDevicesCount(hwInfo);
|
2021-05-05 08:07:53 +00:00
|
|
|
|
2021-05-06 11:33:39 +00:00
|
|
|
if (subEntries.size() > 1) {
|
2021-05-05 16:00:12 +00:00
|
|
|
uint32_t subDeviceIndex = StringHelpers::toUint32t(subEntries[1]);
|
2021-05-06 11:33:39 +00:00
|
|
|
|
2021-09-29 13:53:43 +00:00
|
|
|
bool enableSecondLevelEngineInstanced = ((subDevicesCount == 1) &&
|
|
|
|
|
(hwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled > 1) &&
|
|
|
|
|
DebugManager.flags.AllowSingleTileEngineInstancedSubDevices.get());
|
|
|
|
|
|
|
|
|
|
if (enableSecondLevelEngineInstanced) {
|
|
|
|
|
UNRECOVERABLE_IF(subEntries.size() != 2);
|
|
|
|
|
|
|
|
|
|
if (subDeviceIndex < hwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled) {
|
2023-08-16 03:00:31 +00:00
|
|
|
// Store the Physical Hierarchy for this SubDevice mapped to the Device Index passed to the user.
|
|
|
|
|
mapOfSubDeviceIndices[rootDeviceIndex] = std::make_tuple(rootDeviceIndex, subDeviceIndex, subDevicesCount);
|
2021-09-29 13:53:43 +00:00
|
|
|
affinityMaskHelper[rootDeviceIndex].enableEngineInstancedSubDevice(0, subDeviceIndex); // Mask: X.Y
|
|
|
|
|
}
|
|
|
|
|
} else if (subDeviceIndex < subDevicesCount) {
|
2021-05-06 11:33:39 +00:00
|
|
|
if (subEntries.size() == 2) {
|
2023-08-16 03:00:31 +00:00
|
|
|
// Store the Physical Hierarchy for this SubDevice mapped to the Device Index passed to the user.
|
|
|
|
|
mapOfSubDeviceIndices[rootDeviceIndex] = std::make_tuple(rootDeviceIndex, subDeviceIndex, subDevicesCount);
|
2021-05-06 11:33:39 +00:00
|
|
|
affinityMaskHelper[rootDeviceIndex].enableGenericSubDevice(subDeviceIndex); // Mask: X.Y
|
|
|
|
|
} else {
|
|
|
|
|
UNRECOVERABLE_IF(subEntries.size() != 3);
|
|
|
|
|
uint32_t ccsIndex = StringHelpers::toUint32t(subEntries[2]);
|
|
|
|
|
|
|
|
|
|
if (ccsIndex < hwInfo->gtSystemInfo.CCSInfo.NumberOfCCSEnabled) {
|
|
|
|
|
affinityMaskHelper[rootDeviceIndex].enableEngineInstancedSubDevice(subDeviceIndex, ccsIndex); // Mask: X.Y.Z
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-25 09:24:00 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2021-05-06 11:33:39 +00:00
|
|
|
affinityMaskHelper[rootDeviceIndex].enableAllGenericSubDevices(subDevicesCount); // Mask: X
|
2021-01-25 09:24:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<RootDeviceEnvironment>> filteredEnvironments;
|
2021-05-05 08:07:53 +00:00
|
|
|
for (uint32_t i = 0u; i < numRootDevices; i++) {
|
|
|
|
|
if (!affinityMaskHelper[i].isDeviceEnabled()) {
|
2021-01-25 09:24:00 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-05 08:07:53 +00:00
|
|
|
rootDeviceEnvironments[i]->deviceAffinityMask = affinityMaskHelper[i];
|
2021-01-25 09:24:00 +00:00
|
|
|
filteredEnvironments.emplace_back(rootDeviceEnvironments[i].release());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rootDeviceEnvironments.swap(filteredEnvironments);
|
|
|
|
|
}
|
2022-07-25 12:13:27 +00:00
|
|
|
|
2023-07-11 10:55:25 +00:00
|
|
|
void ExecutionEnvironment::sortNeoDevices() {
|
|
|
|
|
std::sort(rootDeviceEnvironments.begin(), rootDeviceEnvironments.end(), comparePciIdBusNumber);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-05 23:12:34 +00:00
|
|
|
void ExecutionEnvironment::setDeviceHierarchy(const GfxCoreHelper &gfxCoreHelper) {
|
|
|
|
|
NEO::EnvironmentVariableReader envReader;
|
|
|
|
|
std::string hierarchyModel = envReader.getSetting("ZE_FLAT_DEVICE_HIERARCHY", std::string(gfxCoreHelper.getDefaultDeviceHierarchy()));
|
|
|
|
|
if (strcmp(hierarchyModel.c_str(), "COMPOSITE") == 0) {
|
|
|
|
|
setExposeSubDevicesAsDevices(false);
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(hierarchyModel.c_str(), "FLAT") == 0) {
|
|
|
|
|
setExposeSubDevicesAsDevices(true);
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(hierarchyModel.c_str(), "COMBINED") == 0) {
|
|
|
|
|
setCombinedDeviceHierarchy(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NEO::DebugManager.flags.ReturnSubDevicesAsApiDevices.get() != -1) {
|
|
|
|
|
setExposeSubDevicesAsDevices(NEO::DebugManager.flags.ReturnSubDevicesAsApiDevices.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 08:48:55 +00:00
|
|
|
void ExecutionEnvironment::adjustCcsCountImpl(RootDeviceEnvironment *rootDeviceEnvironment) const {
|
|
|
|
|
auto hwInfo = rootDeviceEnvironment->getMutableHardwareInfo();
|
2022-12-06 11:19:36 +00:00
|
|
|
auto &productHelper = rootDeviceEnvironment->getHelper<ProductHelper>();
|
|
|
|
|
productHelper.adjustNumberOfCcs(*hwInfo);
|
2022-09-22 08:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecutionEnvironment::adjustCcsCount() {
|
2022-07-25 12:13:27 +00:00
|
|
|
parseCcsCountLimitations();
|
|
|
|
|
|
2022-09-22 08:48:55 +00:00
|
|
|
for (auto rootDeviceIndex = 0u; rootDeviceIndex < rootDeviceEnvironments.size(); rootDeviceIndex++) {
|
|
|
|
|
auto &rootDeviceEnvironment = rootDeviceEnvironments[rootDeviceIndex];
|
2022-07-25 12:13:27 +00:00
|
|
|
UNRECOVERABLE_IF(!rootDeviceEnvironment);
|
|
|
|
|
if (!rootDeviceEnvironment->isNumberOfCcsLimited()) {
|
2022-09-22 08:48:55 +00:00
|
|
|
adjustCcsCountImpl(rootDeviceEnvironment.get());
|
2022-07-25 12:13:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 08:48:55 +00:00
|
|
|
void ExecutionEnvironment::adjustCcsCount(const uint32_t rootDeviceIndex) const {
|
|
|
|
|
auto &rootDeviceEnvironment = rootDeviceEnvironments[rootDeviceIndex];
|
|
|
|
|
UNRECOVERABLE_IF(!rootDeviceEnvironment);
|
|
|
|
|
if (rootDeviceNumCcsMap.find(rootDeviceIndex) != rootDeviceNumCcsMap.end()) {
|
|
|
|
|
rootDeviceEnvironment->limitNumberOfCcs(rootDeviceNumCcsMap.at(rootDeviceIndex));
|
|
|
|
|
} else {
|
|
|
|
|
adjustCcsCountImpl(rootDeviceEnvironment.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecutionEnvironment::parseCcsCountLimitations() {
|
2022-07-25 12:13:27 +00:00
|
|
|
const auto &numberOfCcsString = DebugManager.flags.ZEX_NUMBER_OF_CCS.get();
|
|
|
|
|
|
|
|
|
|
if (numberOfCcsString.compare("default") == 0 ||
|
|
|
|
|
numberOfCcsString.empty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint32_t numRootDevices = static_cast<uint32_t>(rootDeviceEnvironments.size());
|
|
|
|
|
|
|
|
|
|
auto numberOfCcsEntries = StringHelpers::split(numberOfCcsString, ",");
|
|
|
|
|
|
|
|
|
|
for (const auto &entry : numberOfCcsEntries) {
|
|
|
|
|
auto subEntries = StringHelpers::split(entry, ":");
|
|
|
|
|
uint32_t rootDeviceIndex = StringHelpers::toUint32t(subEntries[0]);
|
|
|
|
|
|
|
|
|
|
if (rootDeviceIndex < numRootDevices) {
|
|
|
|
|
if (subEntries.size() > 1) {
|
|
|
|
|
uint32_t maxCcsCount = StringHelpers::toUint32t(subEntries[1]);
|
2022-09-22 08:48:55 +00:00
|
|
|
rootDeviceNumCcsMap.insert({rootDeviceIndex, maxCcsCount});
|
2022-07-25 12:13:27 +00:00
|
|
|
rootDeviceEnvironments[rootDeviceIndex]->limitNumberOfCcs(maxCcsCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-26 12:41:36 +00:00
|
|
|
|
|
|
|
|
void ExecutionEnvironment::configureNeoEnvironment() {
|
|
|
|
|
if (DebugManager.flags.NEO_CAL_ENABLED.get()) {
|
2023-05-17 13:47:14 +00:00
|
|
|
DebugManager.flags.UseKmdMigration.setIfDefault(0);
|
|
|
|
|
DebugManager.flags.SplitBcsSize.setIfDefault(256);
|
2022-10-26 12:41:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
2023-06-13 15:19:02 +00:00
|
|
|
|
|
|
|
|
bool ExecutionEnvironment::comparePciIdBusNumber(std::unique_ptr<RootDeviceEnvironment> &rootDeviceEnvironment1, std::unique_ptr<RootDeviceEnvironment> &rootDeviceEnvironment2) {
|
|
|
|
|
const auto pciOrderVar = DebugManager.flags.ZE_ENABLE_PCI_ID_DEVICE_ORDER.get();
|
|
|
|
|
if (!pciOrderVar) {
|
|
|
|
|
auto isIntegrated1 = rootDeviceEnvironment1->getHardwareInfo()->capabilityTable.isIntegratedDevice;
|
|
|
|
|
auto isIntegrated2 = rootDeviceEnvironment2->getHardwareInfo()->capabilityTable.isIntegratedDevice;
|
|
|
|
|
if (isIntegrated1 != isIntegrated2) {
|
|
|
|
|
return isIntegrated2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BDF sample format is : 00:02.0
|
|
|
|
|
auto pciBusInfo1 = rootDeviceEnvironment1->osInterface->getDriverModel()->getPciBusInfo();
|
|
|
|
|
auto pciBusInfo2 = rootDeviceEnvironment2->osInterface->getDriverModel()->getPciBusInfo();
|
|
|
|
|
|
|
|
|
|
if (pciBusInfo1.pciDomain != pciBusInfo2.pciDomain) {
|
|
|
|
|
return (pciBusInfo1.pciDomain < pciBusInfo2.pciDomain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pciBusInfo1.pciBus != pciBusInfo2.pciBus) {
|
|
|
|
|
return (pciBusInfo1.pciBus < pciBusInfo2.pciBus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pciBusInfo1.pciDevice != pciBusInfo2.pciDevice) {
|
|
|
|
|
return (pciBusInfo1.pciDevice < pciBusInfo2.pciDevice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (pciBusInfo1.pciFunction < pciBusInfo2.pciFunction);
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|