Refactor GPU-compatible Mul64 handling
This commit is contained in:
1 parent
b677e6cdec
commit
f63254f0f0
4 files changed
+191
-12
No files matched your search
@@ -155,8 +155,8 @@ public static class ULongExtensions
|
||||
step3 = (step3 << 1) % 3UL;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static UInt128 Mul64(this ulong a, ulong b) => ((UInt128)a.MulHigh(b) << 64) | (UInt128)(a * b);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static UInt128 Mul64(this ulong a, ulong b) => ((UInt128)a.MulHigh(b) << 64) | (UInt128)(a * b);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong MulHigh(this ulong x, ulong y)
|
||||
@@ -174,6 +174,14 @@ public static class ULongExtensions
|
||||
return result;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong MulHighGpuCompatible(this ulong x, ulong y)
|
||||
{
|
||||
GpuUInt128 product = new(x);
|
||||
product.Mul64(new GpuUInt128(y));
|
||||
return product.High;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong ModPow64(this ulong value, ulong exponent, ulong modulus)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user