Restored the Dictionary parameter instead of arrays
This commit is contained in:
1 parent
8dc7751084
commit
ea11db6d0f
1 file changed
+24
-24
@@ -13,18 +13,18 @@ internal static partial class PrimeOrderCalculator
|
|||||||
|
|
||||||
private const int GpuSmallPrimeFactorSlots = 64;
|
private const int GpuSmallPrimeFactorSlots = 64;
|
||||||
|
|
||||||
private static bool TryPopulateSmallPrimeFactorsGpu(ulong value, uint limit, Span<ulong> primeBuffer, Span<int> exponentBuffer, out int factorCount, out ulong remaining)
|
private static bool TryPopulateSmallPrimeFactorsGpu(ulong value, uint limit, Dictionary<ulong, int> counts, out int factorCount, out ulong remaining)
|
||||||
{
|
{
|
||||||
// primeBufferArray = ThreadStaticPools.UlongPool.Rent(GpuSmallPrimeFactorSlots);
|
var primeBufferArray = ThreadStaticPools.UlongPool.Rent(GpuSmallPrimeFactorSlots);
|
||||||
// exponentBufferArray = ThreadStaticPools.IntPool.Rent(GpuSmallPrimeFactorSlots);
|
var exponentBufferArray = ThreadStaticPools.IntPool.Rent(GpuSmallPrimeFactorSlots);
|
||||||
// Span<ulong> primeBuffer = primeBufferArray.AsSpan(0, GpuSmallPrimeFactorSlots);
|
Span<ulong> primeBuffer = primeBufferArray.AsSpan(0, GpuSmallPrimeFactorSlots);
|
||||||
// Span<int> exponentBuffer = exponentBufferArray.AsSpan(0, GpuSmallPrimeFactorSlots);
|
Span<int> exponentBuffer = exponentBufferArray.AsSpan(0, GpuSmallPrimeFactorSlots);
|
||||||
// primeBuffer.Clear();
|
// primeBuffer.Clear();
|
||||||
// exponentBuffer.Clear();
|
// exponentBuffer.Clear();
|
||||||
remaining = value;
|
remaining = value;
|
||||||
|
|
||||||
// try
|
try
|
||||||
// {
|
{
|
||||||
var lease = GpuKernelPool.GetKernel(useGpuOrder: true);
|
var lease = GpuKernelPool.GetKernel(useGpuOrder: true);
|
||||||
var execution = lease.EnterExecutionScope();
|
var execution = lease.EnterExecutionScope();
|
||||||
try
|
try
|
||||||
@@ -64,18 +64,18 @@ internal static partial class PrimeOrderCalculator
|
|||||||
|
|
||||||
scratch.RemainingSlot.View.CopyToCPU(ref remaining, 1);
|
scratch.RemainingSlot.View.CopyToCPU(ref remaining, 1);
|
||||||
|
|
||||||
// for (int i = 0; i < factorCount; i++)
|
for (int i = 0; i < factorCount; i++)
|
||||||
// {
|
{
|
||||||
// ulong primeValue = primeBuffer[i];
|
ulong primeValue = primeBuffer[i];
|
||||||
// int exponent = exponentBuffer[i];
|
int exponent = exponentBuffer[i];
|
||||||
// // This will never happen in production code
|
// This will never happen in production code
|
||||||
// // if (primeValue == 0UL || exponent == 0)
|
// if (primeValue == 0UL || exponent == 0)
|
||||||
// // {
|
// {
|
||||||
// // continue;
|
// continue;
|
||||||
// // }
|
// }
|
||||||
|
|
||||||
// counts[primeValue] = exponent;
|
counts.Add(primeValue, exponent);
|
||||||
// }
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -84,11 +84,11 @@ internal static partial class PrimeOrderCalculator
|
|||||||
execution.Dispose();
|
execution.Dispose();
|
||||||
lease.Dispose();
|
lease.Dispose();
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
// finally
|
finally
|
||||||
// {
|
{
|
||||||
// ThreadStaticPools.UlongPool.Return(primeBufferArray);
|
ThreadStaticPools.UlongPool.Return(primeBufferArray);
|
||||||
// ThreadStaticPools.IntPool.Return(exponentBufferArray);
|
ThreadStaticPools.IntPool.Return(exponentBufferArray);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user