Cache native modulo bit masks
This commit is contained in:
1 parent
93a82f756f
commit
8d44b75ca5
3 files changed
+187
No files matched your search
@@ -211,6 +211,22 @@ public static class ULongExtensions
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong MulMod64(this ulong a, ulong b, ulong modulus) => (ulong)(UInt128)(((a % modulus) * (b % modulus)) % modulus);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong MulMod64GpuCompatible(this ulong a, ulong b, ulong modulus)
|
||||
{
|
||||
GpuUInt128 state = new(a % modulus);
|
||||
state.MulMod(b, modulus);
|
||||
return state.Low;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong MulMod64GpuCompatibleDeferred(this ulong a, ulong b, ulong modulus)
|
||||
{
|
||||
GpuUInt128 state = new(a);
|
||||
state.MulModWithNativeModulo(b, modulus);
|
||||
return state.Low;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ulong MontgomeryMultiply(this ulong a, ulong b, ulong modulus, ulong nPrime)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user