GPU warmup disabled when no GPU is in use.
This commit is contained in:
1 parent
b9f2b08c78
commit
c11a886197
3 files changed
+29
-8
No files matched your search
@@ -118,10 +118,18 @@ private static ThreadLocal<object>? MersenneTesters;
|
|||||||
EnvironmentConfiguration.MinK = _cliArguments.MinK;
|
EnvironmentConfiguration.MinK = _cliArguments.MinK;
|
||||||
EnvironmentConfiguration.GpuBatchSize = Math.Max(1, _cliArguments.ScanBatchSize);
|
EnvironmentConfiguration.GpuBatchSize = Math.Max(1, _cliArguments.ScanBatchSize);
|
||||||
EnvironmentConfiguration.GpuRatio = _cliArguments.GpuRatio;
|
EnvironmentConfiguration.GpuRatio = _cliArguments.GpuRatio;
|
||||||
|
EnvironmentConfiguration.MersenneDevice = _cliArguments.MersenneDevice;
|
||||||
EnvironmentConfiguration.OrderDevice = _cliArguments.OrderDevice;
|
EnvironmentConfiguration.OrderDevice = _cliArguments.OrderDevice;
|
||||||
EnvironmentConfiguration.UsePow2GroupDivisors = _cliArguments.ByDivisorKIncrementMode == ByDivisorKIncrementMode.Pow2Groups;
|
EnvironmentConfiguration.UsePow2GroupDivisors = _cliArguments.ByDivisorKIncrementMode == ByDivisorKIncrementMode.Pow2Groups;
|
||||||
EnvironmentConfiguration.ByDivisorSpecialRange = _cliArguments.ByDivisorSpecialRange;
|
EnvironmentConfiguration.ByDivisorSpecialRange = _cliArguments.ByDivisorSpecialRange;
|
||||||
EnvironmentConfiguration.RollingAccelerators = Math.Min(Math.Min(PerfectNumberConstants.RollingAccelerators, gpuPrimeThreads), threadCount);
|
|
||||||
|
bool useGpu = _cliArguments.OrderDevice == ComputationDevice.Hybrid || _cliArguments.OrderDevice == ComputationDevice.Gpu ||
|
||||||
|
_cliArguments.MersenneDevice == ComputationDevice.Hybrid || _cliArguments.MersenneDevice == ComputationDevice.Gpu;
|
||||||
|
|
||||||
|
EnvironmentConfiguration.RollingAccelerators = useGpu
|
||||||
|
? Math.Min(Math.Min(PerfectNumberConstants.RollingAccelerators, gpuPrimeThreads), threadCount)
|
||||||
|
: 0;
|
||||||
|
|
||||||
EnvironmentConfiguration.Initialize();
|
EnvironmentConfiguration.Initialize();
|
||||||
|
|
||||||
// NttGpuMath.GpuTransformBackend = _cliArguments.NttBackend;
|
// NttGpuMath.GpuTransformBackend = _cliArguments.NttBackend;
|
||||||
@@ -137,8 +145,12 @@ private static ThreadLocal<object>? MersenneTesters;
|
|||||||
UnboundedTaskScheduler.ConfigureThreadCount(threadCount);
|
UnboundedTaskScheduler.ConfigureThreadCount(threadCount);
|
||||||
PrimeTester.GpuBatchSize = gpuPrimeBatch;
|
PrimeTester.GpuBatchSize = gpuPrimeBatch;
|
||||||
GpuPrimeWorkLimiter.SetLimit(gpuPrimeThreads);
|
GpuPrimeWorkLimiter.SetLimit(gpuPrimeThreads);
|
||||||
Console.WriteLine("Warming up GPU kernels");
|
if (useGpu)
|
||||||
PrimeTester.WarmUpGpuKernels(EnvironmentConfiguration.RollingAccelerators);
|
{
|
||||||
|
Console.WriteLine("Warming up GPU kernels");
|
||||||
|
PrimeTester.WarmUpGpuKernels(EnvironmentConfiguration.RollingAccelerators);
|
||||||
|
}
|
||||||
|
|
||||||
// PrimeTester.WarmUpGpuKernels(gpuPrimeThreads >> 4);
|
// PrimeTester.WarmUpGpuKernels(gpuPrimeThreads >> 4);
|
||||||
Console.WriteLine("Starting up threads...");
|
Console.WriteLine("Starting up threads...");
|
||||||
_ = UnboundedTaskScheduler.Instance;
|
_ = UnboundedTaskScheduler.Instance;
|
||||||
|
|||||||
@@ -33,12 +33,20 @@ public sealed class DivisorCycleCache
|
|||||||
|
|
||||||
private DivisorCycleCache(int divisorCyclesBatchSize)
|
private DivisorCycleCache(int divisorCyclesBatchSize)
|
||||||
{
|
{
|
||||||
|
bool useGpu = EnvironmentConfiguration.MersenneDevice == ComputationDevice.Hybrid ||
|
||||||
|
EnvironmentConfiguration.MersenneDevice == ComputationDevice.Gpu ||
|
||||||
|
!EnvironmentConfiguration.UseCpuOrder;
|
||||||
|
|
||||||
_divisorCyclesBatchSize = Math.Max(1, divisorCyclesBatchSize);
|
_divisorCyclesBatchSize = Math.Max(1, divisorCyclesBatchSize);
|
||||||
var acceleratorIndex = AcceleratorPool.Shared.Rent();
|
if (useGpu)
|
||||||
_acceleratorIndex = acceleratorIndex;
|
{
|
||||||
Accelerator accelerator = AcceleratorPool.Shared.Accelerators[acceleratorIndex];
|
var acceleratorIndex = AcceleratorPool.Shared.Rent();
|
||||||
_accelerator = accelerator;
|
_acceleratorIndex = acceleratorIndex;
|
||||||
_gpuKernel = LoadKernel(accelerator);
|
Accelerator accelerator = AcceleratorPool.Shared.Accelerators[acceleratorIndex];
|
||||||
|
_accelerator = accelerator;
|
||||||
|
_gpuKernel = LoadKernel(accelerator);
|
||||||
|
}
|
||||||
|
|
||||||
_snapshot = MersenneDivisorCyclesCpu.Shared.ExportSmallCyclesSnapshot();
|
_snapshot = MersenneDivisorCyclesCpu.Shared.ExportSmallCyclesSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public static class EnvironmentConfiguration
|
|||||||
public static ulong DivisorLimit = ulong.MaxValue;
|
public static ulong DivisorLimit = ulong.MaxValue;
|
||||||
public static int GpuBatchSize = GpuConstants.ScanBatchSize;
|
public static int GpuBatchSize = GpuConstants.ScanBatchSize;
|
||||||
public static int GpuRatio = PerfectNumberConstants.GpuRatio;
|
public static int GpuRatio = PerfectNumberConstants.GpuRatio;
|
||||||
|
public static ComputationDevice MersenneDevice = ComputationDevice.Cpu;
|
||||||
public static BigInteger MinK = BigInteger.One;
|
public static BigInteger MinK = BigInteger.One;
|
||||||
public static ComputationDevice OrderDevice = ComputationDevice.Cpu;
|
public static ComputationDevice OrderDevice = ComputationDevice.Cpu;
|
||||||
public static int RollingAccelerators = PerfectNumberConstants.RollingAccelerators;
|
public static int RollingAccelerators = PerfectNumberConstants.RollingAccelerators;
|
||||||
|
|||||||
Reference in new issue
Block a user