Skip to content

Commit

Permalink
Invert GPU timeout feature switch, true by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Jun 25, 2023
1 parent ee67798 commit b7d2b05
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<ItemGroup>
<RuntimeHostConfigurationOption Include="COMPUTESHARP_ENABLE_DEBUG_OUTPUT" Value="false" Trim="true" />
<RuntimeHostConfigurationOption Include="COMPUTESHARP_ENABLE_DEVICE_REMOVED_EXTENDED_DATA" Value="false" Trim="true" />
<RuntimeHostConfigurationOption Include="COMPUTESHARP_DISABLE_GPU_TIMEOUT" Value="false" Trim="true" />
<RuntimeHostConfigurationOption Include="COMPUTESHARP_ENABLE_GPU_TIMEOUT" Value="true" Trim="true" />
</ItemGroup>

<!-- If requested, also reference the UPX compression package -->
Expand Down
8 changes: 4 additions & 4 deletions src/ComputeSharp/ComputeSharp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
Value="$(ComputeSharpEnableDeviceRemovedExtendedData)"
Trim="true" />

<!-- COMPUTESHARP_DISABLE_GPU_TIMEOUT switch -->
<RuntimeHostConfigurationOption Condition="'$(ComputeSharpDisableGpuTimeout)' != ''"
Include="COMPUTESHARP_DISABLE_GPU_TIMEOUT"
Value="$(ComputeSharpDisableGpuTimeout)"
<!-- COMPUTESHARP_ENABLE_GPU_TIMEOUT switch -->
<RuntimeHostConfigurationOption Condition="'$(ComputeSharpEnableGpuTimeout)' != ''"
Include="COMPUTESHARP_ENABLE_GPU_TIMEOUT"
Value="$(ComputeSharpEnableGpuTimeout)"
Trim="true" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public static ComPtr<ID3D12CommandQueue> CreateCommandQueue(this ref ID3D12Devic
d3D12CommandQueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
d3D12CommandQueueDesc.NodeMask = 0;

if (Configuration.IsGpuTimeoutDisabled)
if (!Configuration.IsGpuTimeoutEnabled)
{
d3D12CommandQueueDesc.Flags |= D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT;
}
Expand Down
20 changes: 10 additions & 10 deletions src/ComputeSharp/Properties/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ internal static class Configuration
private const string IsDeviceRemovedExtendedDataEnabledPropertyName = "COMPUTESHARP_ENABLE_DEVICE_REMOVED_EXTENDED_DATA";

/// <summary>
/// The configuration property name for <see cref="IsGpuTimeoutDisabled"/>.
/// The configuration property name for <see cref="IsGpuTimeoutEnabled"/>.
/// </summary>
private const string IsGpuTimeoutDisabledPropertyName = "COMPUTESHARP_DISABLE_GPU_TIMEOUT";
private const string IsGpuTimeoutEnabledPropertyName = "COMPUTESHARP_ENABLE_GPU_TIMEOUT";

/// <summary>
/// The backing field for <see cref="IsDebugOutputEnabled"/>.
Expand All @@ -45,9 +45,9 @@ internal static class Configuration
private static int isDeviceRemovedExtendedDataEnabledConfigurationValue;

/// <summary>
/// The backing field for <see cref="IsGpuTimeoutDisabled"/>.
/// The backing field for <see cref="IsGpuTimeoutEnabled"/>.
/// </summary>
private static int isGpuTimeoutDisabledConfigurationValue;
private static int isGpuTimeoutEnabledConfigurationValue;

/// <summary>
/// Gets a value indicating whether or not the debug output is enabled (defaults to <see langword="false"/>).
Expand All @@ -68,12 +68,12 @@ public static bool IsDeviceRemovedExtendedDataEnabled
}

/// <summary>
/// Gets a value indicating whether or not the GPU timeout is disabled (defaults to <see langword="false"/>).
/// Gets a value indicating whether or not the GPU timeout is enabled (defaults to <see langword="true"/>).
/// </summary>
public static bool IsGpuTimeoutDisabled
public static bool IsGpuTimeoutEnabled
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => GetConfigurationValue(IsGpuTimeoutDisabledPropertyName, ref isGpuTimeoutDisabledConfigurationValue);
get => GetConfigurationValue(IsGpuTimeoutEnabledPropertyName, ref isGpuTimeoutEnabledConfigurationValue);
}

/// <summary>
Expand Down Expand Up @@ -140,10 +140,10 @@ private static bool GetDefaultConfigurationValue(string propertyName)
#endif
}

// Disable GPU timeout (always false by default)
if (propertyName == IsGpuTimeoutDisabledPropertyName)
// GPU timeout (always enabled by default, disabling it is only recommended for debugging purposes)
if (propertyName == IsGpuTimeoutEnabledPropertyName)
{
return false;
return true;
}

return false;
Expand Down
6 changes: 3 additions & 3 deletions src/ComputeSharp/Properties/ILLink.Substitutions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<method signature="System.Boolean get_IsDeviceRemovedExtendedDataEnabled()" body="stub" value="false" feature="COMPUTESHARP_ENABLE_DEVICE_REMOVED_EXTENDED_DATA" featurevalue="false"/>
<method signature="System.Boolean get_IsDeviceRemovedExtendedDataEnabled()" body="stub" value="true" feature="COMPUTESHARP_ENABLE_DEVICE_REMOVED_EXTENDED_DATA" featurevalue="true"/>

<!-- COMPUTESHARP_DISABLE_GPU_TIMEOUT switch -->
<method signature="System.Boolean get_IsGpuTimeoutDisabled()" body="stub" value="false" feature="COMPUTESHARP_DISABLE_GPU_TIMEOUT" featurevalue="false"/>
<method signature="System.Boolean get_IsGpuTimeoutDisabled()" body="stub" value="true" feature="COMPUTESHARP_DISABLE_GPU_TIMEOUT" featurevalue="true"/>
<!-- COMPUTESHARP_ENABLE_GPU_TIMEOUT switch -->
<method signature="System.Boolean get_IsGpuTimeoutEnabled()" body="stub" value="false" feature="COMPUTESHARP_ENABLE_GPU_TIMEOUT" featurevalue="false"/>
<method signature="System.Boolean get_IsGpuTimeoutEnabled()" body="stub" value="true" feature="COMPUTESHARP_ENABLE_GPU_TIMEOUT" featurevalue="true"/>
</type>
</assembly>
</linker>

0 comments on commit b7d2b05

Please sign in to comment.