p.Chaos.PBDEvolution.MinParallelBatchSize
p.Chaos.PBDEvolution.MinParallelBatchSize
#Overview
name: p.Chaos.PBDEvolution.MinParallelBatchSize
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.PBDEvolution.MinParallelBatchSize is to control the minimum batch size for parallel processing in the Position-Based Dynamics (PBD) evolution system within Unreal Engine’s Chaos physics engine.
This setting variable is primarily used by the Chaos physics engine, specifically within the Position-Based Dynamics (PBD) evolution system. It is part of the Experimental Chaos module in Unreal Engine 5.
The value of this variable is set as a console variable using TAutoConsoleVariable. It is initialized with a default value of 300 and can be modified at runtime through console commands.
This variable interacts closely with CVarChaosPBDEvolutionParallelIntegrate. When parallel integration is enabled, MinParallelBatchSize determines the minimum number of items that should be processed in parallel. If parallel integration is disabled, MinParallelBatchSize is set to the maximum possible integer value, effectively disabling parallel processing.
Developers should be aware that this variable can significantly impact performance and simulation accuracy. A larger batch size may improve performance on systems with many cores but could potentially reduce the granularity of the simulation.
Best practices when using this variable include:
- Experiment with different values to find the optimal balance between performance and simulation accuracy for your specific use case.
- Consider the target hardware when setting this value, as optimal batch sizes may vary depending on the number of available cores.
- Use in conjunction with CVarChaosPBDEvolutionParallelIntegrate to fine-tune parallel processing behavior.
Regarding the associated variable CVarChaosPBDEvolutionMinParallelBatchSize:
This is the actual console variable that stores the MinParallelBatchSize value. It’s defined as an int32 type and is used to retrieve the current value of MinParallelBatchSize at runtime.
The value of CVarChaosPBDEvolutionMinParallelBatchSize is accessed using the GetValueOnAnyThread() method, which suggests that it can be safely read from any thread.
Developers should note that changes to this console variable will take effect immediately, potentially affecting ongoing simulations. It’s important to consider the impact of changing this value during runtime, especially in performance-critical scenarios.
Best practices for using CVarChaosPBDEvolutionMinParallelBatchSize include:
- Use it for debugging and performance tuning purposes.
- Consider exposing it as a configurable setting in your game’s options menu for advanced users or developers.
- Monitor its impact on performance and simulation quality when modifying its value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDEvolution.cpp:35
Scope: file
Source code excerpt:
TAutoConsoleVariable<bool> CVarChaosPBDEvolutionFastPositionBasedFriction(TEXT("p.Chaos.PBDEvolution.FastPositionBasedFriction"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosPBDEvolutionUseSmoothTimeStep(TEXT("p.Chaos.PBDEvolution.UseSmoothTimeStep"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<int32> CVarChaosPBDEvolutionMinParallelBatchSize(TEXT("p.Chaos.PBDEvolution.MinParallelBatchSize"), 300, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosPBDEvolutionWriteCCDContacts(TEXT("p.Chaos.PBDEvolution.WriteCCDContacts"), false, TEXT("Write CCD collision contacts and normals potentially causing the CCD collision threads to lock, allowing for debugging of these contacts."), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosPBDEvolutionParallelIntegrate(TEXT("p.Chaos.PBDEvolution.ParalleIntegrate"), false, TEXT("Run the integration step in parallel for."), ECVF_Cheat);
#if INTEL_ISPC && !UE_BUILD_SHIPPING
bool bChaos_PostIterationUpdates_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosPostIterationUpdatesISPCEnabled(TEXT("p.Chaos.PostIterationUpdates.ISPC"), bChaos_PostIterationUpdates_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in PBD Post iteration updates"));
#Associated Variable and Callsites
This variable is associated with another variable named CVarChaosPBDEvolutionMinParallelBatchSize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDEvolution.cpp:35
Scope: file
Source code excerpt:
TAutoConsoleVariable<bool> CVarChaosPBDEvolutionFastPositionBasedFriction(TEXT("p.Chaos.PBDEvolution.FastPositionBasedFriction"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosPBDEvolutionUseSmoothTimeStep(TEXT("p.Chaos.PBDEvolution.UseSmoothTimeStep"), true, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<int32> CVarChaosPBDEvolutionMinParallelBatchSize(TEXT("p.Chaos.PBDEvolution.MinParallelBatchSize"), 300, TEXT(""), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosPBDEvolutionWriteCCDContacts(TEXT("p.Chaos.PBDEvolution.WriteCCDContacts"), false, TEXT("Write CCD collision contacts and normals potentially causing the CCD collision threads to lock, allowing for debugging of these contacts."), ECVF_Cheat);
TAutoConsoleVariable<bool> CVarChaosPBDEvolutionParallelIntegrate(TEXT("p.Chaos.PBDEvolution.ParalleIntegrate"), false, TEXT("Run the integration step in parallel for."), ECVF_Cheat);
#if INTEL_ISPC && !UE_BUILD_SHIPPING
bool bChaos_PostIterationUpdates_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosPostIterationUpdatesISPCEnabled(TEXT("p.Chaos.PostIterationUpdates.ISPC"), bChaos_PostIterationUpdates_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in PBD Post iteration updates"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDEvolution.cpp:477
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FPBDEvolution::AdvanceOneTimeStep
Source code excerpt:
const int32 MinParallelBatchSize = !CVarChaosPBDEvolutionParallelIntegrate.GetValueOnAnyThread() ?
TNumericLimits<int32>::Max() : // Disable
CVarChaosPBDEvolutionMinParallelBatchSize.GetValueOnAnyThread(); // TODO: 1000 is a guess, tune this!
const bool bWriteCCDContacts = CVarChaosPBDEvolutionWriteCCDContacts.GetValueOnAnyThread();
{
TRACE_CPUPROFILER_EVENT_SCOPE(ChaosPBDPreIterationUpdates);
SCOPE_CYCLE_COUNTER(STAT_ChaosPBDPreIterationUpdates);