2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2018-2021 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"
|
|
|
|
#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-03-20 07:14:09 +08:00
|
|
|
#include "shared/source/program/sync_buffer_handler.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/os_interface/performance_counters.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2021-01-20 01:32:22 +08:00
|
|
|
#include "engine_group_types.h"
|
|
|
|
|
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;
|
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:
|
|
|
|
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);
|
2020-07-28 16:36:52 +08:00
|
|
|
std::vector<std::vector<EngineControl>> &getEngineGroups() {
|
|
|
|
return this->engineGroups;
|
|
|
|
}
|
2020-11-16 19:43:03 +08:00
|
|
|
const std::vector<EngineControl> *getNonEmptyEngineGroup(size_t index) const;
|
2021-01-20 01:32:22 +08:00
|
|
|
size_t getIndexOfNonEmptyEngineGroup(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();
|
2020-01-21 16:35:12 +08:00
|
|
|
EngineControl &getInternalEngine();
|
2021-03-21 02:31:26 +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;
|
2017-12-21 07:45:38 +08:00
|
|
|
OSTime *getOSTime() const { return osTime.get(); };
|
|
|
|
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();
|
2020-07-02 17:49:46 +08:00
|
|
|
const std::vector<EngineControl> &getEngines() 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()]; }
|
2018-09-17 23:17:18 +08:00
|
|
|
const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; }
|
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
|
|
|
}
|
2019-09-04 23:26:57 +08:00
|
|
|
bool areSharedSystemAllocationsAllowed() const {
|
2020-03-06 01:13:32 +08:00
|
|
|
return this->deviceInfo.sharedSystemAllocationsSupport;
|
2019-09-04 23:26:57 +08:00
|
|
|
}
|
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
|
|
|
|
|
|
|
virtual uint32_t getRootDeviceIndex() const = 0;
|
2021-04-08 01:00:33 +08:00
|
|
|
uint32_t getNumAvailableDevices() const;
|
|
|
|
virtual Device *getDeviceById(uint32_t deviceId) const;
|
|
|
|
virtual Device *getRootDevice() const = 0;
|
|
|
|
DeviceBitfield getDeviceBitfield() const { return deviceBitfield; };
|
|
|
|
uint32_t getNumSubDevices() const { return numSubDevices; }
|
|
|
|
virtual bool isSubDevice() const = 0;
|
|
|
|
|
|
|
|
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; }
|
|
|
|
void initializeRayTracing();
|
2019-11-29 20:03:35 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
|
|
|
Device() = delete;
|
2019-11-05 20:38:20 +08:00
|
|
|
Device(ExecutionEnvironment *executionEnvironment);
|
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-05-10 03:41:56 +08:00
|
|
|
bool engineSupported(const EngineTypeUsage &engineTypeUsage) const;
|
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);
|
2020-10-30 17:27:48 +08:00
|
|
|
virtual uint64_t getGlobalMemorySize(uint32_t deviceBitfield) 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();
|
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
|
|
|
|
|
|
|
HardwareCapabilities hardwareCapabilities = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
std::unique_ptr<OSTime> osTime;
|
|
|
|
std::unique_ptr<PerformanceCounters> performanceCounters;
|
2019-11-05 20:38:20 +08:00
|
|
|
std::vector<std::unique_ptr<CommandStreamReceiver>> commandStreamReceivers;
|
2019-01-10 20:57:40 +08:00
|
|
|
std::vector<EngineControl> engines;
|
2020-07-28 16:36:52 +08:00
|
|
|
std::vector<std::vector<EngineControl>> engineGroups;
|
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-04-27 17:51:03 +08:00
|
|
|
bool hasGenericSubDevices = false;
|
2021-05-06 19:33:39 +08:00
|
|
|
bool engineInstanced = false;
|
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;
|
|
|
|
GraphicsAllocation *rtDispatchGlobals = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2018-11-29 18:39:10 +08:00
|
|
|
inline EngineControl &Device::getDefaultEngine() {
|
2019-03-23 21:26:06 +08:00
|
|
|
return engines[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
|