DOTNET_PreferredVectorBitWidth
is not respected by Vector<T>
#104978
Open
Description
Description
It appears that Vector<T>
matches native vector width regardless of the value specified in environment variable DOTNET_PreferredVectorBitWidth
.
Reproduction Steps
Given dotnet run -c Release
and the following code:
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
Print(Vector128.IsHardwareAccelerated);
Print(Vector256.IsHardwareAccelerated);
Print(Vector512.IsHardwareAccelerated);
Print(Vector<byte>.Count * 8);
static void Print(object expr,
[CallerArgumentExpression(nameof(expr))] string text = "")
{
Console.WriteLine($"{text}: {expr}");
}
Expected behavior
none
Vector128.IsHardwareAccelerated: True
Vector256.IsHardwareAccelerated: True
Vector512.IsHardwareAccelerated: False
Vector<byte>.Count * 8: 256
$env:DOTNET_PreferredVectorBitWidth=128
Vector128.IsHardwareAccelerated: True
Vector256.IsHardwareAccelerated: False
Vector512.IsHardwareAccelerated: False
Vector<byte>.Count * 8: 128
Actual behavior
none
Vector128.IsHardwareAccelerated: True
Vector256.IsHardwareAccelerated: True
Vector512.IsHardwareAccelerated: False
Vector<byte>.Count * 8: 256
$env:DOTNET_PreferredVectorBitWidth=128
Vector128.IsHardwareAccelerated: True
Vector256.IsHardwareAccelerated: False
Vector512.IsHardwareAccelerated: False
Vector<byte>.Count * 8: 256 <-- unexpected
Regression?
Doesn't seem so
Known Workarounds
Disable platform-specific ISA with e.g. DOTNET_EnableAVX=0
.
Configuration
.NET SDK:
Version: 9.0.100-preview.7.24365.16
Commit: 365af5faed
Workload version: 9.0.100-manifests.d91b6c9f
MSBuild version: 17.12.0-preview-24365-02+977d5ccf6
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.100-preview.7.24365.16\
Other information
No response
Activity