r.EnableMultiGPUForkAndJoin
r.EnableMultiGPUForkAndJoin
#Overview
name: r.EnableMultiGPUForkAndJoin
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to allow unused GPUs to speedup rendering by sharing work.\n
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.EnableMultiGPUForkAndJoin is to control whether unused GPUs can be utilized to speed up rendering by sharing work in a multi-GPU setup.
This setting variable is primarily used in the rendering system of Unreal Engine 5. Based on the callsites, it appears to be part of the SceneRendering module within the Renderer subsystem.
The value of this variable is set through a console variable (CVarEnableMultiGPUForkAndJoin) with a default value of 1, meaning it’s enabled by default. It can be changed at runtime through console commands or programmatically.
The associated variable CVarEnableMultiGPUForkAndJoin interacts directly with r.EnableMultiGPUForkAndJoin, as they share the same value. This console variable is used to check the setting’s value in the code.
Developers should be aware that this variable affects multi-GPU rendering performance. When enabled, it allows for work sharing among GPUs, potentially improving rendering speed. However, it may not always be beneficial in all scenarios or hardware configurations.
Best practices when using this variable include:
- Testing performance with and without this feature enabled on target hardware.
- Considering the impact on different types of scenes and rendering workloads.
- Ensuring proper multi-GPU support in the hardware and drivers.
- Monitoring for any potential artifacts or inconsistencies when enabled.
Regarding the associated variable CVarEnableMultiGPUForkAndJoin:
The purpose of CVarEnableMultiGPUForkAndJoin is to provide a runtime-configurable way to enable or disable the multi-GPU fork and join functionality.
This console variable is used within the Renderer subsystem, specifically in the SceneRendering module. It’s checked in the FSceneRenderer::ComputeGPUMasks function to determine whether to use multi-GPU fork and join or fall back to rendering the whole view family on each relevant GPU.
The value of this variable is set when it’s declared, with a default value of 1 (enabled). It can be changed through console commands or programmatically at runtime.
CVarEnableMultiGPUForkAndJoin directly interacts with the r.EnableMultiGPUForkAndJoin setting, as they represent the same configuration option.
Developers should be aware that this console variable affects the GPU computation strategy in multi-GPU setups. It’s important to consider the performance implications and potential rendering differences when changing this value.
Best practices for using this console variable include:
- Using it for debugging or performance testing in different multi-GPU scenarios.
- Documenting any changes to this variable in project settings or configuration files.
- Considering its impact on different hardware configurations and adjusting accordingly.
- Testing thoroughly when changing this value to ensure rendering correctness and performance improvements.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:337
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarEnableMultiGPUForkAndJoin(
TEXT("r.EnableMultiGPUForkAndJoin"),
1,
TEXT("Whether to allow unused GPUs to speedup rendering by sharing work.\n"),
ECVF_Default
);
/*-----------------------------------------------------------------------------
#Associated Variable and Callsites
This variable is associated with another variable named CVarEnableMultiGPUForkAndJoin
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:336
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe | ECVF_Scalability);
static TAutoConsoleVariable<int32> CVarEnableMultiGPUForkAndJoin(
TEXT("r.EnableMultiGPUForkAndJoin"),
1,
TEXT("Whether to allow unused GPUs to speedup rendering by sharing work.\n"),
ECVF_Default
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:3269
Scope (from outer to inner):
file
function void FSceneRenderer::ComputeGPUMasks
Source code excerpt:
// First check whether we are in multi-GPU and if fork and join cross-gpu transfers are enabled.
// Otherwise fallback on rendering the whole view family on each relevant GPU using broadcast logic.
if (GNumExplicitGPUsForRendering > 1 && CVarEnableMultiGPUForkAndJoin.GetValueOnAnyThread() != 0)
{
// Start iterating from RenderTargetGPUMask and then wrap around. This avoids an
// unnecessary cross-gpu transfer in cases where you only have 1 view and the
// render target is located on a GPU other than GPU 0.
FRHIGPUMask::FIterator GPUIterator(RenderTargetGPUMask);
for (FViewInfo& ViewInfo : Views)