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