Inline GPU capability checks for pow2 heuristics

This commit is contained in:
Marek Lemańczyk committed 2025-10-04 22:40:23 +02:00
1 parent 75586d07b8
commit b2a7190c14
2 files changed
+2 -13

No files matched your search

@@ -73,7 +73,7 @@ internal static class PrimeOrderGpuHeuristics
PrimeOrderGpuCapability capability = s_capability; PrimeOrderGpuCapability capability = s_capability;
if (!SupportsPrime(prime, capability)) if (prime.GetBitLength() > capability.ModulusBits)
{ {
overflowRegistry[prime] = 0; overflowRegistry[prime] = 0;
return GpuPow2ModStatus.Overflow; return GpuPow2ModStatus.Overflow;
@@ -81,7 +81,7 @@ internal static class PrimeOrderGpuHeuristics
for (int i = 0; i < exponents.Length; i++) for (int i = 0; i < exponents.Length; i++)
{ {
if (!SupportsExponent(exponents[i], capability)) if (exponents[i].GetBitLength() > capability.ExponentBits)
{ {
return GpuPow2ModStatus.Overflow; return GpuPow2ModStatus.Overflow;
} }
@@ -91,16 +91,6 @@ internal static class PrimeOrderGpuHeuristics
return computed ? GpuPow2ModStatus.Success : GpuPow2ModStatus.Unavailable; return computed ? GpuPow2ModStatus.Success : GpuPow2ModStatus.Unavailable;
} }
private static bool SupportsPrime(ulong prime, PrimeOrderGpuCapability capability)
{
return prime.GetBitLength() <= capability.ModulusBits;
}
private static bool SupportsExponent(ulong exponent, PrimeOrderGpuCapability capability)
{
return exponent.GetBitLength() <= capability.ExponentBits;
}
private static bool TryComputeOnGpu(ReadOnlySpan<ulong> exponents, ulong prime, Span<ulong> results) private static bool TryComputeOnGpu(ReadOnlySpan<ulong> exponents, ulong prime, Span<ulong> results)
{ {
try try
-1
View File
@@ -1,3 +1,2 @@
- Inline the PrimeOrderGpuHeuristics capability checks at each call site and delete the temporary SupportsPrime/SupportsExponent helpers once the overflow gating is stable.
- Swap PrimeOrderGpuHeuristics.Pow2ModCpu for the existing Pow2MontgomeryModWindowed helper and plan the same windowed ladder for the GPU kernel implementation. - Swap PrimeOrderGpuHeuristics.Pow2ModCpu for the existing Pow2MontgomeryModWindowed helper and plan the same windowed ladder for the GPU kernel implementation.
- Extend the GPU numeric type probe to cover proposed custom types such as GpuUInt256 and GpuUInt512 once their definitions are available so we can plan the wide-order heuristics on the device. - Extend the GPU numeric type probe to cover proposed custom types such as GpuUInt256 and GpuUInt512 once their definitions are available so we can plan the wide-order heuristics on the device.