2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-01-19 17:32:22 +00:00
|
|
|
* Copyright (C) 2017-2021 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/device/device.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
|
|
|
|
#include "shared/source/command_stream/experimental_command_buffer.h"
|
|
|
|
|
#include "shared/source/command_stream/preemption.h"
|
|
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2020-02-24 18:04:30 +01:00
|
|
|
#include "shared/source/gmm_helper/gmm_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
|
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2020-03-16 12:41:25 +01:00
|
|
|
#include "shared/source/os_interface/driver_info.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/os_context.h"
|
|
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
|
|
|
|
#include "shared/source/os_interface/os_time.h"
|
2020-03-06 10:11:44 +01:00
|
|
|
#include "shared/source/source_level_debugger/source_level_debugger.h"
|
2021-01-26 11:22:10 +00:00
|
|
|
#include "shared/source/utilities/software_tags_manager.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
decltype(&PerformanceCounters::create) Device::createPerformanceCountersFunc = PerformanceCounters::create;
|
2020-10-29 15:33:35 +01:00
|
|
|
extern CommandStreamReceiver *createCommandStream(ExecutionEnvironment &executionEnvironment,
|
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
|
const DeviceBitfield deviceBitfield);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-11-05 13:38:20 +01:00
|
|
|
Device::Device(ExecutionEnvironment *executionEnvironment)
|
|
|
|
|
: executionEnvironment(executionEnvironment) {
|
2018-07-10 17:14:20 +02:00
|
|
|
this->executionEnvironment->incRefInternal();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Device::~Device() {
|
2018-07-11 16:47:49 +02:00
|
|
|
DEBUG_BREAK_IF(nullptr == executionEnvironment->memoryManager.get());
|
2021-01-26 11:22:10 +00:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
if (performanceCounters) {
|
|
|
|
|
performanceCounters->shutdown();
|
|
|
|
|
}
|
2018-07-16 13:01:10 +02:00
|
|
|
|
2018-11-21 09:57:51 +01:00
|
|
|
for (auto &engine : engines) {
|
2019-01-10 13:57:40 +01:00
|
|
|
engine.commandStreamReceiver->flushBatchedSubmissions();
|
2018-03-09 14:48:42 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-07 17:00:33 +00:00
|
|
|
for (auto subdevice : subdevices) {
|
|
|
|
|
if (subdevice) {
|
|
|
|
|
delete subdevice;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-19 23:14:09 +00:00
|
|
|
syncBufferHandler.reset();
|
2019-11-05 13:38:20 +01:00
|
|
|
commandStreamReceivers.clear();
|
2019-02-19 08:55:11 +01:00
|
|
|
executionEnvironment->memoryManager->waitForDeletions();
|
2020-10-19 10:02:28 +02:00
|
|
|
|
2018-07-10 17:14:20 +02:00
|
|
|
executionEnvironment->decRefInternal();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-22 14:28:27 +00:00
|
|
|
SubDevice *Device::createSubDevice(uint32_t subDeviceIndex) {
|
|
|
|
|
return Device::create<SubDevice>(executionEnvironment, subDeviceIndex, *getRootDevice());
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-23 10:56:13 +00:00
|
|
|
SubDevice *Device::createEngineInstancedSubDevice(uint32_t subDeviceIndex, aub_stream::EngineType engineType) {
|
|
|
|
|
return Device::create<SubDevice>(executionEnvironment, subDeviceIndex, *getRootDevice(), engineType);
|
|
|
|
|
}
|
2021-04-22 14:28:27 +00:00
|
|
|
|
2021-04-23 10:56:13 +00:00
|
|
|
bool Device::genericSubDevicesAllowed() {
|
2021-05-05 08:07:53 +00:00
|
|
|
auto deviceMask = executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->deviceAffinityMask.getGenericSubDevicesMask();
|
2021-04-22 14:28:27 +00:00
|
|
|
uint32_t subDeviceCount = HwHelper::getSubDevicesCount(&getHardwareInfo());
|
|
|
|
|
deviceBitfield = maxNBitValue(subDeviceCount);
|
|
|
|
|
deviceBitfield &= deviceMask;
|
|
|
|
|
numSubDevices = static_cast<uint32_t>(deviceBitfield.count());
|
|
|
|
|
if (numSubDevices == 1) {
|
|
|
|
|
numSubDevices = 0;
|
|
|
|
|
}
|
2021-04-23 10:56:13 +00:00
|
|
|
|
|
|
|
|
return (numSubDevices > 0);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-06 11:33:39 +00:00
|
|
|
bool Device::engineInstancedSubDevicesAllowed() {
|
|
|
|
|
if ((DebugManager.flags.EngineInstancedSubDevices.get() != 1) || engineInstanced ||
|
|
|
|
|
(getHardwareInfo().gtSystemInfo.CCSInfo.NumberOfCCSEnabled < 2)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UNRECOVERABLE_IF(deviceBitfield.count() != 1);
|
|
|
|
|
uint32_t subDeviceIndex = Math::log2(static_cast<uint32_t>(deviceBitfield.to_ulong()));
|
|
|
|
|
|
|
|
|
|
auto enginesMask = getRootDeviceEnvironment().deviceAffinityMask.getEnginesMask(subDeviceIndex);
|
|
|
|
|
auto ccsCount = getHardwareInfo().gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
|
|
|
|
|
|
|
|
|
|
numSubDevices = std::min(ccsCount, static_cast<uint32_t>(enginesMask.count()));
|
|
|
|
|
|
|
|
|
|
if (numSubDevices == 1) {
|
|
|
|
|
numSubDevices = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (numSubDevices > 0);
|
2021-04-23 10:56:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Device::createEngineInstancedSubDevices() {
|
|
|
|
|
UNRECOVERABLE_IF(deviceBitfield.count() != 1);
|
|
|
|
|
UNRECOVERABLE_IF(!subdevices.empty());
|
|
|
|
|
|
|
|
|
|
uint32_t subDeviceIndex = Math::log2(static_cast<uint32_t>(deviceBitfield.to_ulong()));
|
|
|
|
|
|
2021-05-06 11:33:39 +00:00
|
|
|
auto enginesMask = getRootDeviceEnvironment().deviceAffinityMask.getEnginesMask(subDeviceIndex);
|
|
|
|
|
auto ccsCount = getHardwareInfo().gtSystemInfo.CCSInfo.NumberOfCCSEnabled;
|
|
|
|
|
|
|
|
|
|
subdevices.resize(ccsCount, nullptr);
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < ccsCount; i++) {
|
|
|
|
|
if (!enginesMask.test(i)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-23 10:56:13 +00:00
|
|
|
auto engineType = static_cast<aub_stream::EngineType>(aub_stream::EngineType::ENGINE_CCS + i);
|
|
|
|
|
auto subDevice = createEngineInstancedSubDevice(subDeviceIndex, engineType);
|
|
|
|
|
UNRECOVERABLE_IF(!subDevice);
|
|
|
|
|
subdevices[i] = subDevice;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Device::createGenericSubDevices() {
|
2021-04-22 14:28:27 +00:00
|
|
|
UNRECOVERABLE_IF(!subdevices.empty());
|
2021-04-23 10:56:13 +00:00
|
|
|
uint32_t subDeviceCount = HwHelper::getSubDevicesCount(&getHardwareInfo());
|
|
|
|
|
|
|
|
|
|
subdevices.resize(subDeviceCount, nullptr);
|
|
|
|
|
|
|
|
|
|
for (auto i = 0u; i < subDeviceCount; i++) {
|
|
|
|
|
if (!deviceBitfield.test(i)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
auto subDevice = createSubDevice(i);
|
|
|
|
|
if (!subDevice) {
|
|
|
|
|
return false;
|
2021-04-22 14:28:27 +00:00
|
|
|
}
|
2021-04-23 10:56:13 +00:00
|
|
|
subdevices[i] = subDevice;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-27 09:51:03 +00:00
|
|
|
hasGenericSubDevices = true;
|
2021-04-23 10:56:13 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Device::createSubDevices() {
|
|
|
|
|
if (genericSubDevicesAllowed()) {
|
|
|
|
|
return createGenericSubDevices();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (engineInstancedSubDevicesAllowed()) {
|
|
|
|
|
return createEngineInstancedSubDevices();
|
2021-04-22 14:28:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-06 12:33:44 +02:00
|
|
|
bool Device::createDeviceImpl() {
|
2021-04-22 14:28:27 +00:00
|
|
|
if (!createSubDevices()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-11 10:15:21 +01:00
|
|
|
auto &hwInfo = getHardwareInfo();
|
|
|
|
|
preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfo);
|
|
|
|
|
|
|
|
|
|
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
|
|
|
|
hwHelper.setupHardwareCapabilities(&this->hardwareCapabilities, hwInfo);
|
2020-02-25 16:38:47 +01:00
|
|
|
executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->initGmm();
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-11-23 14:31:20 +00:00
|
|
|
if (!getDebugger()) {
|
|
|
|
|
this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->initDebugger();
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-06 12:33:44 +02:00
|
|
|
if (!createEngines()) {
|
2017-12-21 00:45:38 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
2020-03-06 19:02:24 +01:00
|
|
|
|
|
|
|
|
getDefaultEngine().osContext->setDefaultContext(true);
|
|
|
|
|
|
|
|
|
|
for (auto &engine : engines) {
|
|
|
|
|
auto commandStreamReceiver = engine.commandStreamReceiver;
|
|
|
|
|
auto osContext = engine.osContext;
|
|
|
|
|
if (!commandStreamReceiver->initDirectSubmission(*this, *osContext)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-19 15:06:08 +00:00
|
|
|
uint32_t defaultEngineIndexWithinMemoryManager = 0;
|
|
|
|
|
for (auto engineIndex = 0u; engineIndex < executionEnvironment->memoryManager->getRegisteredEnginesCount(); engineIndex++) {
|
|
|
|
|
OsContext *engine = executionEnvironment->memoryManager->getRegisteredEngines()[engineIndex].osContext;
|
|
|
|
|
if (engine == getDefaultEngine().osContext) {
|
|
|
|
|
defaultEngineIndexWithinMemoryManager = engineIndex;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-20 12:24:04 +00:00
|
|
|
executionEnvironment->memoryManager->setDefaultEngineIndex(getRootDeviceIndex(), defaultEngineIndexWithinMemoryManager);
|
2018-11-28 09:02:55 +01:00
|
|
|
|
2020-01-07 07:42:40 +01:00
|
|
|
auto osInterface = getRootDeviceEnvironment().osInterface.get();
|
2018-11-21 09:57:51 +01:00
|
|
|
|
2019-02-07 09:36:39 +01:00
|
|
|
if (!osTime) {
|
|
|
|
|
osTime = OSTime::create(osInterface);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2018-07-16 17:11:43 +02:00
|
|
|
|
2019-02-07 09:36:39 +01:00
|
|
|
initializeCaps();
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-02-07 09:36:39 +01:00
|
|
|
if (osTime->getOSInterface()) {
|
2019-05-06 12:33:44 +02:00
|
|
|
if (hwInfo.capabilityTable.instrumentationEnabled) {
|
2019-05-20 11:19:27 +02:00
|
|
|
performanceCounters = createPerformanceCountersFunc(this);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-07 09:36:39 +01:00
|
|
|
executionEnvironment->memoryManager->setForce32BitAllocations(getDeviceInfo().force32BitAddressess);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-06-27 21:33:05 +02:00
|
|
|
if (DebugManager.flags.EnableExperimentalCommandBuffer.get() > 0) {
|
|
|
|
|
for (auto &engine : engines) {
|
|
|
|
|
auto csr = engine.commandStreamReceiver;
|
2019-02-07 09:36:39 +01:00
|
|
|
csr->setExperimentalCmdBuffer(std::make_unique<ExperimentalCommandBuffer>(csr, getDeviceInfo().profilingTimerResolution));
|
2018-11-28 09:02:55 +01:00
|
|
|
}
|
2018-07-05 11:23:28 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-26 11:22:10 +00:00
|
|
|
if (DebugManager.flags.EnableSWTags.get() && !getRootDeviceEnvironment().tagsManager->isInitialized()) {
|
|
|
|
|
getRootDeviceEnvironment().tagsManager->initialize(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-22 14:28:27 +00:00
|
|
|
createBindlessHeapsHelper();
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-06 12:33:44 +02:00
|
|
|
bool Device::createEngines() {
|
|
|
|
|
auto &hwInfo = getHardwareInfo();
|
2020-02-21 15:25:04 +01:00
|
|
|
auto gpgpuEngines = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo);
|
2018-11-28 09:02:55 +01:00
|
|
|
|
2020-07-28 01:36:52 -07:00
|
|
|
this->engineGroups.resize(static_cast<uint32_t>(EngineGroupType::MaxEngineGroups));
|
2019-01-10 13:57:40 +01:00
|
|
|
for (uint32_t deviceCsrIndex = 0; deviceCsrIndex < gpgpuEngines.size(); deviceCsrIndex++) {
|
2019-10-24 13:34:25 +02:00
|
|
|
if (!createEngine(deviceCsrIndex, gpgpuEngines[deviceCsrIndex])) {
|
2018-11-28 09:02:55 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
2019-07-16 09:23:02 +02:00
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2018-11-28 09:02:55 +01:00
|
|
|
|
2020-12-15 16:37:05 +00:00
|
|
|
void Device::addEngineToEngineGroup(EngineControl &engine) {
|
|
|
|
|
const HardwareInfo &hardwareInfo = this->getHardwareInfo();
|
|
|
|
|
const HwHelper &hwHelper = NEO::HwHelper::get(hardwareInfo.platform.eRenderCoreFamily);
|
|
|
|
|
const EngineGroupType engineGroupType = hwHelper.getEngineGroupType(engine.getEngineType(), hardwareInfo);
|
|
|
|
|
|
2021-03-03 14:26:16 +00:00
|
|
|
if (!hwHelper.isSubDeviceEngineSupported(hardwareInfo, getDeviceBitfield(), engine.getEngineType())) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-15 16:37:05 +00:00
|
|
|
if (hwHelper.isCopyOnlyEngineType(engineGroupType) && DebugManager.flags.EnableBlitterOperationsSupport.get() == 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const uint32_t engineGroupIndex = static_cast<uint32_t>(engineGroupType);
|
|
|
|
|
this->engineGroups[engineGroupIndex].push_back(engine);
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-05 13:38:20 +01:00
|
|
|
std::unique_ptr<CommandStreamReceiver> Device::createCommandStreamReceiver() const {
|
2020-10-28 16:08:37 +01:00
|
|
|
return std::unique_ptr<CommandStreamReceiver>(createCommandStream(*executionEnvironment, getRootDeviceIndex(), getDeviceBitfield()));
|
2019-11-05 13:38:20 +01:00
|
|
|
}
|
|
|
|
|
|
2020-09-15 17:29:02 +02:00
|
|
|
bool Device::createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsage) {
|
2021-04-15 16:14:04 +00:00
|
|
|
const auto &hwInfo = getHardwareInfo();
|
|
|
|
|
const auto engineType = engineTypeUsage.first;
|
|
|
|
|
const auto engineUsage = engineTypeUsage.second;
|
|
|
|
|
const auto defaultEngineType = getChosenEngineType(hwInfo);
|
|
|
|
|
const bool isDefaultEngine = defaultEngineType == engineType && engineUsage == EngineUsage::Regular;
|
2019-02-18 13:59:16 +01:00
|
|
|
|
2019-11-05 13:38:20 +01:00
|
|
|
std::unique_ptr<CommandStreamReceiver> commandStreamReceiver = createCommandStreamReceiver();
|
|
|
|
|
if (!commandStreamReceiver) {
|
2019-07-16 09:23:02 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2020-02-10 09:44:00 +01:00
|
|
|
|
2020-09-15 17:29:02 +02:00
|
|
|
bool internalUsage = (engineTypeUsage.second == EngineUsage::Internal);
|
2020-09-04 16:18:12 -07:00
|
|
|
if (internalUsage) {
|
|
|
|
|
commandStreamReceiver->initializeDefaultsForInternalEngine();
|
|
|
|
|
}
|
2020-02-10 09:44:00 +01:00
|
|
|
|
2019-12-27 11:32:12 +01:00
|
|
|
if (commandStreamReceiver->needsPageTableManager(engineType)) {
|
2019-11-05 13:38:20 +01:00
|
|
|
commandStreamReceiver->createPageTableManager();
|
|
|
|
|
}
|
2018-11-28 09:02:55 +01:00
|
|
|
|
2020-09-15 17:29:02 +02:00
|
|
|
bool lowPriority = (engineTypeUsage.second == EngineUsage::LowPriority);
|
2021-03-08 18:50:32 +00:00
|
|
|
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(commandStreamReceiver.get(),
|
|
|
|
|
engineTypeUsage,
|
|
|
|
|
getDeviceBitfield(),
|
|
|
|
|
preemptionMode,
|
|
|
|
|
false);
|
2021-04-15 16:14:04 +00:00
|
|
|
if (osContext->isImmediateContextInitializationEnabled(isDefaultEngine)) {
|
|
|
|
|
osContext->ensureContextInitialized();
|
|
|
|
|
}
|
2019-07-16 09:23:02 +02:00
|
|
|
commandStreamReceiver->setupContext(*osContext);
|
|
|
|
|
|
|
|
|
|
if (!commandStreamReceiver->initializeTagAllocation()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-02-05 20:00:08 +01:00
|
|
|
|
|
|
|
|
if (!commandStreamReceiver->createGlobalFenceAllocation()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-15 16:14:04 +00:00
|
|
|
if (isDefaultEngine) {
|
2019-07-16 09:23:02 +02:00
|
|
|
defaultEngineIndex = deviceCsrIndex;
|
|
|
|
|
}
|
2019-06-27 21:33:05 +02:00
|
|
|
|
2021-03-18 16:37:51 +00:00
|
|
|
if (preemptionMode == PreemptionMode::MidThread && !commandStreamReceiver->createPreemptionAllocation()) {
|
2019-07-16 09:23:02 +02:00
|
|
|
return false;
|
2018-11-28 09:02:55 +01:00
|
|
|
}
|
2019-07-16 09:23:02 +02:00
|
|
|
|
2020-07-28 01:36:52 -07:00
|
|
|
EngineControl engine{commandStreamReceiver.get(), osContext};
|
|
|
|
|
engines.push_back(engine);
|
|
|
|
|
if (!lowPriority && !internalUsage) {
|
2020-12-15 16:37:05 +00:00
|
|
|
addEngineToEngineGroup(engine);
|
2020-07-28 01:36:52 -07:00
|
|
|
}
|
|
|
|
|
|
2019-11-05 13:38:20 +01:00
|
|
|
commandStreamReceivers.push_back(std::move(commandStreamReceiver));
|
2019-07-16 09:23:02 +02:00
|
|
|
|
2018-11-28 09:02:55 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 11:27:28 +01:00
|
|
|
const HardwareInfo &Device::getHardwareInfo() const { return *getRootDeviceEnvironment().getHardwareInfo(); }
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
const DeviceInfo &Device::getDeviceInfo() const {
|
|
|
|
|
return deviceInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double Device::getProfilingTimerResolution() {
|
2019-05-06 12:33:44 +02:00
|
|
|
return osTime->getDynamicDeviceTimerResolution(getHardwareInfo());
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-24 13:57:46 -04:00
|
|
|
uint64_t Device::getProfilingTimerClock() {
|
|
|
|
|
return osTime->getDynamicDeviceTimerClock(getHardwareInfo());
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-11 10:32:17 +02:00
|
|
|
bool Device::isSimulation() const {
|
2019-05-06 12:33:44 +02:00
|
|
|
auto &hwInfo = getHardwareInfo();
|
|
|
|
|
|
2019-05-08 16:00:24 +02:00
|
|
|
bool simulation = hwInfo.capabilityTable.isSimulation(hwInfo.platform.usDeviceID);
|
2020-05-14 13:12:17 +02:00
|
|
|
for (const auto &engine : engines) {
|
|
|
|
|
if (engine.commandStreamReceiver->getType() != CommandStreamReceiverType::CSR_HW) {
|
|
|
|
|
simulation = true;
|
|
|
|
|
}
|
2018-06-06 10:34:51 +02:00
|
|
|
}
|
2020-05-14 13:12:17 +02:00
|
|
|
|
2019-05-08 16:00:24 +02:00
|
|
|
if (hwInfo.featureTable.ftrSimulationMode) {
|
2018-07-11 10:32:17 +02:00
|
|
|
simulation = true;
|
|
|
|
|
}
|
2018-06-06 10:34:51 +02:00
|
|
|
return simulation;
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double Device::getPlatformHostTimerResolution() const {
|
|
|
|
|
if (osTime.get())
|
|
|
|
|
return osTime->getHostTimerResolution();
|
|
|
|
|
return 0.0;
|
|
|
|
|
}
|
2019-11-19 16:54:47 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
GFXCORE_FAMILY Device::getRenderCoreFamily() const {
|
2019-05-08 16:00:24 +02:00
|
|
|
return this->getHardwareInfo().platform.eRenderCoreFamily;
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2018-04-06 14:25:22 +02:00
|
|
|
|
2020-02-10 15:57:49 +01:00
|
|
|
bool Device::isDebuggerActive() const {
|
|
|
|
|
return deviceInfo.debuggerActive;
|
2018-04-06 14:25:22 +02:00
|
|
|
}
|
2018-11-22 13:57:10 +01:00
|
|
|
|
2020-11-16 11:43:03 +00:00
|
|
|
const std::vector<EngineControl> *Device::getNonEmptyEngineGroup(size_t index) const {
|
|
|
|
|
auto nonEmptyGroupIndex = 0u;
|
|
|
|
|
for (auto groupIndex = 0u; groupIndex < engineGroups.size(); groupIndex++) {
|
|
|
|
|
const std::vector<EngineControl> *currentGroup = &engineGroups[groupIndex];
|
|
|
|
|
if (currentGroup->empty()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (index == nonEmptyGroupIndex) {
|
|
|
|
|
return currentGroup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nonEmptyGroupIndex++;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-19 17:32:22 +00:00
|
|
|
size_t Device::getIndexOfNonEmptyEngineGroup(EngineGroupType engineGroupType) const {
|
|
|
|
|
const auto groupIndex = static_cast<size_t>(engineGroupType);
|
|
|
|
|
UNRECOVERABLE_IF(groupIndex >= engineGroups.size());
|
|
|
|
|
UNRECOVERABLE_IF(engineGroups[groupIndex].empty());
|
|
|
|
|
|
|
|
|
|
size_t result = 0u;
|
|
|
|
|
for (auto currentGroupIndex = 0u; currentGroupIndex < groupIndex; currentGroupIndex++) {
|
|
|
|
|
if (!engineGroups[currentGroupIndex].empty()) {
|
|
|
|
|
result++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-16 12:34:27 +00:00
|
|
|
EngineControl &Device::getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) {
|
2019-03-23 14:26:06 +01:00
|
|
|
for (auto &engine : engines) {
|
|
|
|
|
if (engine.osContext->getEngineType() == engineType &&
|
2021-03-16 12:34:27 +00:00
|
|
|
engine.osContext->isLowPriority() == (engineUsage == EngineUsage::LowPriority) &&
|
|
|
|
|
engine.osContext->isInternalEngine() == (engineUsage == EngineUsage::Internal)) {
|
2019-03-23 14:26:06 +01:00
|
|
|
return engine;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-09 17:46:23 +02:00
|
|
|
if (DebugManager.flags.OverrideInvalidEngineWithDefault.get()) {
|
|
|
|
|
return engines[0];
|
|
|
|
|
}
|
2019-03-23 14:26:06 +01:00
|
|
|
UNRECOVERABLE_IF(true);
|
|
|
|
|
}
|
2020-02-06 18:57:00 +01:00
|
|
|
|
2020-05-03 12:33:11 -07:00
|
|
|
EngineControl &Device::getEngine(uint32_t index) {
|
|
|
|
|
UNRECOVERABLE_IF(index >= engines.size());
|
|
|
|
|
return engines[index];
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-06 18:57:00 +01:00
|
|
|
bool Device::getDeviceAndHostTimer(uint64_t *deviceTimestamp, uint64_t *hostTimestamp) const {
|
|
|
|
|
TimeStampData queueTimeStamp;
|
|
|
|
|
bool retVal = getOSTime()->getCpuGpuTime(&queueTimeStamp);
|
|
|
|
|
if (retVal) {
|
|
|
|
|
uint64_t resolution = (uint64_t)getOSTime()->getDynamicDeviceTimerResolution(getHardwareInfo());
|
|
|
|
|
*deviceTimestamp = queueTimeStamp.GPUTimeStamp * resolution;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retVal = getOSTime()->getCpuTime(hostTimestamp);
|
|
|
|
|
return retVal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Device::getHostTimer(uint64_t *hostTimestamp) const {
|
|
|
|
|
return getOSTime()->getCpuTime(hostTimestamp);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-07 17:00:33 +00:00
|
|
|
uint32_t Device::getNumAvailableDevices() const {
|
|
|
|
|
if (subdevices.empty()) {
|
|
|
|
|
return 1u;
|
|
|
|
|
}
|
|
|
|
|
return getNumSubDevices();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Device *Device::getDeviceById(uint32_t deviceId) const {
|
|
|
|
|
if (subdevices.empty()) {
|
|
|
|
|
return const_cast<Device *>(this);
|
|
|
|
|
}
|
|
|
|
|
UNRECOVERABLE_IF(deviceId >= subdevices.size());
|
|
|
|
|
return subdevices[deviceId];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BindlessHeapsHelper *Device::getBindlessHeapsHelper() const {
|
|
|
|
|
return getRootDeviceEnvironment().getBindlessHeapsHelper();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-24 18:04:30 +01:00
|
|
|
GmmClientContext *Device::getGmmClientContext() const {
|
|
|
|
|
return getGmmHelper()->getClientContext();
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-19 23:14:09 +00:00
|
|
|
void Device::allocateSyncBufferHandler() {
|
|
|
|
|
static std::mutex mutex;
|
|
|
|
|
std::unique_lock<std::mutex> lock(mutex);
|
|
|
|
|
if (syncBufferHandler.get() == nullptr) {
|
|
|
|
|
syncBufferHandler = std::make_unique<SyncBufferHandler>(*this);
|
|
|
|
|
UNRECOVERABLE_IF(syncBufferHandler.get() == nullptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-30 10:27:48 +01:00
|
|
|
uint64_t Device::getGlobalMemorySize(uint32_t deviceBitfield) const {
|
2020-04-16 14:44:03 +02:00
|
|
|
auto globalMemorySize = getMemoryManager()->isLocalMemorySupported(this->getRootDeviceIndex())
|
2020-10-30 10:27:48 +01:00
|
|
|
? getMemoryManager()->getLocalMemorySize(this->getRootDeviceIndex(), deviceBitfield)
|
2020-04-16 14:44:03 +02:00
|
|
|
: getMemoryManager()->getSystemSharedMemory(this->getRootDeviceIndex());
|
|
|
|
|
globalMemorySize = std::min(globalMemorySize, getMemoryManager()->getMaxApplicationAddress() + 1);
|
|
|
|
|
globalMemorySize = static_cast<uint64_t>(static_cast<double>(globalMemorySize) * 0.8);
|
|
|
|
|
return globalMemorySize;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-18 17:08:55 +02:00
|
|
|
NEO::SourceLevelDebugger *Device::getSourceLevelDebugger() {
|
|
|
|
|
auto debugger = getDebugger();
|
|
|
|
|
if (debugger) {
|
|
|
|
|
return debugger->isLegacy() ? static_cast<NEO::SourceLevelDebugger *>(debugger) : nullptr;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-02 11:49:46 +02:00
|
|
|
const std::vector<EngineControl> &Device::getEngines() const {
|
|
|
|
|
return this->engines;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|