Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EgorBot for saucecontrol in #111853 #312

Open
EgorBot opened this issue Mar 10, 2025 · 2 comments
Open

EgorBot for saucecontrol in #111853 #312

EgorBot opened this issue Mar 10, 2025 · 2 comments

Comments

@EgorBot
Copy link
Owner

EgorBot commented Mar 10, 2025

Processing dotnet/runtime#111853 (comment) command:

Command

-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;
    }
}

(EgorBot will reply in this issue)

@EgorBot
Copy link
Owner Author

EgorBot commented Mar 10, 2025

Benchmark results on linux_azure_genoa

BenchmarkDotNet v0.14.0, Ubuntu 24.04.2 LTS (Noble Numbat)
AMD EPYC 9V74, 1 CPU, 8 logical and 4 physical cores
  Job-HIPFUZ : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX2
  Job-PFYIEK : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX2
EnvironmentVariables=DOTNET_EnableAVX512F=0
Method Toolchain Mean Error Ratio
Multiply128 Main 423.5 ns 0.09 ns 1.00
Multiply128 PR 370.2 ns 0.08 ns 0.87
Multiply256 Main 213.9 ns 0.04 ns 1.00
Multiply256 PR 186.6 ns 0.06 ns 0.87
MultiplyVectorT Main 213.7 ns 0.05 ns 1.00
MultiplyVectorT PR 182.6 ns 0.27 ns 0.85

BDN_Artifacts.zip

cc @saucecontrol (agent_logs.txt). EgorBot manual: link.

@EgorBot
Copy link
Owner Author

EgorBot commented Mar 10, 2025

Benchmark results on linux_azure_cascadelake

BenchmarkDotNet v0.14.0, Ubuntu 24.04.2 LTS (Noble Numbat)
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 8 logical and 4 physical cores
  Job-LSMVEA : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX2
  Job-TUGWTL : .NET 10.0.0 (42.42.42.42424), X64 RyuJIT AVX2
EnvironmentVariables=DOTNET_EnableAVX512F=0
Method Toolchain Mean Error Ratio
Multiply128 Main 574.7 ns 0.21 ns 1.00
Multiply128 PR 508.6 ns 0.03 ns 0.88
Multiply256 Main 291.5 ns 0.05 ns 1.00
Multiply256 PR 256.8 ns 0.18 ns 0.88
MultiplyVectorT Main 292.7 ns 0.04 ns 1.00
MultiplyVectorT PR 255.1 ns 0.01 ns 0.87

BDN_Artifacts.zip

cc @saucecontrol (agent_logs.txt). EgorBot manual: link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant