p.Chaos.LongRange.ISPC
p.Chaos.LongRange.ISPC
#Overview
name: p.Chaos.LongRange.ISPC
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use ISPC optimizations in long range constraints
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.LongRange.ISPC is to control whether ISPC (Intel SPMD Program Compiler) optimizations are used in long-range constraints within the Chaos physics system of Unreal Engine 5. This setting variable is primarily used for performance optimization in the physics simulation, specifically for long-range constraints.
The Chaos physics system, which is part of Unreal Engine’s experimental features, relies on this setting variable. It is used within the Chaos::Softs namespace, indicating its relevance to soft-body physics simulations.
The value of this variable is set through a console variable system, as evidenced by the use of FAutoConsoleVariableRef. This allows for runtime toggling of the optimization on supported platforms in non-shipping configurations.
The associated variable bChaos_LongRange_ISPC_Enabled directly interacts with p.Chaos.LongRange.ISPC. They share the same value and are used interchangeably in the code.
Developers must be aware that this optimization is platform-dependent and may not be available on all systems. The code checks for INTEL_ISPC and bRealTypeCompatibleWithISPC before applying the ISPC-optimized functions.
Best practices when using this variable include:
- Ensuring that the target platform supports ISPC optimizations.
- Testing performance with and without the optimization enabled to determine the best configuration for your specific use case.
- Being cautious when modifying this setting in shipping builds, as it’s designed to be toggled mainly in development environments.
Regarding the associated variable bChaos_LongRange_ISPC_Enabled: Its purpose is identical to p.Chaos.LongRange.ISPC, serving as a boolean flag to enable or disable ISPC optimizations for long-range constraints.
This variable is used extensively in the FPBDLongRangeConstraints::Apply function to determine whether to use ISPC-optimized versions of constraint calculations. It affects various aspects of the long-range constraint calculations, including those with scale and stiffness weightmaps.
The value is set at runtime through the console variable system, allowing for dynamic toggling of the optimization.
Developers should be aware that this variable’s state can significantly impact performance and potentially behavior of soft-body physics simulations. It’s crucial to test thoroughly with both states to ensure consistent behavior across different configurations.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDLongRangeConstraints.cpp:10
Scope: file
Source code excerpt:
bool bChaos_LongRange_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosLongRangeISPCEnabled(TEXT("p.Chaos.LongRange.ISPC"), bChaos_LongRange_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in long range constraints"));
#endif
namespace Chaos::Softs {
void FPBDLongRangeConstraints::SetProperties(
const FCollectionPropertyConstFacade& PropertyCollection,
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_LongRange_ISPC_Enabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDLongRangeConstraints.cpp:9
Scope: file
Source code excerpt:
static_assert(sizeof(ispc::FTether) == sizeof(Chaos::Softs::FPBDLongRangeConstraintsBase::FTether), "sizeof(ispc::FTether) != sizeof(Chaos::Softs::FPBDLongRangeConstraintsBase::FTether)");
bool bChaos_LongRange_ISPC_Enabled = true;
FAutoConsoleVariableRef CVarChaosLongRangeISPCEnabled(TEXT("p.Chaos.LongRange.ISPC"), bChaos_LongRange_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in long range constraints"));
#endif
namespace Chaos::Softs {
void FPBDLongRangeConstraints::SetProperties(
const FCollectionPropertyConstFacade& PropertyCollection,
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDLongRangeConstraints.cpp:62
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FPBDLongRangeConstraints::Apply
Source code excerpt:
const FSolverReal ScaleValue = (FSolverReal)TetherScale;
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_LongRange_ISPC_Enabled)
{
// Run particles in parallel, and batch in sequence to avoid a race condition when updating the same particle from different tethers
for (const TConstArrayView<FTether>& TetherBatch : Tethers)
{
ispc::ApplyLongRangeConstraints(
(ispc::FVector4f*)Particles.GetPAndInvM().GetData(),
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDLongRangeConstraints.cpp:93
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FPBDLongRangeConstraints::Apply
Source code excerpt:
{
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_LongRange_ISPC_Enabled)
{
// Run particles in parallel, and batch in sequence to avoid a race condition when updating the same particle from different tethers
for (const TConstArrayView<FTether>& TetherBatch : Tethers)
{
ispc::ApplyLongRangeConstraintsScaleWeightmap(
(ispc::FVector4f*)Particles.GetPAndInvM().GetData(),
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDLongRangeConstraints.cpp:132
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FPBDLongRangeConstraints::Apply
Source code excerpt:
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_LongRange_ISPC_Enabled)
{
// Run particles in parallel, and batch in sequence to avoid a race condition when updating the same particle from different tethers
for (const TConstArrayView<FTether>& TetherBatch : Tethers)
{
ispc::ApplyLongRangeConstraintsStiffnessWeightmap(
(ispc::FVector4f*)Particles.GetPAndInvM().GetData(),
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDLongRangeConstraints.cpp:166
Scope (from outer to inner):
file
namespace Chaos::Softs
function void FPBDLongRangeConstraints::Apply
Source code excerpt:
{
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_LongRange_ISPC_Enabled)
{
// Run particles in parallel, and batch in sequence to avoid a race condition when updating the same particle from different tethers
for (const TConstArrayView<FTether>& TetherBatch : Tethers)
{
ispc::ApplyLongRangeConstraintsStiffnessScaleWeightmaps(
(ispc::FVector4f*)Particles.GetPAndInvM().GetData(),
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDLongRangeConstraints.h:151
Scope: file
Source code excerpt:
// Support run-time toggling on supported platforms in non-shipping configurations
#if !INTEL_ISPC || UE_BUILD_SHIPPING
static constexpr bool bChaos_LongRange_ISPC_Enabled = INTEL_ISPC && CHAOS_LONG_RANGE_ISPC_ENABLED_DEFAULT;
#else
extern CHAOS_API bool bChaos_LongRange_ISPC_Enabled;
#endif