2019-08-27 15:34:20 +08:00
|
|
|
/*
|
2024-02-29 18:11:37 +08:00
|
|
|
* Copyright (C) 2019-2024 Intel Corporation
|
2019-08-27 15:34:20 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/device/root_device.h"
|
2019-08-27 15:34:20 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
|
|
|
#include "shared/source/command_stream/preemption.h"
|
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
|
|
|
#include "shared/source/device/sub_device.h"
|
2022-12-29 20:27:52 +08:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2022-12-16 01:32:03 +08:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2020-10-19 16:02:28 +08:00
|
|
|
#include "shared/source/helpers/api_specific_config.h"
|
2023-02-02 00:23:01 +08:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2023-02-06 17:05:43 +08:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2021-01-26 19:22:10 +08:00
|
|
|
#include "shared/source/utilities/software_tags_manager.h"
|
2019-08-27 15:34:20 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
2020-10-29 22:33:35 +08:00
|
|
|
extern CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield);
|
2020-01-20 14:02:07 +08:00
|
|
|
|
2021-12-16 19:08:32 +08:00
|
|
|
RootDevice::RootDevice(ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex) : Device(executionEnvironment, rootDeviceIndex) {}
|
2019-08-27 15:34:20 +08:00
|
|
|
|
2020-01-14 21:32:11 +08:00
|
|
|
RootDevice::~RootDevice() {
|
2021-01-26 19:22:10 +08:00
|
|
|
if (getRootDeviceEnvironment().tagsManager) {
|
|
|
|
getRootDeviceEnvironment().tagsManager->shutdown();
|
|
|
|
}
|
2020-01-14 21:32:11 +08:00
|
|
|
}
|
2019-08-28 19:12:44 +08:00
|
|
|
|
2021-04-08 01:00:33 +08:00
|
|
|
Device *RootDevice::getRootDevice() const {
|
|
|
|
return const_cast<RootDevice *>(this);
|
2020-07-15 18:38:34 +08:00
|
|
|
}
|
2019-10-10 21:56:10 +08:00
|
|
|
|
2021-04-22 22:28:27 +08:00
|
|
|
void RootDevice::createBindlessHeapsHelper() {
|
2023-05-30 16:26:29 +08:00
|
|
|
|
2023-10-19 02:37:50 +08:00
|
|
|
if (ApiSpecificConfig::getGlobalBindlessHeapConfiguration() && ApiSpecificConfig::getBindlessMode(this->getReleaseHelper())) {
|
2021-10-05 18:30:14 +08:00
|
|
|
this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->createBindlessHeapsHelper(getMemoryManager(), getNumGenericSubDevices() > 1, rootDeviceIndex, getDeviceBitfield());
|
2020-10-19 16:02:28 +08:00
|
|
|
}
|
2019-08-28 19:12:44 +08:00
|
|
|
}
|
2021-01-25 17:24:00 +08:00
|
|
|
|
2019-10-07 18:42:28 +08:00
|
|
|
bool RootDevice::createEngines() {
|
2021-04-27 17:51:03 +08:00
|
|
|
if (hasGenericSubDevices) {
|
2020-01-20 14:02:07 +08:00
|
|
|
initializeRootCommandStreamReceiver();
|
2021-04-27 17:51:03 +08:00
|
|
|
} else {
|
|
|
|
return Device::createEngines();
|
2019-10-07 18:42:28 +08:00
|
|
|
}
|
2021-04-27 17:51:03 +08:00
|
|
|
|
2019-10-07 18:42:28 +08:00
|
|
|
return true;
|
|
|
|
}
|
2020-01-20 14:02:07 +08:00
|
|
|
|
|
|
|
void RootDevice::initializeRootCommandStreamReceiver() {
|
2020-10-28 23:08:37 +08:00
|
|
|
std::unique_ptr<CommandStreamReceiver> rootCommandStreamReceiver(createCommandStream(*executionEnvironment, rootDeviceIndex, getDeviceBitfield()));
|
2020-01-20 14:02:07 +08:00
|
|
|
|
|
|
|
auto &hwInfo = getHardwareInfo();
|
|
|
|
auto defaultEngineType = getChosenEngineType(hwInfo);
|
|
|
|
auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfo);
|
|
|
|
|
2023-12-11 19:02:15 +08:00
|
|
|
EngineDescriptor engineDescriptor(EngineTypeUsage{defaultEngineType, EngineUsage::regular}, getDeviceBitfield(), preemptionMode, true, false);
|
2021-08-12 01:36:00 +08:00
|
|
|
|
|
|
|
auto osContext = getMemoryManager()->createAndRegisterOsContext(rootCommandStreamReceiver.get(), engineDescriptor);
|
2020-01-20 14:02:07 +08:00
|
|
|
|
|
|
|
rootCommandStreamReceiver->setupContext(*osContext);
|
2022-11-03 23:25:30 +08:00
|
|
|
rootCommandStreamReceiver->initializeResources();
|
2023-02-12 06:03:06 +08:00
|
|
|
rootCsrCreated = true;
|
2020-01-20 14:02:07 +08:00
|
|
|
rootCommandStreamReceiver->initializeTagAllocation();
|
2020-02-06 03:00:08 +08:00
|
|
|
rootCommandStreamReceiver->createGlobalFenceAllocation();
|
2021-02-17 01:04:00 +08:00
|
|
|
rootCommandStreamReceiver->createWorkPartitionAllocation(*this);
|
2024-02-29 18:11:37 +08:00
|
|
|
if (preemptionMode == PreemptionMode::MidThread) {
|
|
|
|
rootCommandStreamReceiver->createPreemptionAllocation();
|
|
|
|
}
|
2020-01-20 14:02:07 +08:00
|
|
|
commandStreamReceivers.push_back(std::move(rootCommandStreamReceiver));
|
2020-12-30 21:36:22 +08:00
|
|
|
|
|
|
|
EngineControl engine{commandStreamReceivers.back().get(), osContext};
|
2021-12-13 20:45:24 +08:00
|
|
|
allEngines.push_back(engine);
|
2020-12-30 21:36:22 +08:00
|
|
|
addEngineToEngineGroup(engine);
|
2020-01-20 14:02:07 +08:00
|
|
|
}
|
|
|
|
|
2019-08-27 15:34:20 +08:00
|
|
|
} // namespace NEO
|