/* * Copyright (C) 2020-2022 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/command_stream/stream_properties.h" #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/helpers/api_specific_config.h" #include "shared/source/helpers/cache_policy.h" #include "shared/source/helpers/constants.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/helpers/preamble.h" #include "shared/source/memory_manager/graphics_allocation.h" #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/unified_memory/usm_memory_support.h" #include namespace NEO { template int HwInfoConfigHw::configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) { enableCompression(hwInfo); enableBlitterOperationsSupport(hwInfo); return 0; } template void HwInfoConfigHw::getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) { *fp16 = 0u; *fp32 = 0u; *fp64 = 0u; } template std::vector HwInfoConfigHw::getKernelSupportedThreadArbitrationPolicies() { using GfxFamily = typename HwMapper::GfxFamily; return PreambleHelper::getSupportedThreadArbitrationPolicies(); } template void HwInfoConfigHw::convertTimestampsFromOaToCsDomain(uint64_t ×tampData){}; template void HwInfoConfigHw::adjustPlatformForProductFamily(HardwareInfo *hwInfo) {} template void HwInfoConfigHw::adjustSamplerState(void *sampler, const HardwareInfo &hwInfo) {} template void HwInfoConfigHw::enableBlitterOperationsSupport(HardwareInfo *hwInfo) { hwInfo->capabilityTable.blitterOperationsSupported = obtainBlitterPreference(*hwInfo); if (DebugManager.flags.EnableBlitterOperationsSupport.get() != -1) { hwInfo->capabilityTable.blitterOperationsSupported = !!DebugManager.flags.EnableBlitterOperationsSupport.get(); } } template uint64_t HwInfoConfigHw::getDeviceMemCapabilities() { uint64_t capabilities = UNIFIED_SHARED_MEMORY_ACCESS | UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS; if (getConcurrentAccessMemCapabilitiesSupported(UsmAccessCapabilities::Device)) { capabilities |= UNIFIED_SHARED_MEMORY_CONCURRENT_ACCESS | UNIFIED_SHARED_MEMORY_CONCURRENT_ATOMIC_ACCESS; } return capabilities; } template uint64_t HwInfoConfigHw::getSingleDeviceSharedMemCapabilities() { uint64_t capabilities = UNIFIED_SHARED_MEMORY_ACCESS | UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS; if (getConcurrentAccessMemCapabilitiesSupported(UsmAccessCapabilities::SharedSingleDevice)) { capabilities |= UNIFIED_SHARED_MEMORY_CONCURRENT_ACCESS | UNIFIED_SHARED_MEMORY_CONCURRENT_ATOMIC_ACCESS; } return capabilities; } template bool HwInfoConfigHw::getHostMemCapabilitiesSupported(const HardwareInfo *hwInfo) { return true; } template uint64_t HwInfoConfigHw::getHostMemCapabilities(const HardwareInfo *hwInfo) { bool supported = getHostMemCapabilitiesSupported(hwInfo); if (DebugManager.flags.EnableHostUsmSupport.get() != -1) { supported = !!DebugManager.flags.EnableHostUsmSupport.get(); } uint64_t capabilities = getHostMemCapabilitiesValue(); if (getConcurrentAccessMemCapabilitiesSupported(UsmAccessCapabilities::Host)) { capabilities |= UNIFIED_SHARED_MEMORY_CONCURRENT_ACCESS | UNIFIED_SHARED_MEMORY_CONCURRENT_ATOMIC_ACCESS; } return (supported ? capabilities : 0); } template uint64_t HwInfoConfigHw::getSharedSystemMemCapabilities(const HardwareInfo *hwInfo) { bool supported = false; if (DebugManager.flags.EnableSharedSystemUsmSupport.get() != -1) { supported = !!DebugManager.flags.EnableSharedSystemUsmSupport.get(); } return (supported ? (UNIFIED_SHARED_MEMORY_ACCESS | UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS | UNIFIED_SHARED_MEMORY_CONCURRENT_ACCESS | UNIFIED_SHARED_MEMORY_CONCURRENT_ATOMIC_ACCESS) : 0); } template bool HwInfoConfigHw::getConcurrentAccessMemCapabilitiesSupported(UsmAccessCapabilities capability) { auto supported = false; if (DebugManager.flags.EnableUsmConcurrentAccessSupport.get() > 0) { auto capabilityBitset = std::bitset<4>(DebugManager.flags.EnableUsmConcurrentAccessSupport.get()); supported = capabilityBitset.test(static_cast(capability)); } return supported; } template uint32_t HwInfoConfigHw::getDeviceMemoryMaxClkRate(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) { return 0u; } template uint64_t HwInfoConfigHw::getDeviceMemoryPhysicalSizeInBytes(const OSInterface *osIface, uint32_t subDeviceIndex) { return 0; } template uint64_t HwInfoConfigHw::getDeviceMemoryMaxBandWidthInBytesPerSecond(const HardwareInfo &hwInfo, const OSInterface *osIface, uint32_t subDeviceIndex) { return 0; } template bool HwInfoConfigHw::isAdditionalStateBaseAddressWARequired(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isMaxThreadsForWorkgroupWARequired(const HardwareInfo &hwInfo) const { return false; } template uint32_t HwInfoConfigHw::getMaxThreadsForWorkgroup(const HardwareInfo &hwInfo, uint32_t maxNumEUsPerSubSlice) const { uint32_t numThreadsPerEU = hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount; return maxNumEUsPerSubSlice * numThreadsPerEU; } template void HwInfoConfigHw::setForceNonCoherent(void *const commandPtr, const StateComputeModeProperties &properties) {} template void HwInfoConfigHw::updateScmCommand(void *const commandPtr, const StateComputeModeProperties &properties) {} template void HwInfoConfigHw::updateIddCommand(void *const commandPtr, uint32_t numGrf, int32_t threadArbitrationPolicy) {} template bool HwInfoConfigHw::isPageTableManagerSupported(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::overrideGfxPartitionLayoutForWsl() const { return false; } template uint32_t HwInfoConfigHw::getHwRevIdFromStepping(uint32_t stepping, const HardwareInfo &hwInfo) const { return CommonConstants::invalidStepping; } template uint32_t HwInfoConfigHw::getSteppingFromHwRevId(const HardwareInfo &hwInfo) const { return CommonConstants::invalidStepping; } template uint32_t HwInfoConfigHw::getAubStreamSteppingFromHwRevId(const HardwareInfo &hwInfo) const { switch (getSteppingFromHwRevId(hwInfo)) { default: case REVISION_A0: case REVISION_A1: case REVISION_A3: return AubMemDump::SteppingValues::A; case REVISION_B: return AubMemDump::SteppingValues::B; case REVISION_C: return AubMemDump::SteppingValues::C; case REVISION_D: return AubMemDump::SteppingValues::D; case REVISION_K: return AubMemDump::SteppingValues::K; } } template bool HwInfoConfigHw::isDefaultEngineTypeAdjustmentRequired(const HardwareInfo &hwInfo) const { return false; } template std::string HwInfoConfigHw::getDeviceMemoryName() const { return "DDR"; } template bool HwInfoConfigHw::isDisableOverdispatchAvailable(const HardwareInfo &hwInfo) const { return getFrontEndPropertyDisableOverDispatchSupport(); } template bool HwInfoConfigHw::allowCompression(const HardwareInfo &hwInfo) const { return true; } template bool HwInfoConfigHw::allowStatelessCompression(const HardwareInfo &hwInfo) const { if (!NEO::ApiSpecificConfig::isStatelessCompressionSupported()) { return false; } if (DebugManager.flags.EnableStatelessCompression.get() != -1) { return static_cast(DebugManager.flags.EnableStatelessCompression.get()); } return false; } template LocalMemoryAccessMode HwInfoConfigHw::getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const { return LocalMemoryAccessMode::Default; } template LocalMemoryAccessMode HwInfoConfigHw::getLocalMemoryAccessMode(const HardwareInfo &hwInfo) const { switch (static_cast(DebugManager.flags.ForceLocalMemoryAccessMode.get())) { case LocalMemoryAccessMode::Default: case LocalMemoryAccessMode::CpuAccessAllowed: case LocalMemoryAccessMode::CpuAccessDisallowed: return static_cast(DebugManager.flags.ForceLocalMemoryAccessMode.get()); } return getDefaultLocalMemoryAccessMode(hwInfo); } template bool HwInfoConfigHw::isAllocationSizeAdjustmentRequired(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isPrefetchDisablingRequired(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isAssignEngineRoundRobinSupported() const { return false; } template std::pair HwInfoConfigHw::isPipeControlPriorToNonPipelinedStateCommandsWARequired(const HardwareInfo &hwInfo, bool isRcs) const { return {false, false}; } template bool HwInfoConfigHw::isAdditionalMediaSamplerProgrammingRequired() const { return false; } template bool HwInfoConfigHw::isInitialFlagsProgrammingRequired() const { return false; } template bool HwInfoConfigHw::isReturnedCmdSizeForMediaSamplerAdjustmentRequired() const { return false; } template bool HwInfoConfigHw::extraParametersInvalid(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::pipeControlWARequired(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::imagePitchAlignmentWARequired(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isDirectSubmissionSupported(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isForceEmuInt32DivRemSPWARequired(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::is3DPipelineSelectWARequired() const { return false; } template bool HwInfoConfigHw::isStorageInfoAdjustmentRequired() const { return false; } template bool HwInfoConfigHw::isBlitterForImagesSupported() const { return false; } template bool HwInfoConfigHw::isDcFlushAllowed() const { return true; } template uint32_t HwInfoConfigHw::computeMaxNeededSubSliceSpace(const HardwareInfo &hwInfo) const { return hwInfo.gtSystemInfo.MaxSubSlicesSupported; } template bool HwInfoConfigHw::getUuid(Device *device, std::array &uuid) const { return false; } template bool HwInfoConfigHw::isFlushTaskAllowed() const { return false; } template bool HwInfoConfigHw::programAllStateComputeCommandFields() const { return false; } template bool HwInfoConfigHw::isSystolicModeConfigurable(const HardwareInfo &hwInfo) const { return getPipelineSelectPropertySystolicModeSupport(); } template bool HwInfoConfigHw::isComputeDispatchAllWalkerEnableInComputeWalkerRequired(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isCopyEngineSelectorEnabled(const HardwareInfo &hwInfo) const { return true; } template bool HwInfoConfigHw::isGlobalFenceInCommandStreamRequired(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isGlobalFenceInDirectSubmissionRequired(const HardwareInfo &hwInfo) const { return HwInfoConfigHw::isGlobalFenceInCommandStreamRequired(hwInfo); }; template bool HwInfoConfigHw::isAdjustProgrammableIdPreferredSlmSizeRequired(const HardwareInfo &hwInfo) const { return false; } template uint32_t HwInfoConfigHw::getThreadEuRatioForScratch(const HardwareInfo &hwInfo) const { return 8u; } template bool HwInfoConfigHw::isComputeDispatchAllWalkerEnableInCfeStateRequired(const HardwareInfo &hwInfo) const { return getFrontEndPropertyComputeDispatchAllWalkerSupport(); } template bool HwInfoConfigHw::isVmBindPatIndexProgrammingSupported() const { return false; } template bool HwInfoConfigHw::isIpSamplingSupported(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isGrfNumReportedWithScm() const { if (DebugManager.flags.ForceGrfNumProgrammingWithScm.get() != -1) { return DebugManager.flags.ForceGrfNumProgrammingWithScm.get(); } return HwInfoConfigHw::getScmPropertyLargeGrfModeSupport(); } template bool HwInfoConfigHw::isThreadArbitrationPolicyReportedWithScm() const { if (DebugManager.flags.ForceThreadArbitrationPolicyProgrammingWithScm.get() != -1) { return DebugManager.flags.ForceThreadArbitrationPolicyProgrammingWithScm.get(); } return HwInfoConfigHw::getScmPropertyThreadArbitrationPolicySupport(); } template bool HwInfoConfigHw::isCooperativeEngineSupported(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isTimestampWaitSupportedForEvents() const { return false; } template bool HwInfoConfigHw::isTilePlacementResourceWaRequired(const HardwareInfo &hwInfo) const { if (DebugManager.flags.ForceTile0PlacementForTile1ResourcesWaActive.get() != -1) { return DebugManager.flags.ForceTile0PlacementForTile1ResourcesWaActive.get(); } return false; } template bool HwInfoConfigHw::allowMemoryPrefetch(const HardwareInfo &hwInfo) const { if (DebugManager.flags.EnableMemoryPrefetch.get() != -1) { return !!DebugManager.flags.EnableMemoryPrefetch.get(); } return true; } template bool HwInfoConfigHw::isBcsReportWaRequired(const HardwareInfo &hwInfo) const { if (DebugManager.flags.DoNotReportTile1BscWaActive.get() != -1) { return DebugManager.flags.DoNotReportTile1BscWaActive.get(); } return false; } template bool HwInfoConfigHw::isBlitSplitEnqueueWARequired(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isBlitCopyRequiredForLocalMemory(const HardwareInfo &hwInfo, const GraphicsAllocation &allocation) const { return allocation.isAllocatedInLocalMemoryPool() && (HwInfoConfig::get(hwInfo.platform.eProductFamily)->getLocalMemoryAccessMode(hwInfo) == LocalMemoryAccessMode::CpuAccessDisallowed || !allocation.isAllocationLockable()); } template bool HwInfoConfigHw::isImplicitScalingSupported(const HardwareInfo &hwInfo) const { return false; } template bool HwInfoConfigHw::isCpuCopyNecessary(const void *ptr, MemoryManager *memoryManager) const { return false; } template bool HwInfoConfigHw::isAdjustWalkOrderAvailable(const HardwareInfo &hwInfo) const { return false; } template uint32_t HwInfoConfigHw::getL1CachePolicy(bool isDebuggerActive) const { return L1CachePolicyHelper::getL1CachePolicy(isDebuggerActive); } template void HwInfoConfigHw::adjustNumberOfCcs(HardwareInfo &hwInfo) const {} template bool HwInfoConfigHw::isPrefetcherDisablingInDirectSubmissionRequired() const { return true; } template bool HwInfoConfigHw::isStatefulAddressingModeSupported() const { return true; } template bool HwInfoConfigHw::isPlatformQuerySupported() const { return false; } template void HwInfoConfigHw::fillScmPropertiesSupportStructureBase(StateComputeModePropertiesSupport &propertiesSupport) { propertiesSupport.coherencyRequired = getScmPropertyCoherencyRequiredSupport(); propertiesSupport.threadArbitrationPolicy = isThreadArbitrationPolicyReportedWithScm(); propertiesSupport.largeGrfMode = isGrfNumReportedWithScm(); propertiesSupport.zPassAsyncComputeThreadLimit = getScmPropertyZPassAsyncComputeThreadLimitSupport(); propertiesSupport.pixelAsyncComputeThreadLimit = getScmPropertyPixelAsyncComputeThreadLimitSupport(); propertiesSupport.devicePreemptionMode = getScmPropertyDevicePreemptionModeSupport(); } template void HwInfoConfigHw::fillScmPropertiesSupportStructure(StateComputeModePropertiesSupport &propertiesSupport) { fillScmPropertiesSupportStructureBase(propertiesSupport); } template bool HwInfoConfigHw::getScmPropertyThreadArbitrationPolicySupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::StateComputeModeStateSupport::threadArbitrationPolicy; } template bool HwInfoConfigHw::getScmPropertyCoherencyRequiredSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::StateComputeModeStateSupport::coherencyRequired; } template bool HwInfoConfigHw::getScmPropertyZPassAsyncComputeThreadLimitSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::StateComputeModeStateSupport::zPassAsyncComputeThreadLimit; } template bool HwInfoConfigHw::getScmPropertyPixelAsyncComputeThreadLimitSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::StateComputeModeStateSupport::pixelAsyncComputeThreadLimit; } template bool HwInfoConfigHw::getScmPropertyLargeGrfModeSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::StateComputeModeStateSupport::largeGrfMode; } template bool HwInfoConfigHw::getScmPropertyDevicePreemptionModeSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::StateComputeModeStateSupport::devicePreemptionMode; } template bool HwInfoConfigHw::getSbaPropertyGlobalAtomicsSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::StateBaseAddressStateSupport::globalAtomics; } template bool HwInfoConfigHw::getSbaPropertyStatelessMocsSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::StateBaseAddressStateSupport::statelessMocs; } template bool HwInfoConfigHw::getPreemptionDbgPropertyPreemptionModeSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::PreemptionDebugSupport::preemptionMode; } template bool HwInfoConfigHw::getPreemptionDbgPropertyStateSipSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::PreemptionDebugSupport::stateSip; } template bool HwInfoConfigHw::getPreemptionDbgPropertyCsrSurfaceSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::PreemptionDebugSupport::csrSurface; } template bool HwInfoConfigHw::getFrontEndPropertyScratchSizeSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::FrontEndStateSupport::scratchSize; } template bool HwInfoConfigHw::getFrontEndPropertyPrivateScratchSizeSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::FrontEndStateSupport::privateScratchSize; } template bool HwInfoConfigHw::getFrontEndPropertyComputeDispatchAllWalkerSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::FrontEndStateSupport::computeDispatchAllWalker; } template bool HwInfoConfigHw::getFrontEndPropertyDisableEuFusionSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::FrontEndStateSupport::disableEuFusion; } template bool HwInfoConfigHw::getFrontEndPropertyDisableOverDispatchSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::FrontEndStateSupport::disableOverdispatch; } template bool HwInfoConfigHw::getFrontEndPropertySingleSliceDispatchCcsModeSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::FrontEndStateSupport::singleSliceDispatchCcsMode; } template void HwInfoConfigHw::fillFrontEndPropertiesSupportStructure(FrontEndPropertiesSupport &propertiesSupport, const HardwareInfo &hwInfo) { propertiesSupport.computeDispatchAllWalker = isComputeDispatchAllWalkerEnableInCfeStateRequired(hwInfo); propertiesSupport.disableEuFusion = getFrontEndPropertyDisableEuFusionSupport(); propertiesSupport.disableOverdispatch = isDisableOverdispatchAvailable(hwInfo); propertiesSupport.singleSliceDispatchCcsMode = getFrontEndPropertySingleSliceDispatchCcsModeSupport(); } template bool HwInfoConfigHw::getPipelineSelectPropertyModeSelectedSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::PipelineSelectStateSupport::modeSelected; } template bool HwInfoConfigHw::getPipelineSelectPropertyMediaSamplerDopClockGateSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::PipelineSelectStateSupport::mediaSamplerDopClockGate; } template bool HwInfoConfigHw::getPipelineSelectPropertySystolicModeSupport() const { using GfxProduct = typename HwMapper::GfxProduct; return GfxProduct::PipelineSelectStateSupport::systolicMode; } template void HwInfoConfigHw::fillPipelineSelectPropertiesSupportStructure(PipelineSelectPropertiesSupport &propertiesSupport, const HardwareInfo &hwInfo) { propertiesSupport.modeSelected = getPipelineSelectPropertyModeSelectedSupport(); propertiesSupport.mediaSamplerDopClockGate = getPipelineSelectPropertyMediaSamplerDopClockGateSupport(); propertiesSupport.systolicMode = isSystolicModeConfigurable(hwInfo); } } // namespace NEO