p.Chaos.PreSimulationTransforms.ISPC
p.Chaos.PreSimulationTransforms.ISPC
#Overview
name: p.Chaos.PreSimulationTransforms.ISPC
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use ISPC optimizations in ApplySimulationTransforms
It is referenced in 8
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.PreSimulationTransforms.ISPC is to control whether ISPC (Intel SPMD Program Compiler) optimizations are used in the ApplySimulationTransforms function within the Chaos Cloth simulation system of Unreal Engine 5.
This setting variable is primarily used by the Chaos Cloth simulation system, which is part of the ChaosCloth plugin in Unreal Engine 5. It specifically affects the performance optimization of the pre-simulation transformation calculations.
The value of this variable is set through the Unreal Engine console variable system. It’s initialized with a default value defined by CHAOS_PRE_SIMULATION_TRANSFORMS_ISPC_ENABLED_DEFAULT and can be changed at runtime.
The associated variable bChaos_PreSimulationTransforms_ISPC_Enabled directly interacts with p.Chaos.PreSimulationTransforms.ISPC. They share the same value, with bChaos_PreSimulationTransforms_ISPC_Enabled being used in the actual code logic.
Developers must be aware that this optimization is only available when INTEL_ISPC is defined and the build configuration is not UE_BUILD_SHIPPING. It’s also important to note that this optimization is specifically for the ApplySimulationTransforms function.
Best practices when using this variable include:
- Only enable it if you’re targeting platforms that support ISPC optimizations.
- Test performance with and without this optimization enabled to ensure it provides benefits for your specific use case.
- Be cautious when enabling in shipping builds, as it’s disabled by default in those configurations.
Regarding the associated variable bChaos_PreSimulationTransforms_ISPC_Enabled:
The purpose of bChaos_PreSimulationTransforms_ISPC_Enabled is to act as a runtime flag for enabling or disabling ISPC optimizations in the ApplySimulationTransforms function.
This variable is used directly in the Chaos Cloth simulation code to determine whether to use the ISPC-optimized version of certain functions or the standard C++ implementation.
Its value is set by the p.Chaos.PreSimulationTransforms.ISPC console variable, allowing for runtime toggling of this optimization.
It interacts closely with other ISPC-related variables in the Chaos Cloth system, such as bChaos_CalculateBounds_ISPC_Enabled and bChaos_PreSubstepInterpolation_ISPC_Enabled.
Developers should be aware that this variable’s state can significantly impact performance and should be profiled in different scenarios to determine the optimal setting.
Best practices include using this variable in conditional compilation blocks to ensure that non-ISPC code paths are available when needed, and to properly handle cases where ISPC optimizations are not available or disabled.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:36
Scope: file
Source code excerpt:
#if INTEL_ISPC && !UE_BUILD_SHIPPING
bool bChaos_PreSimulationTransforms_ISPC_Enabled = CHAOS_PRE_SIMULATION_TRANSFORMS_ISPC_ENABLED_DEFAULT;
FAutoConsoleVariableRef CVarChaosPreSimulationTransformsISPCEnabled(TEXT("p.Chaos.PreSimulationTransforms.ISPC"), bChaos_PreSimulationTransforms_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in ApplySimulationTransforms"));
bool bChaos_CalculateBounds_ISPC_Enabled = CHAOS_CALCULATE_BOUNDS_ISPC_ENABLED_DEFAULT;
FAutoConsoleVariableRef CVarChaosCalculateBoundsISPCEnabled(TEXT("p.Chaos.CalculateBounds.ISPC"), bChaos_CalculateBounds_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in CalculateBounds"));
bool bChaos_PreSubstepInterpolation_ISPC_Enabled = CHAOS_PRE_SUBSTEP_INTERPOLATION_ISPC_ENABLED_DEFAULT;
FAutoConsoleVariableRef CVarChaosPreSubstepInterpolationISPCEnabled(TEXT("p.Chaos.PreSubstepInterpolation.ISPC"), bChaos_PreSubstepInterpolation_ISPC_Enabled, TEXT("Whether to use ISPC optimization in PreSubstep"));
static_assert(sizeof(ispc::FVector3f) == sizeof(Chaos::Softs::FSolverVec3), "sizeof(ispc::FVector) != sizeof(Chaos::Softs::FSolverVec3)");
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_PreSimulationTransforms_ISPC_Enabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:35
Scope: file
Source code excerpt:
#if INTEL_ISPC && !UE_BUILD_SHIPPING
bool bChaos_PreSimulationTransforms_ISPC_Enabled = CHAOS_PRE_SIMULATION_TRANSFORMS_ISPC_ENABLED_DEFAULT;
FAutoConsoleVariableRef CVarChaosPreSimulationTransformsISPCEnabled(TEXT("p.Chaos.PreSimulationTransforms.ISPC"), bChaos_PreSimulationTransforms_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in ApplySimulationTransforms"));
bool bChaos_CalculateBounds_ISPC_Enabled = CHAOS_CALCULATE_BOUNDS_ISPC_ENABLED_DEFAULT;
FAutoConsoleVariableRef CVarChaosCalculateBoundsISPCEnabled(TEXT("p.Chaos.CalculateBounds.ISPC"), bChaos_CalculateBounds_ISPC_Enabled, TEXT("Whether to use ISPC optimizations in CalculateBounds"));
bool bChaos_PreSubstepInterpolation_ISPC_Enabled = CHAOS_PRE_SUBSTEP_INTERPOLATION_ISPC_ENABLED_DEFAULT;
FAutoConsoleVariableRef CVarChaosPreSubstepInterpolationISPCEnabled(TEXT("p.Chaos.PreSubstepInterpolation.ISPC"), bChaos_PreSubstepInterpolation_ISPC_Enabled, TEXT("Whether to use ISPC optimization in PreSubstep"));
static_assert(sizeof(ispc::FVector3f) == sizeof(Chaos::Softs::FSolverVec3), "sizeof(ispc::FVector) != sizeof(Chaos::Softs::FSolverVec3)");
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:1512
Scope (from outer to inner):
file
namespace Chaos
function void FClothingSimulationSolver::ApplyPreSimulationTransforms
lambda-function
Source code excerpt:
Softs::FSolverParticlesRange& Particles = Evolution->GetSoftBodyParticles(SoftBodyId);
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_PreSimulationTransforms_ISPC_Enabled) // TODO: Make the ISPC works with both Single and Double depending on the FSolverReal type
{
if (MaxVelocitySquared == TNumericLimits<FSolverReal>::Max())
{
ispc::ApplyPreSimulationTransform(
(ispc::FVector4f*)Particles.GetPAndInvM().GetData(),
(ispc::FVector3f*)Particles.GetV().GetData(),
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:1612
Scope (from outer to inner):
file
namespace Chaos
function void FClothingSimulationSolver::ApplyPreSimulationTransforms
lambda-function
Source code excerpt:
#if INTEL_ISPC
if (bRealTypeCompatibleWithISPC && bChaos_PreSimulationTransforms_ISPC_Enabled) // TODO: Make the ISPC works with both Single and Double depending on the FSolverReal type
{
if (MaxVelocitySquared == TNumericLimits<FSolverReal>::Max())
{
ispc::ApplyPreSimulationTransforms(
(ispc::FVector4f*)Particles.GetPAndInvM().GetData(),
(ispc::FVector3f*)Particles.GetV().GetData(),
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/IspcTestChaosClothingSimulationSolver.cpp:71
Scope (from outer to inner):
file
function bool FIspcTestChaosClothingSimulationSolverPreSimulation::RunTest
Source code excerpt:
using namespace Chaos;
bool InitialState = bChaos_PreSimulationTransforms_ISPC_Enabled;
const int32 NumParticles = 100;
const Softs::FSolverReal InvMValue = .5f;
Softs::FPAndInvM FPInvMData;
FPInvMData.P = Softs::FSolverVec3(0.f);
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/IspcTestChaosClothingSimulationSolver.cpp:94
Scope (from outer to inner):
file
function bool FIspcTestChaosClothingSimulationSolverPreSimulation::RunTest
Source code excerpt:
const FRealSingle FicticiousAngularScale = 1.f;
bChaos_PreSimulationTransforms_ISPC_Enabled = true;
FClothingSimulationSolver ISPCSimulation;
{
ISPCSimulation.AddParticles(NumParticles, 0);
ISPCSimulation.EnableParticles(0, true);
for (int32 i = 0; i < NumParticles; ++i)
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/IspcTestChaosClothingSimulationSolver.cpp:128
Scope (from outer to inner):
file
function bool FIspcTestChaosClothingSimulationSolverPreSimulation::RunTest
Source code excerpt:
}
bChaos_PreSimulationTransforms_ISPC_Enabled = false;
FClothingSimulationSolver CPPSimulation;
{
CPPSimulation.AddParticles(NumParticles, 0);
CPPSimulation.EnableParticles(0, true);
for (int32 i = 0; i < NumParticles; ++i)
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Public/ChaosCloth/ChaosClothingSimulationSolver.h:477
Scope: file
Source code excerpt:
#if !INTEL_ISPC || UE_BUILD_SHIPPING
static constexpr bool bChaos_CalculateBounds_ISPC_Enabled = INTEL_ISPC && CHAOS_CALCULATE_BOUNDS_ISPC_ENABLED_DEFAULT;
static constexpr bool bChaos_PreSimulationTransforms_ISPC_Enabled = INTEL_ISPC && CHAOS_PRE_SIMULATION_TRANSFORMS_ISPC_ENABLED_DEFAULT;
static constexpr bool bChaos_PreSubstepInterpolation_ISPC_Enabled = INTEL_ISPC && CHAOS_PRE_SUBSTEP_INTERPOLATION_ISPC_ENABLED_DEFAULT;
#else
extern bool bChaos_PreSimulationTransforms_ISPC_Enabled;
extern bool bChaos_CalculateBounds_ISPC_Enabled;
extern bool bChaos_PreSubstepInterpolation_ISPC_Enabled;
#endif