2019-08-27 15:34:20 +08:00
|
|
|
/*
|
2020-12-30 21:36:22 +08:00
|
|
|
* Copyright (C) 2019-2021 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"
|
2020-10-19 16:02:28 +08:00
|
|
|
#include "shared/source/helpers/api_specific_config.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
|
|
|
#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
|
|
|
|
2019-11-05 20:38:20 +08:00
|
|
|
RootDevice::RootDevice(ExecutionEnvironment *executionEnvironment, uint32_t rootDeviceIndex) : Device(executionEnvironment), rootDeviceIndex(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
|
|
|
|
2019-10-21 19:41:35 +08:00
|
|
|
uint32_t RootDevice::getRootDeviceIndex() const {
|
2019-10-24 19:34:25 +08:00
|
|
|
return rootDeviceIndex;
|
2019-10-21 19:41:35 +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() {
|
2020-10-19 16:02:28 +08:00
|
|
|
if (ApiSpecificConfig::getBindlessConfiguration()) {
|
2021-09-01 00:49:46 +08:00
|
|
|
this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->createBindlessHeapsHelper(getMemoryManager(), getNumGenericSubDevices() > 1, rootDeviceIndex);
|
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() {
|
2021-08-26 03:01:44 +08:00
|
|
|
rootCsrCreated = true;
|
|
|
|
|
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);
|
|
|
|
|
2021-08-12 23:43:07 +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
|
|
|
|
2021-04-20 22:42:58 +08:00
|
|
|
osContext->ensureContextInitialized();
|
2020-01-20 14:02:07 +08:00
|
|
|
rootCommandStreamReceiver->setupContext(*osContext);
|
|
|
|
rootCommandStreamReceiver->initializeTagAllocation();
|
2020-02-06 03:00:08 +08:00
|
|
|
rootCommandStreamReceiver->createGlobalFenceAllocation();
|
2021-02-17 01:04:00 +08:00
|
|
|
rootCommandStreamReceiver->createWorkPartitionAllocation(*this);
|
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};
|
|
|
|
engines.push_back(engine);
|
|
|
|
addEngineToEngineGroup(engine);
|
2020-01-20 14:02:07 +08:00
|
|
|
}
|
|
|
|
|
2019-08-27 15:34:20 +08:00
|
|
|
} // namespace NEO
|