New GPU benchmarks added

This commit is contained in:
Marek Lemańczyk committed 2025-09-30 19:24:46 +02:00
1 parent 7fc9f7320d
commit ddca13892b
1 file changed
+35
@@ -3,6 +3,7 @@ using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using PerfectNumbers.Core;
using PerfectNumbers.Core.Gpu;
namespace EvenPerfectBitScanner.Benchmarks;
@@ -43,6 +44,40 @@ public class MulMod64Benchmarks
return Input.Left.MulMod64(Input.Right, Input.Modulus);
}
/// <summary>
/// Calls the UInt128-based <see cref="ULongExtensions.MulMod(ulong, ulong, ulong)"/> helper, which stayed between
/// ?.?? ns and ?.?? ns for CrossWordBlend, MixedBitPattern, PrimeSizedModulus, SparseOperands, and ZeroOperands inputs,
/// and ?.?? ns for NearFullRange, making it the fastest option across every distribution.
/// </summary>
/// <remarks>
/// Observed means: CrossWordBlend ?.??? ns (?.??×), MixedBitPattern ?.??? ns, NearFullRange ?.??? ns, PrimeSizedModulus
/// ?.??? ns, SparseOperands ?.??? ns, ZeroOperands ?.??? ns.
/// </remarks>
[Benchmark]
public ulong GpuCompatibleMulModExtension()
{
GpuUInt128 gpuUInt128 = new(Input.Left);
gpuUInt128.MulMod(Input.Right, Input.Modulus);
return gpuUInt128.Low;
}
/// <summary>
/// Calls the UInt128-based <see cref="ULongExtensions.MulModSimplified(ulong, ulong, ulong)"/> helper, which stayed between
/// ?.?? ns and ?.?? ns for CrossWordBlend, MixedBitPattern, PrimeSizedModulus, SparseOperands, and ZeroOperands inputs,
/// and ?.?? ns for NearFullRange, making it the fastest option across every distribution.
/// </summary>
/// <remarks>
/// Observed means: CrossWordBlend ?.??? ns (?.??×), MixedBitPattern ?.??? ns, NearFullRange ?.??? ns, PrimeSizedModulus
/// ?.??? ns, SparseOperands ?.??? ns, ZeroOperands ?.??? ns.
/// </remarks>
[Benchmark]
public ulong GpuCompatibleMulModSimplifiedExtension()
{
GpuUInt128 gpuUInt128 = new(Input.Left);
gpuUInt128.MulModSimplified(Input.Right, Input.Modulus);
return gpuUInt128.Low;
}
/// <summary>
/// Uses manual UInt128 multiplication in the benchmark method; dense operands cost 23.6–33.6 ns (6.2–8.9× slower than
/// baseline), while SparseOperands and ZeroOperands remain inexpensive at 3.58–3.87 ns.