Move HardwareInfo ownership to ExecutionEnvironment [1/n]

Change-Id: I5e5b4cc45947a8841282c7d431fb69d9c397a2d4
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2019-05-06 12:33:44 +02:00
committed by sys_ocldev
parent b2aee82f41
commit bb80d327c7
233 changed files with 1786 additions and 2298 deletions

View File

@@ -66,18 +66,19 @@ bool familyEnabled[IGFX_MAX_CORE] = {
false,
};
Device::Device(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
: hwInfo(hwInfo), executionEnvironment(executionEnvironment), deviceIndex(deviceIndex) {
Device::Device(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
: executionEnvironment(executionEnvironment), deviceIndex(deviceIndex) {
memset(&deviceInfo, 0, sizeof(deviceInfo));
deviceExtensions.reserve(1000);
name.reserve(100);
auto &hwInfo = getHardwareInfo();
preemptionMode = PreemptionHelper::getDefaultPreemptionMode(hwInfo);
if (!getSourceLevelDebugger()) {
this->executionEnvironment->initSourceLevelDebugger();
}
this->executionEnvironment->incRefInternal();
auto &hwHelper = HwHelper::get(hwInfo.pPlatform->eRenderCoreFamily);
auto &hwHelper = HwHelper::get(hwInfo.pPlatform.eRenderCoreFamily);
hwHelper.setupHardwareCapabilities(&this->hardwareCapabilities, hwInfo);
}
@@ -105,10 +106,10 @@ Device::~Device() {
executionEnvironment->decRefInternal();
}
bool Device::createDeviceImpl(const HardwareInfo *pHwInfo) {
bool Device::createDeviceImpl() {
executionEnvironment->initGmm();
if (!createEngines(pHwInfo)) {
if (!createEngines()) {
return false;
}
@@ -123,10 +124,11 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo) {
initializeCaps();
auto &hwInfo = getHardwareInfo();
if (osTime->getOSInterface()) {
if (pHwInfo->capabilityTable.instrumentationEnabled) {
if (hwInfo.capabilityTable.instrumentationEnabled) {
performanceCounters = createPerformanceCountersFunc(osTime.get());
performanceCounters->initialize(pHwInfo);
performanceCounters->initialize(&hwInfo);
}
}
@@ -165,9 +167,10 @@ AllocationProperties Device::getAllocationPropertiesForPreemption() const {
properties.alignment = 256 * MemoryConstants::kiloByte;
return properties;
}
bool Device::createEngines(const HardwareInfo *pHwInfo) {
auto defaultEngineType = getChosenEngineType(*pHwInfo);
auto &gpgpuEngines = HwHelper::get(pHwInfo->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances();
bool Device::createEngines() {
auto &hwInfo = getHardwareInfo();
auto defaultEngineType = getChosenEngineType(hwInfo);
auto &gpgpuEngines = HwHelper::get(hwInfo.pPlatform.eRenderCoreFamily).getGpgpuEngineInstances();
for (uint32_t deviceCsrIndex = 0; deviceCsrIndex < gpgpuEngines.size(); deviceCsrIndex++) {
if (!executionEnvironment->initializeCommandStreamReceiver(getDeviceIndex(), deviceCsrIndex)) {
@@ -196,13 +199,9 @@ bool Device::createEngines(const HardwareInfo *pHwInfo) {
return true;
}
const HardwareInfo *Device::getDeviceInitHwInfo(const HardwareInfo *pHwInfoIn) {
return pHwInfoIn ? pHwInfoIn : platformDevices[0];
}
const HardwareInfo &Device::getHardwareInfo() const { return *executionEnvironment->getHardwareInfo(); }
const HardwareInfo &Device::getHardwareInfo() const { return hwInfo; }
const WorkaroundTable *Device::getWaTable() const { return hwInfo.pWaTable; }
const WorkaroundTable *Device::getWaTable() const { return &getHardwareInfo().pWaTable; }
const DeviceInfo &Device::getDeviceInfo() const {
return deviceInfo;
@@ -224,21 +223,22 @@ void Device::prepareSLMWindow() {
}
const char *Device::getProductAbbrev() const {
return hardwarePrefix[hwInfo.pPlatform->eProductFamily];
return hardwarePrefix[executionEnvironment->getHardwareInfo()->pPlatform.eProductFamily];
}
const std::string Device::getFamilyNameWithType() const {
std::string platformName = familyName[hwInfo.pPlatform->eRenderCoreFamily];
auto &hwInfo = getHardwareInfo();
std::string platformName = familyName[hwInfo.pPlatform.eRenderCoreFamily];
platformName.append(getPlatformType(hwInfo));
return platformName;
}
double Device::getProfilingTimerResolution() {
return osTime->getDynamicDeviceTimerResolution(hwInfo);
return osTime->getDynamicDeviceTimerResolution(getHardwareInfo());
}
unsigned int Device::getSupportedClVersion() const {
return hwInfo.capabilityTable.clVersionSupport;
return getHardwareInfo().capabilityTable.clVersionSupport;
}
/* We hide the retain and release function of BaseObject. */
@@ -252,11 +252,13 @@ unique_ptr_if_unused<Device> Device::release() {
}
bool Device::isSimulation() const {
bool simulation = hwInfo.capabilityTable.isSimulation(hwInfo.pPlatform->usDeviceID);
auto &hwInfo = getHardwareInfo();
bool simulation = hwInfo.capabilityTable.isSimulation(hwInfo.pPlatform.usDeviceID);
if (engines[0].commandStreamReceiver->getType() != CommandStreamReceiverType::CSR_HW) {
simulation = true;
}
if (hwInfo.pSkuTable->ftrSimulationMode) {
if (hwInfo.pSkuTable.ftrSimulationMode) {
simulation = true;
}
return simulation;
@@ -268,7 +270,7 @@ double Device::getPlatformHostTimerResolution() const {
return 0.0;
}
GFXCORE_FAMILY Device::getRenderCoreFamily() const {
return this->getHardwareInfo().pPlatform->eRenderCoreFamily;
return this->getHardwareInfo().pPlatform.eRenderCoreFamily;
}
bool Device::isSourceLevelDebuggerActive() const {

View File

@@ -39,10 +39,9 @@ class Device : public BaseObject<_cl_device_id> {
static const cl_ulong objectMagic = 0x8055832341AC8D08LL;
template <typename T>
static T *create(const HardwareInfo *pHwInfo, ExecutionEnvironment *execEnv, uint32_t deviceIndex) {
pHwInfo = getDeviceInitHwInfo(pHwInfo);
T *device = new T(*pHwInfo, execEnv, deviceIndex);
return createDeviceInternals(pHwInfo, device);
static T *create(ExecutionEnvironment *execEnv, uint32_t deviceIndex) {
T *device = new T(execEnv, deviceIndex);
return createDeviceInternals(device);
}
Device &operator=(const Device &) = delete;
@@ -106,7 +105,7 @@ class Device : public BaseObject<_cl_device_id> {
static decltype(&PerformanceCounters::create) createPerformanceCountersFunc;
PreemptionMode getPreemptionMode() const { return preemptionMode; }
GraphicsAllocation *getPreemptionAllocation() const { return preemptionAllocation; }
MOCKABLE_VIRTUAL const WhitelistedRegisters &getWhitelistedRegisters() { return hwInfo.capabilityTable.whitelistedRegisters; }
MOCKABLE_VIRTUAL const WhitelistedRegisters &getWhitelistedRegisters() { return getHardwareInfo().capabilityTable.whitelistedRegisters; }
std::vector<unsigned int> simultaneousInterops;
std::string deviceExtensions;
std::string name;
@@ -121,20 +120,20 @@ class Device : public BaseObject<_cl_device_id> {
protected:
Device() = delete;
Device(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
Device(ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
template <typename T>
static T *createDeviceInternals(const HardwareInfo *pHwInfo, T *device) {
if (false == device->createDeviceImpl(pHwInfo)) {
static T *createDeviceInternals(T *device) {
if (false == device->createDeviceImpl()) {
delete device;
return nullptr;
}
return device;
}
bool createDeviceImpl(const HardwareInfo *pHwInfo);
bool createEngines(const HardwareInfo *pHwInfo);
static const HardwareInfo *getDeviceInitHwInfo(const HardwareInfo *pHwInfoIn);
bool createDeviceImpl();
bool createEngines();
MOCKABLE_VIRTUAL void initializeCaps();
void setupFp64Flags();
void appendOSExtensions(std::string &deviceExtensions);
@@ -142,7 +141,6 @@ class Device : public BaseObject<_cl_device_id> {
unsigned int enabledClVersion = 0u;
const HardwareInfo &hwInfo;
HardwareCapabilities hardwareCapabilities = {};
DeviceInfo deviceInfo;

View File

@@ -43,6 +43,7 @@ static constexpr cl_device_fp_config defaultFpFlags = static_cast<cl_device_fp_c
CL_FP_FMA);
void Device::setupFp64Flags() {
auto &hwInfo = getHardwareInfo();
if (DebugManager.flags.OverrideDefaultFP64Settings.get() == -1) {
if (hwInfo.capabilityTable.ftrSupportsFP64) {
deviceExtensions += "cl_khr_fp64 ";
@@ -66,6 +67,7 @@ void Device::setupFp64Flags() {
}
void Device::initializeCaps() {
auto &hwInfo = getHardwareInfo();
deviceExtensions.clear();
deviceExtensions.append(deviceExtensionsList);
// Add our graphics family name to the device name
@@ -77,7 +79,7 @@ void Device::initializeCaps() {
driverVersion = TOSTR(NEO_DRIVER_VERSION);
name += "Intel(R) ";
name += familyName[hwInfo.pPlatform->eRenderCoreFamily];
name += familyName[hwInfo.pPlatform.eRenderCoreFamily];
name += " HD Graphics NEO";
if (driverInfo) {
@@ -85,7 +87,7 @@ void Device::initializeCaps() {
driverVersion.assign(driverInfo.get()->getVersion(driverVersion).c_str());
}
auto &hwHelper = HwHelper::get(hwInfo.pPlatform->eRenderCoreFamily);
auto &hwHelper = HwHelper::get(hwInfo.pPlatform.eRenderCoreFamily);
deviceInfo.name = name.c_str();
deviceInfo.driverVersion = driverVersion.c_str();
@@ -203,7 +205,7 @@ void Device::initializeCaps() {
deviceInfo.addressBits = 64;
//copy system info to prevent misaligned reads
const auto systemInfo = *hwInfo.pSysInfo;
const auto systemInfo = hwInfo.pSysInfo;
deviceInfo.globalMemCachelineSize = 64;
deviceInfo.globalMemCacheSize = systemInfo.L3BankCount * 128 * KB;
@@ -251,7 +253,7 @@ void Device::initializeCaps() {
deviceInfo.numThreadsPerEU = 0;
auto simdSizeUsed = DebugManager.flags.UseMaxSimdSizeToDeduceMaxWorkgroupSize.get() ? 32 : 8;
deviceInfo.maxNumEUsPerSubSlice = (systemInfo.EuCountPerPoolMin == 0 || hwInfo.pSkuTable->ftrPooledEuEnabled == 0)
deviceInfo.maxNumEUsPerSubSlice = (systemInfo.EuCountPerPoolMin == 0 || hwInfo.pSkuTable.ftrPooledEuEnabled == 0)
? (systemInfo.EUCount / systemInfo.SubSliceCount)
: systemInfo.EuCountPerPoolMin;
deviceInfo.numThreadsPerEU = systemInfo.ThreadCount / systemInfo.EUCount;

View File

@@ -206,7 +206,7 @@ cl_int Device::getDeviceInfo(cl_device_info paramName,
getCap<CL_DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL>(src, srcSize, retSize);
break;
default:
DeviceHelper::getExtraDeviceInfo(hwInfo, paramName, param, src, srcSize, retSize);
DeviceHelper::getExtraDeviceInfo(getHardwareInfo(), paramName, param, src, srcSize, retSize);
}
retVal = ::getInfo(paramValue, paramValueSize, src, srcSize);
@@ -222,7 +222,7 @@ bool Device::getDeviceAndHostTimer(uint64_t *deviceTimestamp, uint64_t *hostTime
TimeStampData queueTimeStamp;
bool retVal = getOSTime()->getCpuGpuTime(&queueTimeStamp);
if (retVal) {
uint64_t resolution = (uint64_t)getOSTime()->getDynamicDeviceTimerResolution(this->hwInfo);
uint64_t resolution = (uint64_t)getOSTime()->getDynamicDeviceTimerResolution(getHardwareInfo());
*deviceTimestamp = queueTimeStamp.GPUTimeStamp * resolution;
}