{{ message }}
JIT: Accelerate Vector.Dot for all base types#111853
Merged
Merged
Conversation
Member
Author
Member
Author
|
@EgorBot -amd -intel --envvars DOTNET_EnableAVX512F:0 using BenchmarkDotNet.Running;
using BenchmarkDotNet.Attributes;
using System.Numerics;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
public unsafe class LongBench
{
private const int nitems = 1 << 10;
private long* data;
[GlobalSetup]
public void Setup()
{
const int len = sizeof(long) * nitems;
data = (long*)NativeMemory.AlignedAlloc(len, 64);
Random.Shared.NextBytes(new Span<byte>(data, len));
}
[Benchmark]
public Vector128<long> Multiply128()
{
long* ptr = data, end = ptr + nitems - Vector128<long>.Count;
var res = Vector128<long>.Zero;
while (ptr < end)
{
res ^= Vector128.LoadAligned(ptr) * Vector128.LoadAligned(ptr + Vector128<long>.Count);
ptr += Vector128<long>.Count;
}
return res;
}
[Benchmark]
public Vector256<long> Multiply256()
{
long* ptr = data, end = ptr + nitems - Vector256<long>.Count;
var res = Vector256<long>.Zero;
while (ptr < end)
{
res ^= Vector256.LoadAligned(ptr) * Vector256.LoadAligned(ptr + Vector256<long>.Count);
ptr += Vector256<long>.Count;
}
return res;
}
[Benchmark]
public Vector<long> MultiplyVectorT()
{
long* ptr = data, end = ptr + nitems - Vector<long>.Count;
var res = Vector<long>.Zero;
while (ptr < end)
{
res ^= Vector.Load(ptr) * Vector.Load(ptr + Vector256<long>.Count);
ptr += Vector<long>.Count;
}
return res;
}
} |
Member
Author
|
cc @EgorBo I believe you were the last to touch most of this |
Member
|
/azp run Fuzzlyn, runtime-coreclr jitstress-isas-x86, runtime-coreclr jitstress-isas-avx512 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Resolves #85207
op_MultiplyandMultiplyAddEstimateintrinsics since these can always be accelerated now.Vector256.Sumto be treated as intrinsic (only AVX instructions are used).Dotcan be treated as intrinsic for all types.Vector512.Dotas intrinsic.Diffs look good. The only regressions are due to inlining or the slightly larger (but faster) SSE2 multiply code.