Add TODOs for divisor metadata caching

This commit is contained in:
Marek Lemańczyk committed 2025-10-01 22:52:21 +02:00
1 parent 513fc7acb0
commit 36d316d19c
53 files changed
+929 -393

No files matched your search

@@ -30,8 +30,13 @@ public class Mul64Benchmarks
public static IEnumerable<Mul64Input> GetInputs() => Inputs;
/// <summary>
/// Mul64 layout that keeps the high-word accumulation in locals.
/// Mul64 layout that keeps the high-word accumulation in locals; measured 1.49–1.57 ns across all operand mixes, making it
/// the fastest CPU layout we profiled.
/// </summary>
/// <remarks>
/// Observed means: AllBitsSet 1.568 ns, HighWordOnly 1.495 ns, InterleavedHighLow 1.526 ns,
/// LowWordMax 1.506 ns, ShiftHeavyMixed 1.481 ns, TinyOperands 1.503 ns.
/// </remarks>
[Benchmark(Baseline = true)]
public UInt128 HighWordAccumulatedInLocals()
{
@@ -39,8 +44,13 @@ public class Mul64Benchmarks
}
/// <summary>
/// Mul64 layout that folds the high-word expression into a single return value.
/// Mul64 layout that folds the high-word expression into a single return value; costs roughly 3–5% extra with 1.54–1.58 ns
/// runtimes depending on the operand mix.
/// </summary>
/// <remarks>
/// Observed means: AllBitsSet 1.583 ns, HighWordOnly 1.542 ns, InterleavedHighLow 1.575 ns,
/// LowWordMax 1.581 ns, ShiftHeavyMixed 1.562 ns, TinyOperands 1.546 ns.
/// </remarks>
[Benchmark]
public UInt128 FoldedHighReturnValue()
{
@@ -48,8 +58,13 @@ public class Mul64Benchmarks
}
/// <summary>
/// Mul64 layout shaped for the GPU helper to keep the cross products in registers.
/// Mul64 layout shaped for the GPU helper to keep the cross products in registers; roughly 2.35× slower than the baseline at
/// 3.68–3.72 ns, but useful when mirroring GPU arithmetic on the CPU.
/// </summary>
/// <remarks>
/// Observed means: AllBitsSet 3.682 ns, HighWordOnly 3.679 ns, InterleavedHighLow 3.719 ns,
/// LowWordMax 3.684 ns, ShiftHeavyMixed 3.707 ns, TinyOperands 3.683 ns.
/// </remarks>
[Benchmark]
public UInt128 GpuFriendlyLayout()
{
@@ -57,8 +72,13 @@ public class Mul64Benchmarks
}
/// <summary>
/// Reference implementation that multiplies with BigInteger to expose the full 256-bit product.
/// Reference implementation that multiplies with <see cref="BigInteger"/> to expose the full 256-bit product; handy for
/// validation but 22–57× slower at 34–87 ns depending on the operand distribution.
/// </summary>
/// <remarks>
/// Observed means: AllBitsSet 86.087 ns, HighWordOnly 78.860 ns, InterleavedHighLow 87.367 ns,
/// LowWordMax 74.418 ns, ShiftHeavyMixed 81.020 ns, TinyOperands 34.286 ns.
/// </remarks>
[Benchmark]
public UInt128 BigIntegerReference()
{