Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aff66f0c8f | ||
|
|
411310cf40 | ||
|
|
9ed467b4b0 | ||
|
|
241a147d70 | ||
|
|
db7fe14208 | ||
|
|
0eb511aaff | ||
|
|
fea95509a7 | ||
|
|
22cc8f368f | ||
|
|
b453d46c5f | ||
|
|
43b267da8c | ||
|
|
467cf0293a | ||
|
|
f1eaab8582 | ||
|
|
b31aab4d89 | ||
|
|
45f21efa56 | ||
|
|
5c77d6c3af | ||
|
|
a6deb7bfba | ||
|
|
46801737dc | ||
|
|
e30c83584b | ||
|
|
17763033e1 | ||
|
|
e61d166eb1 | ||
|
|
a4aead2802 |
No files matched your search
Vendored
+10
-10
@@ -20,7 +20,7 @@
|
|||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "Build Debug",
|
"preLaunchTask": "Build Debug",
|
||||||
"program": "${workspaceFolder}/${input:projectName}/bin/Debug/net8.0/${input:projectName}.dll",
|
"program": "${workspaceFolder}/${input:projectName}/bin/Debug/net9.0/${input:projectName}.dll",
|
||||||
"args": [
|
"args": [
|
||||||
"--increment=add",
|
"--increment=add",
|
||||||
"--mersenne=bydivisor",
|
"--mersenne=bydivisor",
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"noDebug": true,
|
"noDebug": true,
|
||||||
"preLaunchTask": "Build Release",
|
"preLaunchTask": "Build Release",
|
||||||
"program": "${workspaceFolder}/${input:projectName}/bin/Release/net8.0/${input:projectName}.dll",
|
"program": "${workspaceFolder}/${input:projectName}/bin/Release/net9.0/${input:projectName}.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"noDebug": true,
|
"noDebug": true,
|
||||||
"preLaunchTask": "Build EvenPerfectBitScanner Release",
|
"preLaunchTask": "Build EvenPerfectBitScanner Release",
|
||||||
"program": "${workspaceFolder}/EvenPerfectBitScanner/bin/Release/net8.0/EvenPerfectBitScanner.dll",
|
"program": "${workspaceFolder}/EvenPerfectBitScanner/bin/Release/net9.0/EvenPerfectBitScanner.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"noDebug": true,
|
"noDebug": true,
|
||||||
"preLaunchTask": "Build BuildDivisorTransitions Release",
|
"preLaunchTask": "Build BuildDivisorTransitions Release",
|
||||||
"program": "${workspaceFolder}/BuildDivisorTransitions/bin/Release/net8.0/BuildDivisorTransitions.dll",
|
"program": "${workspaceFolder}/BuildDivisorTransitions/bin/Release/net9.0/BuildDivisorTransitions.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "Build BuildDivisorTransitions Debug",
|
"preLaunchTask": "Build BuildDivisorTransitions Debug",
|
||||||
"program": "${workspaceFolder}/BuildDivisorTransitions/bin/Debug/net8.0/BuildDivisorTransitions.dll",
|
"program": "${workspaceFolder}/BuildDivisorTransitions/bin/Debug/net9.0/BuildDivisorTransitions.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
@@ -102,7 +102,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"noDebug": true,
|
"noDebug": true,
|
||||||
"preLaunchTask": "Build EvenPerfectBitScanner.ResultsParser Release",
|
"preLaunchTask": "Build EvenPerfectBitScanner.ResultsParser Release",
|
||||||
"program": "${workspaceFolder}/EvenPerfectBitScanner.ResultsParser/bin/Release/net8.0/EvenPerfectBitScanner.ResultsParser.dll",
|
"program": "${workspaceFolder}/EvenPerfectBitScanner.ResultsParser/bin/Release/net9.0/EvenPerfectBitScanner.ResultsParser.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "Build EvenPerfectBitScanner Debug",
|
"preLaunchTask": "Build EvenPerfectBitScanner Debug",
|
||||||
"program": "${workspaceFolder}/EvenPerfectBitScanner/bin/Debug/net8.0/EvenPerfectBitScanner.dll",
|
"program": "${workspaceFolder}/EvenPerfectBitScanner/bin/Debug/net9.0/EvenPerfectBitScanner.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
@@ -128,7 +128,7 @@
|
|||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "Build EvenPerfectBitScanner.ResultsParser Debug",
|
"preLaunchTask": "Build EvenPerfectBitScanner.ResultsParser Debug",
|
||||||
"program": "${workspaceFolder}/EvenPerfectBitScanner.ResultsParser/bin/Debug/net8.0/EvenPerfectBitScanner.ResultsParser.dll",
|
"program": "${workspaceFolder}/EvenPerfectBitScanner.ResultsParser/bin/Debug/net9.0/EvenPerfectBitScanner.ResultsParser.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
@@ -142,7 +142,7 @@
|
|||||||
"request": "launch",
|
"request": "launch",
|
||||||
"noDebug": true,
|
"noDebug": true,
|
||||||
"preLaunchTask": "Build EvenPerfectBitScanner.Benchmarks Release",
|
"preLaunchTask": "Build EvenPerfectBitScanner.Benchmarks Release",
|
||||||
"program": "${workspaceFolder}/EvenPerfectBitScanner.Benchmarks/bin/Release/net8.0/EvenPerfectBitScanner.Benchmarks.dll",
|
"program": "${workspaceFolder}/EvenPerfectBitScanner.Benchmarks/bin/Release/net9.0/EvenPerfectBitScanner.Benchmarks.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "Build EvenPerfectBitScanner.Benchmarks Debug",
|
"preLaunchTask": "Build EvenPerfectBitScanner.Benchmarks Debug",
|
||||||
"program": "${workspaceFolder}/EvenPerfectBitScanner.Benchmarks/bin/Debug/net8.0/EvenPerfectBitScanner.Benchmarks.dll",
|
"program": "${workspaceFolder}/EvenPerfectBitScanner.Benchmarks/bin/Debug/net9.0/EvenPerfectBitScanner.Benchmarks.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
|
|||||||
Vendored
+15
-15
@@ -11,7 +11,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Debug",
|
"Debug",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0",
|
"net9.0",
|
||||||
"/p:DeviceDependentGenerator_CopyGeneratedToProjectDir=true"
|
"/p:DeviceDependentGenerator_CopyGeneratedToProjectDir=true"
|
||||||
],
|
],
|
||||||
"group": {
|
"group": {
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Release",
|
"Release",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0",
|
"net9.0",
|
||||||
"/p:DeviceDependentGenerator_CopyGeneratedToProjectDir=true"
|
"/p:DeviceDependentGenerator_CopyGeneratedToProjectDir=true"
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Debug",
|
"Debug",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Release",
|
"Release",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Debug",
|
"Debug",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Release",
|
"Release",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Debug",
|
"Debug",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Release",
|
"Release",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
@@ -137,7 +137,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Release",
|
"Release",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
},
|
},
|
||||||
@@ -152,7 +152,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Release",
|
"Release",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
},
|
},
|
||||||
@@ -167,7 +167,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Release",
|
"Release",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
},
|
},
|
||||||
@@ -180,7 +180,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Release",
|
"Release",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
},
|
},
|
||||||
@@ -194,7 +194,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Debug",
|
"Debug",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
@@ -209,7 +209,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Release",
|
"Release",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
@@ -225,7 +225,7 @@
|
|||||||
"--configuration",
|
"--configuration",
|
||||||
"Release",
|
"Release",
|
||||||
"--framework",
|
"--framework",
|
||||||
"net8.0"
|
"net9.0"
|
||||||
],
|
],
|
||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Open.Numeric.Primes" Version="4.0.4" />
|
<PackageReference Include="Open.Numeric.Primes" Version="4.0.4" />
|
||||||
|
<PackageReference Include="Spectre.Console" Version="0.54.1-alpha.0.37" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Open.Numeric.Primes;
|
using Open.Numeric.Primes;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace EvenPerfectBitScanner.ResultsParser;
|
namespace EvenPerfectBitScanner.ResultsParser;
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ private const string DefaultHeader = "p,divisor,searchedMersenne,detailedCheck,p
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine($"Processing failed: {exception.Message}");
|
AnsiConsole.WriteException(exception);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
|||||||
@@ -5,18 +5,6 @@ using PerfectNumbers.Core.Gpu;
|
|||||||
|
|
||||||
namespace EvenPerfectBitScanner;
|
namespace EvenPerfectBitScanner;
|
||||||
|
|
||||||
internal enum ByDivisorKIncrementMode
|
|
||||||
{
|
|
||||||
Sequential,
|
|
||||||
Pow2Groups,
|
|
||||||
Predictive,
|
|
||||||
Percentile,
|
|
||||||
Additive,
|
|
||||||
TopDown,
|
|
||||||
BitContradiction,
|
|
||||||
BitTree,
|
|
||||||
}
|
|
||||||
|
|
||||||
internal readonly struct CliArguments
|
internal readonly struct CliArguments
|
||||||
{
|
{
|
||||||
private const string DefaultCyclesPath = "divisor_cycles.bin";
|
private const string DefaultCyclesPath = "divisor_cycles.bin";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
<PackageReference Include="Open.Numeric" Version="3.0.1" />
|
<PackageReference Include="Open.Numeric" Version="3.0.1" />
|
||||||
<PackageReference Include="Open.Numeric.Primes" Version="4.0.4" />
|
<PackageReference Include="Open.Numeric.Primes" Version="4.0.4" />
|
||||||
<PackageReference Include="Plotly.NET" Version="3.0.1" />
|
<PackageReference Include="Plotly.NET" Version="3.0.1" />
|
||||||
|
<PackageReference Include="Spectre.Console" Version="0.54.1-alpha.0.37" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="MLModel1">
|
<ItemGroup Label="MLModel1">
|
||||||
<None Include="MLModel1.mlnet">
|
<None Include="MLModel1.mlnet">
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace EvenPerfectBitScanner;
|
|||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
// private static ThreadLocal<PrimeTester> PrimeTesters = null!;
|
// private static ThreadLocal<PrimeTester> PrimeTesters = null!;
|
||||||
private static ThreadLocal<object>? MersenneTesters;
|
private static ThreadLocal<object>? MersenneTesters;
|
||||||
private const ulong InitialP = PerfectNumberConstants.BiggestKnownEvenPerfectP;
|
private const ulong InitialP = PerfectNumberConstants.BiggestKnownEvenPerfectP;
|
||||||
private static MersenneNumberDivisorGpuTester? _divisorTester;
|
private static MersenneNumberDivisorGpuTester? _divisorTester;
|
||||||
private static UInt128 _divisor;
|
private static UInt128 _divisor;
|
||||||
@@ -111,26 +111,31 @@ private static ThreadLocal<object>? MersenneTesters;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Initializing");
|
Console.WriteLine("Initializing");
|
||||||
int gpuPrimeThreads = Math.Max(1, _cliArguments.GpuPrimeThreads);
|
|
||||||
int threadCount = Math.Max(1, _cliArguments.ThreadCount);
|
|
||||||
|
|
||||||
EnvironmentConfiguration.MinK = _cliArguments.MinK;
|
EnvironmentConfiguration.ByDivisorKIncrementMode = _cliArguments.ByDivisorKIncrementMode;
|
||||||
EnvironmentConfiguration.GpuBatchSize = Math.Max(1, _cliArguments.ScanBatchSize);
|
EnvironmentConfiguration.ByDivisorSpecialRange = _cliArguments.ByDivisorSpecialRange;
|
||||||
EnvironmentConfiguration.GpuRatio = _cliArguments.GpuRatio;
|
EnvironmentConfiguration.CalculationMethod =
|
||||||
EnvironmentConfiguration.MersenneDevice = _cliArguments.MersenneDevice;
|
_cliArguments.UseByDivisor ? CalculationMethod.ByDivisor
|
||||||
EnvironmentConfiguration.OrderDevice = _cliArguments.OrderDevice;
|
: _cliArguments.UseDivisor ? CalculationMethod.Divisor
|
||||||
EnvironmentConfiguration.UsePow2GroupDivisors = _cliArguments.ByDivisorKIncrementMode == ByDivisorKIncrementMode.Pow2Groups;
|
: _cliArguments.UseResidue ? CalculationMethod.Residue
|
||||||
EnvironmentConfiguration.ByDivisorSpecialRange = _cliArguments.ByDivisorSpecialRange;
|
: _cliArguments.UseLucas ? CalculationMethod.LucasLehmer
|
||||||
|
: _cliArguments.KernelType == GpuKernelType.Pow2Mod ? CalculationMethod.Pow2Mod
|
||||||
|
: CalculationMethod.Incremental;
|
||||||
|
EnvironmentConfiguration.GpuBatchSize = Math.Max(1, _cliArguments.ScanBatchSize);
|
||||||
|
EnvironmentConfiguration.GpuPrimeThreads = Math.Max(1, _cliArguments.GpuPrimeThreads * PerfectNumberConstants.ThreadsByAccelerator);
|
||||||
|
EnvironmentConfiguration.GpuRatio = _cliArguments.GpuRatio;
|
||||||
|
EnvironmentConfiguration.MersenneDevice = _cliArguments.MersenneDevice;
|
||||||
|
EnvironmentConfiguration.MinK = _cliArguments.MinK;
|
||||||
|
EnvironmentConfiguration.OrderDevice = _cliArguments.OrderDevice;
|
||||||
|
EnvironmentConfiguration.ThreadCount = Math.Max(1, _cliArguments.ThreadCount);
|
||||||
|
|
||||||
bool useGpu = _cliArguments.OrderDevice == ComputationDevice.Hybrid || _cliArguments.OrderDevice == ComputationDevice.Gpu ||
|
EnvironmentConfiguration.Initialize();
|
||||||
_cliArguments.MersenneDevice == ComputationDevice.Hybrid || _cliArguments.MersenneDevice == ComputationDevice.Gpu;
|
|
||||||
|
|
||||||
EnvironmentConfiguration.RollingAccelerators = useGpu
|
PrimeOrderCalculatorAccelerator.SkipOrderTablesAndKernels =
|
||||||
? Math.Min(Math.Min(PerfectNumberConstants.RollingAccelerators, gpuPrimeThreads), threadCount)
|
EnvironmentConfiguration.MersenneDevice == ComputationDevice.Gpu &&
|
||||||
: 0;
|
EnvironmentConfiguration.CalculationMethod == CalculationMethod.ByDivisor &&
|
||||||
|
EnvironmentConfiguration.ByDivisorKIncrementMode == ByDivisorKIncrementMode.BitContradiction;
|
||||||
EnvironmentConfiguration.Initialize();
|
|
||||||
|
|
||||||
// NttGpuMath.GpuTransformBackend = _cliArguments.NttBackend;
|
// NttGpuMath.GpuTransformBackend = _cliArguments.NttBackend;
|
||||||
// NttGpuMath.ReductionMode = _cliArguments.ModReductionMode;
|
// NttGpuMath.ReductionMode = _cliArguments.ModReductionMode;
|
||||||
@@ -140,6 +145,9 @@ private static ThreadLocal<object>? MersenneTesters;
|
|||||||
ulong remainder = currentP % 6UL;
|
ulong remainder = currentP % 6UL;
|
||||||
bool startPrimeProvided = _cliArguments.StartPrimeProvided;
|
bool startPrimeProvided = _cliArguments.StartPrimeProvided;
|
||||||
int gpuPrimeBatch = Math.Max(1, _cliArguments.GpuPrimeBatch);
|
int gpuPrimeBatch = Math.Max(1, _cliArguments.GpuPrimeBatch);
|
||||||
|
bool useGpu = EnvironmentConfiguration.UseGpu;
|
||||||
|
int threadCount = EnvironmentConfiguration.ThreadCount;
|
||||||
|
int gpuPrimeThreads = EnvironmentConfiguration.GpuPrimeThreads;
|
||||||
// int gpuPrimeThreads = SharedGpuContext.Device.MaxNumThreads;
|
// int gpuPrimeThreads = SharedGpuContext.Device.MaxNumThreads;
|
||||||
Console.WriteLine("Setting up parameters");
|
Console.WriteLine("Setting up parameters");
|
||||||
UnboundedTaskScheduler.ConfigureThreadCount(threadCount);
|
UnboundedTaskScheduler.ConfigureThreadCount(threadCount);
|
||||||
@@ -148,7 +156,16 @@ private static ThreadLocal<object>? MersenneTesters;
|
|||||||
if (useGpu)
|
if (useGpu)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Warming up GPU kernels");
|
Console.WriteLine("Warming up GPU kernels");
|
||||||
PrimeTester.WarmUpGpuKernels(EnvironmentConfiguration.RollingAccelerators);
|
if (_cliArguments.UseByDivisor &&
|
||||||
|
_cliArguments.ByDivisorKIncrementMode == ByDivisorKIncrementMode.BitContradiction &&
|
||||||
|
_cliArguments.MersenneDevice == ComputationDevice.Gpu)
|
||||||
|
{
|
||||||
|
PrimeTester.WarmUpGpuKernelsForBitContradiction(EnvironmentConfiguration.RollingAccelerators);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PrimeTester.WarmUpGpuKernels(EnvironmentConfiguration.RollingAccelerators);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrimeTester.WarmUpGpuKernels(gpuPrimeThreads >> 4);
|
// PrimeTester.WarmUpGpuKernels(gpuPrimeThreads >> 4);
|
||||||
@@ -328,11 +345,6 @@ private static ThreadLocal<object>? MersenneTesters;
|
|||||||
}
|
}
|
||||||
else if (useByDivisor)
|
else if (useByDivisor)
|
||||||
{
|
{
|
||||||
if (mersenneOnGpu)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException("--mersenne-device=gpu is not supported for --mersenne=bydivisor on this execution path.");
|
|
||||||
}
|
|
||||||
|
|
||||||
ByDivisorKIncrementMode kIncrementMode = _cliArguments.ByDivisorKIncrementMode;
|
ByDivisorKIncrementMode kIncrementMode = _cliArguments.ByDivisorKIncrementMode;
|
||||||
if (EnvironmentConfiguration.UseCpuOrder)
|
if (EnvironmentConfiguration.UseCpuOrder)
|
||||||
{
|
{
|
||||||
@@ -591,16 +603,16 @@ private static ThreadLocal<object>? MersenneTesters;
|
|||||||
EnvironmentConfiguration.ByDivisorPow2Minus1Repository ??= Pow2Minus1StateRepository.Open(Path.Combine(checksDir, "pow2minus1.faster"), pow2MinusLmdb, checksDir);
|
EnvironmentConfiguration.ByDivisorPow2Minus1Repository ??= Pow2Minus1StateRepository.Open(Path.Combine(checksDir, "pow2minus1.faster"), pow2MinusLmdb, checksDir);
|
||||||
EnvironmentConfiguration.BitContradictionStateRepository ??= BitContradictionStateRepository.Open(checksDir);
|
EnvironmentConfiguration.BitContradictionStateRepository ??= BitContradictionStateRepository.Open(checksDir);
|
||||||
|
|
||||||
if (kIncrementMode == ByDivisorKIncrementMode.Pow2Groups)
|
if (kIncrementMode == ByDivisorKIncrementMode.Pow2Groups)
|
||||||
{
|
{
|
||||||
EnvironmentConfiguration.ByDivisorSpecialStateRepository = KStateRepository.Open(checksDir, "pow2groups.special.kstate.faster", Path.Combine(checksDir, "pow2groups.special.kstate.lmdb"), checksDir);
|
EnvironmentConfiguration.ByDivisorSpecialStateRepository = KStateRepository.Open(checksDir, "pow2groups.special.kstate.faster", Path.Combine(checksDir, "pow2groups.special.kstate.lmdb"), checksDir);
|
||||||
EnvironmentConfiguration.ByDivisorGroupsStateRepository = KStateRepository.Open(checksDir, "pow2groups.groups.kstate.faster", Path.Combine(checksDir, "pow2groups.groups.kstate.lmdb"), checksDir);
|
EnvironmentConfiguration.ByDivisorGroupsStateRepository = KStateRepository.Open(checksDir, "pow2groups.groups.kstate.faster", Path.Combine(checksDir, "pow2groups.groups.kstate.lmdb"), checksDir);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EnvironmentConfiguration.ByDivisorSpecialStateRepository = null;
|
EnvironmentConfiguration.ByDivisorSpecialStateRepository = null;
|
||||||
EnvironmentConfiguration.ByDivisorGroupsStateRepository = null;
|
EnvironmentConfiguration.ByDivisorGroupsStateRepository = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool useFilter = !testMode && !string.IsNullOrEmpty(filterFile);
|
bool useFilter = !testMode && !string.IsNullOrEmpty(filterFile);
|
||||||
@@ -1394,48 +1406,48 @@ private static ThreadLocal<object>? MersenneTesters;
|
|||||||
// Windowed pow2mod kernel handles by-divisor scans.
|
// Windowed pow2mod kernel handles by-divisor scans.
|
||||||
ByDivisorKIncrementMode mode = _cliArguments.ByDivisorKIncrementMode;
|
ByDivisorKIncrementMode mode = _cliArguments.ByDivisorKIncrementMode;
|
||||||
if (EnvironmentConfiguration.UseCpuOrder)
|
if (EnvironmentConfiguration.UseCpuOrder)
|
||||||
{
|
{
|
||||||
return mode switch
|
|
||||||
{
|
|
||||||
ByDivisorKIncrementMode.Pow2Groups => _byDivisorCpuOrderTesterPow2.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.Predictive => _byDivisorCpuOrderTesterPredictive.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.Percentile => _byDivisorCpuOrderTesterPercentile.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.Additive => _byDivisorCpuOrderTesterAdditive.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.TopDown => _byDivisorCpuOrderTesterTopDown.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.BitContradiction => _byDivisorCpuOrderTesterBitContradiction.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.BitTree => _byDivisorCpuOrderTesterBitTree.IsPrime(p, out detailedCheck, out _),
|
|
||||||
_ => _byDivisorCpuOrderTester.IsPrime(p, out detailedCheck, out _),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EnvironmentConfiguration.UseHybridOrder)
|
|
||||||
{
|
|
||||||
return mode switch
|
|
||||||
{
|
|
||||||
ByDivisorKIncrementMode.Pow2Groups => _byDivisorHybridOrderTesterPow2.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.Predictive => _byDivisorHybridOrderTesterPredictive.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.Percentile => _byDivisorHybridOrderTesterPercentile.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.Additive => _byDivisorHybridOrderTesterAdditive.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.TopDown => _byDivisorHybridOrderTesterTopDown.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.BitContradiction => _byDivisorHybridOrderTesterBitContradiction.IsPrime(p, out detailedCheck, out _),
|
|
||||||
ByDivisorKIncrementMode.BitTree => _byDivisorHybridOrderTesterBitTree.IsPrime(p, out detailedCheck, out _),
|
|
||||||
_ => _byDivisorHybridOrderTester.IsPrime(p, out detailedCheck, out _),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return mode switch
|
return mode switch
|
||||||
{
|
{
|
||||||
ByDivisorKIncrementMode.Pow2Groups => _byDivisorGpuOrderTesterPow2.IsPrime(p, out detailedCheck, out _),
|
ByDivisorKIncrementMode.Pow2Groups => _byDivisorCpuOrderTesterPow2.IsPrime(p, out detailedCheck, out _),
|
||||||
ByDivisorKIncrementMode.Predictive => _byDivisorGpuOrderTesterPredictive.IsPrime(p, out detailedCheck, out _),
|
ByDivisorKIncrementMode.Predictive => _byDivisorCpuOrderTesterPredictive.IsPrime(p, out detailedCheck, out _),
|
||||||
ByDivisorKIncrementMode.Percentile => _byDivisorGpuOrderTesterPercentile.IsPrime(p, out detailedCheck, out _),
|
ByDivisorKIncrementMode.Percentile => _byDivisorCpuOrderTesterPercentile.IsPrime(p, out detailedCheck, out _),
|
||||||
ByDivisorKIncrementMode.Additive => _byDivisorGpuOrderTesterAdditive.IsPrime(p, out detailedCheck, out _),
|
ByDivisorKIncrementMode.Additive => _byDivisorCpuOrderTesterAdditive.IsPrime(p, out detailedCheck, out _),
|
||||||
ByDivisorKIncrementMode.TopDown => _byDivisorGpuOrderTesterTopDown.IsPrime(p, out detailedCheck, out _),
|
ByDivisorKIncrementMode.TopDown => _byDivisorCpuOrderTesterTopDown.IsPrime(p, out detailedCheck, out _),
|
||||||
ByDivisorKIncrementMode.BitContradiction => _byDivisorGpuOrderTesterBitContradiction.IsPrime(p, out detailedCheck, out _),
|
ByDivisorKIncrementMode.BitContradiction => _byDivisorCpuOrderTesterBitContradiction.IsPrime(p, out detailedCheck, out _),
|
||||||
ByDivisorKIncrementMode.BitTree => _byDivisorGpuOrderTesterBitTree.IsPrime(p, out detailedCheck, out _),
|
ByDivisorKIncrementMode.BitTree => _byDivisorCpuOrderTesterBitTree.IsPrime(p, out detailedCheck, out _),
|
||||||
_ => _byDivisorGpuOrderTester.IsPrime(p, out detailedCheck, out _),
|
_ => _byDivisorCpuOrderTester.IsPrime(p, out detailedCheck, out _),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (EnvironmentConfiguration.UseHybridOrder)
|
||||||
|
{
|
||||||
|
return mode switch
|
||||||
|
{
|
||||||
|
ByDivisorKIncrementMode.Pow2Groups => _byDivisorHybridOrderTesterPow2.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.Predictive => _byDivisorHybridOrderTesterPredictive.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.Percentile => _byDivisorHybridOrderTesterPercentile.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.Additive => _byDivisorHybridOrderTesterAdditive.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.TopDown => _byDivisorHybridOrderTesterTopDown.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.BitContradiction => _byDivisorHybridOrderTesterBitContradiction.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.BitTree => _byDivisorHybridOrderTesterBitTree.IsPrime(p, out detailedCheck, out _),
|
||||||
|
_ => _byDivisorHybridOrderTester.IsPrime(p, out detailedCheck, out _),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return mode switch
|
||||||
|
{
|
||||||
|
ByDivisorKIncrementMode.Pow2Groups => _byDivisorGpuOrderTesterPow2.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.Predictive => _byDivisorGpuOrderTesterPredictive.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.Percentile => _byDivisorGpuOrderTesterPercentile.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.Additive => _byDivisorGpuOrderTesterAdditive.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.TopDown => _byDivisorGpuOrderTesterTopDown.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.BitContradiction => _byDivisorGpuOrderTesterBitContradiction.IsPrime(p, out detailedCheck, out _),
|
||||||
|
ByDivisorKIncrementMode.BitTree => _byDivisorGpuOrderTesterBitTree.IsPrime(p, out detailedCheck, out _),
|
||||||
|
_ => _byDivisorGpuOrderTester.IsPrime(p, out detailedCheck, out _),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
detailedCheck = IsMersennePrime(gpu, p);
|
detailedCheck = IsMersennePrime(gpu, p);
|
||||||
return detailedCheck;
|
return detailedCheck;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Xunit;
|
|||||||
|
|
||||||
namespace PerfectNumbers.Core.Tests;
|
namespace PerfectNumbers.Core.Tests;
|
||||||
|
|
||||||
|
[Trait("Category", "Fast")]
|
||||||
public class BitContradictionIntegrationTests
|
public class BitContradictionIntegrationTests
|
||||||
{
|
{
|
||||||
// 2^11 - 1 = 2047 = 23 * 89
|
// 2^11 - 1 = 2047 = 23 * 89
|
||||||
@@ -39,11 +40,21 @@ public class BitContradictionIntegrationTests
|
|||||||
divides.Should().BeFalse();
|
divides.Should().BeFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void BitContradictionAcceptsKnownLargeDivisor()
|
||||||
|
{
|
||||||
|
BigInteger divisor = BigInteger.Parse("1209708008767");
|
||||||
|
ulong p = 138000001;
|
||||||
|
bool decided = Invoke(divisor, p, out bool divides);
|
||||||
|
decided.Should().BeTrue();
|
||||||
|
divides.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void BitContradictionRejectsNonDivisorWithDecision()
|
public void BitContradictionRejectsNonDivisorWithDecision()
|
||||||
{
|
{
|
||||||
// 2^11 - 1 is not divisible by 25
|
// 2^11 - 1 is not divisible by 45 (k=2, q=22*2+1).
|
||||||
BigInteger divisor = 25;
|
BigInteger divisor = 45;
|
||||||
ulong p = 11;
|
ulong p = 11;
|
||||||
bool decided = Invoke(divisor, p, out bool divides);
|
bool decided = Invoke(divisor, p, out bool divides);
|
||||||
decided.Should().BeTrue("small p should be decided exactly");
|
decided.Should().BeTrue("small p should be decided exactly");
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
using System;
|
||||||
|
using System.Numerics;
|
||||||
|
using FluentAssertions;
|
||||||
|
using PerfectNumbers.Core.Gpu.Kernels;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace PerfectNumbers.Core.Tests;
|
||||||
|
|
||||||
|
public class BitContradictionKernelsTests
|
||||||
|
{
|
||||||
|
[Theory]
|
||||||
|
[Trait("Category", "Fast")]
|
||||||
|
[InlineData(31UL, 0UL, 0)]
|
||||||
|
[InlineData(31UL, 0UL, 5)]
|
||||||
|
[InlineData(61UL, 7UL, 3)]
|
||||||
|
[InlineData(36721UL, 1UL, 0)]
|
||||||
|
public void TryBuildQWordsFromBatchIndex_matches_BigInteger(ulong exponent, ulong batchIndex, int batchOffset)
|
||||||
|
{
|
||||||
|
int wordCount = BitContradictionKernels.MaxQWordCount;
|
||||||
|
ulong[] batchIndexWords = new ulong[wordCount];
|
||||||
|
batchIndexWords[0] = batchIndex;
|
||||||
|
|
||||||
|
ulong[] qWords = new ulong[wordCount];
|
||||||
|
bool ok = BitContradictionKernels.TryBuildQWordsFromBatchIndex(
|
||||||
|
exponent,
|
||||||
|
batchIndexWords,
|
||||||
|
wordCount,
|
||||||
|
batchOffset,
|
||||||
|
qWords,
|
||||||
|
out int qBitLen);
|
||||||
|
|
||||||
|
ok.Should().BeTrue();
|
||||||
|
|
||||||
|
BigInteger expectedK = ((BigInteger)batchIndex * BitContradictionKernels.BatchCount) + BigInteger.One + batchOffset;
|
||||||
|
BigInteger expectedQ = (expectedK * (exponent << 1)) + BigInteger.One;
|
||||||
|
BigInteger actualQ = ReadBigIntegerFromWords(qWords);
|
||||||
|
|
||||||
|
actualQ.Should().Be(expectedQ);
|
||||||
|
qBitLen.Should().Be(GetBitLength(expectedQ));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BigInteger ReadBigIntegerFromWords(ReadOnlySpan<ulong> words)
|
||||||
|
{
|
||||||
|
byte[] bytes = new byte[words.Length * sizeof(ulong)];
|
||||||
|
for (int w = 0; w < words.Length; w++)
|
||||||
|
{
|
||||||
|
ulong word = words[w];
|
||||||
|
int byteIndex = w << 3;
|
||||||
|
bytes[byteIndex] = (byte)word;
|
||||||
|
bytes[byteIndex + 1] = (byte)(word >> 8);
|
||||||
|
bytes[byteIndex + 2] = (byte)(word >> 16);
|
||||||
|
bytes[byteIndex + 3] = (byte)(word >> 24);
|
||||||
|
bytes[byteIndex + 4] = (byte)(word >> 32);
|
||||||
|
bytes[byteIndex + 5] = (byte)(word >> 40);
|
||||||
|
bytes[byteIndex + 6] = (byte)(word >> 48);
|
||||||
|
bytes[byteIndex + 7] = (byte)(word >> 56);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BigInteger(bytes, isUnsigned: true, isBigEndian: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int GetBitLength(BigInteger value)
|
||||||
|
{
|
||||||
|
if (value.IsZero)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] bytes = value.ToByteArray(isUnsigned: true, isBigEndian: false);
|
||||||
|
int last = bytes[^1];
|
||||||
|
int bits = (bytes.Length - 1) * 8;
|
||||||
|
while (last != 0)
|
||||||
|
{
|
||||||
|
bits++;
|
||||||
|
last >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bits;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Numerics;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using PerfectNumbers.Core.ByDivisor;
|
using PerfectNumbers.Core.ByDivisor;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
@@ -16,13 +17,13 @@ public class BitContradictionSolverTests
|
|||||||
ColumnBounds bounds = ComputeColumnBounds(a, q, 1);
|
ColumnBounds bounds = ComputeColumnBounds(a, q, 1);
|
||||||
|
|
||||||
bounds.ForcedOnes.Should().Be(1);
|
bounds.ForcedOnes.Should().Be(1);
|
||||||
bounds.PossibleOnes.Should().Be(1);
|
bounds.PossibleOnes.Should().Be(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TryPropagateCarry_FailsWhenParityUnreachable()
|
public void TryPropagateCarry_FailsWhenParityUnreachable()
|
||||||
{
|
{
|
||||||
CarryRange carry = CarryRange.Single(0);
|
CarryRange carry = CarryRange.Single(0);
|
||||||
bool success = TryPropagateCarry(
|
bool success = TryPropagateCarry(
|
||||||
currentCarry: ref carry,
|
currentCarry: ref carry,
|
||||||
forcedOnes: 0,
|
forcedOnes: 0,
|
||||||
@@ -34,10 +35,34 @@ public class BitContradictionSolverTests
|
|||||||
carry.Max.Should().Be(0);
|
carry.Max.Should().Be(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Category", "Fast")]
|
||||||
|
public void ShouldPruneWithFinalPow2Shift_ReturnsTrue_WhenShiftedResidueStaysBelowModulusAndResidueIsNotOne()
|
||||||
|
{
|
||||||
|
bool shouldPrune = ShouldPruneWithFinalPow2Shift(
|
||||||
|
prefixResidue: new BigInteger(3),
|
||||||
|
modulus: new BigInteger(1000),
|
||||||
|
tailShift: 8);
|
||||||
|
|
||||||
|
shouldPrune.Should().BeTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
[Trait("Category", "Fast")]
|
||||||
|
public void ShouldPruneWithFinalPow2Shift_ReturnsFalse_WhenResidueIsOne()
|
||||||
|
{
|
||||||
|
bool shouldPrune = ShouldPruneWithFinalPow2Shift(
|
||||||
|
prefixResidue: BigInteger.One,
|
||||||
|
modulus: new BigInteger(1000),
|
||||||
|
tailShift: 8);
|
||||||
|
|
||||||
|
shouldPrune.Should().BeFalse();
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TryPropagateCarry_ComputesNextCarryRange()
|
public void TryPropagateCarry_ComputesNextCarryRange()
|
||||||
{
|
{
|
||||||
CarryRange carry = new(0, 1);
|
CarryRange carry = new(0, 1);
|
||||||
bool success = TryPropagateCarry(
|
bool success = TryPropagateCarry(
|
||||||
currentCarry: ref carry,
|
currentCarry: ref carry,
|
||||||
forcedOnes: 1,
|
forcedOnes: 1,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -9,13 +9,19 @@ public readonly struct ColumnBounds(int forcedOnes, int possibleOnes)
|
|||||||
public readonly int PossibleOnes = possibleOnes;
|
public readonly int PossibleOnes = possibleOnes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly struct CarryRange(long min, long max)
|
public readonly struct CarryRange(long min, long max, byte mod4Mask = byte.MinValue)
|
||||||
{
|
{
|
||||||
public readonly long Min = min;
|
public readonly long Min = min;
|
||||||
public readonly long Max = max;
|
public readonly long Max = max;
|
||||||
|
public readonly byte Mod4Mask = mod4Mask;
|
||||||
|
|
||||||
public static CarryRange Single(long value) => new(value, value);
|
public static CarryRange Single(long value) => new(value, value, byte.MinValue);
|
||||||
public static readonly CarryRange Zero = Single(0);
|
public static CarryRange Single(long value, byte mod4Mask) => new(value, value, mod4Mask);
|
||||||
|
|
||||||
|
public static readonly CarryRange Zero = Single(0, 0);
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public bool IsEmpty() => Min > Max || Mod4Mask == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ContradictionReason
|
public enum ContradictionReason
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
namespace PerfectNumbers.Core;
|
||||||
|
#pragma warning disable CA2211 // The fields are settable on purpose for the best performance
|
||||||
|
|
||||||
|
public enum ByDivisorKIncrementMode
|
||||||
|
{
|
||||||
|
Sequential,
|
||||||
|
Pow2Groups,
|
||||||
|
Predictive,
|
||||||
|
Percentile,
|
||||||
|
Additive,
|
||||||
|
TopDown,
|
||||||
|
BitContradiction,
|
||||||
|
BitTree,
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning restore CA2211 // Non-constant fields should not be visible
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace PerfectNumbers.Core;
|
||||||
|
|
||||||
|
public enum CacheStatus
|
||||||
|
{
|
||||||
|
Disabled,
|
||||||
|
Enabled,
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace PerfectNumbers.Core;
|
||||||
|
|
||||||
|
public enum CalculationMethod
|
||||||
|
{
|
||||||
|
ByDivisor,
|
||||||
|
Divisor,
|
||||||
|
Incremental,
|
||||||
|
LucasLehmer,
|
||||||
|
Pow2Mod,
|
||||||
|
Residue,
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
// #define DivisorSet_BitContradiction
|
// #define DivisorSet_BitContradiction
|
||||||
// #define DivisorSet_BitTree
|
// #define DivisorSet_BitTree
|
||||||
|
// #define DEVICE_GPU
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -11,7 +12,10 @@ using System.Globalization;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
|
using ILGPU;
|
||||||
|
using ILGPU.Runtime;
|
||||||
using PerfectNumbers.Core.Gpu;
|
using PerfectNumbers.Core.Gpu;
|
||||||
|
using PerfectNumbers.Core.Gpu.Kernels;
|
||||||
using PerfectNumbers.Core.Gpu.Accelerators;
|
using PerfectNumbers.Core.Gpu.Accelerators;
|
||||||
using PerfectNumbers.Core.ByDivisor;
|
using PerfectNumbers.Core.ByDivisor;
|
||||||
using PerfectNumbers.Core.Persistence;
|
using PerfectNumbers.Core.Persistence;
|
||||||
@@ -58,6 +62,500 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
private GpuUInt128WorkSet _divisorScanGpuWorkSet;
|
private GpuUInt128WorkSet _divisorScanGpuWorkSet;
|
||||||
private static readonly ConcurrentDictionary<ulong, byte> _checkedPow2MinusOne = new();
|
private static readonly ConcurrentDictionary<ulong, byte> _checkedPow2MinusOne = new();
|
||||||
private ulong _currentPrime;
|
private ulong _currentPrime;
|
||||||
|
#if WITH_PRUNE_STATS
|
||||||
|
private readonly TimeSpan _slowCalculationThreshold = TimeSpan.FromMilliseconds(700);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DEVICE_GPU && DivisorSet_BitContradiction
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||||
|
private bool CheckDivisorsBitContradictionGpu(
|
||||||
|
ulong prime,
|
||||||
|
ushort primeDecimalMask,
|
||||||
|
BigInteger allowedMax,
|
||||||
|
BigInteger minK,
|
||||||
|
BigInteger step,
|
||||||
|
out bool processedAll,
|
||||||
|
out BigInteger foundDivisor)
|
||||||
|
{
|
||||||
|
processedAll = false;
|
||||||
|
foundDivisor = BigInteger.Zero;
|
||||||
|
|
||||||
|
BigInteger currentK = minK;
|
||||||
|
|
||||||
|
#if OVERRIDE_MIN_K
|
||||||
|
// Regression test convenience: ensure we actually scan the range that contains the known divisor for p=138000001.
|
||||||
|
if (currentK > 1)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"[GPU OVERRIDE] p={prime} forcing minK from {currentK} to 1 for known-divisor regression test.");
|
||||||
|
currentK = BigInteger.One;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
const int TargetBatchIndex = 273;
|
||||||
|
|
||||||
|
bool hasLimit = !allowedMax.IsZero;
|
||||||
|
BigInteger maxK = hasLimit ? (allowedMax - BigInteger.One) / step : BigInteger.Zero;
|
||||||
|
|
||||||
|
BigInteger maxQ = (BigInteger.One << BitContradictionKernels.MaxQBitLength) - BigInteger.One;
|
||||||
|
BigInteger maxKByBits = (maxQ - BigInteger.One) / step;
|
||||||
|
if (!hasLimit || maxKByBits < maxK)
|
||||||
|
{
|
||||||
|
maxK = maxKByBits;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxK < currentK)
|
||||||
|
{
|
||||||
|
processedAll = hasLimit;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrimeOrderCalculatorAccelerator gpu = Accelerator;
|
||||||
|
int maxThreadCount = PerfectNumberConstants.BitContradictionGpuThreads;
|
||||||
|
int batchSize = PerfectNumberConstants.BitContradictionGpuBatchCount;
|
||||||
|
BigInteger batchSizeBig = batchSize;
|
||||||
|
int wordCount = BitContradictionKernels.MaxQWordCount;
|
||||||
|
int inputCapacity = maxThreadCount * wordCount;
|
||||||
|
var buffers = gpu.EnsureBitContradictionCapacity(inputCapacity, inputCapacity, maxThreadCount);
|
||||||
|
|
||||||
|
var stream = AcceleratorStreamPool.Rent(gpu.AcceleratorIndex);
|
||||||
|
var kernels = GpuKernelPool.GetOrAddKernels(gpu.AcceleratorIndex, stream, KernelType.BitContradictionScan);
|
||||||
|
var kernel = kernels.BitContradiction!;
|
||||||
|
|
||||||
|
int[] found = new int[maxThreadCount];
|
||||||
|
ulong[] batchIndexWords = new ulong[inputCapacity];
|
||||||
|
ArrayView1D<int, Stride1D.Dense> delta8KeysView = buffers.Delta8CacheKeysView;
|
||||||
|
ArrayView1D<int, Stride1D.Dense> delta8CacheView = buffers.Delta8CacheValuesView;
|
||||||
|
|
||||||
|
Span<int> temp = stackalloc int[(int)delta8KeysView.Length];
|
||||||
|
temp.Fill(int.MinValue);
|
||||||
|
delta8KeysView.CopyFromCPU(stream, temp);
|
||||||
|
|
||||||
|
|
||||||
|
#if INVERSION_VALIDATION
|
||||||
|
///
|
||||||
|
/// INVERSION VALIDATION
|
||||||
|
///
|
||||||
|
{
|
||||||
|
// --- Inputs (known test case)
|
||||||
|
ulong p = 138000001UL;
|
||||||
|
ulong k = 4383UL;
|
||||||
|
|
||||||
|
// --- ILGPU setup (minimal)
|
||||||
|
var accelerator = gpu.Accelerator;
|
||||||
|
|
||||||
|
// --- Compile kernel (Extent=1)
|
||||||
|
// Kernel signature must be: (Index1D, ulong p, ulong k, ArrayView1D<ulong, Stride1D.Dense> outBuf)
|
||||||
|
var kernel2 = accelerator.LoadAutoGroupedStreamKernel<
|
||||||
|
Index1D,
|
||||||
|
ulong,
|
||||||
|
ulong,
|
||||||
|
ArrayView1D<ulong, Stride1D.Dense>
|
||||||
|
>(BitContradictionKernels.BitContradictionKernelExportInverse1024);
|
||||||
|
|
||||||
|
// --- Output buffer (64 ulongs is enough: 16 qPrefix + 16 inv + 16 aLow + meta)
|
||||||
|
using var outBufGpu = accelerator.Allocate1D<ulong>(64);
|
||||||
|
var outCpu = new ulong[64];
|
||||||
|
|
||||||
|
// Optional: clear buffer
|
||||||
|
for (int i = 0; i < outCpu.Length; i++) outCpu[i] = 0;
|
||||||
|
outBufGpu.View.CopyFromCPU(stream, outCpu);
|
||||||
|
|
||||||
|
// --- Run kernel
|
||||||
|
kernel2(1, p, k, outBufGpu.View);
|
||||||
|
stream.Synchronize();
|
||||||
|
|
||||||
|
// --- Copy back
|
||||||
|
outBufGpu.View.CopyToCPU(stream, outCpu);
|
||||||
|
stream.Synchronize();
|
||||||
|
|
||||||
|
// --- Parse meta
|
||||||
|
ulong pOut = outCpu[48];
|
||||||
|
ulong kOut = outCpu[49];
|
||||||
|
ulong qOut = outCpu[50];
|
||||||
|
ulong marker = outCpu[51];
|
||||||
|
|
||||||
|
Console.WriteLine($"[GPU EXPORT] pOut={pOut} kOut={kOut} qOut={qOut} marker=0x{marker:X}");
|
||||||
|
|
||||||
|
// --- Helpers: build BigInteger from 16x ulong limbs (little-endian)
|
||||||
|
BigInteger FromU64Le(int startIndex)
|
||||||
|
{
|
||||||
|
// +1 byte to force positive sign for BigInteger ctor
|
||||||
|
byte[] bytes = new byte[16 * 8 + 1];
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
ulong w = outCpu[startIndex + i];
|
||||||
|
int o = i * 8;
|
||||||
|
bytes[o + 0] = (byte)(w);
|
||||||
|
bytes[o + 1] = (byte)(w >> 8);
|
||||||
|
bytes[o + 2] = (byte)(w >> 16);
|
||||||
|
bytes[o + 3] = (byte)(w >> 24);
|
||||||
|
bytes[o + 4] = (byte)(w >> 32);
|
||||||
|
bytes[o + 5] = (byte)(w >> 40);
|
||||||
|
bytes[o + 6] = (byte)(w >> 48);
|
||||||
|
bytes[o + 7] = (byte)(w >> 56);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BigInteger(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
var qPrefix = FromU64Le(0);
|
||||||
|
var inv = FromU64Le(16);
|
||||||
|
var aLow = FromU64Le(32);
|
||||||
|
|
||||||
|
var mask = (BigInteger.One << 1024) - 1;
|
||||||
|
|
||||||
|
// --- Validate inverse: (qPrefix * inv) mod 2^1024 == 1
|
||||||
|
var prod = (qPrefix * inv) & mask;
|
||||||
|
bool invOk = prod == BigInteger.One;
|
||||||
|
|
||||||
|
// --- Validate aLow: aLow == (-inv) mod 2^1024
|
||||||
|
var expectedALow = (mask + BigInteger.One - (inv & mask)) & mask;
|
||||||
|
bool aLowOk = ((aLow & mask) == expectedALow);
|
||||||
|
|
||||||
|
// --- Print concise diagnostics
|
||||||
|
Console.WriteLine($"[CPU VALIDATION] invOk={invOk} aLowOk={aLowOk}");
|
||||||
|
|
||||||
|
// Print low 64 bits (quick sanity)
|
||||||
|
ulong prodLow64 = (ulong)(prod & ((BigInteger.One << 64) - 1));
|
||||||
|
ulong invLow64 = (ulong)(inv & ((BigInteger.One << 64) - 1));
|
||||||
|
ulong aLowLow64 = (ulong)(aLow & ((BigInteger.One << 64) - 1));
|
||||||
|
|
||||||
|
Console.WriteLine($"[LOW64] qPrefix=0x{(ulong)(qPrefix & ((System.Numerics.BigInteger.One<<64)-1)):X}");
|
||||||
|
Console.WriteLine($"[LOW64] inv=0x{invLow64:X} aLow=0x{aLowLow64:X} prod=0x{prodLow64:X}");
|
||||||
|
|
||||||
|
// Optional: hard fail for CI/regression
|
||||||
|
if (!invOk || !aLowOk)
|
||||||
|
throw new System.InvalidOperationException($"Inverse export validation failed: invOk={invOk}, aLowOk={aLowOk}");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SELF_TEST
|
||||||
|
///
|
||||||
|
/// SELF-TEST
|
||||||
|
///
|
||||||
|
{
|
||||||
|
ulong p = 138000001UL;
|
||||||
|
ulong k = 4383UL;
|
||||||
|
|
||||||
|
var accelerator = gpu.Accelerator;
|
||||||
|
|
||||||
|
Console.WriteLine($"Compiling kernel for {prime}");
|
||||||
|
var kernel3 = accelerator.LoadAutoGroupedStreamKernel<
|
||||||
|
Index1D,
|
||||||
|
ulong,
|
||||||
|
ulong,
|
||||||
|
int,
|
||||||
|
ArrayView1D<ulong, Stride1D.Dense>
|
||||||
|
>(BitContradictionKernels.BitContradictionKernelDebugDpSingleQ);
|
||||||
|
|
||||||
|
var launcher3 = KernelUtil.GetKernel(kernel3).CreateLauncherDelegate<
|
||||||
|
Action<AcceleratorStream, Index1D, ulong, ulong, int, ArrayView1D<ulong, Stride1D.Dense>>>();
|
||||||
|
|
||||||
|
Console.WriteLine($"Preparing buffers for {prime}");
|
||||||
|
using var outGpu = accelerator.Allocate1D<ulong>(128);
|
||||||
|
var outCpu = new ulong[128];
|
||||||
|
Array.Clear(outCpu, 0, outCpu.Length);
|
||||||
|
outGpu.View.CopyFromCPU(stream, outCpu);
|
||||||
|
|
||||||
|
// First run: disable batching (scalar DP)
|
||||||
|
Console.WriteLine($"Launching GPU kernel for {prime}");
|
||||||
|
launcher3(stream, 1, p, k, 1, outGpu.View);
|
||||||
|
outGpu.View.CopyToCPU(stream, outCpu);
|
||||||
|
stream.Synchronize();
|
||||||
|
|
||||||
|
Console.WriteLine($"[DP DEBUG] marker=0x{outCpu[0]:X} p={outCpu[1]} k={outCpu[2]} q={outCpu[3]} qBitLen={outCpu[4]} offsetCount={outCpu[6]} ok={outCpu[9]} carryMin={outCpu[10]} carryMax={outCpu[11]}");
|
||||||
|
|
||||||
|
// Print first 10 step records
|
||||||
|
Console.WriteLine($"[DP DEBUG] marker=0x{outCpu[0]:X} p={outCpu[1]} k={outCpu[2]} q={outCpu[3]} qBitLen={outCpu[4]} offsetCount={outCpu[6]} ok={outCpu[9]} carryMin={outCpu[10]} carryMax={outCpu[11]} disableBatching={outCpu[12]}");
|
||||||
|
Console.WriteLine($"[DP EXTRA] maxAllowedA={outCpu[14]} maxFixed={outCpu[15]} windowSize={outCpu[16]} aWordCount={outCpu[17]}");
|
||||||
|
Console.WriteLine($"[DP FIRST] firstForced={unchecked((long)outCpu[18])} firstRemaining={unchecked((long)outCpu[19])} firstQWordsEff={outCpu[20]} firstQLastEff=0x{outCpu[21]:X} firstCarryMin={unchecked((long)outCpu[22])} firstCarryMax={unchecked((long)outCpu[23])}");
|
||||||
|
Console.WriteLine($"[DP SNAP] aLow0=0x{outCpu[24]:X} knownOne0=0x{outCpu[25]:X} knownZero0=0x{outCpu[26]:X} aOneWin0=0x{outCpu[27]:X} aZeroWin0=0x{outCpu[28]:X} qMask0=0x{outCpu[29]:X} lastMask=0x{outCpu[30]:X} off0={outCpu[31]} offLast={outCpu[32]}");
|
||||||
|
|
||||||
|
if (outCpu[0] != 0xD00DF00DUL)
|
||||||
|
throw new Exception("DP debug kernel did not run as expected.");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
BigInteger currentBatch = (currentK - BigInteger.One) / batchSizeBig;
|
||||||
|
currentK = (currentBatch * batchSizeBig) + BigInteger.One;
|
||||||
|
BigInteger maxBatch = (maxK - BigInteger.One) / batchSizeBig;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (hasLimit && currentBatch > maxBatch)
|
||||||
|
{
|
||||||
|
processedAll = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigInteger remainingBatches = maxBatch - currentBatch + BigInteger.One;
|
||||||
|
if (remainingBatches <= BigInteger.Zero)
|
||||||
|
{
|
||||||
|
processedAll = hasLimit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Preparing data for{prime}, batch {currentBatch}");
|
||||||
|
int threadCount = maxThreadCount;
|
||||||
|
if (remainingBatches < threadCount)
|
||||||
|
{
|
||||||
|
threadCount = (int)remainingBatches;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentBatch > ulong.MaxValue)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"BitContradiction GPU batch index overflow for p={prime}, batch={currentBatch}");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigInteger maxBatchIndex = currentBatch + (threadCount - 1);
|
||||||
|
if (maxBatchIndex > ulong.MaxValue)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"BitContradiction GPU batch index overflow for p={prime}, batch={currentBatch}, threads={threadCount}");
|
||||||
|
}
|
||||||
|
|
||||||
|
int countQ = batchSize;
|
||||||
|
|
||||||
|
for (int t = 0; t < threadCount; t++)
|
||||||
|
{
|
||||||
|
BigInteger batchIndex = currentBatch + t;
|
||||||
|
WriteBigIntegerToWords(batchIndex, batchIndexWords.AsSpan(t * wordCount, wordCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Copying data to GPU for {prime}, batch {currentBatch}");
|
||||||
|
buffers.BatchIndexWordsView.CopyFromCPU(stream, batchIndexWords.AsSpan(0, threadCount * wordCount));
|
||||||
|
// #if DETAILED_LOG
|
||||||
|
Console.WriteLine($"Launching GPU kernel for {prime}, batch {currentBatch}");
|
||||||
|
// #endif
|
||||||
|
kernel(stream, 1, prime, buffers.BatchIndexWordsView, countQ, buffers.FoundQWordsView,
|
||||||
|
// kernel(stream, threadCount, prime, buffers.BatchIndexWords, countQ, buffers.FoundQWords,
|
||||||
|
delta8KeysView, delta8CacheView);
|
||||||
|
buffers.FoundQWordsView.CopyToCPU(stream, found.AsSpan(0, threadCount));
|
||||||
|
stream.Synchronize();
|
||||||
|
|
||||||
|
_consolePrintOut++;
|
||||||
|
if (_consolePrintOut >= PerfectNumberConstants.ConsoleInterval)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"GPU kernel for {prime} complete, batch {currentBatch}");
|
||||||
|
Console.WriteLine($"[GPU FOUND RAW] batch={currentBatch} found[0]={found[0]}");
|
||||||
|
_consolePrintOut = 0;
|
||||||
|
}
|
||||||
|
#if DETAILED_LOG || SELF_TEST
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// TODO: This loop is incorrect. We have a loop over the threads outside from here
|
||||||
|
for (int i = 0; i < threadCount; i++)
|
||||||
|
{
|
||||||
|
int foundIndex = found[i];
|
||||||
|
if (foundIndex >= 0)
|
||||||
|
{
|
||||||
|
BigInteger batchIndex = currentBatch + i;
|
||||||
|
BigInteger candidateK = (batchIndex * batchSizeBig) + BigInteger.One + foundIndex;
|
||||||
|
if (hasLimit && candidateK > maxK)
|
||||||
|
{
|
||||||
|
processedAll = true;
|
||||||
|
AcceleratorStreamPool.Return(gpu.AcceleratorIndex, stream);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigInteger candidateQ = (step * candidateK) + BigInteger.One;
|
||||||
|
// Span<ulong> debugQWords = stackalloc ulong[BitContradictionKernels.MaxQWordCount];
|
||||||
|
// if (!BitContradictionKernels.TryBuildQWordsFromBatchIndex(prime, batchIndexWords.AsSpan(i * wordCount, wordCount), wordCount, foundIndex, debugQWords, out int debugQBitLen))
|
||||||
|
// {
|
||||||
|
// throw new InvalidOperationException($"BitContradiction GPU qWords overflow for p={prime}, k={candidateK}, batch={batchIndex}, index={foundIndex}");
|
||||||
|
// }
|
||||||
|
// BigInteger debugQ = ReadBigIntegerFromWords(debugQWords);
|
||||||
|
// if (debugQ != candidateQ)
|
||||||
|
// {
|
||||||
|
// throw new InvalidOperationException($"BitContradiction GPU qWords mismatch for p={prime}, k={candidateK}, batch={batchIndex}, index={foundIndex}, cpuQ={candidateQ}, gpuQ={debugQ}, gpuQBits={debugQBitLen}");
|
||||||
|
// }
|
||||||
|
// #if DivisorSet_BitContradiction
|
||||||
|
// int[]? qBits = _qBits;
|
||||||
|
// if (qBits == null || qBits.Length < (int)prime)
|
||||||
|
// {
|
||||||
|
// qBits = new int[(int)prime];
|
||||||
|
// _qBits = qBits;
|
||||||
|
// }
|
||||||
|
// bool cpuDecided = TryExactBitContradictionCheck(prime, candidateQ, candidateK, out bool cpuDivides);
|
||||||
|
// if (!cpuDecided)
|
||||||
|
// {
|
||||||
|
// throw new InvalidOperationException($"BitContradiction CPU undecided for p={prime}, q={candidateQ}, k={candidateK}, batch={batchIndex}");
|
||||||
|
// }
|
||||||
|
// if (!cpuDivides)
|
||||||
|
// {
|
||||||
|
// throw new InvalidOperationException($"BitContradiction CPU/GPU mismatch for p={prime}, q={candidateQ}, k={candidateK}, batch={batchIndex}");
|
||||||
|
// }
|
||||||
|
// #endif
|
||||||
|
// bool dividesExact = BigInteger.ModPow(2, prime, candidateQ) == BigInteger.One;
|
||||||
|
// if (!dividesExact)
|
||||||
|
// {
|
||||||
|
// throw new InvalidOperationException($"BitContradiction CPU/GPU false positive for p={prime}, q={candidateQ}, k={candidateK}, batch={batchIndex}");
|
||||||
|
#if DETAILED_LOG
|
||||||
|
if (prime == 138000001UL)
|
||||||
|
// --- Fast self-check for known divisor: run scan kernel with ONE thread and SMALL countQ.
|
||||||
|
// This avoids waiting for other threads that would scan huge ranges and never hit the target.
|
||||||
|
{
|
||||||
|
const int expectedFoundIndex = 4382; // k=4383 => index=k-1 in batch 0
|
||||||
|
countQ = 6000; // must be > 4382, keep small to finish quickly
|
||||||
|
|
||||||
|
Array.Clear(found, 0, found.Length);
|
||||||
|
Array.Clear(batchIndexWords, 0, batchIndexWords.Length);
|
||||||
|
|
||||||
|
// batchIndex = 0
|
||||||
|
WriteBigIntegerToWords(BigInteger.Zero, batchIndexWords.AsSpan(0, wordCount));
|
||||||
|
buffers.BatchIndexWords.CopyFromCPU(stream, batchIndexWords.AsSpan(0, threadCount * wordCount));
|
||||||
|
|
||||||
|
Console.WriteLine($"[GPU SELFTEST] launching scan kernel (threads={threadCount}, countQ={countQ})");
|
||||||
|
kernel(
|
||||||
|
stream,
|
||||||
|
threadCount,
|
||||||
|
prime,
|
||||||
|
buffers.BatchIndexWords,
|
||||||
|
countQ,
|
||||||
|
buffers.FoundQWords,
|
||||||
|
#if DETAILED_LOG
|
||||||
|
debugView,
|
||||||
|
#endif
|
||||||
|
delta8Keys.View,
|
||||||
|
delta8Cache.View);
|
||||||
|
|
||||||
|
stream.Synchronize();
|
||||||
|
buffers.FoundQWords.CopyToCPU(stream, found.AsSpan(0, threadCount));
|
||||||
|
stream.Synchronize();
|
||||||
|
|
||||||
|
Console.WriteLine($"[GPU SELFTEST] found[0]={found[0]} (expected {expectedFoundIndex})");
|
||||||
|
if (found[0] != expectedFoundIndex)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"[GPU SELFTEST FAILED] got={found[0]} expected={expectedFoundIndex}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Self-test succeeded => stop here (do not start full scan which may hit TDR during debugging).
|
||||||
|
processedAll = false;
|
||||||
|
foundDivisor = BigInteger.Zero;
|
||||||
|
AcceleratorStreamPool.Return(gpu.AcceleratorIndex, stream);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// {
|
||||||
|
// ulong[] debugWords = new ulong[debugWordsPerSlot];
|
||||||
|
// debugView.SubView(i * debugWordsPerSlot, debugWordsPerSlot).CopyToCPU(stream, debugWords);
|
||||||
|
// BigInteger gpuQ = ReadBigIntegerFromWords(debugWords.AsSpan(0, 16));
|
||||||
|
// BigInteger gpuInv = ReadBigIntegerFromWords(debugWords.AsSpan(16, 16));
|
||||||
|
// BigInteger gpuALow = ReadBigIntegerFromWords(debugWords.AsSpan(32, 16));
|
||||||
|
// ulong gpuQBits = debugWords[48];
|
||||||
|
// ulong gpuQWordCount = debugWords[49];
|
||||||
|
// ulong gpuQMask0 = debugWords[50];
|
||||||
|
// ulong gpuQMask1 = debugWords[51];
|
||||||
|
// ulong gpuKnownOne0 = debugWords[52];
|
||||||
|
// ulong gpuKnownZero0 = debugWords[53];
|
||||||
|
// ulong gpuAOneWin0 = debugWords[54];
|
||||||
|
// ulong gpuAZeroWin0 = debugWords[55];
|
||||||
|
// long gpuCarryMin = unchecked((long)debugWords[56]);
|
||||||
|
// long gpuCarryMax = unchecked((long)debugWords[57]);
|
||||||
|
// long gpuMaxAllowedA = unchecked((long)debugWords[58]);
|
||||||
|
// long gpuMaxFixed = unchecked((long)debugWords[59]);
|
||||||
|
// long gpuWindowSize = unchecked((long)debugWords[60]);
|
||||||
|
// long gpuAWordCount = unchecked((long)debugWords[61]);
|
||||||
|
// long gpuMaxKnownA = unchecked((long)debugWords[62]);
|
||||||
|
// long gpuMaxFixedPrefilter = unchecked((long)debugWords[63]);
|
||||||
|
// ulong preKnownOne0 = debugWords[64];
|
||||||
|
// ulong preKnownZero0 = debugWords[65];
|
||||||
|
// ulong preAOneWin0 = debugWords[66];
|
||||||
|
// ulong preAZeroWin0 = debugWords[67];
|
||||||
|
// long preCarryMin = unchecked((long)debugWords[68]);
|
||||||
|
// long preCarryMax = unchecked((long)debugWords[69]);
|
||||||
|
// long preSegmentBase = unchecked((long)debugWords[70]);
|
||||||
|
// long preWindowColumn = unchecked((long)debugWords[71]);
|
||||||
|
// long gpuOffsetCount = unchecked((long)debugWords[72]);
|
||||||
|
// long gpuMaxOffset = unchecked((long)debugWords[73]);
|
||||||
|
// long gpuFirstForced = unchecked((long)debugWords[74]);
|
||||||
|
// long gpuFirstRemaining = unchecked((long)debugWords[75]);
|
||||||
|
// long gpuFirstQWordsEff = unchecked((long)debugWords[76]);
|
||||||
|
// ulong gpuFirstQLastEff = debugWords[77];
|
||||||
|
// long gpuFirstCarryMin = unchecked((long)debugWords[78]);
|
||||||
|
// long gpuFirstCarryMax = unchecked((long)debugWords[79]);
|
||||||
|
// throw new InvalidOperationException($"BitContradiction GPU debug for p={prime}, q={candidateQ}, k={candidateK}, qBits={gpuQBits}, qWordCount={gpuQWordCount}, qMask0=0x{gpuQMask0:X16}, qMask1=0x{gpuQMask1:X16}, knownOne0=0x{gpuKnownOne0:X16}, knownZero0=0x{gpuKnownZero0:X16}, aOneWin0=0x{gpuAOneWin0:X16}, aZeroWin0=0x{gpuAZeroWin0:X16}, carryMin={gpuCarryMin}, carryMax={gpuCarryMax}, maxAllowedA={gpuMaxAllowedA}, maxFixed={gpuMaxFixed}, windowSize={gpuWindowSize}, aWordCount={gpuAWordCount}, maxKnownA={gpuMaxKnownA}, maxFixedPrefilter={gpuMaxFixedPrefilter}, preKnownOne0=0x{preKnownOne0:X16}, preKnownZero0=0x{preKnownZero0:X16}, preAOneWin0=0x{preAOneWin0:X16}, preAZeroWin0=0x{preAZeroWin0:X16}, preCarryMin={preCarryMin}, preCarryMax={preCarryMax}, preSegmentBase={preSegmentBase}, preWindowColumn={preWindowColumn}, offsetCount={gpuOffsetCount}, maxOffset={gpuMaxOffset}, firstForced={gpuFirstForced}, firstRemaining={gpuFirstRemaining}, firstQWordsEff={gpuFirstQWordsEff}, firstQLastEff=0x{gpuFirstQLastEff:X16}, firstCarryMin={gpuFirstCarryMin}, firstCarryMax={gpuFirstCarryMax}, gpuQ={gpuQ}, gpuInv={gpuInv}, gpuALow={gpuALow}");
|
||||||
|
// }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
foundDivisor = candidateQ;
|
||||||
|
AcceleratorStreamPool.Return(gpu.AcceleratorIndex, stream);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentBatch == TargetBatchIndex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"No divisor found up to batch index = {currentBatch}, with the target batch index = {TargetBatchIndex}");
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ContinueOuter:
|
||||||
|
RecordState(currentK);
|
||||||
|
if (hasLimit && currentK > maxK)
|
||||||
|
{
|
||||||
|
processedAll = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentBatch += threadCount;
|
||||||
|
currentK = (currentBatch * batchSizeBig) + BigInteger.One;
|
||||||
|
}
|
||||||
|
|
||||||
|
AcceleratorStreamPool.Return(gpu.AcceleratorIndex, stream);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteBigIntegerToWords(BigInteger value, Span<ulong> words)
|
||||||
|
{
|
||||||
|
Span<byte> bytes = stackalloc byte[BitContradictionKernels.MaxQWordCount * 8];
|
||||||
|
if (!value.TryWriteBytes(bytes, out int written, isUnsigned: true, isBigEndian: false))
|
||||||
|
{
|
||||||
|
written = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wordCount = words.Length;
|
||||||
|
for (int w = 0; w < wordCount; w++)
|
||||||
|
{
|
||||||
|
ulong word = 0UL;
|
||||||
|
int byteIndex = w << 3;
|
||||||
|
int limit = written - byteIndex;
|
||||||
|
if (limit > 0)
|
||||||
|
{
|
||||||
|
if (limit > 8)
|
||||||
|
{
|
||||||
|
limit = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int b = 0; b < limit; b++)
|
||||||
|
{
|
||||||
|
word |= (ulong)bytes[byteIndex + b] << (b << 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
words[w] = word;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BigInteger ReadBigIntegerFromWords(ReadOnlySpan<ulong> words)
|
||||||
|
{
|
||||||
|
Span<byte> bytes = stackalloc byte[BitContradictionKernels.MaxQWordCount * 8];
|
||||||
|
int wordCount = words.Length;
|
||||||
|
for (int w = 0; w < wordCount; w++)
|
||||||
|
{
|
||||||
|
ulong word = words[w];
|
||||||
|
int byteIndex = w << 3;
|
||||||
|
bytes[byteIndex] = (byte)word;
|
||||||
|
bytes[byteIndex + 1] = (byte)(word >> 8);
|
||||||
|
bytes[byteIndex + 2] = (byte)(word >> 16);
|
||||||
|
bytes[byteIndex + 3] = (byte)(word >> 24);
|
||||||
|
bytes[byteIndex + 4] = (byte)(word >> 32);
|
||||||
|
bytes[byteIndex + 5] = (byte)(word >> 40);
|
||||||
|
bytes[byteIndex + 6] = (byte)(word >> 48);
|
||||||
|
bytes[byteIndex + 7] = (byte)(word >> 56);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BigInteger(bytes, isUnsigned: true, isBigEndian: false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
[ThreadStatic]
|
[ThreadStatic]
|
||||||
private static Dictionary<ulong, ulong>? _pow2DivisorPowModCache;
|
private static Dictionary<ulong, ulong>? _pow2DivisorPowModCache;
|
||||||
#if DETAILED_LOG
|
#if DETAILED_LOG
|
||||||
@@ -578,7 +1076,6 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
out processedAll,
|
out processedAll,
|
||||||
out foundDivisor);
|
out foundDivisor);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// return CheckDivisorsLarge(
|
// return CheckDivisorsLarge(
|
||||||
// prime,
|
// prime,
|
||||||
@@ -596,6 +1093,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
step,
|
step,
|
||||||
out processedAll,
|
out processedAll,
|
||||||
out foundDivisor);
|
out foundDivisor);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DivisorSet_Pow2Groups
|
#if DivisorSet_Pow2Groups
|
||||||
@@ -1421,6 +1919,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContinueOuter:
|
||||||
RecordState(currentK);
|
RecordState(currentK);
|
||||||
|
|
||||||
MOVE_NEXT:
|
MOVE_NEXT:
|
||||||
@@ -1732,6 +2231,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
{
|
{
|
||||||
processedAll = false;
|
processedAll = false;
|
||||||
foundDivisor = BigInteger.Zero;
|
foundDivisor = BigInteger.Zero;
|
||||||
|
bool coversRange = true;
|
||||||
|
|
||||||
if (minK > ulong.MaxValue)
|
if (minK > ulong.MaxValue)
|
||||||
{
|
{
|
||||||
@@ -2130,7 +2630,8 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
{
|
{
|
||||||
if (((primeDecimalMask >> remainder10) & 1) != 0)
|
if (((primeDecimalMask >> remainder10) & 1) != 0)
|
||||||
{
|
{
|
||||||
RecordState(currentK);
|
ContinueOuter:
|
||||||
|
RecordState(currentK);
|
||||||
BigInteger powResult = BigInteger.ModPow(BigIntegerNumbers.Two, primeBig, divisor);
|
BigInteger powResult = BigInteger.ModPow(BigIntegerNumbers.Two, primeBig, divisor);
|
||||||
// if (powResult.IsOne && !IsMersenneValue(prime, divisor))
|
// if (powResult.IsOne && !IsMersenneValue(prime, divisor))
|
||||||
if (powResult.IsOne)
|
if (powResult.IsOne)
|
||||||
@@ -2757,6 +3258,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContinueOuter:
|
||||||
RecordState(currentK);
|
RecordState(currentK);
|
||||||
// if (divisorCycle == prime && !IsMersenneValue(prime, candidate))
|
// if (divisorCycle == prime && !IsMersenneValue(prime, candidate))
|
||||||
if (divisorCycle == prime)
|
if (divisorCycle == prime)
|
||||||
@@ -2877,6 +3379,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
if (residueStepper.IsAdmissible())
|
if (residueStepper.IsAdmissible())
|
||||||
{
|
{
|
||||||
// Stopwatch sw = Stopwatch.StartNew();
|
// Stopwatch sw = Stopwatch.StartNew();
|
||||||
|
ContinueOuter:
|
||||||
RecordState(currentK);
|
RecordState(currentK);
|
||||||
ulong powMod;
|
ulong powMod;
|
||||||
bool isPow2 = IsPowerOfTwo(currentK);
|
bool isPow2 = IsPowerOfTwo(currentK);
|
||||||
@@ -2978,6 +3481,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
byte remainder8 = rem8.ComputeNext(divisor);
|
byte remainder8 = rem8.ComputeNext(divisor);
|
||||||
if (remainder8 == 1 || remainder8 == 7)
|
if (remainder8 == 1 || remainder8 == 7)
|
||||||
{
|
{
|
||||||
|
ContinueOuter:
|
||||||
RecordState(currentK);
|
RecordState(currentK);
|
||||||
BigInteger powResult = BigInteger.ModPow(BigIntegerNumbers.Two, primeBig, divisor);
|
BigInteger powResult = BigInteger.ModPow(BigIntegerNumbers.Two, primeBig, divisor);
|
||||||
if (powResult.IsOne)
|
if (powResult.IsOne)
|
||||||
@@ -3677,6 +4181,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
byte remainder8 = rem8.ComputeNext(divisor);
|
byte remainder8 = rem8.ComputeNext(divisor);
|
||||||
if (remainder8 == 1 || remainder8 == 7)
|
if (remainder8 == 1 || remainder8 == 7)
|
||||||
{
|
{
|
||||||
|
ContinueOuter:
|
||||||
RecordState(currentK);
|
RecordState(currentK);
|
||||||
BigInteger powResult = BigInteger.ModPow(BigIntegerNumbers.Two, primeBig, divisor);
|
BigInteger powResult = BigInteger.ModPow(BigIntegerNumbers.Two, primeBig, divisor);
|
||||||
// if (powResult.IsOne && !IsMersenneValue(prime, divisor))
|
// if (powResult.IsOne && !IsMersenneValue(prime, divisor))
|
||||||
@@ -4031,6 +4536,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
divisorCycle = computedCycle;
|
divisorCycle = computedCycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContinueOuter:
|
||||||
RecordState(currentK);
|
RecordState(currentK);
|
||||||
if (divisorCycle == prime && !IsMersenneValue(prime, divisor))
|
if (divisorCycle == prime && !IsMersenneValue(prime, divisor))
|
||||||
{
|
{
|
||||||
@@ -4585,6 +5091,10 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
out bool processedAll,
|
out bool processedAll,
|
||||||
out BigInteger foundDivisor)
|
out BigInteger foundDivisor)
|
||||||
{
|
{
|
||||||
|
#if DEVICE_GPU
|
||||||
|
return CheckDivisorsBitContradictionGpu(prime, primeDecimalMask, allowedMax, minK, step, out processedAll, out foundDivisor);
|
||||||
|
#else
|
||||||
|
|
||||||
processedAll = true;
|
processedAll = true;
|
||||||
foundDivisor = BigInteger.Zero;
|
foundDivisor = BigInteger.Zero;
|
||||||
|
|
||||||
@@ -4597,10 +5107,19 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
BigInteger divisor = (step * currentK) + BigInteger.One;
|
BigInteger divisor = (step * currentK) + BigInteger.One;
|
||||||
_qBits = new int[(int)prime];
|
_qBits = new int[(int)prime];
|
||||||
Stopwatch sw = new Stopwatch();
|
Stopwatch sw = new Stopwatch();
|
||||||
|
#if WITH_PRUNE_STATS
|
||||||
|
var slowCalculationThreshold = _slowCalculationThreshold;
|
||||||
|
#endif
|
||||||
|
|
||||||
// sw.Start();
|
// sw.Start();
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
int remainder8 = (stepMod8 * kRem8 + 1) & 7;
|
int remainder8 = (stepMod8 * kRem8 + 1) & 7;
|
||||||
|
#if DETAILED_LOG
|
||||||
|
if (prime == 138000001UL && divisor == 1209708008767)
|
||||||
|
Console.WriteLine("[HIT] enumerated target q before remainder8 check");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (remainder8 != 1 && remainder8 != 7)
|
if (remainder8 != 1 && remainder8 != 7)
|
||||||
{
|
{
|
||||||
goto MOVE_NEXT;
|
goto MOVE_NEXT;
|
||||||
@@ -4631,6 +5150,13 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if WITH_PRUNE_STATS
|
||||||
|
if (sw.Elapsed >= slowCalculationThreshold)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"SLOW CALCULATIONS: Prime {prime} ({sw.Elapsed}: {divisor})");
|
||||||
|
_consolePrintOut = 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
var printToConsole = (_consolePrintOut++) == PerfectNumberConstants.ConsoleInterval;
|
var printToConsole = (_consolePrintOut++) == PerfectNumberConstants.ConsoleInterval;
|
||||||
if (printToConsole)
|
if (printToConsole)
|
||||||
{
|
{
|
||||||
@@ -4640,12 +5166,23 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
// sw.Reset();
|
// sw.Reset();
|
||||||
// sw.Start();
|
// sw.Start();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MOVE_NEXT:
|
#if DETAILED_LOG
|
||||||
|
if (prime == 138000001UL && divisor == 1209708008767)
|
||||||
|
{
|
||||||
|
Console.WriteLine("[HIT] processed target q. Stopping.");
|
||||||
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
RecordState(currentK);
|
RecordState(currentK);
|
||||||
|
MOVE_NEXT:
|
||||||
|
ContinueOuter:
|
||||||
if (hasLimit && currentK >= maxK)
|
if (hasLimit && currentK >= maxK)
|
||||||
{
|
{
|
||||||
|
RecordState(currentK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4707,6 +5244,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
// step,
|
// step,
|
||||||
// out processedAll,
|
// out processedAll,
|
||||||
// out foundDivisor);
|
// out foundDivisor);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
[ThreadStatic]
|
[ThreadStatic]
|
||||||
@@ -4798,6 +5336,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
{
|
{
|
||||||
oneOffsets[i + 1] = pow2Offsets[i] + 1;
|
oneOffsets[i + 1] = pow2Offsets[i] + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
oneCount = needed;
|
oneCount = needed;
|
||||||
usedPow2Offsets = true;
|
usedPow2Offsets = true;
|
||||||
}
|
}
|
||||||
@@ -4822,6 +5361,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
pow2OffsetsTarget = new int[oneCount];
|
pow2OffsetsTarget = new int[oneCount];
|
||||||
_pow2Offsets = pow2OffsetsTarget;
|
_pow2Offsets = pow2OffsetsTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
Array.Copy(oneOffsets, pow2OffsetsTarget, oneCount);
|
Array.Copy(oneOffsets, pow2OffsetsTarget, oneCount);
|
||||||
_pow2OffsetCount = oneCount;
|
_pow2OffsetCount = oneCount;
|
||||||
_pow2K = currentK;
|
_pow2K = currentK;
|
||||||
@@ -4836,11 +5376,11 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
|
|
||||||
ReadOnlySpan<int> oneOffsetsSlice = oneOffsets[..oneCount];
|
ReadOnlySpan<int> oneOffsetsSlice = oneOffsets[..oneCount];
|
||||||
// BitContradictionSolverWithQMultiplier.SetDebugEnabled(true);
|
// BitContradictionSolverWithQMultiplier.SetDebugEnabled(true);
|
||||||
#if DETAILED_LOG
|
#if DETAILED_LOG
|
||||||
bool decided = BitContradictionSolverWithAMultiplier.TryCheckDivisibilityFromOneOffsets(oneOffsetsSlice, prime, currentK, isPowerOfTwo, out divides, out var reason);
|
bool decided = BitContradictionSolverWithAMultiplier.TryCheckDivisibilityFromOneOffsets(oneOffsetsSlice, prime, divisor, currentK, isPowerOfTwo, out divides, out var reason);
|
||||||
#else
|
#else
|
||||||
bool decided = BitContradictionSolverWithAMultiplier.TryCheckDivisibilityFromOneOffsets(oneOffsetsSlice, prime, currentK, isPowerOfTwo, out divides);
|
bool decided = BitContradictionSolverWithAMultiplier.TryCheckDivisibilityFromOneOffsets(oneOffsetsSlice, prime, divisor, currentK, isPowerOfTwo, out divides);
|
||||||
#endif
|
#endif
|
||||||
// BitContradictionSolverWithQMultiplier.SetDebugEnabled(false);
|
// BitContradictionSolverWithQMultiplier.SetDebugEnabled(false);
|
||||||
if (decided && divides)
|
if (decided && divides)
|
||||||
{
|
{
|
||||||
@@ -4849,10 +5389,12 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
bool dividesExact = structuralOk && BigInteger.ModPow(2, prime, divisor) == BigInteger.One;
|
bool dividesExact = structuralOk && BigInteger.ModPow(2, prime, divisor) == BigInteger.One;
|
||||||
if (!dividesExact)
|
if (!dividesExact)
|
||||||
{
|
{
|
||||||
|
throw new InvalidOperationException($"We reported divisor q={divisor} as dividing {prime} but it doesn't divide it");
|
||||||
|
|
||||||
divides = false;
|
divides = false;
|
||||||
#if DETAILED_LOG
|
#if DETAILED_LOG
|
||||||
reason = ContradictionReason.ParityUnreachable;
|
reason = ContradictionReason.ParityUnreachable;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (decided && !divides)
|
if (decided && !divides)
|
||||||
@@ -4965,3 +5507,7 @@ public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneN
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+7
-4
@@ -5,6 +5,8 @@ using System.Numerics;
|
|||||||
using PerfectNumbers.Core.Gpu;
|
using PerfectNumbers.Core.Gpu;
|
||||||
using PerfectNumbers.Core.Gpu.Accelerators;
|
using PerfectNumbers.Core.Gpu.Accelerators;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if DivisorSet_Pow2Groups
|
#if DivisorSet_Pow2Groups
|
||||||
@@ -83,7 +85,7 @@ internal struct MersenneNumberDivisorByDivisorPrimeScanSessionWithTemplate
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Processing {prime}");
|
AnsiConsole.MarkupLine($"[Gray100]Processing[/] [Yellow Bold]{prime}[/]");
|
||||||
string extension = ".bin";
|
string extension = ".bin";
|
||||||
#if DivisorSet_Predictive
|
#if DivisorSet_Predictive
|
||||||
extension = ".predictive";
|
extension = ".predictive";
|
||||||
@@ -108,17 +110,18 @@ internal struct MersenneNumberDivisorByDivisorPrimeScanSessionWithTemplate
|
|||||||
{
|
{
|
||||||
_markComposite();
|
_markComposite();
|
||||||
_printResult(prime, true, true, false, divisor);
|
_printResult(prime, true, true, false, divisor);
|
||||||
Console.WriteLine($"Finished processing {prime}");
|
AnsiConsole.MarkupLine($"[DarkTurquoise]Finished processing[/] [Yellow Bold]{prime}[/]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_clearComposite();
|
_clearComposite();
|
||||||
_printResult(prime, true, divisorsExhausted, true, divisor);
|
_printResult(prime, true, divisorsExhausted, true, divisor);
|
||||||
Console.WriteLine($"Finished processing {prime}");
|
AnsiConsole.MarkupLine($"[DarkTurquoise]Finished processing[/] [Yellow Bold]{prime}[/]");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Error processing {ex.Message} {ex.StackTrace}");
|
AnsiConsole.WriteException(ex);
|
||||||
|
// Console.WriteLine($"Error processing {ex.Message} {ex.StackTrace}");
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,21 @@ using PerfectNumbers.Core.Gpu;
|
|||||||
|
|
||||||
namespace PerfectNumbers.Core;
|
namespace PerfectNumbers.Core;
|
||||||
|
|
||||||
#pragma warning disable CA2211 // The fields are settable on purpose for the best performance
|
#pragma warning disable CA2211 // Non-constant fields should not be visible
|
||||||
|
|
||||||
public static class EnvironmentConfiguration
|
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 GpuPrimeThreads = 1;
|
||||||
public static int GpuRatio = PerfectNumberConstants.GpuRatio;
|
public static int GpuRatio = PerfectNumberConstants.GpuRatio;
|
||||||
public static ComputationDevice MersenneDevice = ComputationDevice.Cpu;
|
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;
|
||||||
public static string? StateFilePath;
|
public static string? StateFilePath;
|
||||||
|
public static int ThreadCount;
|
||||||
|
public static bool UseGpu;
|
||||||
public static bool UseGpuOrder;
|
public static bool UseGpuOrder;
|
||||||
public static bool UseHybridOrder;
|
public static bool UseHybridOrder;
|
||||||
public static bool UseCpuOrder;
|
public static bool UseCpuOrder;
|
||||||
@@ -24,6 +27,7 @@ public static class EnvironmentConfiguration
|
|||||||
public static ByDivisor.ByDivisorClassModel? ByDivisorClassModel;
|
public static ByDivisor.ByDivisorClassModel? ByDivisorClassModel;
|
||||||
public static ByDivisor.ByDivisorScanTuning ByDivisorScanTuning = ByDivisor.ByDivisorScanTuning.Default;
|
public static ByDivisor.ByDivisorScanTuning ByDivisorScanTuning = ByDivisor.ByDivisorScanTuning.Default;
|
||||||
public static double ByDivisorCheapKLimit = 10_000d;
|
public static double ByDivisorCheapKLimit = 10_000d;
|
||||||
|
public static ByDivisorKIncrementMode ByDivisorKIncrementMode = ByDivisorKIncrementMode.Sequential;
|
||||||
public static Persistence.ByDivisorClassModelRepository? ByDivisorClassModelRepository;
|
public static Persistence.ByDivisorClassModelRepository? ByDivisorClassModelRepository;
|
||||||
public static Persistence.KStateRepository? ByDivisorKStateRepository;
|
public static Persistence.KStateRepository? ByDivisorKStateRepository;
|
||||||
public static Persistence.KStateRepository? ByDivisorCheapKStateRepository;
|
public static Persistence.KStateRepository? ByDivisorCheapKStateRepository;
|
||||||
@@ -31,13 +35,31 @@ public static class EnvironmentConfiguration
|
|||||||
public static Persistence.KStateRepository? ByDivisorGroupsStateRepository;
|
public static Persistence.KStateRepository? ByDivisorGroupsStateRepository;
|
||||||
public static Persistence.Pow2Minus1StateRepository? ByDivisorPow2Minus1Repository;
|
public static Persistence.Pow2Minus1StateRepository? ByDivisorPow2Minus1Repository;
|
||||||
public static Persistence.BitContradictionStateRepository? BitContradictionStateRepository;
|
public static Persistence.BitContradictionStateRepository? BitContradictionStateRepository;
|
||||||
|
public static CalculationMethod CalculationMethod = CalculationMethod.Residue;
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
|
if (MersenneDevice == ComputationDevice.Gpu &&
|
||||||
|
ByDivisorKIncrementMode == ByDivisorKIncrementMode.BitContradiction)
|
||||||
|
{
|
||||||
|
OrderDevice = ComputationDevice.Gpu;
|
||||||
|
}
|
||||||
|
|
||||||
UseGpuOrder = OrderDevice == ComputationDevice.Gpu;
|
UseGpuOrder = OrderDevice == ComputationDevice.Gpu;
|
||||||
UseHybridOrder = OrderDevice == ComputationDevice.Hybrid;
|
UseHybridOrder = OrderDevice == ComputationDevice.Hybrid;
|
||||||
UseCpuOrder = OrderDevice == ComputationDevice.Cpu;
|
UseCpuOrder = OrderDevice == ComputationDevice.Cpu;
|
||||||
|
|
||||||
|
UseGpu =
|
||||||
|
UseGpuOrder || UseHybridOrder ||
|
||||||
|
MersenneDevice is ComputationDevice.Hybrid or ComputationDevice.Gpu;
|
||||||
|
|
||||||
|
RollingAccelerators = UseGpu
|
||||||
|
? Math.Min(Math.Min(
|
||||||
|
PerfectNumberConstants.RollingAccelerators, GpuPrimeThreads), ThreadCount)
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
UsePow2GroupDivisors = ByDivisorKIncrementMode == ByDivisorKIncrementMode.Pow2Groups;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,238 @@ using PerfectNumbers.Core.Gpu.Kernels;
|
|||||||
|
|
||||||
namespace PerfectNumbers.Core.Gpu.Accelerators;
|
namespace PerfectNumbers.Core.Gpu.Accelerators;
|
||||||
|
|
||||||
|
public static class PrimeOrderCalculatorAcceleratorCapacityProviders
|
||||||
|
{
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||||
|
public static void EnsureCalculateOrderWideCapacity(this PrimeOrderCalculatorAccelerator gpu, int newSize)
|
||||||
|
{
|
||||||
|
if (newSize > gpu.Input.Length)
|
||||||
|
{
|
||||||
|
gpu.CalculateOrderWideExponentBuffer.Dispose();
|
||||||
|
gpu.CalculateOrderWideRemainderBuffer.Dispose();
|
||||||
|
|
||||||
|
var accelerator = gpu.Accelerator;
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
gpu.CalculateOrderWideExponentBuffer = accelerator.Allocate1D<GpuUInt128>(newSize);
|
||||||
|
gpu.CalculateOrderWideRemainderBuffer = accelerator.Allocate1D<GpuUInt128>(newSize);
|
||||||
|
gpu.CalculateOrderWideExponentBufferView = gpu.CalculateOrderWideExponentBuffer.View;
|
||||||
|
gpu.CalculateOrderWideRemainderBufferView = gpu.CalculateOrderWideRemainderBuffer.View;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||||
|
public static void EnsurePrimeOrderCalculatorCapacity(this PrimeOrderCalculatorAccelerator gpu, int factorsCount, int primeTesterCapacity)
|
||||||
|
{
|
||||||
|
Accelerator accelerator = gpu.Accelerator;
|
||||||
|
|
||||||
|
MemoryBuffer1D<KeyValuePair<ulong, int>, Stride1D.Dense> pow2ModEntriesToTestOnDevice = gpu.Pow2ModEntriesToTestOnDevice;
|
||||||
|
if (pow2ModEntriesToTestOnDevice.Length < factorsCount)
|
||||||
|
{
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
pow2ModEntriesToTestOnDevice.Dispose();
|
||||||
|
pow2ModEntriesToTestOnDevice = accelerator.Allocate1D<KeyValuePair<ulong, int>>(factorsCount);
|
||||||
|
gpu.Pow2ModEntriesToTestOnDevice = pow2ModEntriesToTestOnDevice;
|
||||||
|
gpu.Pow2ModEntriesToTestOnDeviceView = pow2ModEntriesToTestOnDevice.View;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryBuffer1D<ulong, Stride1D.Dense> input = gpu.Input;
|
||||||
|
if (input.Length < primeTesterCapacity)
|
||||||
|
{
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
input.Dispose();
|
||||||
|
|
||||||
|
input = accelerator.Allocate1D<ulong>(primeTesterCapacity);
|
||||||
|
gpu.Input = input;
|
||||||
|
gpu.InputView = input.View;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryBuffer1D<byte, Stride1D.Dense> outputByte = gpu.OutputByte;
|
||||||
|
if (outputByte.Length < primeTesterCapacity)
|
||||||
|
{
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
outputByte.Dispose();
|
||||||
|
|
||||||
|
outputByte = accelerator.Allocate1D<byte>(primeTesterCapacity);
|
||||||
|
gpu.OutputByte = outputByte;
|
||||||
|
gpu.OutputByteView = outputByte.View;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryBuffer1D<int, Stride1D.Dense> outputInt = gpu.OutputInt;
|
||||||
|
if (outputInt.Length < primeTesterCapacity)
|
||||||
|
{
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
outputInt.Dispose();
|
||||||
|
|
||||||
|
outputInt = accelerator.Allocate1D<int>(primeTesterCapacity);
|
||||||
|
gpu.OutputInt = outputInt;
|
||||||
|
gpu.OutputIntView = outputInt.View;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EnsurePartialFactorCapacity(this PrimeOrderCalculatorAccelerator gpu, int newSize)
|
||||||
|
{
|
||||||
|
var accelerator = gpu.Accelerator;
|
||||||
|
|
||||||
|
var outputUlong = gpu.OutputUlong;
|
||||||
|
if (newSize > outputUlong.Length)
|
||||||
|
{
|
||||||
|
outputUlong.Dispose();
|
||||||
|
|
||||||
|
outputUlong = accelerator.Allocate1D<ulong>(newSize);
|
||||||
|
gpu.OutputUlong = outputUlong;
|
||||||
|
gpu.OutputUlongView = outputUlong.View;
|
||||||
|
}
|
||||||
|
|
||||||
|
var outputInt = gpu.OutputInt;
|
||||||
|
if (newSize > outputInt.Length)
|
||||||
|
{
|
||||||
|
outputInt.Dispose();
|
||||||
|
|
||||||
|
outputInt = accelerator.Allocate1D<int>(newSize);
|
||||||
|
gpu.OutputInt = outputInt;
|
||||||
|
gpu.OutputIntView = outputInt.View;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EnsureSmallPrimeFactorSlotsCapacity(this PrimeOrderCalculatorAccelerator gpu, int newSize)
|
||||||
|
{
|
||||||
|
// Console.WriteLine($"Resizing GPU scratch buffer from pool ({buffer.SmallPrimeFactorPrimeSlots.Length} / {smallPrimeFactorSlotCount}), ({buffer.SpecialMaxFactors.Length}/{specialMaxFactorCapacity})");
|
||||||
|
var accelerator = gpu.Accelerator;
|
||||||
|
MemoryBuffer1D<ulong, Stride1D.Dense> outputUlong = gpu.OutputUlong;
|
||||||
|
if (outputUlong.Length < newSize)
|
||||||
|
{
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
outputUlong.Dispose();
|
||||||
|
|
||||||
|
outputUlong = accelerator.Allocate1D<ulong>(newSize);
|
||||||
|
gpu.OutputUlong = outputUlong;
|
||||||
|
gpu.OutputUlongView = outputUlong.View;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryBuffer1D<int, Stride1D.Dense> outputInt = gpu.OutputInt;
|
||||||
|
if (outputInt.Length < newSize)
|
||||||
|
{
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
outputInt.Dispose();
|
||||||
|
|
||||||
|
outputInt = accelerator.Allocate1D<int>(newSize);
|
||||||
|
gpu.OutputInt = outputInt;
|
||||||
|
gpu.OutputIntView = outputInt.View;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||||
|
public static void EnsureUlongInputOutputCapacity(this PrimeOrderCalculatorAccelerator gpu, int newSize)
|
||||||
|
{
|
||||||
|
var accelerator = gpu.Accelerator;
|
||||||
|
MemoryBuffer1D<ulong, Stride1D.Dense> buffer = gpu.Input;
|
||||||
|
if (buffer.Length < newSize)
|
||||||
|
{
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
buffer.Dispose();
|
||||||
|
|
||||||
|
buffer = accelerator.Allocate1D<ulong>(newSize);
|
||||||
|
gpu.Input = buffer;
|
||||||
|
gpu.InputView = buffer.View;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = gpu.OutputUlong;
|
||||||
|
if (buffer.Length < newSize)
|
||||||
|
{
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
buffer.Dispose();
|
||||||
|
|
||||||
|
buffer = accelerator.Allocate1D<ulong>(newSize);
|
||||||
|
gpu.OutputUlong = buffer;
|
||||||
|
gpu.OutputUlongView = buffer.View;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||||
|
public static BitContradictionBuffers EnsureBitContradictionCapacity(this PrimeOrderCalculatorAccelerator gpu, int maxBatchIndexWords, int maxQWords, int delta8CacheConcurrentThreads)
|
||||||
|
{
|
||||||
|
var accelerator = gpu.Accelerator;
|
||||||
|
|
||||||
|
MemoryBuffer1D<ulong, Stride1D.Dense> bufferUlong = gpu.Input;
|
||||||
|
if (bufferUlong.Length < maxBatchIndexWords)
|
||||||
|
{
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
bufferUlong.Dispose();
|
||||||
|
|
||||||
|
bufferUlong = accelerator.Allocate1D<ulong>(maxBatchIndexWords);
|
||||||
|
gpu.Input = bufferUlong;
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
MemoryBuffer1D<int, Stride1D.Dense> bufferInt = gpu.OutputInt;
|
||||||
|
maxQWords <<= 1;
|
||||||
|
if (bufferUlong.Length < maxQWords)
|
||||||
|
{
|
||||||
|
// lock (accelerator)
|
||||||
|
// {
|
||||||
|
bufferInt.Dispose();
|
||||||
|
|
||||||
|
bufferInt = accelerator.Allocate1D<int>(maxQWords);
|
||||||
|
gpu.OutputInt = bufferInt;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
bufferInt = gpu.StackIndexBuffer;
|
||||||
|
int requiredCapacity = BitContradictionKernels.GetDeltaCacheKeyLength(delta8CacheConcurrentThreads);
|
||||||
|
if (bufferInt.Length < requiredCapacity)
|
||||||
|
{
|
||||||
|
bufferInt.Dispose();
|
||||||
|
bufferInt = accelerator.Allocate1D<int>(requiredCapacity);
|
||||||
|
gpu.StackIndexBuffer = bufferInt;
|
||||||
|
|
||||||
|
bufferInt = gpu.StackExponentBuffer;
|
||||||
|
bufferInt.Dispose();
|
||||||
|
bufferInt = accelerator.Allocate1D<int>(BitContradictionKernels.GetDeltaCacheIntLength(delta8CacheConcurrentThreads));
|
||||||
|
gpu.StackExponentBuffer = bufferInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new(
|
||||||
|
gpu.Input.View,
|
||||||
|
gpu.OutputInt.View,
|
||||||
|
gpu.StackIndexBuffer.View,
|
||||||
|
gpu.StackExponentBuffer.View
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly struct BitContradictionBuffers(
|
||||||
|
in ArrayView1D<ulong, Stride1D.Dense> batchIndexWords,
|
||||||
|
in ArrayView1D<int, Stride1D.Dense> foundQWords,
|
||||||
|
in ArrayView1D<int, Stride1D.Dense> delta8CacheKeys,
|
||||||
|
in ArrayView1D<int, Stride1D.Dense> delta8CacheValues
|
||||||
|
)
|
||||||
|
{
|
||||||
|
public readonly ArrayView1D<ulong, Stride1D.Dense> BatchIndexWordsView = batchIndexWords;
|
||||||
|
public readonly ArrayView1D<int, Stride1D.Dense> FoundQWordsView = foundQWords;
|
||||||
|
public readonly ArrayView1D<int, Stride1D.Dense> Delta8CacheKeysView = delta8CacheKeys;
|
||||||
|
public readonly ArrayView1D<int, Stride1D.Dense> Delta8CacheValuesView = delta8CacheValues;
|
||||||
|
}
|
||||||
|
|
||||||
public sealed class PrimeOrderCalculatorAccelerator
|
public sealed class PrimeOrderCalculatorAccelerator
|
||||||
{
|
{
|
||||||
#region Pool
|
#region Pool
|
||||||
@@ -18,7 +250,7 @@ public sealed class PrimeOrderCalculatorAccelerator
|
|||||||
var pool = _pool ??= new(PerfectNumberConstants.DefaultThreadPoolCapacity);
|
var pool = _pool ??= new(PerfectNumberConstants.DefaultThreadPoolCapacity);
|
||||||
if (pool.TryPop(out var gpu))
|
if (pool.TryPop(out var gpu))
|
||||||
{
|
{
|
||||||
gpu.EnsureCapacity(PerfectNumberConstants.DefaultFactorsBuffer, primeTesterCapacity);
|
gpu.EnsurePrimeOrderCalculatorCapacity(PerfectNumberConstants.DefaultFactorsBuffer, primeTesterCapacity);
|
||||||
return gpu;
|
return gpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +288,11 @@ public sealed class PrimeOrderCalculatorAccelerator
|
|||||||
internal static void WarmUp()
|
internal static void WarmUp()
|
||||||
{
|
{
|
||||||
Accelerator[] accelerators = AcceleratorPool.Shared.Accelerators;
|
Accelerator[] accelerators = AcceleratorPool.Shared.Accelerators;
|
||||||
int acceleratorCount = accelerators.Length;
|
int acceleratorCount = EnvironmentConfiguration.RollingAccelerators;
|
||||||
|
if (acceleratorCount > accelerators.Length)
|
||||||
|
{
|
||||||
|
acceleratorCount = accelerators.Length;
|
||||||
|
}
|
||||||
for (var i = 0; i < acceleratorCount; i++)
|
for (var i = 0; i < acceleratorCount; i++)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Preparing accelerator {i}...");
|
Console.WriteLine($"Preparing accelerator {i}...");
|
||||||
@@ -64,6 +300,13 @@ public sealed class PrimeOrderCalculatorAccelerator
|
|||||||
AcceleratorStreamPool.WarmUp(i);
|
AcceleratorStreamPool.WarmUp(i);
|
||||||
// Don't take this from the pool as quick uploads of data to the accelerator consumes much of GPU's memory and throws.
|
// Don't take this from the pool as quick uploads of data to the accelerator consumes much of GPU's memory and throws.
|
||||||
AcceleratorStream stream = accelerator.CreateStream();
|
AcceleratorStream stream = accelerator.CreateStream();
|
||||||
|
if (SkipOrderTablesAndKernels)
|
||||||
|
{
|
||||||
|
stream.Synchronize();
|
||||||
|
stream.Dispose();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Review which tables are needed when final execution path is defined.
|
// TODO: Review which tables are needed when final execution path is defined.
|
||||||
LastDigitGpuTables.WarmUp(i, stream);
|
LastDigitGpuTables.WarmUp(i, stream);
|
||||||
_kernels[i] = new CalculatorKernels(accelerator);
|
_kernels[i] = new CalculatorKernels(accelerator);
|
||||||
@@ -99,6 +342,9 @@ public sealed class PrimeOrderCalculatorAccelerator
|
|||||||
|
|
||||||
private static readonly Accelerator[] _accelerators = AcceleratorPool.Shared.Accelerators;
|
private static readonly Accelerator[] _accelerators = AcceleratorPool.Shared.Accelerators;
|
||||||
|
|
||||||
|
public static bool SkipOrderTablesAndKernels;
|
||||||
|
|
||||||
|
|
||||||
public readonly Accelerator Accelerator;
|
public readonly Accelerator Accelerator;
|
||||||
public readonly int AcceleratorIndex;
|
public readonly int AcceleratorIndex;
|
||||||
|
|
||||||
@@ -123,8 +369,8 @@ public sealed class PrimeOrderCalculatorAccelerator
|
|||||||
|
|
||||||
public readonly MemoryBuffer1D<ulong, Stride1D.Dense> WorkFactorBuffer;
|
public readonly MemoryBuffer1D<ulong, Stride1D.Dense> WorkFactorBuffer;
|
||||||
public readonly MemoryBuffer1D<ulong, Stride1D.Dense> CandidateBuffer;
|
public readonly MemoryBuffer1D<ulong, Stride1D.Dense> CandidateBuffer;
|
||||||
public readonly MemoryBuffer1D<int, Stride1D.Dense> StackIndexBuffer;
|
public MemoryBuffer1D<int, Stride1D.Dense> StackIndexBuffer;
|
||||||
public readonly MemoryBuffer1D<int, Stride1D.Dense> StackExponentBuffer;
|
public MemoryBuffer1D<int, Stride1D.Dense> StackExponentBuffer;
|
||||||
public readonly MemoryBuffer1D<ulong, Stride1D.Dense> StackProductBuffer;
|
public readonly MemoryBuffer1D<ulong, Stride1D.Dense> StackProductBuffer;
|
||||||
|
|
||||||
public OrderKernelBuffers CalculateOrderKernelBuffers;
|
public OrderKernelBuffers CalculateOrderKernelBuffers;
|
||||||
@@ -134,15 +380,11 @@ public sealed class PrimeOrderCalculatorAccelerator
|
|||||||
public readonly ArrayView1D<int, Stride1D.Dense> StackExponentBufferView;
|
public readonly ArrayView1D<int, Stride1D.Dense> StackExponentBufferView;
|
||||||
public readonly ArrayView1D<ulong, Stride1D.Dense> StackProductBufferView;
|
public readonly ArrayView1D<ulong, Stride1D.Dense> StackProductBufferView;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MemoryBuffer1D<GpuUInt128, Stride1D.Dense> CalculateOrderWideExponentBuffer;
|
public MemoryBuffer1D<GpuUInt128, Stride1D.Dense> CalculateOrderWideExponentBuffer;
|
||||||
public MemoryBuffer1D<GpuUInt128, Stride1D.Dense> CalculateOrderWideRemainderBuffer;
|
public MemoryBuffer1D<GpuUInt128, Stride1D.Dense> CalculateOrderWideRemainderBuffer;
|
||||||
public ArrayView1D<GpuUInt128, Stride1D.Dense> CalculateOrderWideExponentBufferView;
|
public ArrayView1D<GpuUInt128, Stride1D.Dense> CalculateOrderWideExponentBufferView;
|
||||||
public ArrayView1D<GpuUInt128, Stride1D.Dense> CalculateOrderWideRemainderBufferView;
|
public ArrayView1D<GpuUInt128, Stride1D.Dense> CalculateOrderWideRemainderBufferView;
|
||||||
|
|
||||||
|
|
||||||
public Dictionary<ulong, int> Pow2ModEntriesToTestOnHost = [];
|
public Dictionary<ulong, int> Pow2ModEntriesToTestOnHost = [];
|
||||||
|
|
||||||
private static readonly CalculatorKernels[] _kernels = new CalculatorKernels[_accelerators.Length];
|
private static readonly CalculatorKernels[] _kernels = new CalculatorKernels[_accelerators.Length];
|
||||||
@@ -191,169 +433,6 @@ public sealed class PrimeOrderCalculatorAccelerator
|
|||||||
public readonly Action<AcceleratorStream, Index1D, ArrayView<ulong>, ArrayView<uint>, ArrayView<uint>, ArrayView<uint>, ArrayView<uint>, ArrayView<ulong>, ArrayView<ulong>, ArrayView<ulong>, ArrayView<ulong>, ArrayView<byte>> SmallPrimeSieveKernelLauncher;
|
public readonly Action<AcceleratorStream, Index1D, ArrayView<ulong>, ArrayView<uint>, ArrayView<uint>, ArrayView<uint>, ArrayView<uint>, ArrayView<ulong>, ArrayView<ulong>, ArrayView<ulong>, ArrayView<ulong>, ArrayView<byte>> SmallPrimeSieveKernelLauncher;
|
||||||
public readonly Action<AcceleratorStream, Index1D, ulong, ArrayView<ulong>, int, ulong, ArrayView<ulong>> SpecialMaxKernelLauncher;
|
public readonly Action<AcceleratorStream, Index1D, ulong, ArrayView<ulong>, int, ulong, ArrayView<ulong>> SpecialMaxKernelLauncher;
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public void EnsureCalculateOrderWideCapacity(int newSize)
|
|
||||||
{
|
|
||||||
if (newSize > Input.Length)
|
|
||||||
{
|
|
||||||
CalculateOrderWideExponentBuffer.Dispose();
|
|
||||||
CalculateOrderWideRemainderBuffer.Dispose();
|
|
||||||
|
|
||||||
var accelerator = Accelerator;
|
|
||||||
// lock (accelerator)
|
|
||||||
// {
|
|
||||||
CalculateOrderWideExponentBuffer = accelerator.Allocate1D<GpuUInt128>(newSize);
|
|
||||||
CalculateOrderWideRemainderBuffer = accelerator.Allocate1D<GpuUInt128>(newSize);
|
|
||||||
CalculateOrderWideExponentBufferView = CalculateOrderWideExponentBuffer.View;
|
|
||||||
CalculateOrderWideRemainderBufferView = CalculateOrderWideRemainderBuffer.View;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public void EnsureCapacity(int factorsCount, int primeTesterCapacity)
|
|
||||||
{
|
|
||||||
Accelerator accelerator = Accelerator;
|
|
||||||
|
|
||||||
MemoryBuffer1D<KeyValuePair<ulong, int>, Stride1D.Dense> pow2ModEntriesToTestOnDevice = Pow2ModEntriesToTestOnDevice;
|
|
||||||
if (pow2ModEntriesToTestOnDevice.Length < factorsCount)
|
|
||||||
{
|
|
||||||
// lock (accelerator)
|
|
||||||
// {
|
|
||||||
pow2ModEntriesToTestOnDevice.Dispose();
|
|
||||||
pow2ModEntriesToTestOnDevice = accelerator.Allocate1D<KeyValuePair<ulong, int>>(factorsCount);
|
|
||||||
Pow2ModEntriesToTestOnDevice = pow2ModEntriesToTestOnDevice;
|
|
||||||
Pow2ModEntriesToTestOnDeviceView = pow2ModEntriesToTestOnDevice.View;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryBuffer1D<ulong, Stride1D.Dense> input = Input;
|
|
||||||
if (input.Length < primeTesterCapacity)
|
|
||||||
{
|
|
||||||
// lock (accelerator)
|
|
||||||
// {
|
|
||||||
input.Dispose();
|
|
||||||
|
|
||||||
input = accelerator.Allocate1D<ulong>(primeTesterCapacity);
|
|
||||||
Input = input;
|
|
||||||
InputView = input.View;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryBuffer1D<byte, Stride1D.Dense> outputByte = OutputByte;
|
|
||||||
if (outputByte.Length < primeTesterCapacity)
|
|
||||||
{
|
|
||||||
// lock (accelerator)
|
|
||||||
// {
|
|
||||||
outputByte.Dispose();
|
|
||||||
|
|
||||||
outputByte = accelerator.Allocate1D<byte>(primeTesterCapacity);
|
|
||||||
OutputByte = outputByte;
|
|
||||||
OutputByteView = outputByte.View;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryBuffer1D<int, Stride1D.Dense> outputInt = OutputInt;
|
|
||||||
if (outputInt.Length < primeTesterCapacity)
|
|
||||||
{
|
|
||||||
// lock (accelerator)
|
|
||||||
// {
|
|
||||||
outputInt.Dispose();
|
|
||||||
|
|
||||||
outputInt = accelerator.Allocate1D<int>(primeTesterCapacity);
|
|
||||||
OutputInt = outputInt;
|
|
||||||
OutputIntView = outputInt.View;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void EnsurePartialFactorCapacity(int newSize)
|
|
||||||
{
|
|
||||||
var accelerator = Accelerator;
|
|
||||||
|
|
||||||
var outputUlong = OutputUlong;
|
|
||||||
if (newSize > outputUlong.Length)
|
|
||||||
{
|
|
||||||
outputUlong.Dispose();
|
|
||||||
|
|
||||||
outputUlong = accelerator.Allocate1D<ulong>(newSize);
|
|
||||||
OutputUlong = outputUlong;
|
|
||||||
OutputUlongView = outputUlong.View;
|
|
||||||
}
|
|
||||||
|
|
||||||
var outputInt = OutputInt;
|
|
||||||
if (newSize > outputInt.Length)
|
|
||||||
{
|
|
||||||
outputInt.Dispose();
|
|
||||||
|
|
||||||
outputInt = accelerator.Allocate1D<int>(newSize);
|
|
||||||
OutputInt = outputInt;
|
|
||||||
OutputIntView = outputInt.View;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void EnsureSmallPrimeFactorSlotsCapacity(int newSize)
|
|
||||||
{
|
|
||||||
// Console.WriteLine($"Resizing GPU scratch buffer from pool ({buffer.SmallPrimeFactorPrimeSlots.Length} / {smallPrimeFactorSlotCount}), ({buffer.SpecialMaxFactors.Length}/{specialMaxFactorCapacity})");
|
|
||||||
var accelerator = Accelerator;
|
|
||||||
MemoryBuffer1D<ulong, Stride1D.Dense> outputUlong = OutputUlong;
|
|
||||||
if (outputUlong.Length < newSize)
|
|
||||||
{
|
|
||||||
// lock (accelerator)
|
|
||||||
// {
|
|
||||||
outputUlong.Dispose();
|
|
||||||
|
|
||||||
outputUlong = accelerator.Allocate1D<ulong>(newSize);
|
|
||||||
OutputUlong = outputUlong;
|
|
||||||
OutputUlongView = outputUlong.View;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
MemoryBuffer1D<int, Stride1D.Dense> outputInt = OutputInt;
|
|
||||||
if (outputInt.Length < newSize)
|
|
||||||
{
|
|
||||||
// lock (accelerator)
|
|
||||||
// {
|
|
||||||
outputInt.Dispose();
|
|
||||||
|
|
||||||
outputInt = accelerator.Allocate1D<int>(newSize);
|
|
||||||
OutputInt = outputInt;
|
|
||||||
OutputIntView = outputInt.View;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public void EnsureUlongInputOutputCapacity(int newSize)
|
|
||||||
{
|
|
||||||
var accelerator = Accelerator;
|
|
||||||
MemoryBuffer1D<ulong, Stride1D.Dense> buffer = Input;
|
|
||||||
if (buffer.Length < newSize)
|
|
||||||
{
|
|
||||||
// lock (accelerator)
|
|
||||||
// {
|
|
||||||
buffer.Dispose();
|
|
||||||
|
|
||||||
buffer = accelerator.Allocate1D<ulong>(newSize);
|
|
||||||
Input = buffer;
|
|
||||||
InputView = buffer.View;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = OutputUlong;
|
|
||||||
if (buffer.Length < newSize)
|
|
||||||
{
|
|
||||||
// lock (accelerator)
|
|
||||||
// {
|
|
||||||
buffer.Dispose();
|
|
||||||
|
|
||||||
buffer = accelerator.Allocate1D<ulong>(newSize);
|
|
||||||
OutputUlong = buffer;
|
|
||||||
OutputUlongView = buffer.View;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrimeOrderCalculatorAccelerator(int acceleratorIndex, int factorsCount, int primeTesterCapacity, int smallPrimeFactorSlotCount, int specialMaxFactorCapacity)
|
public PrimeOrderCalculatorAccelerator(int acceleratorIndex, int factorsCount, int primeTesterCapacity, int smallPrimeFactorSlotCount, int specialMaxFactorCapacity)
|
||||||
{
|
{
|
||||||
var accelerator = _accelerators[acceleratorIndex];
|
var accelerator = _accelerators[acceleratorIndex];
|
||||||
@@ -411,6 +490,28 @@ public sealed class PrimeOrderCalculatorAccelerator
|
|||||||
CalculateOrderWideExponentBufferView = CalculateOrderWideExponentBuffer.View;
|
CalculateOrderWideExponentBufferView = CalculateOrderWideExponentBuffer.View;
|
||||||
CalculateOrderWideRemainderBufferView = CalculateOrderWideRemainderBuffer.View;
|
CalculateOrderWideRemainderBufferView = CalculateOrderWideRemainderBuffer.View;
|
||||||
|
|
||||||
|
if (SkipOrderTablesAndKernels)
|
||||||
|
{
|
||||||
|
DevicePrimesLastOne = default;
|
||||||
|
DevicePrimesLastSeven = default;
|
||||||
|
DevicePrimesLastThree = default;
|
||||||
|
DevicePrimesLastNine = default;
|
||||||
|
DevicePrimesPow2LastOne = default;
|
||||||
|
DevicePrimesPow2LastSeven = default;
|
||||||
|
DevicePrimesPow2LastThree = default;
|
||||||
|
DevicePrimesPow2LastNine = default;
|
||||||
|
SmallPrimeFactorPrimes = default;
|
||||||
|
SmallPrimeFactorSquares = default;
|
||||||
|
CheckFactorsKernel = default;
|
||||||
|
ConvertToStandardKernelLauncher = default;
|
||||||
|
HeuristicCombinedTrialDivisionKernelLauncher = default;
|
||||||
|
Pow2ModKernelLauncher = default;
|
||||||
|
Pow2ModWideKernelLauncher = default;
|
||||||
|
SmallPrimeFactorKernelLauncher = default;
|
||||||
|
SpecialMaxKernelLauncher = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LastDigitGpuTables lastDigitSharedTables = LastDigitGpuTables.GetStaticTables(acceleratorIndex);
|
LastDigitGpuTables lastDigitSharedTables = LastDigitGpuTables.GetStaticTables(acceleratorIndex);
|
||||||
DevicePrimesLastOne = lastDigitSharedTables.DevicePrimesLastOne.View;
|
DevicePrimesLastOne = lastDigitSharedTables.DevicePrimesLastOne.View;
|
||||||
DevicePrimesLastSeven = lastDigitSharedTables.DevicePrimesLastSeven.View;
|
DevicePrimesLastSeven = lastDigitSharedTables.DevicePrimesLastSeven.View;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System.Runtime.CompilerServices;
|
|||||||
using ILGPU;
|
using ILGPU;
|
||||||
using ILGPU.Runtime;
|
using ILGPU.Runtime;
|
||||||
using PerfectNumbers.Core.Gpu.Accelerators;
|
using PerfectNumbers.Core.Gpu.Accelerators;
|
||||||
|
using PerfectNumbers.Core.Gpu.Kernels;
|
||||||
|
|
||||||
namespace PerfectNumbers.Core.Gpu;
|
namespace PerfectNumbers.Core.Gpu;
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ public class GpuKernelPool
|
|||||||
|
|
||||||
internal static KernelContainer GetOrAddKernels(int acceleratorIndex, AcceleratorStream stream, KernelType kernelType)
|
internal static KernelContainer GetOrAddKernels(int acceleratorIndex, AcceleratorStream stream, KernelType kernelType)
|
||||||
{
|
{
|
||||||
var pool = _pool ??= [];
|
var pool = _pool ??= new KernelContainer[_accelerators.Length];
|
||||||
if (pool[acceleratorIndex] is not { } kernels)
|
if (pool[acceleratorIndex] is not { } kernels)
|
||||||
{
|
{
|
||||||
kernels = new();
|
kernels = new();
|
||||||
@@ -58,6 +59,11 @@ public class GpuKernelPool
|
|||||||
InitPow2ModOrderKernelScan(accelerator, kernels);
|
InitPow2ModOrderKernelScan(accelerator, kernels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (kernelType.HasFlag(KernelType.BitContradictionScan))
|
||||||
|
{
|
||||||
|
InitBitContradictionKernel(accelerator, kernels);
|
||||||
|
}
|
||||||
|
|
||||||
PreloadStaticTables(accelerator, kernels, stream, kernelType);
|
PreloadStaticTables(accelerator, kernels, stream, kernelType);
|
||||||
|
|
||||||
pool[acceleratorIndex] = kernels;
|
pool[acceleratorIndex] = kernels;
|
||||||
@@ -113,6 +119,29 @@ public class GpuKernelPool
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void InitBitContradictionKernel(Accelerator accelerator, KernelContainer kernels)
|
||||||
|
{
|
||||||
|
InitOnce(ref kernels.BitContradiction, () =>
|
||||||
|
{
|
||||||
|
var loaded = accelerator.LoadAutoGroupedStreamKernel<
|
||||||
|
Index1D, ulong, ArrayView1D<ulong, Stride1D.Dense>, int, ArrayView1D<int, Stride1D.Dense>,
|
||||||
|
#if DETAILED_LOG || SELF_TEST
|
||||||
|
ArrayView1D<ulong, Stride1D.Dense>,
|
||||||
|
#endif
|
||||||
|
ArrayView1D<int, Stride1D.Dense>, ArrayView1D<int, Stride1D.Dense>
|
||||||
|
>(BitContradictionKernels.BitContradictionKernelScanWithDeltaCache64);
|
||||||
|
|
||||||
|
var kernel = KernelUtil.GetKernel(loaded);
|
||||||
|
|
||||||
|
return kernel.CreateLauncherDelegate<Action<AcceleratorStream, Index1D, ulong, ArrayView1D<ulong, Stride1D.Dense>, int,
|
||||||
|
ArrayView1D<int, Stride1D.Dense>,
|
||||||
|
#if DETAILED_LOG || SELF_TEST
|
||||||
|
ArrayView1D<ulong, Stride1D.Dense>,
|
||||||
|
#endif
|
||||||
|
ArrayView1D<int, Stride1D.Dense>, ArrayView1D<int, Stride1D.Dense>>>();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static void InitPow2ModOrderKernelScan(Accelerator accelerator, KernelContainer kernels)
|
static void InitPow2ModOrderKernelScan(Accelerator accelerator, KernelContainer kernels)
|
||||||
{
|
{
|
||||||
InitOnce(ref kernels.Pow2ModOrder, () =>
|
InitOnce(ref kernels.Pow2ModOrder, () =>
|
||||||
|
|||||||
@@ -22,6 +22,12 @@ public sealed class KernelContainer
|
|||||||
public Action<AcceleratorStream, Index1D, ulong, GpuUInt128, GpuUInt128, byte, ulong,
|
public Action<AcceleratorStream, Index1D, ulong, GpuUInt128, GpuUInt128, byte, ulong,
|
||||||
ResidueAutomatonArgs, ArrayView<int>, ArrayView1D<ulong, Stride1D.Dense>>? Pow2ModOrder;
|
ResidueAutomatonArgs, ArrayView<int>, ArrayView1D<ulong, Stride1D.Dense>>? Pow2ModOrder;
|
||||||
|
|
||||||
|
public Action<AcceleratorStream, Index1D, ulong, ArrayView1D<ulong, Stride1D.Dense>, int, ArrayView1D<int, Stride1D.Dense>,
|
||||||
|
#if DETAILED_LOG || SELF_TEST
|
||||||
|
ArrayView1D<ulong, Stride1D.Dense>,
|
||||||
|
#endif
|
||||||
|
ArrayView1D<int, Stride1D.Dense>, ArrayView1D<int, Stride1D.Dense>>? BitContradiction;
|
||||||
|
|
||||||
public Kernel? SmallPrimeFactor;
|
public Kernel? SmallPrimeFactor;
|
||||||
|
|
||||||
public Action<AcceleratorStream, Index1D, ulong, ArrayView1D<ulong, Stride1D.Dense>, int, MontgomeryDivisorData, ArrayView1D<ulong, Stride1D.Dense>, ArrayView1D<ulong, Stride1D.Dense>>? SpecialMax;
|
public Action<AcceleratorStream, Index1D, ulong, ArrayView1D<ulong, Stride1D.Dense>, int, MontgomeryDivisorData, ArrayView1D<ulong, Stride1D.Dense>, ArrayView1D<ulong, Stride1D.Dense>>? SpecialMax;
|
||||||
|
|||||||
@@ -10,5 +10,6 @@ public enum KernelType
|
|||||||
OrderKernelScan,
|
OrderKernelScan,
|
||||||
IncrementalKernelScan,
|
IncrementalKernelScan,
|
||||||
IncrementalOrderKernelScan,
|
IncrementalOrderKernelScan,
|
||||||
Pow2ModOrderKernelScan
|
Pow2ModOrderKernelScan,
|
||||||
|
BitContradictionScan
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,7 @@
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace PerfectNumbers.Core.Gpu;
|
namespace PerfectNumbers.Core.Gpu;
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ internal struct MersenneNumberDivisorByDivisorGpuPrimeScanSession
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Processing {prime}");
|
AnsiConsole.MarkupLine($"[Gray100]Processing[/] [Yellow Bold]{prime}[/]");
|
||||||
string stateFile = prime.ToString(CultureInfo.InvariantCulture) + ".bin";
|
string stateFile = prime.ToString(CultureInfo.InvariantCulture) + ".bin";
|
||||||
|
|
||||||
ConfigureForPrime(stateFile);
|
ConfigureForPrime(stateFile);
|
||||||
@@ -45,17 +46,17 @@ internal struct MersenneNumberDivisorByDivisorGpuPrimeScanSession
|
|||||||
{
|
{
|
||||||
_markComposite();
|
_markComposite();
|
||||||
_printResult(prime, true, true, false, divisor);
|
_printResult(prime, true, true, false, divisor);
|
||||||
Console.WriteLine($"Finished processing {prime}");
|
AnsiConsole.MarkupLine($"[DarkTurquoise]Finished processing[/] [Yellow Bold]{prime}[/]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_clearComposite();
|
_clearComposite();
|
||||||
_printResult(prime, true, divisorsExhausted, true, divisor);
|
_printResult(prime, true, divisorsExhausted, true, divisor);
|
||||||
Console.WriteLine($"Finished processing {prime}");
|
AnsiConsole.MarkupLine($"[DarkTurquoise]Finished processing[/] [Yellow Bold]{prime}[/]");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Error processing {ex.Message} {ex.StackTrace}");
|
AnsiConsole.WriteException(ex);
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace PerfectNumbers.Core;
|
||||||
|
|
||||||
|
public enum GpuKernelType
|
||||||
|
{
|
||||||
|
Incremental,
|
||||||
|
Pow2Mod,
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ using MersenneNumberDivisorByDivisorCpuTesterWithBitContradictionGpuOrder = Perf
|
|||||||
using MersenneNumberDivisorByDivisorCpuTesterWithBitTreeCpuOrder = PerfectNumbers.Core.Cpu.MersenneNumberDivisorByDivisorCpuTesterWithForBitTreeDivisorSetForCpuOrder;
|
using MersenneNumberDivisorByDivisorCpuTesterWithBitTreeCpuOrder = PerfectNumbers.Core.Cpu.MersenneNumberDivisorByDivisorCpuTesterWithForBitTreeDivisorSetForCpuOrder;
|
||||||
using MersenneNumberDivisorByDivisorCpuTesterWithBitTreeHybridOrder = PerfectNumbers.Core.Cpu.MersenneNumberDivisorByDivisorCpuTesterWithForBitTreeDivisorSetForHybridOrder;
|
using MersenneNumberDivisorByDivisorCpuTesterWithBitTreeHybridOrder = PerfectNumbers.Core.Cpu.MersenneNumberDivisorByDivisorCpuTesterWithForBitTreeDivisorSetForHybridOrder;
|
||||||
using MersenneNumberDivisorByDivisorCpuTesterWithBitTreeGpuOrder = PerfectNumbers.Core.Cpu.MersenneNumberDivisorByDivisorCpuTesterWithForBitTreeDivisorSetForGpuOrder;
|
using MersenneNumberDivisorByDivisorCpuTesterWithBitTreeGpuOrder = PerfectNumbers.Core.Cpu.MersenneNumberDivisorByDivisorCpuTesterWithForBitTreeDivisorSetForGpuOrder;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace PerfectNumbers.Core;
|
namespace PerfectNumbers.Core;
|
||||||
|
|
||||||
@@ -1199,7 +1200,7 @@ public static class MersenneNumberDivisorByDivisorTester
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Processing {prime}");
|
AnsiConsole.MarkupLine($"[Gray100]Processing[/] [Yellow Bold]{prime}[/]");
|
||||||
string stateFile = Path.Combine(
|
string stateFile = Path.Combine(
|
||||||
PerfectNumberConstants.ByDivisorStateDirectory,
|
PerfectNumberConstants.ByDivisorStateDirectory,
|
||||||
prime.ToString(CultureInfo.InvariantCulture) + ".bin");
|
prime.ToString(CultureInfo.InvariantCulture) + ".bin");
|
||||||
@@ -1235,17 +1236,18 @@ public static class MersenneNumberDivisorByDivisorTester
|
|||||||
|
|
||||||
markComposite();
|
markComposite();
|
||||||
printResult(prime, true, true, false, divisor);
|
printResult(prime, true, true, false, divisor);
|
||||||
Console.WriteLine($"Finished processing {prime}");
|
AnsiConsole.MarkupLine($"[DarkTurquoise]Finished processing[/] [Yellow Bold]{prime}[/]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearComposite();
|
clearComposite();
|
||||||
printResult(prime, true, divisorsExhausted, true, divisor);
|
printResult(prime, true, divisorsExhausted, true, divisor);
|
||||||
Console.WriteLine($"Finished processing {prime}");
|
AnsiConsole.MarkupLine($"[DarkTurquoise]Finished processing[/] [Yellow Bold]{prime}[/]");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Error processing {ex.Message} {ex.StackTrace}");
|
AnsiConsole.WriteException(ex);
|
||||||
|
// Console.WriteLine($"Error processing {ex.Message} {ex.StackTrace}");
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,35 +11,6 @@ using PerfectNumbers.Core.Gpu.Accelerators;
|
|||||||
|
|
||||||
namespace PerfectNumbers.Core;
|
namespace PerfectNumbers.Core;
|
||||||
|
|
||||||
public enum GpuKernelType
|
|
||||||
{
|
|
||||||
Incremental,
|
|
||||||
Pow2Mod,
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CalculationMethod
|
|
||||||
{
|
|
||||||
ByDivisor,
|
|
||||||
Divisor,
|
|
||||||
Incremental,
|
|
||||||
LucasLehmer,
|
|
||||||
Pow2Mod,
|
|
||||||
Residue,
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CacheStatus
|
|
||||||
{
|
|
||||||
Disabled,
|
|
||||||
Enabled,
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum OrderDevice
|
|
||||||
{
|
|
||||||
Cpu,
|
|
||||||
Hybrid,
|
|
||||||
Gpu,
|
|
||||||
}
|
|
||||||
|
|
||||||
[EnumDependentTemplate(typeof(CalculationMethod))]
|
[EnumDependentTemplate(typeof(CalculationMethod))]
|
||||||
[EnumDependentTemplate(typeof(CacheStatus))]
|
[EnumDependentTemplate(typeof(CacheStatus))]
|
||||||
[EnumDependentTemplate(typeof(OrderDevice))]
|
[EnumDependentTemplate(typeof(OrderDevice))]
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace PerfectNumbers.Core;
|
||||||
|
|
||||||
|
public enum OrderDevice
|
||||||
|
{
|
||||||
|
Cpu,
|
||||||
|
Hybrid,
|
||||||
|
Gpu,
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace PerfectNumbers.Core;
|
|||||||
public static class PerfectNumberConstants
|
public static class PerfectNumberConstants
|
||||||
{
|
{
|
||||||
public const ulong BiggestKnownEvenPerfectP = 136279841UL;
|
public const ulong BiggestKnownEvenPerfectP = 136279841UL;
|
||||||
|
// public const int ConsoleInterval = 1;
|
||||||
public const int ConsoleInterval = 100_000;
|
public const int ConsoleInterval = 100_000;
|
||||||
public const int DefaultFactorsBuffer = 32;
|
public const int DefaultFactorsBuffer = 32;
|
||||||
public const int DefaultPoolCapacity = 10_240;
|
public const int DefaultPoolCapacity = 10_240;
|
||||||
@@ -20,12 +21,19 @@ public static class PerfectNumberConstants
|
|||||||
public const int PooledArrayThreshold = 64;
|
public const int PooledArrayThreshold = 64;
|
||||||
public const int Pow2WindowSize = 8;
|
public const int Pow2WindowSize = 8;
|
||||||
public const int RollingAccelerators = 298;
|
public const int RollingAccelerators = 298;
|
||||||
public const int ThreadsByAccelerator = 1;
|
public const int ThreadsByAccelerator = 4;
|
||||||
public const int ByDivisorStateSaveInterval = 1_000;
|
public const int ByDivisorFlushAndEvictInterval = 5;
|
||||||
|
public const int ByDivisorStateSaveInterval = 10_000_000;
|
||||||
public const string ByDivisorStateDirectory = "Checks";
|
public const string ByDivisorStateDirectory = "Checks";
|
||||||
public const int PollardRhoMilliseconds = 100;
|
public const int PollardRhoMilliseconds = 100;
|
||||||
public const int ByDivisorMersenneTailCount = 8;
|
public const int ByDivisorMersenneTailCount = 8;
|
||||||
public const int ByDivisorMersenneBitLimit = 4096;
|
public const int ByDivisorMersenneBitLimit = 4096;
|
||||||
|
public const int BitContradictionForcedALowBits = 4096;
|
||||||
|
public const int BitContradictionGpuBatchCount = 16;
|
||||||
|
// public const int BitContradictionGpuBatchCount = 512;
|
||||||
|
// public const int BitContradictionGpuBatchCount = 131_072;
|
||||||
|
// public const int BitContradictionGpuBatchCount = 2_097_152;
|
||||||
|
public const int BitContradictionGpuThreads = 1;
|
||||||
// TODO: Load these limits from the benchmark-driven configuration so CPU and GPU scans stay aligned with the optimal
|
// TODO: Load these limits from the benchmark-driven configuration so CPU and GPU scans stay aligned with the optimal
|
||||||
// divisor-cycle datasets we generate offline.
|
// divisor-cycle datasets we generate offline.
|
||||||
// TODO: Promote these magic numbers into a runtime profile derived from EvenPerfectBitScanner.Benchmarks so we can retune
|
// TODO: Promote these magic numbers into a runtime profile derived from EvenPerfectBitScanner.Benchmarks so we can retune
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>12.0</LangVersion>
|
<LangVersion>12.0</LangVersion>
|
||||||
@@ -9,6 +9,12 @@
|
|||||||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
||||||
<CompilerGeneratedFilesOutputPath>$(IntermediateOutputPath)generated</CompilerGeneratedFilesOutputPath>
|
<CompilerGeneratedFilesOutputPath>$(IntermediateOutputPath)generated</CompilerGeneratedFilesOutputPath>
|
||||||
<!-- <DefineConstants>$(DefineConstants);DETAILED_LOG</DefineConstants> -->
|
<!-- <DefineConstants>$(DefineConstants);DETAILED_LOG</DefineConstants> -->
|
||||||
|
<!-- <DefineConstants>$(DefineConstants);INVERSION_VALIDATION</DefineConstants> -->
|
||||||
|
<!-- <DefineConstants>$(DefineConstants);OVERRIDE_MIN_K</DefineConstants> -->
|
||||||
|
<!-- <DefineConstants>$(DefineConstants);SELF_TEST</DefineConstants> -->
|
||||||
|
<!-- <DefineConstants>$(DefineConstants);EXPORT_STAGE</DefineConstants> -->
|
||||||
|
<DefineConstants>$(DefineConstants);WITH_PRUNE_STATS</DefineConstants>
|
||||||
|
<DefineConstants>$(DefineConstants);WITH_PRUNE_VALIDATION</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -24,6 +30,7 @@
|
|||||||
<PackageReference Include="ILGPU.Algorithms" Version="1.5.3" />
|
<PackageReference Include="ILGPU.Algorithms" Version="1.5.3" />
|
||||||
<PackageReference Include="LightningDB" Version="0.21.0" />
|
<PackageReference Include="LightningDB" Version="0.21.0" />
|
||||||
<PackageReference Include="Microsoft.FASTER.Core" Version="2.4.0" />
|
<PackageReference Include="Microsoft.FASTER.Core" Version="2.4.0" />
|
||||||
|
<PackageReference Include="Spectre.Console" Version="0.54.1-alpha.0.37" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -68,12 +68,15 @@ public sealed class KStateRepository : IDisposable
|
|||||||
session.Upsert(keyString, valueString);
|
session.Upsert(keyString, valueString);
|
||||||
session.CompletePending(true);
|
session.CompletePending(true);
|
||||||
var flushCount = ++_flushCount;
|
var flushCount = ++_flushCount;
|
||||||
if (flushCount >= PerfectNumberConstants.ByDivisorStateSaveInterval)
|
if (flushCount >= PerfectNumberConstants.ByDivisorFlushAndEvictInterval)
|
||||||
{
|
{
|
||||||
_flushCount = 0;
|
_flushCount = 0;
|
||||||
_store.Log.FlushAndEvict(wait: true);
|
_store.Log.FlushAndEvict(wait: true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_store.Log.Flush(wait: false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGet(ulong prime, out BigInteger value)
|
public bool TryGet(ulong prime, out BigInteger value)
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ namespace PerfectNumbers.Core
|
|||||||
61 => BigIntegerNumbers.Pow2Exact61,
|
61 => BigIntegerNumbers.Pow2Exact61,
|
||||||
62 => BigIntegerNumbers.Pow2Exact62,
|
62 => BigIntegerNumbers.Pow2Exact62,
|
||||||
63 => BigIntegerNumbers.Pow2Exact63,
|
63 => BigIntegerNumbers.Pow2Exact63,
|
||||||
|
_ when i >= 0 => System.Numerics.BigInteger.One << i,
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(i), $"Parameter value {i} is incorrect"),
|
_ => throw new ArgumentOutOfRangeException(nameof(i), $"Parameter value {i} is incorrect"),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -140,6 +141,7 @@ namespace PerfectNumbers.Core
|
|||||||
62 => BigIntegerNumbers.Pow2MinusOne62,
|
62 => BigIntegerNumbers.Pow2MinusOne62,
|
||||||
63 => BigIntegerNumbers.Pow2MinusOne63,
|
63 => BigIntegerNumbers.Pow2MinusOne63,
|
||||||
1024 => BigIntegerNumbers.Pow2MinusOne1024,
|
1024 => BigIntegerNumbers.Pow2MinusOne1024,
|
||||||
|
_ when i >= 0 => (System.Numerics.BigInteger.One << i) - System.Numerics.BigInteger.One,
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(i), $"Parameter value {i} is incorrect"),
|
_ => throw new ArgumentOutOfRangeException(nameof(i), $"Parameter value {i} is incorrect"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using ILGPU.Runtime;
|
using ILGPU.Runtime;
|
||||||
|
using PerfectNumbers.Core.Gpu;
|
||||||
using PerfectNumbers.Core.Gpu.Accelerators;
|
using PerfectNumbers.Core.Gpu.Accelerators;
|
||||||
|
|
||||||
namespace PerfectNumbers.Core;
|
namespace PerfectNumbers.Core;
|
||||||
@@ -157,6 +158,45 @@ public sealed class PrimeTester
|
|||||||
|
|
||||||
private static readonly object GpuWarmUpLock = new();
|
private static readonly object GpuWarmUpLock = new();
|
||||||
private static int WarmedGpuLeaseCount;
|
private static int WarmedGpuLeaseCount;
|
||||||
|
private static int WarmedBitContradictionGpuLeaseCount;
|
||||||
|
|
||||||
|
public static void WarmUpGpuKernelsForBitContradiction(int threadCount)
|
||||||
|
{
|
||||||
|
int target = threadCount;
|
||||||
|
if (target == 0)
|
||||||
|
{
|
||||||
|
target = threadCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (GpuWarmUpLock)
|
||||||
|
{
|
||||||
|
PrimeOrderCalculatorAccelerator.SkipOrderTablesAndKernels = true;
|
||||||
|
|
||||||
|
if (target <= WarmedBitContradictionGpuLeaseCount)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Accelerator[] accelerators = AcceleratorPool.Shared.Accelerators;
|
||||||
|
int acceleratorCount = EnvironmentConfiguration.RollingAccelerators;
|
||||||
|
if (acceleratorCount > accelerators.Length)
|
||||||
|
{
|
||||||
|
acceleratorCount = accelerators.Length;
|
||||||
|
}
|
||||||
|
for (var i = 0; i < acceleratorCount; i++)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Preparing accelerator {i}...");
|
||||||
|
AcceleratorStreamPool.WarmUp(i);
|
||||||
|
Accelerator accelerator = accelerators[i];
|
||||||
|
AcceleratorStream stream = accelerator.CreateStream();
|
||||||
|
_ = GpuKernelPool.GetOrAddKernels(i, stream, KernelType.BitContradictionScan);
|
||||||
|
stream.Synchronize();
|
||||||
|
stream.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
WarmedBitContradictionGpuLeaseCount = target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void WarmUpGpuKernels(int threadCount)
|
public static void WarmUpGpuKernels(int threadCount)
|
||||||
{
|
{
|
||||||
@@ -173,6 +213,7 @@ public sealed class PrimeTester
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrimeOrderCalculatorAccelerator.SkipOrderTablesAndKernels = false;
|
||||||
PrimeOrderCalculatorAccelerator.WarmUp();
|
PrimeOrderCalculatorAccelerator.WarmUp();
|
||||||
WarmedGpuLeaseCount = target;
|
WarmedGpuLeaseCount = target;
|
||||||
}
|
}
|
||||||
@@ -262,7 +303,7 @@ public sealed class PrimeTester
|
|||||||
int length = values.Length;
|
int length = values.Length;
|
||||||
|
|
||||||
int acceleratorIndex = gpu.AcceleratorIndex;
|
int acceleratorIndex = gpu.AcceleratorIndex;
|
||||||
gpu.EnsureCapacity(0, length);
|
gpu.EnsurePrimeOrderCalculatorCapacity(0, length);
|
||||||
var inputBufferView = gpu.InputView;
|
var inputBufferView = gpu.InputView;
|
||||||
var resultBufferView = gpu.OutputByteView;
|
var resultBufferView = gpu.OutputByteView;
|
||||||
var kernelLauncher = gpu.SharesFactorKernelLauncher;
|
var kernelLauncher = gpu.SharesFactorKernelLauncher;
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ public sealed class PrimeTesterSeverOrOthers
|
|||||||
int length = values.Length;
|
int length = values.Length;
|
||||||
|
|
||||||
int acceleratorIndex = gpu.AcceleratorIndex;
|
int acceleratorIndex = gpu.AcceleratorIndex;
|
||||||
gpu.EnsureCapacity(0, length);
|
gpu.EnsurePrimeOrderCalculatorCapacity(0, length);
|
||||||
var inputBufferView = gpu.InputView;
|
var inputBufferView = gpu.InputView;
|
||||||
var resultBufferView = gpu.OutputByteView;
|
var resultBufferView = gpu.OutputByteView;
|
||||||
var kernelLauncher = gpu.SharesFactorKernelLauncher;
|
var kernelLauncher = gpu.SharesFactorKernelLauncher;
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,250 @@
|
|||||||
|
k,n_total,n_typical,q_typ,q_min_typ,q_max_typ,min_over_max_pct,column_stability
|
||||||
|
1,4,4,1433,1433,1433,100.0,tight
|
||||||
|
2,4,4,3449,3449,3449,100.0,tight
|
||||||
|
3,4,4,7276,4513,8191,55.1,unstable
|
||||||
|
4,4,4,13153,10937,15193,71.99,relaxed
|
||||||
|
5,4,4,20665,18121,26849,67.49,relaxed
|
||||||
|
6,4,4,51337,33569,63577,52.8,unstable
|
||||||
|
7,4,4,127,127,127,100.0,tight
|
||||||
|
8,4,4,233,233,233,100.0,tight
|
||||||
|
9,4,4,524287,524287,524287,100.0,tight
|
||||||
|
10,4,4,750249,554129,855857,64.75,unstable
|
||||||
|
11,4,4,1913,1913,1913,100.0,tight
|
||||||
|
12,4,3,3449,3449,3449,100.0,tight
|
||||||
|
13,4,4,8191,8191,8191,100.0,tight
|
||||||
|
14,4,4,14153,11113,15193,73.15,relaxed
|
||||||
|
15,4,3,18121,18121,18121,100.0,tight
|
||||||
|
16,4,4,44885,35081,54217,64.7,unstable
|
||||||
|
17,4,4,127,127,127,100.0,tight
|
||||||
|
18,4,4,233,233,233,100.0,tight
|
||||||
|
19,4,3,524287,524287,524287,100.0,tight
|
||||||
|
20,4,4,717457,531793,867577,61.3,unstable
|
||||||
|
21,4,4,1433,1433,1433,100.0,tight
|
||||||
|
22,4,4,1198821,3449,2806537,0.12,unstable
|
||||||
|
23,4,4,7272,4513,8191,55.1,unstable
|
||||||
|
24,4,3,15193,15193,15193,100.0,tight
|
||||||
|
25,4,3,18121,18121,18121,100.0,tight
|
||||||
|
26,4,3,43441,35897,43441,82.63,tight
|
||||||
|
27,4,4,127,127,127,100.0,tight
|
||||||
|
28,4,4,233,233,233,100.0,tight
|
||||||
|
29,4,3,524287,524287,524287,100.0,tight
|
||||||
|
30,4,3,704161,622577,730753,85.2,tight
|
||||||
|
31,4,4,1673,1433,1913,74.91,relaxed
|
||||||
|
32,4,3,2298041,2298041,2298041,100.0,tight
|
||||||
|
33,4,4,7276,6089,8191,74.34,relaxed
|
||||||
|
34,4,4,13153,11113,15193,73.15,relaxed
|
||||||
|
35,4,4,22765,18121,27409,66.11,unstable
|
||||||
|
36,4,3,54217,54217,57881,93.67,tight
|
||||||
|
37,4,4,127,127,127,100.0,tight
|
||||||
|
38,4,4,233,233,233,100.0,tight
|
||||||
|
39,4,4,524287,524287,524287,100.0,tight
|
||||||
|
40,4,3,704161,622577,730753,85.2,tight
|
||||||
|
41,4,4,1673,1433,1913,74.91,relaxed
|
||||||
|
42,4,3,2298041,2298041,2298041,100.0,tight
|
||||||
|
43,4,4,5685,4513,8191,55.1,unstable
|
||||||
|
44,4,4,15193,15193,15193,100.0,tight
|
||||||
|
45,4,3,18121,18121,18121,100.0,tight
|
||||||
|
46,4,4,50545,43441,59233,73.34,relaxed
|
||||||
|
47,4,4,127,127,127,100.0,tight
|
||||||
|
48,4,4,233,233,233,100.0,tight
|
||||||
|
49,4,4,524287,524287,524287,100.0,tight
|
||||||
|
50,4,3,704161,704161,730753,96.36,tight
|
||||||
|
51,4,4,1673,1433,1913,74.91,relaxed
|
||||||
|
52,4,3,2298041,2298041,2298041,100.0,tight
|
||||||
|
53,4,4,7276,6361,8191,77.66,tight
|
||||||
|
54,4,4,13153,11113,15193,73.15,relaxed
|
||||||
|
55,4,3,18121,18121,18121,100.0,tight
|
||||||
|
56,4,4,48829,43441,54217,80.12,tight
|
||||||
|
57,4,4,127,127,127,100.0,tight
|
||||||
|
58,4,4,233,233,233,100.0,tight
|
||||||
|
59,4,4,524287,524287,524287,100.0,tight
|
||||||
|
60,4,4,717457,622577,730753,85.2,tight
|
||||||
|
61,4,4,1673,1433,1913,74.91,relaxed
|
||||||
|
62,4,4,2298041,2298041,2298041,100.0,tight
|
||||||
|
63,4,3,8191,8191,8191,100.0,tight
|
||||||
|
64,4,3,15193,11113,15193,73.15,relaxed
|
||||||
|
65,4,3,18121,18121,18121,100.0,tight
|
||||||
|
66,4,3,43441,35897,43441,82.63,tight
|
||||||
|
67,4,4,127,127,127,100.0,tight
|
||||||
|
68,4,4,233,233,233,100.0,tight
|
||||||
|
69,4,4,524287,524287,524287,100.0,tight
|
||||||
|
70,4,3,704161,704161,730753,96.36,tight
|
||||||
|
71,4,4,1673,1433,1913,74.91,relaxed
|
||||||
|
72,4,3,2298041,2298041,2298041,100.0,tight
|
||||||
|
73,4,3,6361,6361,8191,77.66,tight
|
||||||
|
74,4,3,10960009,10722169,12619129,84.97,tight
|
||||||
|
75,4,4,18121,18121,18121,100.0,tight
|
||||||
|
76,4,4,48829,43441,54217,80.12,tight
|
||||||
|
77,4,4,127,127,127,100.0,tight
|
||||||
|
78,4,4,233,233,233,100.0,tight
|
||||||
|
79,4,4,524287,524287,524287,100.0,tight
|
||||||
|
80,4,4,717457,704161,730753,96.36,tight
|
||||||
|
81,4,3,1433,1433,1913,74.91,relaxed
|
||||||
|
82,4,3,2298041,2298041,2298041,100.0,tight
|
||||||
|
83,4,4,8191,8191,8191,100.0,tight
|
||||||
|
84,4,4,12391153,10444849,15854617,65.88,unstable
|
||||||
|
85,4,3,26849,23209,26849,86.44,tight
|
||||||
|
86,4,4,45057,35897,54217,66.21,unstable
|
||||||
|
87,4,4,127,127,127,100.0,tight
|
||||||
|
88,4,4,233,233,233,100.0,tight
|
||||||
|
89,4,4,524287,524287,524287,100.0,tight
|
||||||
|
90,4,3,730753,622577,730753,85.2,tight
|
||||||
|
91,4,3,1433,1433,1913,74.91,relaxed
|
||||||
|
92,4,4,2298041,2298041,2298041,100.0,tight
|
||||||
|
93,4,3,8191,8191,8191,100.0,tight
|
||||||
|
94,4,4,12391153,10960009,13822297,79.29,tight
|
||||||
|
95,4,3,22000409,22000409,32392273,67.92,relaxed
|
||||||
|
96,4,3,43441,43441,43441,100.0,tight
|
||||||
|
97,4,4,127,127,127,100.0,tight
|
||||||
|
98,4,4,233,233,233,100.0,tight
|
||||||
|
99,4,4,524287,524287,524287,100.0,tight
|
||||||
|
100,4,4,739217,622577,855857,72.74,relaxed
|
||||||
|
101,4,4,561605,1433,1466449,0.1,unstable
|
||||||
|
102,4,3,2298041,2298041,2806537,81.88,tight
|
||||||
|
103,4,4,7276,4513,8191,55.1,unstable
|
||||||
|
104,2,2,13822297,13822297,13822297,100.0,tight
|
||||||
|
105,3,3,22000409,18121,22000409,0.08,unstable
|
||||||
|
106,4,3,43441,35081,43441,80.76,tight
|
||||||
|
107,4,4,127,127,127,100.0,tight
|
||||||
|
108,4,4,233,233,233,100.0,tight
|
||||||
|
109,4,4,524287,524287,524287,100.0,tight
|
||||||
|
110,4,3,704161,704161,704161,100.0,tight
|
||||||
|
111,4,3,1504073,1466449,1504073,97.5,tight
|
||||||
|
112,4,3,2298041,2298041,2298041,100.0,tight
|
||||||
|
113,4,3,8191,8191,8191,100.0,tight
|
||||||
|
114,2,2,10960009,10960009,10960009,100.0,tight
|
||||||
|
115,2,2,22000409,22000409,22000409,100.0,tight
|
||||||
|
116,4,3,54217,53617,59233,90.52,tight
|
||||||
|
117,4,4,127,127,127,100.0,tight
|
||||||
|
118,4,4,233,233,233,100.0,tight
|
||||||
|
119,4,4,524287,524287,524287,100.0,tight
|
||||||
|
120,4,3,730753,704161,730753,96.36,tight
|
||||||
|
121,4,3,1504073,1466449,1807097,81.15,tight
|
||||||
|
122,4,3,2298041,2298041,2298041,100.0,tight
|
||||||
|
123,4,4,7276,4513,8191,55.1,unstable
|
||||||
|
124,2,2,13220713,12619129,13822297,91.3,tight
|
||||||
|
126,4,4,47529,40841,63577,64.24,unstable
|
||||||
|
127,4,4,127,127,127,100.0,tight
|
||||||
|
128,4,4,233,233,233,100.0,tight
|
||||||
|
129,4,4,524287,524287,524287,100.0,tight
|
||||||
|
130,4,4,663369,622577,931921,66.81,relaxed
|
||||||
|
131,4,3,1504073,1466449,1504073,97.5,tight
|
||||||
|
132,4,4,1152921504608250368,2298041,2305843009213693952,0.0,unstable
|
||||||
|
133,4,3,8191,8191,8191,100.0,tight
|
||||||
|
134,2,2,13220713,12619129,13822297,91.3,tight
|
||||||
|
136,4,3,43441,43441,43441,100.0,tight
|
||||||
|
137,4,4,127,127,127,100.0,tight
|
||||||
|
138,4,4,233,233,233,100.0,tight
|
||||||
|
139,4,4,524287,524287,524287,100.0,tight
|
||||||
|
140,4,3,730753,730753,730753,100.0,tight
|
||||||
|
141,4,3,1466449,1235417,1504073,82.14,tight
|
||||||
|
142,4,4,1152921504607995904,2298041,2305843009213693952,0.0,unstable
|
||||||
|
143,4,4,7276,4513,8191,55.1,unstable
|
||||||
|
144,2,2,13407313,10960009,15854617,69.13,relaxed
|
||||||
|
146,4,3,54217,54217,59233,91.53,tight
|
||||||
|
147,4,4,127,127,127,100.0,tight
|
||||||
|
148,4,4,233,233,233,100.0,tight
|
||||||
|
149,4,4,524287,524287,524287,100.0,tight
|
||||||
|
150,4,4,309485009821345034365042688,622577,618970019642690068730085376,0.0,unstable
|
||||||
|
151,4,3,1466449,1121297,1504073,74.55,relaxed
|
||||||
|
152,4,4,1152921504608250368,2298041,2305843009213693952,0.0,unstable
|
||||||
|
153,4,3,8191,8191,8191,100.0,tight
|
||||||
|
156,4,4,24293781,43441,48544121,0.09,unstable
|
||||||
|
157,4,4,127,127,127,100.0,tight
|
||||||
|
158,4,4,233,233,233,100.0,tight
|
||||||
|
159,4,4,524287,524287,524287,100.0,tight
|
||||||
|
160,4,3,618970019642690068730085376,618970019642690068730085376,618970019642690068730085376,100.0,tight
|
||||||
|
161,4,3,1466449,1121297,1504073,74.55,relaxed
|
||||||
|
162,4,3,2305843009213693952,2305843009213693952,2305843009213693952,100.0,tight
|
||||||
|
163,4,4,7276,4513,8191,55.1,unstable
|
||||||
|
166,4,3,48544121,48544121,48544121,100.0,tight
|
||||||
|
167,4,4,127,127,127,100.0,tight
|
||||||
|
168,4,4,233,233,233,100.0,tight
|
||||||
|
169,4,4,524287,524287,524287,100.0,tight
|
||||||
|
170,4,3,618970019642690068730085376,618970019642690068730085376,618970019642690068730085376,100.0,tight
|
||||||
|
171,4,3,1121297,1121297,1504073,74.55,relaxed
|
||||||
|
172,3,3,2305843009213693696,2305843009213693696,2305843009213693696,100.0,tight
|
||||||
|
173,4,4,7276,6361,8191,77.66,tight
|
||||||
|
176,4,3,48544121,48544121,48544121,100.0,tight
|
||||||
|
177,4,4,127,127,127,100.0,tight
|
||||||
|
178,4,4,233,233,233,100.0,tight
|
||||||
|
179,4,4,524287,524287,524287,100.0,tight
|
||||||
|
180,4,3,618970019642690068730085376,618970019642690068730085376,618970019642690068730085376,100.0,tight
|
||||||
|
181,4,4,1074493860,1466449,2147483647,0.07,unstable
|
||||||
|
182,3,3,2305843009213693696,2305843009213693696,2305843009213693696,100.0,tight
|
||||||
|
183,4,3,8191,8191,8191,100.0,tight
|
||||||
|
186,4,3,48544121,48544121,48544121,100.0,tight
|
||||||
|
187,4,4,127,127,127,100.0,tight
|
||||||
|
188,4,4,233,233,233,100.0,tight
|
||||||
|
189,4,4,524287,524287,524287,100.0,tight
|
||||||
|
190,3,3,618970019642690068730085376,704161,618970019642690068730085376,0.0,unstable
|
||||||
|
191,4,4,1074493860,1466449,2147483647,0.07,unstable
|
||||||
|
192,3,3,2305843009213693696,2305843009213693696,2305843009213693696,100.0,tight
|
||||||
|
193,4,3,8191,8191,8191,100.0,tight
|
||||||
|
196,3,3,48544121,48544121,48544121,100.0,tight
|
||||||
|
197,4,4,127,127,127,100.0,tight
|
||||||
|
198,4,4,233,233,233,100.0,tight
|
||||||
|
199,4,4,524287,524287,524287,100.0,tight
|
||||||
|
200,2,2,309485009821345034365042688,622577,618970019642690068730085376,0.0,unstable
|
||||||
|
201,4,4,1074475048,1121297,2147483647,0.05,unstable
|
||||||
|
202,3,3,2305843009213693696,2305843009213693696,2305843009213693696,100.0,tight
|
||||||
|
203,4,4,8191,8191,8191,100.0,tight
|
||||||
|
206,3,3,48544121,48544121,48544121,100.0,tight
|
||||||
|
207,4,4,127,127,127,100.0,tight
|
||||||
|
208,4,4,233,233,233,100.0,tight
|
||||||
|
209,4,4,524287,524287,524287,100.0,tight
|
||||||
|
210,2,2,309485009821345034365042688,730753,618970019642690068730085376,0.0,unstable
|
||||||
|
211,4,4,1074475048,1121297,2147483647,0.05,unstable
|
||||||
|
212,3,3,2305843009213693696,2305843009213693696,2305843009213693696,100.0,tight
|
||||||
|
213,4,4,6352,4513,8191,55.1,unstable
|
||||||
|
216,3,3,48544121,48544121,48544121,100.0,tight
|
||||||
|
217,4,4,127,127,127,100.0,tight
|
||||||
|
218,4,4,233,233,233,100.0,tight
|
||||||
|
219,4,4,524287,524287,524287,100.0,tight
|
||||||
|
221,4,3,2147483647,2147483647,2147483647,100.0,tight
|
||||||
|
222,3,3,2305843009213693696,2305843009213693696,2305843009213693696,100.0,tight
|
||||||
|
223,4,3,6361,6361,6361,100.0,tight
|
||||||
|
226,2,2,48544121,48544121,48544121,100.0,tight
|
||||||
|
227,4,4,127,127,127,100.0,tight
|
||||||
|
228,4,4,233,233,233,100.0,tight
|
||||||
|
229,4,4,524287,524287,524287,100.0,tight
|
||||||
|
231,4,3,2147483647,2147483647,2147483647,100.0,tight
|
||||||
|
232,2,2,2305843009213693696,2305843009213693696,2305843009213693696,100.0,tight
|
||||||
|
233,4,3,8191,8191,8191,100.0,tight
|
||||||
|
236,2,2,48544121,48544121,48544121,100.0,tight
|
||||||
|
237,4,4,127,127,127,100.0,tight
|
||||||
|
238,4,4,233,233,233,100.0,tight
|
||||||
|
239,4,4,524287,524287,524287,100.0,tight
|
||||||
|
241,4,3,2147483647,2147483647,2147483647,100.0,tight
|
||||||
|
243,4,4,6352,4513,8191,55.1,unstable
|
||||||
|
246,2,2,48544121,48544121,48544121,100.0,tight
|
||||||
|
247,4,4,127,127,127,100.0,tight
|
||||||
|
248,4,4,233,233,233,100.0,tight
|
||||||
|
249,4,4,524287,524287,524287,100.0,tight
|
||||||
|
251,4,4,2147483647,2147483647,2147483647,100.0,tight
|
||||||
|
253,4,3,8191,8191,8191,100.0,tight
|
||||||
|
256,2,2,48544121,48544121,48544121,100.0,tight
|
||||||
|
257,4,4,127,127,127,100.0,tight
|
||||||
|
258,4,4,233,233,233,100.0,tight
|
||||||
|
259,4,4,524287,524287,524287,100.0,tight
|
||||||
|
261,4,4,2147483647,2147483647,2147483647,100.0,tight
|
||||||
|
263,4,4,7276,4513,8191,55.1,unstable
|
||||||
|
266,2,2,48544121,48544121,48544121,100.0,tight
|
||||||
|
267,4,4,127,127,127,100.0,tight
|
||||||
|
268,4,4,233,233,233,100.0,tight
|
||||||
|
269,4,4,524287,524287,524287,100.0,tight
|
||||||
|
271,4,4,2147483647,2147483647,2147483647,100.0,tight
|
||||||
|
273,4,3,8191,8191,8191,100.0,tight
|
||||||
|
277,4,4,127,127,127,100.0,tight
|
||||||
|
278,4,4,233,233,233,100.0,tight
|
||||||
|
279,4,4,524287,524287,524287,100.0,tight
|
||||||
|
281,4,4,2147483647,2147483647,2147483647,100.0,tight
|
||||||
|
283,4,3,8191,8191,8191,100.0,tight
|
||||||
|
287,4,4,127,127,127,100.0,tight
|
||||||
|
288,4,4,233,233,233,100.0,tight
|
||||||
|
289,4,4,524287,524287,524287,100.0,tight
|
||||||
|
291,4,4,2147483647,2147483647,2147483647,100.0,tight
|
||||||
|
293,4,4,8191,8191,8191,100.0,tight
|
||||||
|
297,4,4,127,127,127,100.0,tight
|
||||||
|
298,4,4,233,233,233,100.0,tight
|
||||||
|
299,4,4,524287,524287,524287,100.0,tight
|
||||||
|
@@ -0,0 +1,48 @@
|
|||||||
|
q , mu10 , support, class
|
||||||
|
127 , 0.2436974789915966 , 119 , A
|
||||||
|
233 , 0.2436974789915966 , 119 , A
|
||||||
|
524287 , 0.24786324786324787, 117 , A
|
||||||
|
3449 , 0.25 , 8 , A
|
||||||
|
2298041 , 0.3529411764705882 , 34 , A
|
||||||
|
2147483647 , 0.375 , 40 , A
|
||||||
|
2305843009213693696 , 0.38095238095238093, 21 , A
|
||||||
|
8191 , 0.38666666666666666, 75 , A
|
||||||
|
15193 , 0.4 , 15 , A
|
||||||
|
48544121 , 0.4193548387096774 , 31 , A
|
||||||
|
18121 , 0.43478260869565216, 23 , A
|
||||||
|
1433 , 0.4782608695652174 , 23 , A
|
||||||
|
2305843009213693952 , 0.5454545454545454 , 11 , A
|
||||||
|
1913 , 0.6470588235294118 , 17 , B
|
||||||
|
618970019642690068730085376, 0.6521739130434783 , 23 , B
|
||||||
|
22000409 , 0.6666666666666667 , 9 , B
|
||||||
|
43441 , 0.75 , 20 , B
|
||||||
|
54217 , 1.0 , 13 , B
|
||||||
|
11113 , 1.0 , 7 , B
|
||||||
|
1504073 , 1.0 , 11 , B
|
||||||
|
704161 , 1.0588235294117647 , 17 , B
|
||||||
|
730753 , 1.1176470588235294 , 17 , B
|
||||||
|
13822297 , 1.125 , 8 , B
|
||||||
|
10960009 , 1.1666666666666665 , 6 , B
|
||||||
|
1466449 , 1.25 , 12 , B
|
||||||
|
4513 , 1.3333333333333335 , 21 , B
|
||||||
|
6361 , 1.5294117647058825 , 17 , C
|
||||||
|
622577 , 1.5454545454545454 , 11 , C
|
||||||
|
1121297 , 1.625 , 8 , C
|
||||||
|
27409 , 2.0 , 4 , C
|
||||||
|
2806537 , 2.6 , 5 , C
|
||||||
|
26849 , 2.666666666666667 , 3 , C
|
||||||
|
12619129 , 3.0 , 2 , C
|
||||||
|
931921 , 3.5 , 4 , C
|
||||||
|
59233 , 3.5 , 4 , C
|
||||||
|
35897 , 3.75 , 4 , C
|
||||||
|
855857 , 3.75 , 4 , C
|
||||||
|
23209 , 4.0 , 2 , C
|
||||||
|
40841 , 4.5 , 2 , D
|
||||||
|
35081 , 4.5 , 2 , D
|
||||||
|
63577 , 6.0 , 2 , D
|
||||||
|
15854617 , 6.0 , 1 , D
|
||||||
|
33569 , 9.0 , 2 , D
|
||||||
|
53617 , 9.0 , 1 , D
|
||||||
|
554129 , 11.0 , 1 , D
|
||||||
|
3189281 , 12.0 , 1 , D
|
||||||
|
43721 , 15.0 , 1 , D
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
r, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48 , 49 , 50 , 51 , 52 , 53 , 54 , 55 , 56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 , 64 , 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 91 , 92 , 93 , 94 , 95 , 96 , 97 , 98 , 99 , 100 , 101 , 102 , 103 , 104 , 105 , 106 , 107, 108, 109 , 110 , 111 , 112 , 113 , 114 , 115 , 116 , 117, 118, 119 , 120 , 121 , 122 , 123 , 124 , 125 , 126 , 127, 128, 129 , 130 , 131 , 132 , 133 , 134 , 135 , 136 , 137, 138, 139 , 140 , 141 , 142 , 143 , 144 , 145 , 146 , 147, 148, 149 , 150 , 151 , 152 , 153 , 154 , 155 , 156 , 157, 158, 159 , 160 , 161 , 162 , 163 , 164, 165, 166 , 167, 168, 169 , 170 , 171 , 172 , 173 , 174, 175, 176 , 177, 178, 179 , 180 , 181 , 182 , 183 , 184, 185, 186 , 187, 188, 189 , 190 , 191 , 192 , 193 , 194, 195, 196 , 197, 198, 199 , 200 , 201 , 202 , 203 , 204, 205, 206 , 207, 208, 209 , 210 , 211 , 212 , 213 , 214, 215, 216 , 217, 218, 219 , 220 , 221 , 222 , 223 , 224, 225, 226 , 227, 228, 229 , 230 , 231 , 232 , 233 , 234, 235, 236 , 237, 238, 239 , 240 , 241 , 242 , 243 , 244, 245, 246 , 247, 248, 249 , 250 , 251 , 252 , 253 , 254, 255, 256 , 257, 258, 259 , 260 , 261 , 262 , 263 , 264, 265, 266 , 267, 268, 269 , 270 , 271 , 272, 273 , 274, 275, 276 , 277, 278, 279 , 280 , 281 , 282, 283 , 284, 285, 286, 287, 288, 289 , 290 , 291 , 292, 293 , 294, 295, 296, 297, 298, 299 , 300
|
||||||
|
1, 1433, 3449, 8191, 15193, 18121, 43441, 127, 233, 524287, 796337, 1913, 3449 , 8191, 14969, 27409, 54217, 127, 233, 524287, 531793, 1433, 3449 , 4513, 15193, 28817, 35897, 127, 233, 524287, 1002817, 1913, 3397057, 6089, 11113, 18121, 40841, 127, 233, 524287, 704161, 1433, 2298041, 8191, 15193, 18121, 57649, 127, 233, 524287, 730753, 1433, 2298041, 6361, 15193, 18121, 43441, 127, 233, 524287, 622577, 1913, 2298041, 7529, 15193 , 18121, 43441, 127, 233, 524287, 704161, 1433, 2298041, 4513, 11113 , 18121, 54217, 127, 233, 524287, 730753, 1394977, 2298041, 8191, 10960009, 26849 , 54217, 127, 233, 524287, 931921, 1466449, 2298041, 8191, 13822297, 27409 , 43441, 127, 233, 524287, 622577, 1121297, 2298041 , 8191, , 18121 , 43441, 127, 233, 524287, 704161, 1504073, 2298041 , 8191, , 22000409, 59233, 127, 233, 524287, 730753, 1466449, 2298041 , 6361, , 22000409, 63577, 127, 233, 524287, 704161, 1504073, 2806537 , 4513, , 22000409, 54217, 127, 233, 524287, 730753, 2147483647, 2298041 , 8191, , 22000409, 54217 , 127, 233, 524287, 618970019642690137449562112, 2147483647, 2298041 , 8191, , 22000409, 43441 , 127, 233, 524287, 618970019642690137449562112, 2147483647, 2305843009213693952, 4513, , , 43721 , 127, 233, 524287, 618970019642690137449562112, 2147483647, 2305843009213693952, 8191, , , 35897 , 127, 233, 524287, 618970019642690137449562112, 2147483647, 2305843009213693952, 8191, , , 33569 , 127, 233, 524287, 618970019642690137449562112, 2147483647, 2305843009213693952, 8191, , , 48544121, 127, 233, 524287, 618970019642690137449562112, 2147483647, 2305843009213693952, 8191, , , 48544121, 127, 233, 524287, 618970019642690137449562112, 2147483647, 2305843009213693952, 4513, , , 48544121, 127, 233, 524287, , 2147483647, 2305843009213693952, 6361, , , 48544121, 127, 233, 524287, , 2147483647, , 8191, , , 48544121, 127, 233, 524287, , 2147483647, , 4513, , , 48544121, 127, 233, 524287, , 2147483647, , 8191, , , 48544121, 127, 233, 524287, , 2147483647, , 8191, , , 48544121, 127, 233, 524287, , 2147483647, , 8191, , , 48544121, 127, 233, 524287, , 2147483647, , 8191, , , , 127, 233, 524287, , 2147483647, , 8191, , , , 127, 233, 524287,
|
||||||
|
3, 1433, 3449, 6361, 11113, 18121, 63577, 127, 233, 524287, 704161, 1913, 3449 , 8191, 15193, 18121, 43721, 127, 233, 343081, 730753, 1433, 3449 , 8191, 15193, 18121, 43441, 127, 233, 267497, 622577 , 1433, 2298041, 8191, 11113, 18121, 54217, 127, 233, 524287, 931921, 1913, 3189281, 4513, 15193, 27409, 43441, 127, 233, 524287, 704161, 1913, 2522089, 8191, 15193, 26849, 54217, 127, 233, 524287, 730753, 1433, 2298041, 8191, 11113 , 18121, 59233, 127, 233, 524287, 704161, 1913, 2298041, 6361, 10960009, 18121, 43441, 127, 233, 524287, 730753, 1433 , 2298041, 8191, 10444849, 23209 , 35897, 127, 233, 524287, 622577, 1433 , 2298041, 8191, 10960009, 22000409, 43441, 127, 233, 524287, 622577, 1466449, 2298041 , 6361, 13822297, , 35081, 127, 233, 524287, 704161, 1466449, 2298041 , 8191, 10960009, , 33569, 127, 233, 524287, 730753, 1504073, 2298041 , 8191, 13822297, , 54217, 127, 233, 524287, 931921, 1466449, 2298041 , 8191, 12619129, , 43441, 127, 233, 524287, 704161, 1466449 , 2298041 , 4513, 10960009, , 48544121, 127, 233, 524287, 730753 , 1504073 , 2806537 , 8191, , , 48544121, 127, 233, 524287, 855857 , 1466449 , 3189281 , 8191, , , 48544121, 127, 233, 524287, 622577 , 1121297 , 2305843009213693952, 6361, , , 48544121, 127, 233, 524287, 931921 , 2147483647, 2305843009213693952, 8191, , , 48544121, 127, 233, 524287, 704161 , 2147483647, 2305843009213693952, 8191, , , , 127, 233, 524287, 622577 , 2147483647, 2305843009213693952, 8191, , , , 127, 233, 524287, 730753 , 2147483647, 2305843009213693952, 4513, , , , 127, 233, 524287, 618970019642690137449562112, 2147483647, 2305843009213693952, 6361, , , , 127, 233, 524287, 618970019642690137449562112, 2147483647, 2305843009213693952, 8191, , , , 127, 233, 524287, 618970019642690137449562112, 2147483647, , 4513, , , , 127, 233, 524287, 618970019642690137449562112, 2147483647, , 8191, , , , 127, 233, 524287, 618970019642690137449562112, 2147483647, , 8191, , , , 127, 233, 524287, 618970019642690137449562112, 2147483647, , 8191, , , , 127, 233, 524287, 618970019642690137449562112, 2147483647, , 4513, , , , 127, 233, 524287, 618970019642690137449562112, 2147483647, , 8191, , , , 127, 233, 524287, 618970019642690137449562112
|
||||||
|
7, 1433, 3449, 4513, 10937, 23209, 59233, 127, 233, 524287, 554129, 1913, 3449 , 8191, 13337, 18121, 35081, 127, 233, 524287, 867577, 1433, 2806537, 6353, 15017, 18121, 53617, 127, 233, 524287, 704161 , 1913, 2298041, 8191, 15193, 27409, 57881, 127, 233, 524287, 730753, 1433, 2298041, 6857, 15193, 18121, 43441, 127, 233, 524287, 704161, 1433, 2298041, 6361, 11113, 18121, 54217, 127, 233, 524287, 730753, 1913, 2298041, 8191, 15193 , 18121, 43441, 127, 233, 524287, 622577, 1913, 2298041, 8191, 10722169, 18121, 54217, 127, 233, 524287, 704161, 1433 , 2806537, 8191, 13822297, 26849 , 35897, 127, 233, 524287, 730753, 1433 , 2298041, 4513, 10960009, 22000409, 43441, 127, 233, 524287, 855857, 1913 , 2806537 , 8191, , 22000409, 63577, 127, 233, 524287, 704161, 1433 , 2298041 , 4513, , , 54217, 127, 233, 524287, 554129, 1913 , 2298041 , 8191, , , 40841, 127, 233, 524287, 622577, 1121297, 2305843009213693952, 8191, , , 43441, 127, 233, 524287, 730753, 1235417 , 2305843009213693952, 8191, , , 59233 , 127, 233, 524287, 618970019642690137449562112, 1121297 , 2305843009213693952, 4513, , , 43441 , 127, 233, 524287, 618970019642690137449562112, 1504073 , 2305843009213693952, 8191, , , 48544121, 127, 233, 524287, 618970019642690137449562112, 1121297 , 2305843009213693952, 6361, , , 48544121, 127, 233, 524287, 618970019642690137449562112, 1466449 , 2305843009213693952, 4513, , , 48544121, 127, 233, 524287, , 1504073 , 2305843009213693952, 8191, , , 48544121, 127, 233, 524287, , 1121297 , 2305843009213693952, 8191, , , 48544121, 127, 233, 524287, , 1466449 , 2305843009213693952, 8191, , , 48544121, 127, 233, 524287, , 1504073 , 2305843009213693952, 6361, , , 48544121, 127, 233, 524287, , 1121297 , 2305843009213693952, 8191, , , 48544121, 127, 233, 524287, , 1466449 , 2305843009213693952, 8191, , , 48544121, 127, 233, 524287, , 2147483647, 2305843009213693952, 6361, , , 48544121, 127, 233, 524287, , 2147483647, 6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057152, 4513, , , 48544121, 127, 233, 524287, , 2147483647, , 8191, , , , 127, 233, 524287, , 2147483647, , 8191, , , , 127, 233, 524287, , 2147483647, , 8191, , , , 127, 233, 524287,
|
||||||
|
9, 1433, 3449, 8191, 15193, 26849, 33569, 127, 233, 524287, 855857, 1913, 3454817, 8191, 11113, 18121, 46049, 127, 233, 524287, 704161, 1433, 2394193, 8191, 15193, 18121, 43441, 127, 233, 524287, 730753 , 1433, 2298041, 6361, 15193, 27409, 54217, 127, 233, 524287, 622577, 1913, 2298041, 4513, 15193, 18121, 59233, 127, 233, 524287, 855857, 1913, 2298041, 8191, 11113, 18121, 43441, 127, 233, 524287, 704161, 1433, 2298041, 8191, 13822297, 23209, 35897, 127, 233, 524287, 730753, 1433, 2806537, 6361, 12619129, 18121, 43441, 127, 233, 524287, 704161, 1913 , 2298041, 8191, 15854617, 28875361, 54217, 127, 233, 524287, 730753, 1913 , 2298041, 8191, 13822297, 32392273, 35081, 127, 233, 524287, 855857, 1433 , 2305843009213693952, 4513, 13822297, 22000409, 43441, 127, 233, 524287, 931921, 1504073, 2305843009213693952, 8191, 10960009, 22000409, 53617, 127, 233, 524287, 704161, 1807097, 2305843009213693952, 4513, 12619129, , 40841, 127, 233, 524287, 622577, 1504073, 2305843009213693952, 8191, 13822297, , 43441, 127, 233, 524287, 730753, 1504073 , 2305843009213693952, 6361, 15854617, , 54217 , 127, 233, 524287, 622577 , 1466449 , 2305843009213693952, 8191, 13822297, , 48544121, 127, 233, 524287, 618970019642690137449562112, 1121297 , 2305843009213693952, 6361, , , 48544121, 127, 233, 524287, 618970019642690137449562112, 1504073 , , 8191, , , 48544121, 127, 233, 524287, 618970019642690137449562112, 1504073 , , 8191, , , 48544121, 127, 233, 524287, 618970019642690137449562112, 1466449 , , 4513, , , 48544121, 127, 233, 524287, , 1466449 , , 8191, , , 48544121, 127, 233, 524287, , 1121297 , , 8191, , , 48544121, 127, 233, 524287, , 2147483647, , 8191, , , , 127, 233, 524287, , 2147483647, , 6361, , , , 127, 233, 524287, , 2147483647, , 8191, , , , 127, 233, 524287, , 2147483647, , 8191, , , , 127, 233, 524287, , 2147483647, , 6361, , , , 127, 233, 524287, , 2147483647, , 4513, , , , 127, 233, 524287, , 2147483647, , 8191, , , , 127, 233, 524287, , 2147483647, , 8191, , , , 127, 233, 524287,
|
||||||
|
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,11 @@
|
|||||||
|
offset,total,dominant_digit,dominant_share,strong_dominance,allowed_digits_min15pct,allowed_mask,dominant_bit,allowed_mask_hex,dominant_bit_hex,allowed_digits_from_mask
|
||||||
|
1,120,3,0.45,False,"3,7",6,2,0x6,0x2,"3,7"
|
||||||
|
2,56,1,0.6607142857142857,True,"1,9",9,1,0x9,0x1,"1,9"
|
||||||
|
3,120,1,0.7833333333333333,True,"1,3",3,1,0x3,0x1,"1,3"
|
||||||
|
4,51,3,0.4705882352941176,False,"3,7,9",14,2,0xE,0x2,"3,7,9"
|
||||||
|
5,49,1,0.5102040816326531,False,"1,9",9,1,0x9,0x1,"1,9"
|
||||||
|
6,96,1,0.6458333333333334,True,"1,7",5,1,0x5,0x1,"1,7"
|
||||||
|
7,120,7,1.0,True,7,4,4,0x4,0x4,7
|
||||||
|
8,120,3,1.0,True,3,2,2,0x2,0x2,3
|
||||||
|
9,120,7,0.9916666666666668,True,7,4,4,0x4,0x4,7
|
||||||
|
10,64,1,0.359375,False,"1,3,7",7,1,0x7,0x1,"1,3,7"
|
||||||
|
@@ -0,0 +1,7 @@
|
|||||||
|
offset,total,dominant_digit,dominant_share,strong_dominance,allowed_digits_min15pct,allowed_mask,dominant_bit,allowed_mask_hex,dominant_bit_hex,allowed_digits_from_mask,min_total_required,usable
|
||||||
|
1,43,3,0.6976744186046512,True,"3,9",10,2,0xA,0x2,"3,9",10,True
|
||||||
|
3,22,3,1.0,True,3,2,2,0x2,0x2,3,10,True
|
||||||
|
4,24,7,0.375,False,"3,7,9",14,4,0xE,0x4,"3,7,9",10,True
|
||||||
|
5,10,9,1.0,True,9,8,8,0x8,0x8,9,10,True
|
||||||
|
6,35,1,0.6,True,"1,7",5,1,0x5,0x1,"1,7",10,True
|
||||||
|
10,36,1,0.5,False,"1,3",3,1,0x3,0x1,"1,3",10,True
|
||||||
|
@@ -0,0 +1,8 @@
|
|||||||
|
offset,total,dominant_digit,dominant_share,strong_dominance,allowed_digits_min15pct,allowed_mask,dominant_bit,allowed_mask_hex,dominant_bit_hex,allowed_digits_from_mask,min_total_required,usable
|
||||||
|
1,9,7,1.0,True,7,4,4,0x4,0x4,7,10,False
|
||||||
|
2,6,7,1.0,True,7,4,4,0x4,0x4,7,10,False
|
||||||
|
3,18,1,1.0,True,1,1,1,0x1,0x1,1,10,True
|
||||||
|
4,3,9,1.0,True,9,8,8,0x8,0x8,9,10,False
|
||||||
|
5,12,9,1.0,True,9,8,8,0x8,0x8,9,10,True
|
||||||
|
6,10,3,0.5,False,"3,7",6,2,0x6,0x2,"3,7",10,True
|
||||||
|
10,22,7,0.7727272727272727,True,"1,7",5,4,0x5,0x4,"1,7",10,True
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
offset,total,dominant_digit,dominant_share,strong_dominance,allowed_digits_min15pct,allowed_mask,dominant_bit,allowed_mask_hex,dominant_bit_hex,allowed_digits_from_mask,min_total_required,usable
|
||||||
|
2,2,1,1.0,True,1,1,1,0x1,0x1,1,5,False
|
||||||
|
4,2,7,1.0,True,7,4,4,0x4,0x4,7,5,False
|
||||||
|
6,16,1,0.5,False,"1,7,9",13,1,0xD,0x1,"1,7,9",5,True
|
||||||
|
10,2,9,1.0,True,9,8,8,0x8,0x8,9,5,False
|
||||||
|
@@ -0,0 +1,18 @@
|
|||||||
|
offset,total,dominant_digit,dominant_share,strong_dominance,allowed_digits_min15pct,allowed_mask,dominant_bit,allowed_mask_hex,dominant_bit_hex,allowed_digits_from_mask,min_total_required,usable,class
|
||||||
|
1,43,3,0.6976744186046512,True,"3,9",10,2,0xA,0x2,"3,9",10,True,B
|
||||||
|
3,22,3,1.0,True,3,2,2,0x2,0x2,3,10,True,B
|
||||||
|
4,24,7,0.375,False,"3,7,9",14,4,0xE,0x4,"3,7,9",10,True,B
|
||||||
|
5,10,9,1.0,True,9,8,8,0x8,0x8,9,10,True,B
|
||||||
|
6,35,1,0.6,True,"1,7",5,1,0x5,0x1,"1,7",10,True,B
|
||||||
|
10,36,1,0.5,False,"1,3",3,1,0x3,0x1,"1,3",10,True,B
|
||||||
|
1,9,7,1.0,True,7,4,4,0x4,0x4,7,10,False,C
|
||||||
|
2,6,7,1.0,True,7,4,4,0x4,0x4,7,10,False,C
|
||||||
|
3,18,1,1.0,True,1,1,1,0x1,0x1,1,10,True,C
|
||||||
|
4,3,9,1.0,True,9,8,8,0x8,0x8,9,10,False,C
|
||||||
|
5,12,9,1.0,True,9,8,8,0x8,0x8,9,10,True,C
|
||||||
|
6,10,3,0.5,False,"3,7",6,2,0x6,0x2,"3,7",10,True,C
|
||||||
|
10,22,7,0.7727272727272727,True,"1,7",5,4,0x5,0x4,"1,7",10,True,C
|
||||||
|
2,2,1,1.0,True,1,1,1,0x1,0x1,1,5,False,D
|
||||||
|
4,2,7,1.0,True,7,4,4,0x4,0x4,7,5,False,D
|
||||||
|
6,16,1,0.5,False,"1,7,9",13,1,0xD,0x1,"1,7,9",5,True,D
|
||||||
|
10,2,9,1.0,True,9,8,8,0x8,0x8,9,5,False,D
|
||||||
|
@@ -0,0 +1,11 @@
|
|||||||
|
offset,total,dominant_digit,dominant_share,strong_dominance,allowed_digits_min15pct,p1,p3,p7,p9,entropy_bits
|
||||||
|
1,120,3,0.45,False,"3,7",0.0,0.45,0.44166666666666665,0.10833333333333334,1.3864787160709264
|
||||||
|
2,56,1,0.6607142857142857,True,"1,9",0.6607142857142857,0.017857142857142856,0.14285714285714285,0.17857142857142858,1.343621788537162
|
||||||
|
3,120,1,0.7833333333333333,True,"1,3",0.7833333333333333,0.19166666666666668,0.008333333333333333,0.016666666666666666,0.8887799535501084
|
||||||
|
4,51,3,0.47058823529411764,False,"3,7,9",0.0,0.47058823529411764,0.27450980392156865,0.2549019607843137,1.5263903368352523
|
||||||
|
5,49,1,0.5102040816326531,False,"1,9",0.5102040816326531,0.02040816326530612,0.02040816326530612,0.4489795918367347,1.2432016736174807
|
||||||
|
6,96,1,0.6458333333333334,True,"1,7",0.6458333333333334,0.052083333333333336,0.25,0.052083333333333336,1.3514359151985766
|
||||||
|
7,120,7,1.0,True,7,0.0,0.0,1.0,0.0,-0.0
|
||||||
|
8,120,3,1.0,True,3,0.0,1.0,0.0,0.0,-0.0
|
||||||
|
9,120,7,0.9916666666666667,True,7,0.008333333333333333,0.0,0.9916666666666667,0.0,0.06952964699480783
|
||||||
|
10,64,1,0.359375,False,"1,3,7",0.359375,0.296875,0.3125,0.03125,1.7313889118361458
|
||||||
|
@@ -0,0 +1,41 @@
|
|||||||
|
offset, q_last_digit, p , score_neg_ln_p , total
|
||||||
|
1 , 1 , 0.0 , 27.631021115928547 , 120
|
||||||
|
1 , 3 , 0.45 , 0.7985076962177716 , 120
|
||||||
|
1 , 7 , 0.4416666666666666, 0.8171998292299243 , 120
|
||||||
|
1 , 9 , 0.1083333333333333, 2.2225423853205095 , 120
|
||||||
|
2 , 1 , 0.6607142857142857, 0.4144337780909248 , 56
|
||||||
|
2 , 3 , 0.0178571428571428, 4.025351690735152 , 56
|
||||||
|
2 , 7 , 0.1428571428571428, 1.9459101490553137 , 56
|
||||||
|
2 , 9 , 0.1785714285714285, 1.722766597741104 , 56
|
||||||
|
3 , 1 , 0.7833333333333333, 0.2441969605120421 , 120
|
||||||
|
3 , 3 , 0.1916666666666666, 1.6519975268528966 , 120
|
||||||
|
3 , 7 , 0.0083333333333333, 4.78749174278205 , 120
|
||||||
|
3 , 9 , 0.0166666666666666, 4.094344562222105 , 120
|
||||||
|
4 , 1 , 0.0 , 27.631021115928547 , 51
|
||||||
|
4 , 3 , 0.4705882352941176, 0.7537718023763803 , 51
|
||||||
|
4 , 7 , 0.2745098039215686, 1.2927683031090673 , 51
|
||||||
|
4 , 9 , 0.2549019607843137, 1.3668762752627892 , 51
|
||||||
|
5 , 1 , 0.5102040816326531, 0.6729444732424258 , 49
|
||||||
|
5 , 3 , 0.0204081632653061, 3.891820298110628 , 49
|
||||||
|
5 , 7 , 0.0204081632653061, 3.891820298110628 , 49
|
||||||
|
5 , 9 , 0.4489795918367347, 0.8007778447523107 , 49
|
||||||
|
6 , 1 , 0.6458333333333334, 0.4372138064227446 , 96
|
||||||
|
6 , 3 , 0.0520833333333333, 2.9549102790337365 , 96
|
||||||
|
6 , 7 , 0.25 , 1.3862943611198906 , 96
|
||||||
|
6 , 9 , 0.0520833333333333, 2.9549102790337365 , 96
|
||||||
|
7 , 1 , 0.0 , 27.631021115928547 , 120
|
||||||
|
7 , 3 , 0.0 , 27.631021115928547 , 120
|
||||||
|
7 , 7 , 1.0 , -0.0 , 120
|
||||||
|
7 , 9 , 0.0 , 27.631021115928547 , 120
|
||||||
|
8 , 1 , 0.0 , 27.631021115928547 , 120
|
||||||
|
8 , 3 , 1.0 , -0.0 , 120
|
||||||
|
8 , 7 , 0.0 , 27.631021115928547 , 120
|
||||||
|
8 , 9 , 0.0 , 27.631021115928547 , 120
|
||||||
|
9 , 1 , 0.0083333333333333, 4.78749174278205 , 120
|
||||||
|
9 , 3 , 0.0 , 27.631021115928547 , 120
|
||||||
|
9 , 7 , 0.9916666666666668, 0.008368249670516466, 120
|
||||||
|
9 , 9 , 0.0 , 27.631021115928547 , 120
|
||||||
|
10 , 1 , 0.359375 , 1.0233888674305223 , 64
|
||||||
|
10 , 3 , 0.296875 , 1.2144441041932315 , 64
|
||||||
|
10 , 7 , 0.3125 , 1.1631508098056809 , 64
|
||||||
|
10 , 9 , 0.03125 , 3.4657359027997265 , 64
|
||||||
|
@@ -0,0 +1,2 @@
|
|||||||
|
strong_dominance_threshold,allowed_digit_threshold,min_total_all,min_total_BC,min_total_D,score_function,p_source,digits_considered
|
||||||
|
0.6,0.15,20,10,5,"score = -ln(max(p, 1e-12))","offset_last_digit_rules_*.csv columns p1,p3,p7,p9","1,3,7,9"
|
||||||
|
+3321
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,8 @@
|
|||||||
|
138000133,0,True,True,False,3036002927
|
||||||
|
138000221,0,True,True,False,828001327
|
||||||
|
138000557,0,True,True,False,235638435087527
|
||||||
|
138000953,0,True,True,False,337429718205079
|
||||||
|
138001483,0,True,True,False,22080237281
|
||||||
|
138001793,0,True,True,False,1976939441553367
|
||||||
|
138002017,0,True,True,False,110125609567
|
||||||
|
138000077,0,True,True,False,13746583730190991
|
||||||
|
-1
@@ -1 +0,0 @@
|
|||||||
p, searchedMersenne, detailedCheck, passedAllTests
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
Reference in new issue
Block a user