2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-01-10 18:10:58 +08:00
|
|
|
* Copyright (C) 2017-2019 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
|
|
|
|
#include "runtime/api/cl_types.h"
|
|
|
|
#include "runtime/device/device_info_map.h"
|
2018-07-11 20:16:35 +08:00
|
|
|
#include "runtime/execution_environment/execution_environment.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/helpers/base_object.h"
|
2018-11-21 16:57:51 +08:00
|
|
|
#include "runtime/helpers/engine_control.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/os_interface/performance_counters.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
class OSTime;
|
|
|
|
class DriverInfo;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct OpenCLObjectMapper<_cl_device_id> {
|
|
|
|
typedef class Device DerivedType;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Device : public BaseObject<_cl_device_id> {
|
|
|
|
public:
|
|
|
|
static const cl_ulong objectMagic = 0x8055832341AC8D08LL;
|
|
|
|
|
|
|
|
template <typename T>
|
2019-05-06 18:33:44 +08:00
|
|
|
static T *create(ExecutionEnvironment *execEnv, uint32_t deviceIndex) {
|
|
|
|
T *device = new T(execEnv, deviceIndex);
|
|
|
|
return createDeviceInternals(device);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Device &operator=(const Device &) = delete;
|
|
|
|
Device(const Device &) = delete;
|
|
|
|
|
|
|
|
~Device() override;
|
|
|
|
|
|
|
|
// API entry points
|
|
|
|
cl_int getDeviceInfo(cl_device_info paramName,
|
|
|
|
size_t paramValueSize,
|
|
|
|
void *paramValue,
|
|
|
|
size_t *paramValueSizeRet);
|
|
|
|
|
|
|
|
bool getDeviceAndHostTimer(uint64_t *deviceTimestamp, uint64_t *hostTimestamp) const;
|
|
|
|
bool getHostTimer(uint64_t *hostTimestamp) const;
|
|
|
|
|
|
|
|
// Helper functions
|
|
|
|
const HardwareInfo &getHardwareInfo() const;
|
|
|
|
const DeviceInfo &getDeviceInfo() const;
|
|
|
|
|
2019-03-27 17:06:29 +08:00
|
|
|
EngineControl &getEngine(aub_stream::EngineType engineType, bool lowPriority);
|
2018-11-29 18:39:10 +08:00
|
|
|
EngineControl &getDefaultEngine();
|
2018-01-17 23:23:51 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
const char *getProductAbbrev() const;
|
|
|
|
|
|
|
|
// This helper template is meant to simplify getDeviceInfo
|
|
|
|
template <cl_device_info Param>
|
|
|
|
void getCap(const void *&src,
|
|
|
|
size_t &size,
|
|
|
|
size_t &retSize);
|
|
|
|
|
|
|
|
template <cl_device_info Param>
|
|
|
|
void getStr(const void *&src,
|
|
|
|
size_t &size,
|
|
|
|
size_t &retSize);
|
|
|
|
|
|
|
|
MemoryManager *getMemoryManager() const;
|
2018-07-23 18:23:48 +08:00
|
|
|
GmmHelper *getGmmHelper() const;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
/* We hide the retain and release function of BaseObject. */
|
|
|
|
void retain() override;
|
|
|
|
unique_ptr_if_unused<Device> release() override;
|
|
|
|
OSTime *getOSTime() const { return osTime.get(); };
|
|
|
|
double getProfilingTimerResolution();
|
|
|
|
unsigned int getEnabledClVersion() const { return enabledClVersion; };
|
|
|
|
unsigned int getSupportedClVersion() const;
|
|
|
|
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(); }
|
|
|
|
static decltype(&PerformanceCounters::create) createPerformanceCountersFunc;
|
2018-01-02 19:10:34 +08:00
|
|
|
PreemptionMode getPreemptionMode() const { return preemptionMode; }
|
2017-12-21 07:45:38 +08:00
|
|
|
std::vector<unsigned int> simultaneousInterops;
|
|
|
|
std::string deviceExtensions;
|
2018-06-21 16:47:21 +08:00
|
|
|
std::string name;
|
2019-06-28 03:33:05 +08:00
|
|
|
MOCKABLE_VIRTUAL bool isSourceLevelDebuggerActive() const;
|
2018-07-12 21:47:48 +08:00
|
|
|
SourceLevelDebugger *getSourceLevelDebugger() { return executionEnvironment->sourceLevelDebugger.get(); }
|
2018-07-31 15:52:48 +08:00
|
|
|
ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; }
|
2018-09-17 23:17:18 +08:00
|
|
|
const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; }
|
2018-12-10 17:30:39 +08:00
|
|
|
uint32_t getDeviceIndex() const { return deviceIndex; }
|
2019-01-10 18:10:58 +08:00
|
|
|
bool isFullRangeSvm() const {
|
2019-04-18 21:30:47 +08:00
|
|
|
return executionEnvironment->isFullRangeSvm();
|
2018-09-10 18:50:45 +08:00
|
|
|
}
|
2019-09-04 23:26:57 +08:00
|
|
|
bool areSharedSystemAllocationsAllowed() const {
|
|
|
|
return this->deviceInfo.sharedSystemMemCapabilities != 0u;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Device() = delete;
|
2019-05-06 18:33:44 +08:00
|
|
|
Device(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-05-06 18:33:44 +08:00
|
|
|
bool createDeviceImpl();
|
|
|
|
bool createEngines();
|
2019-07-16 15:23:02 +08:00
|
|
|
bool createEngine(uint32_t deviceIndex, uint32_t deviceCsrIndex, aub_stream::EngineType engineType);
|
2019-05-06 18:33:44 +08:00
|
|
|
|
2018-04-10 19:49:26 +08:00
|
|
|
MOCKABLE_VIRTUAL void initializeCaps();
|
2018-06-05 21:39:17 +08:00
|
|
|
void setupFp64Flags();
|
2017-12-21 07:45:38 +08:00
|
|
|
void appendOSExtensions(std::string &deviceExtensions);
|
2018-08-27 21:48:29 +08:00
|
|
|
unsigned int enabledClVersion = 0u;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-08-17 17:00:21 +08:00
|
|
|
HardwareCapabilities hardwareCapabilities = {};
|
2017-12-21 07:45:38 +08:00
|
|
|
DeviceInfo deviceInfo;
|
|
|
|
std::unique_ptr<OSTime> osTime;
|
|
|
|
std::unique_ptr<DriverInfo> driverInfo;
|
|
|
|
std::unique_ptr<PerformanceCounters> performanceCounters;
|
|
|
|
|
2019-01-10 20:57:40 +08:00
|
|
|
std::vector<EngineControl> engines;
|
2018-08-27 21:48:29 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
std::string exposedBuiltinKernels = "";
|
|
|
|
|
|
|
|
PreemptionMode preemptionMode;
|
2018-06-27 17:35:37 +08:00
|
|
|
ExecutionEnvironment *executionEnvironment = nullptr;
|
2019-02-12 17:56:27 +08:00
|
|
|
const uint32_t deviceIndex;
|
2018-11-29 18:39:10 +08:00
|
|
|
uint32_t defaultEngineIndex = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
template <cl_device_info Param>
|
|
|
|
inline void Device::getCap(const void *&src,
|
|
|
|
size_t &size,
|
|
|
|
size_t &retSize) {
|
|
|
|
src = &DeviceInfoTable::Map<Param>::getValue(deviceInfo);
|
|
|
|
retSize = size = DeviceInfoTable::Map<Param>::size;
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
return executionEnvironment->getGmmHelper();
|
|
|
|
}
|
2018-08-21 21:47:21 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|