1 /* 2 * Copyright (C) 2021 Intel Corporation 3 * 4 * SPDX-License-Identifier: MIT 5 * 6 */ 7 8 #include "shared/source/command_container/implicit_scaling.h" 9 10 #include "shared/source/command_container/walker_partition_interface.h" 11 #include "shared/source/debug_settings/debug_settings_manager.h" 12 #include "shared/source/os_interface/os_interface.h" 13 14 namespace NEO { 15 isImplicitScalingEnabled(const DeviceBitfield & devices,bool preCondition)16bool ImplicitScalingHelper::isImplicitScalingEnabled(const DeviceBitfield &devices, bool preCondition) { 17 bool apiSupport = ImplicitScaling::apiSupport; 18 if (DebugManager.flags.EnableImplicitScaling.get() != -1) { 19 apiSupport = !!DebugManager.flags.EnableImplicitScaling.get(); 20 } 21 22 bool partitionWalker = (devices.count() > 1u) && 23 preCondition && 24 apiSupport; 25 26 if (DebugManager.flags.EnableWalkerPartition.get() != -1) { 27 partitionWalker = !!DebugManager.flags.EnableWalkerPartition.get(); 28 } 29 //we can't do this without local memory 30 partitionWalker &= OSInterface::osEnableLocalMemory; 31 32 return partitionWalker; 33 } 34 isSynchronizeBeforeExecutionRequired()35bool ImplicitScalingHelper::isSynchronizeBeforeExecutionRequired() { 36 auto synchronizeBeforeExecution = false; 37 int overrideSynchronizeBeforeExecution = DebugManager.flags.SynchronizeWalkerInWparidMode.get(); 38 if (overrideSynchronizeBeforeExecution != -1) { 39 synchronizeBeforeExecution = !!overrideSynchronizeBeforeExecution; 40 } 41 return synchronizeBeforeExecution; 42 } 43 isSemaphoreProgrammingRequired()44bool ImplicitScalingHelper::isSemaphoreProgrammingRequired() { 45 auto semaphoreProgrammingRequired = false; 46 int overrideSemaphoreProgrammingRequired = DebugManager.flags.SynchronizeWithSemaphores.get(); 47 if (overrideSemaphoreProgrammingRequired != -1) { 48 semaphoreProgrammingRequired = !!overrideSemaphoreProgrammingRequired; 49 } 50 return semaphoreProgrammingRequired; 51 } 52 isCrossTileAtomicRequired(bool defaultCrossTileRequirement)53bool ImplicitScalingHelper::isCrossTileAtomicRequired(bool defaultCrossTileRequirement) { 54 auto crossTileAtomicSynchronization = defaultCrossTileRequirement; 55 int overrideCrossTileAtomicSynchronization = DebugManager.flags.UseCrossAtomicSynchronization.get(); 56 if (overrideCrossTileAtomicSynchronization != -1) { 57 crossTileAtomicSynchronization = !!overrideCrossTileAtomicSynchronization; 58 } 59 return crossTileAtomicSynchronization; 60 } 61 isAtomicsUsedForSelfCleanup()62bool ImplicitScalingHelper::isAtomicsUsedForSelfCleanup() { 63 bool useAtomics = false; 64 int overrideUseAtomics = DebugManager.flags.UseAtomicsForSelfCleanupSection.get(); 65 if (overrideUseAtomics != -1) { 66 useAtomics = !!(overrideUseAtomics); 67 } 68 return useAtomics; 69 } 70 isSelfCleanupRequired(const WalkerPartition::WalkerPartitionArgs & args,bool apiSelfCleanup)71bool ImplicitScalingHelper::isSelfCleanupRequired(const WalkerPartition::WalkerPartitionArgs &args, bool apiSelfCleanup) { 72 bool defaultSelfCleanup = apiSelfCleanup && 73 (args.crossTileAtomicSynchronization || 74 args.synchronizeBeforeExecution || 75 !args.staticPartitioning); 76 77 int overrideProgramSelfCleanup = DebugManager.flags.ProgramWalkerPartitionSelfCleanup.get(); 78 if (overrideProgramSelfCleanup != -1) { 79 defaultSelfCleanup = !!(overrideProgramSelfCleanup); 80 } 81 return defaultSelfCleanup; 82 } 83 isWparidRegisterInitializationRequired()84bool ImplicitScalingHelper::isWparidRegisterInitializationRequired() { 85 bool initWparidRegister = false; 86 int overrideInitWparidRegister = DebugManager.flags.WparidRegisterProgramming.get(); 87 if (overrideInitWparidRegister != -1) { 88 initWparidRegister = !!(overrideInitWparidRegister); 89 } 90 return initWparidRegister; 91 } 92 isPipeControlStallRequired(bool defaultEmitPipeControl)93bool ImplicitScalingHelper::isPipeControlStallRequired(bool defaultEmitPipeControl) { 94 int overrideUsePipeControl = DebugManager.flags.UsePipeControlAfterPartitionedWalker.get(); 95 if (overrideUsePipeControl != -1) { 96 defaultEmitPipeControl = !!(overrideUsePipeControl); 97 } 98 return defaultEmitPipeControl; 99 } 100 101 } // namespace NEO 102