1 /* 2 * Copyright (C) 2018-2021 Intel Corporation 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 */ 7 8 #pragma once 9 #include "shared/source/command_stream/preemption_mode.h" 10 #include "shared/source/direct_submission/direct_submission_properties.h" 11 #include "shared/source/helpers/kmd_notify_properties.h" 12 13 #include "engine_node.h" 14 #include "gtsysinfo.h" 15 #include "igfxfmid.h" 16 #include "sku_info.h" 17 18 #include <cstddef> 19 #include <string> 20 21 namespace NEO { 22 23 struct RuntimeCapabilityTable { 24 DirectSubmissionProperyEngines directSubmissionEngines; 25 KmdNotifyProperties kmdNotifyProperties; 26 uint64_t gpuAddressSpace; 27 uint64_t sharedSystemMemCapabilities; 28 double defaultProfilingTimerResolution; 29 size_t requiredPreemptionSurfaceSize; 30 bool (*isSimulation)(unsigned short); 31 const char *platformType; 32 const char *deviceName; 33 PreemptionMode defaultPreemptionMode; 34 aub_stream::EngineType defaultEngineType; 35 uint32_t maxRenderFrequency; 36 unsigned int clVersionSupport; 37 uint32_t aubDeviceId; 38 uint32_t extraQuantityThreadsPerEU; 39 uint32_t slmSize; 40 uint32_t grfSize; 41 uint32_t timestampValidBits; 42 uint32_t kernelTimestampValidBits; 43 bool blitterOperationsSupported; 44 bool ftrSupportsInteger64BitAtomics; 45 bool ftrSupportsFP64; 46 bool ftrSupports64BitMath; 47 bool ftrSvm; 48 bool ftrSupportsCoherency; 49 bool ftrSupportsVmeAvcTextureSampler; 50 bool ftrSupportsVmeAvcPreemption; 51 bool ftrRenderCompressedBuffers; 52 bool ftrRenderCompressedImages; 53 bool ftr64KBpages; 54 bool instrumentationEnabled; 55 bool debuggerSupported; 56 bool supportsVme; 57 bool supportCacheFlushAfterWalker; 58 bool supportsImages; 59 bool supportsDeviceEnqueue; 60 bool supportsPipes; 61 bool supportsOcl21Features; 62 bool supportsOnDemandPageFaults; 63 bool supportsIndependentForwardProgress; 64 bool hostPtrTrackingEnabled; 65 bool levelZeroSupported; 66 bool isIntegratedDevice; 67 bool supportsMediaBlock; 68 bool fusedEuEnabled; 69 }; 70 71 inline bool operator==(const RuntimeCapabilityTable &lhs, const RuntimeCapabilityTable &rhs) { 72 bool result = 1; 73 74 for (size_t i = 0; i < (sizeof(lhs.directSubmissionEngines.data) / sizeof(*lhs.directSubmissionEngines.data)); ++i) { 75 result &= (lhs.directSubmissionEngines.data[i].engineSupported == rhs.directSubmissionEngines.data[i].engineSupported); 76 result &= (lhs.directSubmissionEngines.data[i].submitOnInit == rhs.directSubmissionEngines.data[i].submitOnInit); 77 result &= (lhs.directSubmissionEngines.data[i].useNonDefault == rhs.directSubmissionEngines.data[i].useNonDefault); 78 result &= (lhs.directSubmissionEngines.data[i].useRootDevice == rhs.directSubmissionEngines.data[i].useRootDevice); 79 result &= (lhs.directSubmissionEngines.data[i].useInternal == rhs.directSubmissionEngines.data[i].useInternal); 80 result &= (lhs.directSubmissionEngines.data[i].useLowPriority == rhs.directSubmissionEngines.data[i].useLowPriority); 81 } 82 83 result &= (lhs.kmdNotifyProperties.delayKmdNotifyMicroseconds == rhs.kmdNotifyProperties.delayKmdNotifyMicroseconds); 84 result &= (lhs.kmdNotifyProperties.delayQuickKmdSleepMicroseconds == rhs.kmdNotifyProperties.delayQuickKmdSleepMicroseconds); 85 result &= (lhs.kmdNotifyProperties.delayQuickKmdSleepForSporadicWaitsMicroseconds == rhs.kmdNotifyProperties.delayQuickKmdSleepForSporadicWaitsMicroseconds); 86 result &= (lhs.kmdNotifyProperties.enableQuickKmdSleepForDirectSubmission == rhs.kmdNotifyProperties.enableQuickKmdSleepForDirectSubmission); 87 result &= (lhs.kmdNotifyProperties.delayQuickKmdSleepForDirectSubmissionMicroseconds == rhs.kmdNotifyProperties.delayQuickKmdSleepForDirectSubmissionMicroseconds); 88 result &= (lhs.kmdNotifyProperties.enableKmdNotify == rhs.kmdNotifyProperties.enableKmdNotify); 89 result &= (lhs.kmdNotifyProperties.enableQuickKmdSleep == rhs.kmdNotifyProperties.enableQuickKmdSleep); 90 result &= (lhs.kmdNotifyProperties.enableQuickKmdSleepForSporadicWaits == rhs.kmdNotifyProperties.enableQuickKmdSleepForSporadicWaits); 91 result &= (lhs.gpuAddressSpace == rhs.gpuAddressSpace); 92 result &= (lhs.sharedSystemMemCapabilities == rhs.sharedSystemMemCapabilities); 93 result &= (lhs.defaultProfilingTimerResolution == rhs.defaultProfilingTimerResolution); 94 result &= (lhs.requiredPreemptionSurfaceSize == rhs.requiredPreemptionSurfaceSize); 95 result &= (lhs.isSimulation == rhs.isSimulation); 96 result &= (lhs.defaultPreemptionMode == rhs.defaultPreemptionMode); 97 result &= (lhs.defaultEngineType == rhs.defaultEngineType); 98 result &= (lhs.maxRenderFrequency == rhs.maxRenderFrequency); 99 result &= (lhs.clVersionSupport == rhs.clVersionSupport); 100 result &= (lhs.aubDeviceId == rhs.aubDeviceId); 101 result &= (lhs.extraQuantityThreadsPerEU == rhs.extraQuantityThreadsPerEU); 102 result &= (lhs.slmSize == rhs.slmSize); 103 result &= (lhs.grfSize == rhs.grfSize); 104 result &= (lhs.timestampValidBits == rhs.timestampValidBits); 105 result &= (lhs.kernelTimestampValidBits == rhs.kernelTimestampValidBits); 106 result &= (lhs.blitterOperationsSupported == rhs.blitterOperationsSupported); 107 result &= (lhs.ftrSupportsInteger64BitAtomics == rhs.ftrSupportsInteger64BitAtomics); 108 result &= (lhs.ftrSupportsFP64 == rhs.ftrSupportsFP64); 109 result &= (lhs.ftrSupports64BitMath == rhs.ftrSupports64BitMath); 110 result &= (lhs.ftrSvm == rhs.ftrSvm); 111 result &= (lhs.ftrSupportsCoherency == rhs.ftrSupportsCoherency); 112 result &= (lhs.ftrSupportsVmeAvcTextureSampler == rhs.ftrSupportsVmeAvcTextureSampler); 113 result &= (lhs.ftrSupportsVmeAvcPreemption == rhs.ftrSupportsVmeAvcPreemption); 114 result &= (lhs.ftrRenderCompressedBuffers == rhs.ftrRenderCompressedBuffers); 115 result &= (lhs.ftrRenderCompressedImages == rhs.ftrRenderCompressedImages); 116 result &= (lhs.ftr64KBpages == rhs.ftr64KBpages); 117 result &= (lhs.instrumentationEnabled == rhs.instrumentationEnabled); 118 result &= (lhs.platformType == rhs.platformType); 119 result &= (lhs.deviceName == rhs.deviceName); 120 result &= (lhs.debuggerSupported == rhs.debuggerSupported); 121 result &= (lhs.supportsVme == rhs.supportsVme); 122 result &= (lhs.supportCacheFlushAfterWalker == rhs.supportCacheFlushAfterWalker); 123 result &= (lhs.supportsImages == rhs.supportsImages); 124 result &= (lhs.supportsDeviceEnqueue == rhs.supportsDeviceEnqueue); 125 result &= (lhs.supportsPipes == rhs.supportsPipes); 126 result &= (lhs.supportsOcl21Features == rhs.supportsOcl21Features); 127 result &= (lhs.supportsOnDemandPageFaults == rhs.supportsOnDemandPageFaults); 128 result &= (lhs.supportsIndependentForwardProgress == rhs.supportsIndependentForwardProgress); 129 result &= (lhs.hostPtrTrackingEnabled == rhs.hostPtrTrackingEnabled); 130 result &= (lhs.levelZeroSupported == rhs.levelZeroSupported); 131 result &= (lhs.isIntegratedDevice == rhs.isIntegratedDevice); 132 result &= (lhs.supportsMediaBlock == rhs.supportsMediaBlock); 133 result &= (lhs.fusedEuEnabled == rhs.fusedEuEnabled); 134 135 return result; 136 } 137 138 struct HardwareInfo { 139 HardwareInfo() = default; 140 HardwareInfo(const PLATFORM *platform, const FeatureTable *featureTable, const WorkaroundTable *workaroundTable, 141 const GT_SYSTEM_INFO *gtSystemInfo, const RuntimeCapabilityTable &capabilityTable); 142 143 PLATFORM platform = {}; 144 FeatureTable featureTable = {}; 145 WorkaroundTable workaroundTable = {}; 146 alignas(4) GT_SYSTEM_INFO gtSystemInfo = {}; 147 148 alignas(8) RuntimeCapabilityTable capabilityTable = {}; 149 }; 150 151 template <PRODUCT_FAMILY product> 152 struct HwMapper {}; 153 154 template <GFXCORE_FAMILY gfxFamily> 155 struct GfxFamilyMapper {}; 156 157 // Global table of hardware prefixes 158 extern bool familyEnabled[IGFX_MAX_CORE]; 159 extern const char *familyName[IGFX_MAX_CORE]; 160 extern const char *hardwarePrefix[IGFX_MAX_PRODUCT]; 161 extern uint64_t defaultHardwareInfoConfigTable[IGFX_MAX_PRODUCT]; 162 extern const HardwareInfo *hardwareInfoTable[IGFX_MAX_PRODUCT]; 163 extern void (*hardwareInfoSetup[IGFX_MAX_PRODUCT])(HardwareInfo *hwInfo, bool setupFeatureTableAndWorkaroundTable, uint64_t hwInfoConfig); 164 165 template <GFXCORE_FAMILY gfxFamily> 166 struct EnableGfxFamilyHw { EnableGfxFamilyHwEnableGfxFamilyHw167 EnableGfxFamilyHw() { 168 familyEnabled[gfxFamily] = true; 169 familyName[gfxFamily] = GfxFamilyMapper<gfxFamily>::name; 170 } 171 }; 172 173 bool getHwInfoForPlatformString(std::string &platform, const HardwareInfo *&hwInfoIn); 174 void setHwInfoValuesFromConfig(const uint64_t hwInfoConfig, HardwareInfo &hwInfoIn); 175 bool parseHwInfoConfigString(const std::string &hwInfoConfigStr, uint64_t &hwInfoConfig); 176 void overridePlatformName(std::string &name); 177 aub_stream::EngineType getChosenEngineType(const HardwareInfo &hwInfo); 178 const std::string getFamilyNameWithType(const HardwareInfo &hwInfo); 179 180 // Utility conversion 181 template <PRODUCT_FAMILY productFamily> 182 struct ToGfxCoreFamily { 183 static const GFXCORE_FAMILY gfxCoreFamily = 184 static_cast<GFXCORE_FAMILY>(NEO::HwMapper<productFamily>::gfxFamily); getToGfxCoreFamily185 static constexpr GFXCORE_FAMILY get() { return gfxCoreFamily; } 186 }; 187 } // namespace NEO 188