2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-12-20 12:58:34 +00:00
|
|
|
* Copyright (C) 2018-2022 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
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-06-18 17:08:55 +02:00
|
|
|
#include "shared/source/debugger/debugger.h"
|
2020-03-18 11:36:17 +01:00
|
|
|
#include "shared/source/device/device_info.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2020-02-24 18:04:30 +01:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2020-11-18 11:17:45 +00:00
|
|
|
#include "shared/source/helpers/bindless_heaps_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/common_types.h"
|
2021-12-07 13:50:28 +00:00
|
|
|
#include "shared/source/helpers/definitions/engine_group_types.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/engine_control.h"
|
2020-09-15 17:29:02 +02:00
|
|
|
#include "shared/source/helpers/engine_node_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2022-05-17 19:04:23 +00:00
|
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
2021-11-26 09:40:06 +00:00
|
|
|
#include "shared/source/os_interface/hw_info_config.h"
|
2021-09-24 09:02:44 +00:00
|
|
|
#include "shared/source/os_interface/performance_counters.h"
|
2021-03-19 23:14:09 +00:00
|
|
|
#include "shared/source/program/sync_buffer_handler.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2019-11-19 16:54:47 +01:00
|
|
|
class OSTime;
|
2020-06-18 17:08:55 +02:00
|
|
|
class SourceLevelDebugger;
|
2021-04-07 17:00:33 +00:00
|
|
|
class SubDevice;
|
2021-12-20 12:58:34 +00:00
|
|
|
struct PhysicalDevicePciBusInfo;
|
2020-01-14 14:32:11 +01:00
|
|
|
|
2021-07-02 11:34:07 +00:00
|
|
|
struct SelectorCopyEngine : NonCopyableOrMovableClass {
|
|
|
|
|
std::atomic<bool> isMainUsed = false;
|
|
|
|
|
std::atomic<uint32_t> selector = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2022-07-05 11:11:16 +00:00
|
|
|
using EnginesT = std::vector<EngineControl>;
|
|
|
|
|
struct EngineGroupT {
|
|
|
|
|
EngineGroupType engineGroupType;
|
|
|
|
|
EnginesT engines;
|
|
|
|
|
};
|
|
|
|
|
using EngineGroupsT = std::vector<EngineGroupT>;
|
|
|
|
|
|
2020-01-14 14:32:11 +01:00
|
|
|
class Device : public ReferenceTrackedObject<Device> {
|
|
|
|
|
public:
|
|
|
|
|
Device &operator=(const Device &) = delete;
|
|
|
|
|
Device(const Device &) = delete;
|
|
|
|
|
~Device() override;
|
|
|
|
|
|
2019-11-29 13:03:35 +01:00
|
|
|
template <typename DeviceT, typename... ArgsT>
|
2021-03-15 11:39:58 +00:00
|
|
|
static DeviceT *create(ArgsT &&...args) {
|
2019-11-29 13:03:35 +01:00
|
|
|
DeviceT *device = new DeviceT(std::forward<ArgsT>(args)...);
|
|
|
|
|
return createDeviceInternals(device);
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-04-02 16:38:42 +02:00
|
|
|
virtual void incRefInternal() {
|
|
|
|
|
ReferenceTrackedObject<Device>::incRefInternal();
|
|
|
|
|
}
|
|
|
|
|
virtual unique_ptr_if_unused<Device> decRefInternal() {
|
|
|
|
|
return ReferenceTrackedObject<Device>::decRefInternal();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-29 13:03:35 +01:00
|
|
|
bool getDeviceAndHostTimer(uint64_t *deviceTimestamp, uint64_t *hostTimestamp) const;
|
|
|
|
|
bool getHostTimer(uint64_t *hostTimestamp) const;
|
|
|
|
|
const HardwareInfo &getHardwareInfo() const;
|
|
|
|
|
const DeviceInfo &getDeviceInfo() const;
|
2021-05-11 09:46:12 +00:00
|
|
|
EngineControl *tryGetEngine(aub_stream::EngineType engineType, EngineUsage engineUsage);
|
2021-03-16 12:34:27 +00:00
|
|
|
EngineControl &getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage);
|
2021-12-13 12:45:24 +00:00
|
|
|
EngineGroupsT &getRegularEngineGroups() {
|
|
|
|
|
return this->regularEngineGroups;
|
2020-07-28 01:36:52 -07:00
|
|
|
}
|
2021-12-03 14:30:46 +00:00
|
|
|
size_t getEngineGroupIndexFromEngineGroupType(EngineGroupType engineGroupType) const;
|
2020-05-03 12:33:11 -07:00
|
|
|
EngineControl &getEngine(uint32_t index);
|
2019-11-29 13:03:35 +01:00
|
|
|
EngineControl &getDefaultEngine();
|
2021-11-12 11:02:17 +00:00
|
|
|
EngineControl &getNextEngineForCommandQueue();
|
2020-01-21 09:35:12 +01:00
|
|
|
EngineControl &getInternalEngine();
|
2021-09-28 01:57:51 +00:00
|
|
|
EngineControl *getInternalCopyEngine();
|
2021-07-02 11:34:07 +00:00
|
|
|
SelectorCopyEngine &getSelectorCopyEngine();
|
2017-12-21 00:45:38 +01:00
|
|
|
MemoryManager *getMemoryManager() const;
|
2018-07-23 12:23:48 +02:00
|
|
|
GmmHelper *getGmmHelper() const;
|
2020-02-24 18:04:30 +01:00
|
|
|
GmmClientContext *getGmmClientContext() const;
|
2021-09-24 10:51:57 +00:00
|
|
|
OSTime *getOSTime() const;
|
2017-12-21 00:45:38 +01:00
|
|
|
double getProfilingTimerResolution();
|
2021-03-24 13:57:46 -04:00
|
|
|
uint64_t getProfilingTimerClock();
|
2017-12-21 00:45:38 +01:00
|
|
|
double getPlatformHostTimerResolution() const;
|
2018-07-11 10:32:17 +02:00
|
|
|
bool isSimulation() const;
|
2017-12-21 00:45:38 +01:00
|
|
|
GFXCORE_FAMILY getRenderCoreFamily() const;
|
|
|
|
|
PerformanceCounters *getPerformanceCounters() { return performanceCounters.get(); }
|
2018-01-02 12:10:34 +01:00
|
|
|
PreemptionMode getPreemptionMode() const { return preemptionMode; }
|
2020-02-10 15:57:49 +01:00
|
|
|
MOCKABLE_VIRTUAL bool isDebuggerActive() const;
|
2020-10-27 16:00:56 +01:00
|
|
|
Debugger *getDebugger() const { return getRootDeviceEnvironment().debugger.get(); }
|
2020-06-18 17:08:55 +02:00
|
|
|
NEO::SourceLevelDebugger *getSourceLevelDebugger();
|
2021-12-13 12:45:24 +00:00
|
|
|
const EnginesT &getAllEngines() const;
|
2020-07-21 13:25:14 +02:00
|
|
|
const std::string getDeviceName(const HardwareInfo &hwInfo) const;
|
2020-06-18 17:08:55 +02:00
|
|
|
|
2018-07-31 09:52:48 +02:00
|
|
|
ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; }
|
2019-12-09 13:59:08 +01:00
|
|
|
const RootDeviceEnvironment &getRootDeviceEnvironment() const { return *executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]; }
|
2021-07-06 15:44:16 +02:00
|
|
|
RootDeviceEnvironment &getRootDeviceEnvironmentRef() const { return *executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]; }
|
2019-01-10 11:10:58 +01:00
|
|
|
bool isFullRangeSvm() const {
|
2020-03-04 08:51:02 +01:00
|
|
|
return getRootDeviceEnvironment().isFullRangeSvm();
|
2018-09-10 12:50:45 +02:00
|
|
|
}
|
2021-11-17 11:26:26 +00:00
|
|
|
bool areSharedSystemAllocationsAllowed() const;
|
2020-01-31 15:00:25 +01:00
|
|
|
template <typename SpecializedDeviceT>
|
|
|
|
|
void setSpecializedDevice(SpecializedDeviceT *specializedDevice) {
|
|
|
|
|
this->specializedDevice = reinterpret_cast<uintptr_t>(specializedDevice);
|
|
|
|
|
}
|
|
|
|
|
template <typename SpecializedDeviceT>
|
|
|
|
|
SpecializedDeviceT *getSpecializedDevice() const {
|
|
|
|
|
return reinterpret_cast<SpecializedDeviceT *>(specializedDevice);
|
|
|
|
|
}
|
2020-10-04 11:43:24 +02:00
|
|
|
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface() const;
|
2020-03-05 07:11:11 +01:00
|
|
|
BuiltIns *getBuiltIns() const;
|
2021-03-19 23:14:09 +00:00
|
|
|
void allocateSyncBufferHandler();
|
2019-11-29 13:03:35 +01:00
|
|
|
|
2021-12-16 11:08:32 +00:00
|
|
|
uint32_t getRootDeviceIndex() const {
|
|
|
|
|
return this->rootDeviceIndex;
|
|
|
|
|
}
|
2021-08-31 16:49:46 +00:00
|
|
|
uint32_t getNumGenericSubDevices() const;
|
2021-08-25 19:01:44 +00:00
|
|
|
Device *getSubDevice(uint32_t deviceId) const;
|
2021-08-31 11:49:04 +00:00
|
|
|
Device *getNearestGenericSubDevice(uint32_t deviceId);
|
2021-04-07 17:00:33 +00:00
|
|
|
virtual Device *getRootDevice() const = 0;
|
|
|
|
|
DeviceBitfield getDeviceBitfield() const { return deviceBitfield; };
|
|
|
|
|
uint32_t getNumSubDevices() const { return numSubDevices; }
|
|
|
|
|
virtual bool isSubDevice() const = 0;
|
2021-08-25 19:01:44 +00:00
|
|
|
bool hasRootCsr() const { return rootCsrCreated; }
|
2021-08-31 11:49:04 +00:00
|
|
|
bool isEngineInstanced() const { return engineInstanced; }
|
2021-04-07 17:00:33 +00:00
|
|
|
|
|
|
|
|
BindlessHeapsHelper *getBindlessHeapsHelper() const;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-11-29 13:03:35 +01:00
|
|
|
static decltype(&PerformanceCounters::create) createPerformanceCountersFunc;
|
2021-03-19 23:14:09 +00:00
|
|
|
std::unique_ptr<SyncBufferHandler> syncBufferHandler;
|
2021-02-26 22:02:57 +00:00
|
|
|
GraphicsAllocation *getRTMemoryBackedBuffer() { return rtMemoryBackedBuffer; }
|
2021-07-28 04:31:52 +00:00
|
|
|
GraphicsAllocation *getRTDispatchGlobals(uint32_t maxBvhLevels);
|
|
|
|
|
bool rayTracingIsInitialized() const { return rtMemoryBackedBuffer != nullptr; }
|
|
|
|
|
void initializeRayTracing(uint32_t maxBvhLevels);
|
2019-11-29 13:03:35 +01:00
|
|
|
|
2021-12-06 11:38:24 +00:00
|
|
|
uint64_t getGlobalMemorySize(uint32_t deviceBitfield) const;
|
2021-10-13 12:39:29 +00:00
|
|
|
const std::vector<SubDevice *> getSubDevices() const { return subdevices; }
|
2021-11-26 09:40:06 +00:00
|
|
|
bool getUuid(std::array<uint8_t, HwInfoConfig::uuidSize> &uuid);
|
2022-03-02 09:42:51 +00:00
|
|
|
void generateUuid(std::array<uint8_t, HwInfoConfig::uuidSize> &uuid);
|
2021-07-23 19:23:42 +02:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
protected:
|
|
|
|
|
Device() = delete;
|
2021-12-16 11:08:32 +00:00
|
|
|
Device(ExecutionEnvironment *executionEnvironment, const uint32_t rootDeviceIndex);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-11-29 13:03:35 +01:00
|
|
|
MOCKABLE_VIRTUAL void initializeCaps();
|
|
|
|
|
|
2018-07-20 09:01:58 +02:00
|
|
|
template <typename T>
|
2019-05-06 12:33:44 +02:00
|
|
|
static T *createDeviceInternals(T *device) {
|
|
|
|
|
if (false == device->createDeviceImpl()) {
|
2018-07-20 09:01:58 +02:00
|
|
|
delete device;
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
return device;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-22 14:28:27 +00:00
|
|
|
MOCKABLE_VIRTUAL bool createDeviceImpl();
|
2019-10-07 12:42:28 +02:00
|
|
|
virtual bool createEngines();
|
2021-05-09 19:41:56 +00:00
|
|
|
|
2020-12-15 16:37:05 +00:00
|
|
|
void addEngineToEngineGroup(EngineControl &engine);
|
2021-04-28 17:46:13 +00:00
|
|
|
MOCKABLE_VIRTUAL bool createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsage);
|
2019-11-05 13:38:20 +01:00
|
|
|
MOCKABLE_VIRTUAL std::unique_ptr<CommandStreamReceiver> createCommandStreamReceiver() const;
|
2021-04-22 14:28:27 +00:00
|
|
|
MOCKABLE_VIRTUAL SubDevice *createSubDevice(uint32_t subDeviceIndex);
|
2021-04-23 10:56:13 +00:00
|
|
|
MOCKABLE_VIRTUAL SubDevice *createEngineInstancedSubDevice(uint32_t subDeviceIndex, aub_stream::EngineType engineType);
|
2021-12-27 12:44:57 +00:00
|
|
|
MOCKABLE_VIRTUAL size_t getMaxParameterSizeFromIGC() const;
|
2021-05-19 12:40:51 +00:00
|
|
|
double getPercentOfGlobalMemoryAvailable() const;
|
2021-04-22 14:28:27 +00:00
|
|
|
virtual void createBindlessHeapsHelper() {}
|
|
|
|
|
bool createSubDevices();
|
2021-04-23 10:56:13 +00:00
|
|
|
bool createGenericSubDevices();
|
|
|
|
|
bool createEngineInstancedSubDevices();
|
|
|
|
|
virtual bool genericSubDevicesAllowed();
|
2021-05-06 11:33:39 +00:00
|
|
|
bool engineInstancedSubDevicesAllowed();
|
2021-05-10 15:24:31 +00:00
|
|
|
void setAsEngineInstanced();
|
2022-04-25 14:54:13 +00:00
|
|
|
void allocateRTDispatchGlobals(uint32_t maxBvhLevels);
|
2021-07-28 04:31:52 +00:00
|
|
|
void finalizeRayTracing();
|
2019-11-29 13:03:35 +01:00
|
|
|
|
2020-02-20 09:20:33 +01:00
|
|
|
DeviceInfo deviceInfo = {};
|
2019-11-29 13:03:35 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
std::unique_ptr<PerformanceCounters> performanceCounters;
|
2019-11-05 13:38:20 +01:00
|
|
|
std::vector<std::unique_ptr<CommandStreamReceiver>> commandStreamReceivers;
|
2021-12-13 12:45:24 +00:00
|
|
|
EnginesT allEngines;
|
|
|
|
|
EngineGroupsT regularEngineGroups;
|
2021-04-07 17:00:33 +00:00
|
|
|
std::vector<SubDevice *> subdevices;
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
PreemptionMode preemptionMode;
|
2018-06-27 11:35:37 +02:00
|
|
|
ExecutionEnvironment *executionEnvironment = nullptr;
|
2021-05-06 11:33:39 +00:00
|
|
|
aub_stream::EngineType engineInstancedType = aub_stream::EngineType::NUM_ENGINES;
|
2018-11-29 11:39:10 +01:00
|
|
|
uint32_t defaultEngineIndex = 0;
|
2021-04-07 17:00:33 +00:00
|
|
|
uint32_t numSubDevices = 0;
|
2021-11-12 11:02:17 +00:00
|
|
|
std::atomic_uint32_t regularCommandQueuesCreatedWithinDeviceCount{0};
|
2022-03-11 13:56:59 +00:00
|
|
|
std::bitset<8> availableEnginesForCommandQueueusRoundRobin = 0;
|
|
|
|
|
uint32_t queuesPerEngineCount = 1;
|
|
|
|
|
void initializeEngineRoundRobinControls();
|
2021-04-27 09:51:03 +00:00
|
|
|
bool hasGenericSubDevices = false;
|
2021-05-06 11:33:39 +00:00
|
|
|
bool engineInstanced = false;
|
2021-08-25 19:01:44 +00:00
|
|
|
bool rootCsrCreated = false;
|
2021-12-16 11:08:32 +00:00
|
|
|
const uint32_t rootDeviceIndex;
|
2021-04-07 17:00:33 +00:00
|
|
|
|
2021-07-02 11:34:07 +00:00
|
|
|
SelectorCopyEngine selectorCopyEngine = {};
|
2020-01-31 15:00:25 +01:00
|
|
|
|
2021-04-07 17:00:33 +00:00
|
|
|
DeviceBitfield deviceBitfield = 1;
|
|
|
|
|
|
2020-01-31 15:00:25 +01:00
|
|
|
uintptr_t specializedDevice = reinterpret_cast<uintptr_t>(nullptr);
|
2021-02-26 22:02:57 +00:00
|
|
|
|
|
|
|
|
GraphicsAllocation *rtMemoryBackedBuffer = nullptr;
|
2021-07-28 04:31:52 +00:00
|
|
|
std::vector<GraphicsAllocation *> rtDispatchGlobals;
|
2021-11-26 09:40:06 +00:00
|
|
|
struct {
|
|
|
|
|
bool isValid = false;
|
|
|
|
|
std::array<uint8_t, HwInfoConfig::uuidSize> id;
|
|
|
|
|
} uuid;
|
2021-12-20 12:58:34 +00:00
|
|
|
bool generateUuidFromPciBusInfo(const PhysicalDevicePciBusInfo &pciBusInfo, std::array<uint8_t, HwInfoConfig::uuidSize> &uuid);
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
2018-11-29 11:39:10 +01:00
|
|
|
inline EngineControl &Device::getDefaultEngine() {
|
2021-12-13 12:45:24 +00:00
|
|
|
return allEngines[defaultEngineIndex];
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline MemoryManager *Device::getMemoryManager() const {
|
2018-07-11 16:47:49 +02:00
|
|
|
return executionEnvironment->memoryManager.get();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2018-08-21 15:47:21 +02:00
|
|
|
|
2018-07-23 12:23:48 +02:00
|
|
|
inline GmmHelper *Device::getGmmHelper() const {
|
2020-02-24 18:04:30 +01:00
|
|
|
return getRootDeviceEnvironment().getGmmHelper();
|
2018-07-23 12:23:48 +02:00
|
|
|
}
|
2020-02-24 18:25:42 +01:00
|
|
|
|
2020-03-05 07:11:11 +01:00
|
|
|
inline CompilerInterface *Device::getCompilerInterface() const {
|
2020-02-27 15:32:57 +01:00
|
|
|
return executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->getCompilerInterface();
|
2020-03-05 07:11:11 +01:00
|
|
|
}
|
|
|
|
|
inline BuiltIns *Device::getBuiltIns() const {
|
2020-02-27 15:32:57 +01:00
|
|
|
return executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->getBuiltIns();
|
2020-03-05 07:11:11 +01:00
|
|
|
}
|
|
|
|
|
|
2021-07-02 11:34:07 +00:00
|
|
|
inline SelectorCopyEngine &Device::getSelectorCopyEngine() {
|
2020-02-24 18:25:42 +01:00
|
|
|
return selectorCopyEngine;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|