p.Chaos.DisableParticleParallelFor
p.Chaos.DisableParticleParallelFor
#Overview
name: p.Chaos.DisableParticleParallelFor
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Disable parallel execution for Chaos Particles (Collisions,
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.DisableParticleParallelFor is to control parallel execution for Chaos Particles in Unreal Engine 5’s physics system. This setting variable is part of the Chaos physics engine, which is an experimental physics simulation framework in Unreal Engine.
The Unreal Engine subsystem that relies on this setting variable is the Chaos physics engine, specifically the particle simulation component. This can be seen from the file paths and namespaces in the provided code snippets, which are all within the Chaos namespace and located in the Experimental/Chaos directory.
The value of this variable is set through the Unreal Engine console variable system. It’s defined as an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands or configuration files.
This variable interacts closely with two other variables: bDisablePhysicsParallelFor and bDisableCollisionParallelFor. Together, these three variables control different aspects of parallel execution in the Chaos physics system.
Developers must be aware that this variable is only effective in non-shipping builds. In shipping builds, it’s always set to false, as seen in the Parallel.h file.
Best practices when using this variable include:
- Use it for debugging or performance testing purposes.
- Be aware that disabling parallel execution may significantly impact performance, especially in scenes with many particles.
- Consider the interaction with other parallel execution settings (physics and collision) when modifying this variable.
Regarding the associated variable bDisableParticleParallelFor:
The purpose of bDisableParticleParallelFor is the same as p.Chaos.DisableParticleParallelFor. It’s the actual boolean variable that controls the behavior, while p.Chaos.DisableParticleParallelFor is the console variable that allows runtime modification of this setting.
This variable is used directly in the Chaos physics code to determine whether to use parallel or sequential execution for particle operations. For example, in the ParticleIterator.h file, it’s checked to decide whether to use ParticlesParallelForImp or ParticlesSequentialFor.
The value of bDisableParticleParallelFor is set by the console variable system, linked to p.Chaos.DisableParticleParallelFor.
It interacts with bDisablePhysicsParallelFor and bDisableCollisionParallelFor, as part of the overall parallel execution control for the Chaos physics system.
Developers should be aware that this variable is declared as extern in non-shipping builds, allowing for runtime modification, but is const in shipping builds.
Best practices for using bDisableParticleParallelFor are similar to those for p.Chaos.DisableParticleParallelFor, with the addition that developers should generally interact with the console variable (p.Chaos.DisableParticleParallelFor) rather than directly modifying bDisableParticleParallelFor, to ensure proper integration with the engine’s configuration systems.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Framework/Parallel.cpp:19
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
FAutoConsoleVariableRef CVarDisablePhysicsParallelFor(TEXT("p.Chaos.DisablePhysicsParallelFor"), bDisablePhysicsParallelFor, TEXT("Disable parallel execution in Chaos Evolution"));
FAutoConsoleVariableRef CVarDisableParticleParallelFor(TEXT("p.Chaos.DisableParticleParallelFor"), bDisableParticleParallelFor, TEXT("Disable parallel execution for Chaos Particles (Collisions, "));
FAutoConsoleVariableRef CVarDisableCollisionParallelFor(TEXT("p.Chaos.DisableCollisionParallelFor"), bDisableCollisionParallelFor, TEXT("Disable parallel execution for Chaos Collisions (also disabled by DisableParticleParallelFor)"));
FAutoConsoleVariableRef CVarInnerPhysicsBatchSize(TEXT("p.Chaos.InnerParallelForBatchSize"), InnerParallelForBatchSize, TEXT("Set the batch size threshold for inner parallel fors"));
FAutoConsoleVariableRef CVarMinRangeBatchSize(TEXT("p.Chaos.MinRangeBatchSize"), MinRangeBatchSize, TEXT("Set the min range batch size for parallel for"));
FAutoConsoleVariableRef CVarMaxRangeBatchWorkers(TEXT("p.Chaos.MaxNumWorkers"), MaxNumWorkers, TEXT("Set the max number of workers for physics"));
FAutoConsoleVariableRef CVarSmallBatchSize(TEXT("p.Chaos.SmallBatchSize"), SmallBatchSize, TEXT("Small batch size for chaos parallel loops"));
FAutoConsoleVariableRef CVarLargeBatchSize(TEXT("p.Chaos.LargeBatchSize"), LargeBatchSize, TEXT("Large batch size for chaos parallel loops"));
#Associated Variable and Callsites
This variable is associated with another variable named bDisableParticleParallelFor
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Programs/HeadlessChaos/Private/HeadlessChaosTestPerf.cpp:116
Scope (from outer to inner):
file
namespace ChaosTest
function GTEST_TEST
Source code excerpt:
// let's make this serial
//bDisablePhysicsParallelFor = true;
//bDisableParticleParallelFor = true;
//bDisableCollisionParallelFor = true;
double MinTime = DBL_MAX;
double MaxTime = DBL_MIN;
double TotalTime = 0.;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Framework/Parallel.cpp:15
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
#if !UE_BUILD_SHIPPING
CHAOS_API bool bDisablePhysicsParallelFor = false;
CHAOS_API bool bDisableParticleParallelFor = false;
CHAOS_API bool bDisableCollisionParallelFor = false;
FAutoConsoleVariableRef CVarDisablePhysicsParallelFor(TEXT("p.Chaos.DisablePhysicsParallelFor"), bDisablePhysicsParallelFor, TEXT("Disable parallel execution in Chaos Evolution"));
FAutoConsoleVariableRef CVarDisableParticleParallelFor(TEXT("p.Chaos.DisableParticleParallelFor"), bDisableParticleParallelFor, TEXT("Disable parallel execution for Chaos Particles (Collisions, "));
FAutoConsoleVariableRef CVarDisableCollisionParallelFor(TEXT("p.Chaos.DisableCollisionParallelFor"), bDisableCollisionParallelFor, TEXT("Disable parallel execution for Chaos Collisions (also disabled by DisableParticleParallelFor)"));
FAutoConsoleVariableRef CVarInnerPhysicsBatchSize(TEXT("p.Chaos.InnerParallelForBatchSize"), InnerParallelForBatchSize, TEXT("Set the batch size threshold for inner parallel fors"));
FAutoConsoleVariableRef CVarMinRangeBatchSize(TEXT("p.Chaos.MinRangeBatchSize"), MinRangeBatchSize, TEXT("Set the min range batch size for parallel for"));
FAutoConsoleVariableRef CVarMaxRangeBatchWorkers(TEXT("p.Chaos.MaxNumWorkers"), MaxNumWorkers, TEXT("Set the max number of workers for physics"));
FAutoConsoleVariableRef CVarSmallBatchSize(TEXT("p.Chaos.SmallBatchSize"), SmallBatchSize, TEXT("Small batch size for chaos parallel loops"));
FAutoConsoleVariableRef CVarLargeBatchSize(TEXT("p.Chaos.LargeBatchSize"), LargeBatchSize, TEXT("Large batch size for chaos parallel loops"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Framework/Parallel.h:19
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
#if UE_BUILD_SHIPPING
const bool bDisablePhysicsParallelFor = false;
const bool bDisableParticleParallelFor = false;
const bool bDisableCollisionParallelFor = false;
#else
CHAOS_API extern bool bDisablePhysicsParallelFor;
CHAOS_API extern bool bDisableParticleParallelFor;
CHAOS_API extern bool bDisableCollisionParallelFor;
#endif
}
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/ParticleIterator.h:100
Scope (from outer to inner):
file
namespace Chaos
function void ParticlesParallelFor
Source code excerpt:
SCOPE_CYCLE_COUNTER(STAT_ParticlesParallelFor);
if (!bForceSingleThreaded && !bDisableParticleParallelFor)
{
Chaos::ParticlesParallelForImp(Particles, ContextCreator, Func);
}
else
{
Chaos::ParticlesSequentialFor(Particles, ContextCreator, Func);