{"id":34600602,"url":"https://github.com/cherubrock-seb/prmers","last_synced_at":"2026-07-05T02:01:03.248Z","repository":{"id":279422263,"uuid":"938733117","full_name":"cherubrock-seb/PrMers","owner":"cherubrock-seb","description":"Mersenne prime search using integer arithmetic and an IDBWT via an NTT executed on the GPU through OpenCL.","archived":false,"fork":false,"pushed_at":"2026-07-01T15:59:55.000Z","size":64547,"stargazers_count":12,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-07-01T17:30:03.171Z","etag":null,"topics":["ecm","elliptic-curve-cryptography","elliptic-curves","factoring","factoring-algorithms","factoring-integers","fft","gpu","gpu-computing","lucas","lucas-lehmer","mathematics","mersenne","mersenne-numbers","mersenne-prime","ntt","opencl","p-1","prime-numbers"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cherubrock-seb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-25T12:19:16.000Z","updated_at":"2026-07-01T16:00:10.000Z","dependencies_parsed_at":"2025-04-19T07:35:14.016Z","dependency_job_id":"6f7fc494-16d9-476d-8792-8f007151da88","html_url":"https://github.com/cherubrock-seb/PrMers","commit_stats":null,"previous_names":["cherubrock-seb/prmers"],"tags_count":521,"template":false,"template_full_name":null,"purl":"pkg:github/cherubrock-seb/PrMers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherubrock-seb%2FPrMers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherubrock-seb%2FPrMers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherubrock-seb%2FPrMers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherubrock-seb%2FPrMers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cherubrock-seb","download_url":"https://codeload.github.com/cherubrock-seb/PrMers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherubrock-seb%2FPrMers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35141083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-05T02:00:06.290Z","response_time":100,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecm","elliptic-curve-cryptography","elliptic-curves","factoring","factoring-algorithms","factoring-integers","fft","gpu","gpu-computing","lucas","lucas-lehmer","mathematics","mersenne","mersenne-numbers","mersenne-prime","ntt","opencl","p-1","prime-numbers"],"created_at":"2025-12-24T12:39:14.167Z","updated_at":"2026-07-05T02:01:03.222Z","avatar_url":"https://github.com/cherubrock-seb.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PrMers\n\nGPU-accelerated PRP, Lucas-Lehmer, P-1 and ECM testing for Mersenne numbers.\n\nhttps://github.com/cherubrock-seb/PrMers\n\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/cherubrock-seb/PrMers/blob/main/prmers.ipynb)\n\nReleases for Linux, macOS and Windows are available here:\n\n[https://github.com/cherubrock-seb/PrMers/releases](https://github.com/cherubrock-seb/PrMers/tags)\n\nPrMers is an OpenCL GPU program focused on long modular arithmetic runs for numbers of the form `2^p - 1`. It supports PRP, Lucas-Lehmer, P-1 and ECM workflows, with checkpointing, result JSON output, Prime95 compatible handoff files, worktodo parsing, and an optional web GUI.\n\nThe default computation engine is the Marin backend by Yves Gallot. It uses an integer IBDWT style transform modulo `2^64 - 2^32 + 1`, avoiding floating point roundoff in the core modular arithmetic.\n\n## Contents\n\n- [What PrMers can do](#what-prmers-can-do)\n- [Quick start](#quick-start)\n- [Build from source](#build-from-source)\n- [Command line options](#command-line-options)\n- [PRP and proof generation](#prp-and-proof-generation)\n- [Lucas-Lehmer modes](#lucas-lehmer-modes)\n- [P-1 factoring](#p-1-factoring)\n- [ECM factoring](#ecm-factoring)\n- [worktodo.txt and AutoPrimeNet](#worktodotxt-and-autoprimenet)\n- [Prime95 and mprime interop](#prime95-and-mprime-interop)\n- [Web GUI](#web-gui)\n- [GPU memory test](#gpu-memory-test)\n- [NTT and IBDWT transform sizes](#ntt-and-ibdwt-transform-sizes)\n- [Benchmarks](#benchmarks)\n- [Backend and code](#backend-and-code)\n- [Related inspiration](#related-inspiration)\n- [Must read papers](#must-read-papers)\n\n## What PrMers can do\n\n| Area | Status | Notes |\n|---|---|---|\n| Mersenne PRP | Supported | Default mode, GPU, Marin backend by default |\n| Mersenne Lucas-Lehmer | Supported | Safe GL mode, classic unsafe mode, doubling safe mode |\n| P-1 factoring | Supported | Stage 1, default V-trace Stage 2, classic Stage 2 fallback, resume export, Prime95 handoff |\n| P-1 ultra-low-memory mode | Supported | 1-register Stage 1 and 1-register Stage 2 product-exponent path |\n| ECM factoring | Supported | Edwards and Montgomery variants, optional Prime95 Stage 2 handoff |\n| Wagstaff PRP | Supported | `W = (2^p + 1) / 3` with `-wagstaff` |\n| Mersenne cofactors | Supported | PRP with known factors using `-factors` |\n| worktodo.txt | Supported | PRP and Pminus1 parsing, including Prime95 compatible Pminus1 metadata |\n| Web GUI | Supported | Local browser interface for monitoring and worktodo editing |\n| GPU memory test | Supported | OpenCL VRAM and stability test |\n\n## Quick start\n\nRun a PRP test on a Mersenne number:\n\n```bash\n./prmers 136279841\n```\n\nRun a safe Lucas-Lehmer test:\n\n```bash\n./prmers 127 -ll\n```\n\nRun P-1 factoring with Stage 1 and Stage 2. Normal-memory Stage 2 uses the V-trace path by default, with conservative automatic `D` selection:\n\n```bash\n./prmers 367 -pm1 -b1 11981 -b2 38971\n```\n\nForce the previous classic Stage 2 path when comparing or debugging:\n\n```bash\n./prmers 367 -pm1 -b1 11981 -b2 38971 -pm1-vtrace-off\n```\n\nRun the MM31 ultra-low-memory P-1 example that uses a 1-register GPU Stage 2:\n\n```bash\n./prmers 2147483647 -pm1 -b1 100 -b2 5000 -pm1-ultralowmem -nogcd-stage1\n```\n\nExpected test factor for that example:\n\n```text\n295257526626031\n```\n\nRun ECM:\n\n```bash\n./prmers 701 -ecm -b1 6000 -b2 33333 -K 8\n```\n\nUse a worktodo file:\n\n```bash\n./prmers -worktodo ./worktodo.txt\n```\n\nStart the web GUI:\n\n```bash\n./prmers -gui -http 3131\n```\n\nThen open the URL printed by the program.\n\n## Build from source\n\n### Requirements\n\n- C++20 compiler\n- OpenCL runtime and headers\n- GMP development library\n- Make or CMake\n\nUbuntu or Debian:\n\n```bash\nsudo apt-get update\nsudo apt-get install -y g++ make ocl-icd-opencl-dev opencl-headers libgmp-dev\n```\n\n### Linux and macOS with Makefile\n\n```bash\ngit clone https://github.com/cherubrock-seb/PrMers.git\ncd PrMers\nmake -j\"$(nproc)\"\n```\n\nInstall system-wide:\n\n```bash\nsudo make install\n```\n\nInstalled paths:\n\n```text\n/usr/local/bin/prmers\n/usr/local/share/prmers/\n```\n\nWhen building a local zip or test copy, pass the kernel path explicitly:\n\n```bash\nmake clean\nmake -j\"$(nproc)\" KERNEL_PATH=./kernels/\n```\n\n### Windows with CMake and vcpkg\n\n```powershell\ngit clone https://github.com/cherubrock-seb/PrMers.git\ncd PrMers\ngit clone https://github.com/microsoft/vcpkg.git\ncd vcpkg\n.\\bootstrap-vcpkg.bat\ncd ..\n\ncmake -S . -B build ^\n  -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake ^\n  -DCMAKE_BUILD_TYPE=Release\n\ncmake --build build --config Release\n```\n\nCopy required DLLs from `vcpkg\\installed\\x64-windows\\bin` next to `prmers.exe`, or add that directory to `PATH`.\n\n### Windows with MSYS2 UCRT64\n\n```bash\npacman -Syu\npacman -S --noconfirm make \\\n  mingw-w64-ucrt-x86_64-gcc \\\n  mingw-w64-ucrt-x86_64-opencl-headers \\\n  mingw-w64-ucrt-x86_64-opencl-icd-loader \\\n  mingw-w64-ucrt-x86_64-gmp\n\nmake -j\"$(nproc)\"\n```\n\n## Command line options\n\nRun the built-in help for the exact option list supported by your binary:\n\n```bash\n./prmers -h\n```\n\n### General options\n\n| Option | Meaning |\n|---|---|\n| `\u003cp\u003e` | Exponent for `2^p - 1`, unless `-worktodo` supplies it |\n| `-d \u003cid\u003e` | OpenCL device id, default `0` |\n| `-c \u003cdepth\u003e` | Local carry propagation depth |\n| `-t \u003cseconds\u003e` | Checkpoint interval |\n| `-f \u003cpath\u003e` | Checkpoint and state directory |\n| `-config \u003cpath\u003e` | Read options from a config file |\n| `-worktodo [path]` | Read assignment from worktodo.txt |\n| `-profile` | Enable kernel profiling |\n| `-debug` | Verbose debug output |\n| `-bench` | Run benchmark over supported transform sizes |\n| `-v`, `--version` | Print version |\n| `-h`, `--help` | Print help |\n\n### Device and stability options\n\n| Option | Meaning |\n|---|---|\n| `-iterforce \u003cn\u003e` | Force GPU queue synchronization every `n` iterations |\n| `-iterforce2 \u003cn\u003e` | Force queue synchronization in P-1 Stage 2 |\n| `-memtest` | Run GPU memory and stability test |\n| `-memlim \u003cpercent\u003e` | Limit memory used by some precompute paths |\n| `-maxe \u003cMiB\u003e` | Maximum P-1 exponent chunk size in MiB |\n| `-res64_display_interval \u003cn\u003e` | Print Res64 every `n` iterations in Marin mode |\n\n### Mode selection\n\n| Option | Meaning |\n|---|---|\n| `-prp` | PRP mode, default |\n| `-ll` | Lucas-Lehmer safe mode with Gerbicz-Li style checks |\n| `-llunsafe` | Classic Lucas-Lehmer mode without error checking |\n| `-llsafe2` | Lucas-Lehmer block-doubling safe mode |\n| `-wagstaff` | Test `W = (2^p + 1) / 3` |\n| `-pm1` | P-1 factoring mode |\n| `-ecm` | ECM factoring mode |\n| `-marin` | Disable Marin and use the internal NTT backend |\n\nNote: the option name `-marin` currently disables the Marin backend. The default is Marin enabled.\n\n### PRP and proof options\n\n| Option | Meaning |\n|---|---|\n| `-proof \u003clevel\u003e` | Proof power, `1` to `12`, or `0` to disable proof generation |\n| `-noverify` | Skip verification of generated PRP proof |\n| `-factors \u003cf1,f2,...\u003e` | Test the remaining cofactor after known Mersenne factors |\n| `-gerbiczli` | Disable Gerbicz-Li checks, mainly for benchmarking |\n| `-checklevel \u003ck\u003e` | Tune Gerbicz-Li check frequency |\n| `-erroriter \u003ci\u003e` | Inject an error at iteration `i` to test recovery |\n\n### Lucas-Lehmer options\n\n| Option | Meaning |\n|---|---|\n| `-ll` | Safe LL mode |\n| `-llunsafe` | Fast classic LL mode, no error checking |\n| `-llsafe2` | Block-doubling safe LL mode |\n| `-llsafeb \u003cB\u003e` | Override block size for `-llsafe2` |\n\n### P-1 options\n\n| Option | Meaning |\n|---|---|\n| `-pm1` | Enable P-1 factoring |\n| `-b1 \u003cB1\u003e` | Stage 1 bound |\n| `-b2 \u003cB2\u003e` | Stage 2 bound |\n| `-pm1-vtrace` | Use scalar-trace P-1 Stage 2. This is the default for normal-memory Stage 2, with conservative auto-D |\n| `-pm1-vtrace-off` | Disable V-trace and use the previous classic Stage 2 BSGS path |\n| `-pm1-vtrace-d \u003cD\u003e` | Force the V-trace giant-step parameter `D`, for example `4620`, `13860`, or `30030` |\n| `-pm1-vtrace-auto-d` | Explicitly auto-select `D` for V-trace under a conservative register cap |\n| `-pm1-vtrace-auto-d-aggressive` | Auto-select `D` with a larger register cap for normal-size Mersennes |\n| `-pm1-vtrace-max-regs \u003cN\u003e` | Register cap used by V-trace auto-D |\n| `-b1old \u003cB1old\u003e` | Extend Stage 1 from an existing `.save` or `.p95` file |\n| `-resume` | Write GMP-ECM `.save` and Prime95 `.p95` resume files |\n| `-p95` | Write Prime95 `.p95` resume file |\n| `-p95path \u003cpath\u003e` | Delegate P-1 Stage 2 to Prime95 or mprime |\n| `-nop95stage2` | Disable Prime95 Stage 2 handoff even if `-p95path` is set |\n| `-filemers \u003cpath\u003e` | Convert a `.mers` state to GMP-ECM `.save` |\n| `-K \u003cK\u003e` | Enable the `n^K` Stage 2 variant |\n| `-nmax \u003cn\u003e` | Upper bound for the `n^K` variant |\n| `-pm1-lowmem` | P-1 low-memory mode, fewer GPU registers |\n| `-pm1-ultralowmem` | P-1 ultra-low-memory mode, 1-register Stage 1 and 1-register product-exponent Stage 2 |\n| `-nogcd-stage1` | Skip ordinary Stage 1 GCD after writing resume data, useful before Stage 2 |\n\n### ECM options\n\n| Option | Meaning |\n|---|---|\n| `-ecm` | Enable ECM mode |\n| `-b1 \u003cB1\u003e` | ECM Stage 1 bound |\n| `-b2 \u003cB2\u003e` | ECM Stage 2 bound |\n| `-K \u003ccurves\u003e` | Number of curves |\n| `-montgomery` | Use Montgomery curve model |\n| `-edwards` | Use Edwards curve setup |\n| `-ced` | Compute directly in Twisted Edwards coordinates |\n| `-cmont` | Compute in Montgomery coordinates |\n| `-torsion8` | Use torsion-8 family |\n| `-torsion16` | Use torsion-16 family |\n| `-notorsion` | Disable torsion family |\n| `-iv163` | Use family IV 163 curves |\n| `-seed \u003cvalue\u003e` | Force curve seed |\n| `-sigma \u003cvalue\u003e` | Force Montgomery sigma |\n| `-ecm_check_interval \u003cseconds\u003e` | ECM error-check interval |\n| `-ecm_progress_ms \u003cms\u003e` | ECM progress update interval |\n| `-p95path \u003cpath\u003e` | Delegate ECM Stage 2 to Prime95 or mprime |\n\n### Web GUI options\n\n| Option | Meaning |\n|---|---|\n| `-gui` | Enable embedded web GUI |\n| `-http \u003cport\u003e` | HTTP port, default `3131` |\n| `-host \u003cip\u003e` | HTTP host, default `localhost` |\n\n## PRP and proof generation\n\nDefault PRP mode tests `2^p - 1` using GPU modular exponentiation and Gerbicz-Li style checking. Results are written to `results.txt` and to a JSON result file.\n\nExample:\n\n```bash\n./prmers 136279841\n```\n\nUseful files include:\n\n| File | Purpose |\n|---|---|\n| `results.txt` | Human-readable result history |\n| `\u003cp\u003e_prp_result.json` | JSON result for automation |\n| proof files | Optional PRP proof output depending on proof settings |\n\nCofactor PRP:\n\n```bash\n./prmers 10449497 -factors 62696983\n```\n\n## Lucas-Lehmer modes\n\nPrMers implements three GPU LL variants.\n\n| Mode | Option | Safety | Notes |\n|---|---|---|---|\n| LL safe | `-ll` | Gerbicz-Li style checking | Recommended safe LL mode |\n| LL classic | `-llunsafe` | No checking | Fast, for quick checks and debugging |\n| LL safe2 | `-llsafe2` | Block-doubling checks | Lighter safe mode with block verification |\n\nSafe LL uses the split representation `s = a + b*sqrt(3)` and checks progress periodically. `-llunsafe` uses the classic recurrence `S_{i+1} = S_i^2 - 2` and should not be used for production runs on unstable hardware.\n\n## P-1 factoring\n\nFor a factor `q` of `M_p = 2^p - 1`, factors have the form:\n\n```text\nq = 2*k*p + 1\n```\n\n### Stage 1\n\nStage 1 computes:\n\n```text\nx = 3^(E(B1)*2*p) mod M_p\n```\n\nwhere `E(B1)` is the product of prime powers up to `B1`. Then it tests:\n\n```text\ngcd(x - 1, M_p)\n```\n\nExample:\n\n```bash\n./prmers 541 -pm1 -b1 8099\n```\n\nWrite resume files:\n\n```bash\n./prmers 541 -pm1 -b1 8099 -resume\n./prmers 541 -pm1 -b1 8099 -p95\n```\n\nExtend from an older Stage 1 bound:\n\n```bash\n./prmers 541 -pm1 -b1 20000 -b1old 8099\n```\n\n### Stage 2\n\nStandard Stage 2 extends the search from `B1` to `B2`.\n\n```bash\n./prmers 367 -pm1 -b1 11981 -b2 38971\n```\n\nFor normal-memory P-1, Stage 2 uses the V-trace path by default. Let `H` be the Stage 1 result. Instead of accumulating one term per prime with powers of `H`, V-trace works with the scalar trace:\n\n```text\nV_n = H^n + H^(-n) mod M_p\n```\n\nFor a giant step `kD` and baby step `j`, the difference\n\n```text\nV_(kD) - V_j\n```\n\ncovers both `kD - j` and `kD + j`, because it contains the factors `(H^(kD-j)-1)` and `(H^(kD+j)-1)` up to multiplication by an invertible term. This gives a compact baby/giant Stage 2 using one scalar residue per baby trace. By default PrMers uses conservative automatic `D` selection. `D` can also be forced explicitly with `-pm1-vtrace-d`.\n\nExamples:\n\n```bash\n./prmers 1362763 -pm1 -b1 29 -b2 6910159 -nogcd-stage1 \\\n  -factors 46333943,282345414919\n\n./prmers 1362763 -pm1 -b1 29 -b2 6910159 -nogcd-stage1 \\\n  -factors 46333943,282345414919 -pm1-vtrace-d 30030\n```\n\nExpected factor for this regression test:\n\n```text\n28401397572100073\n```\n\nTo force the previous classic Stage 2 path, add:\n\n```bash\n-pm1-vtrace-off\n```\n\nThe classic Stage 2 path uses GPU precomputation and prime sweeps. The `n^K` variant can be enabled with:\n\n```bash\n./prmers 367 -pm1 -b1 11981 -b2 38971 -K 8 -nmax 200000\n```\n\n### Ultra-low-memory P-1\n\n`-pm1-ultralowmem` is designed for huge transforms where a normal multi-register Stage 2 does not fit in VRAM.\n\nCurrent behavior:\n\n| Stage | Method |\n|---|---|\n| Stage 1 | 1 GPU register, fast3 path, Gerbicz-Li disabled |\n| Stage 2 | 1 GPU register, product-exponent path |\n\nThe Stage 2 ultra-low-memory path computes the product of Stage 2 primes into the exponent and runs one direct GPU exponentiation:\n\n```text\n3^(E(B1)*2*p*product_primes(B1,B2]) mod M_p\n```\n\nIt then tests `gcd(x - 1, M_p)`. This is slower than a full-memory BSGS-style Stage 2, but it fits on GPUs where a 2-register or table-based Stage 2 does not fit.\n\nMM31 validation example:\n\n```bash\n./prmers 2147483647 -pm1 -b1 100 -b2 5000 -pm1-ultralowmem -nogcd-stage1\n```\n\nExpected known factor:\n\n```text\n295257526626031\n```\n\n## ECM factoring\n\nBasic ECM:\n\n```bash\n./prmers p -ecm -b1 B1 -b2 B2 -K curves\n```\n\nExamples:\n\n```bash\n./prmers 701 -ecm -b1 6000 -K 8\n./prmers 701 -ecm -b1 6000 -b2 33333 -K 8\n```\n\nCurve and arithmetic options include Montgomery, Edwards, torsion variants, seeds and sigma values. Use `./prmers -h` for the exact list supported by your build.\n\n## worktodo.txt and AutoPrimeNet\n\nPrMers can read GIMPS-style `worktodo.txt` assignments.\n\n```bash\n./prmers -worktodo\n./prmers -worktodo ./worktodo.txt\n```\n\n### PRP format\n\n```text\nPRP=AID,k,b,n,c,tf_bits,tests_saved\n```\n\nExample:\n\n```text\nPRP=DEADBEEFCAFEBABEDEADBEEFCAFEBABE,1,2,197493337,-1,76,0\n```\n\n### Pminus1 format\n\nPrime95-compatible P-1 format:\n\n```text\nPminus1=k,b,n,c,B1,B2[,how_far_factored][,B2_start][,\"factors\"]\nPminus1=AID,k,b,n,c,B1,B2[,how_far_factored][,B2_start][,\"factors\"]\n```\n\nExamples:\n\n```text\nPminus1=AID,1,2,160575647,-1,900000,32000000\nPminus1=AID,1,2,160575647,-1,900000,32000000,79\nPminus1=AID,1,2,160575647,-1,900000,32000000,79,5000000\nPminus1=AID,1,2,11,-1,100,200,79,\"23\"\n```\n\nThe parser keeps these fields separate:\n\n| Field | Meaning |\n|---|---|\n| `how_far_factored` | Trial factoring depth, for example `79` means TF completed to `2^79` |\n| `B2_start` | Optional Stage 2 start bound |\n| `\"factors\"` | Quoted known-factor list |\n\nSo the trailing `79` in this line is not a known factor:\n\n```text\nPminus1=AID,1,2,160575647,-1,900000,32000000,79\n```\n\nIt is interpreted as trial factoring completed to `2^79`.\n\n### AutoPrimeNet\n\nAutoPrimeNet can fetch assignments, monitor progress and submit results.\n\nProject:\n\nhttps://github.com/tdulcet/AutoPrimeNet\n\nWindows:\n\n```powershell\nautoprimenet.exe --setup\nautoprimenet.exe\nprmers.exe -worktodo worktodo.txt\n```\n\nLinux or macOS:\n\n```bash\npython3 autoprimenet.py --setup\npython3 -OO autoprimenet.py\n./prmers -worktodo worktodo.txt\n```\n\nFor multiple GPUs or workers, use one working directory per worker.\n\n## Prime95 and mprime interop\n\n### P-1 Stage 2 handoff\n\nPrMers can run P-1 Stage 1 and let Prime95 or mprime run Stage 2.\n\n```bash\n./prmers 75931 -pm1 -b1 100 -b2 200000000 -p95path /home/sebastien/gimps/v31_31.04_b05c\n```\n\nWindows:\n\n```powershell\nprmers.exe 75931 -pm1 -b1 100 -b2 200000000 -p95path C:\\gimps\\v31_31.04_b05c\n```\n\nWhat happens:\n\n1. PrMers runs P-1 Stage 1.\n2. PrMers writes a Prime95 Stage 1 state file.\n3. PrMers copies it as `mXXXXXXX` in the Prime95 directory.\n4. PrMers writes a `Pminus1` line to Prime95 `worktodo.txt`.\n5. Prime95 or mprime runs Stage 2.\n6. PrMers reads `results.json.txt` and reports `NF` or `F`.\n\nExample Prime95 line:\n\n```text\nPminus1=1,2,75931,-1,100,200000000,68\n```\n\nWith known factors:\n\n```text\nPminus1=1,2,10449497,-1,1440000,1440000,68,\"62696983\"\n```\n\n### ECM Stage 2 handoff\n\nPrMers can run ECM Stage 1 and let Prime95 or mprime run ECM Stage 2.\n\n```bash\n./prmers 757 -ecm -b1 97 -b2 9500 -K 15 -p95path /home/sebastien/gimps/v31_31.04_b05c\n```\n\nExample Prime95 line:\n\n```text\nECMSTAGE2=N/A,1,2,757,-1,\"resume_p757_ECM_TE_B1_97_c000006.p95\",9500\n```\n\n## Web GUI\n\nStart the GUI:\n\n```bash\n./prmers -gui -http 3131\n```\n\nCommon options:\n\n```bash\n./prmers -gui -host 127.0.0.1 -http 3131\n./prmers -gui -host 0.0.0.0 -http 3131\n```\n\nThe GUI can monitor progress, show logs, inspect results and help edit `worktodo.txt`.\n\n## GPU memory test\n\n```bash\n./prmers -memtest\n./prmers -memtest -d 1\n```\n\nThe memory test scans GPU VRAM with several patterns and reports bandwidth, coverage and errors.\n\n## NTT and IBDWT transform sizes\n\nFor a given exponent p, PrMers chooses an NTT/IBDWT size N:\n\n| Exponent p range | N | Structure |\n|---|---:|---|\n| 3-113 | 4 | 2^2 |\n| 127-239 | 8 | 2^3 |\n| 241-463 | 16 | 2^4 |\n| 467-919 | 32 | 2^5 |\n| 929-1153 | 40 | 5*2^3 |\n| 1163-1789 | 64 | 2^6 |\n| 1801-2239 | 80 | 5*2^4 |\n| 2243-3583 | 128 | 2^7 |\n| 3593-4463 | 160 | 5*2^5 |\n| 4481-6911 | 256 | 2^8 |\n| 6917-8629 | 320 | 5*2^6 |\n| 8641-13807 | 512 | 2^9 |\n| 13829-17257 | 640 | 5*2^7 |\n| 17291-26597 | 1024 | 2^10 |\n| 26627-33247 | 1280 | 5*2^8 |\n| 33287-53239 | 2048 | 2^11 |\n| 53267-66553 | 2560 | 5*2^9 |\n| 66569-102397 | 4096 | 2^12 |\n| 102407-127997 | 5120 | 5*2^10 |\n| 128021-204797 | 8192 | 2^13 |\n| 204803-255989 | 10240 | 5*2^11 |\n| 256019-393209 | 16384 | 2^14 |\n| 393241-491503 | 20480 | 5*2^12 |\n| 491527-786431 | 32768 | 2^15 |\n| 786433-982981 | 40960 | 5*2^13 |\n| 983063-1507321 | 65536 | 2^16 |\n| 1507369-1884133 | 81920 | 5*2^14 |\n| 1884193-3014653 | 131072 | 2^17 |\n| 3014659-3768311 | 163840 | 5*2^15 |\n| 3768341-5767129 | 262144 | 2^18 |\n| 5767169-7208951 | 327680 | 5*2^16 |\n| 7208977-11534329 | 524288 | 2^19 |\n| 11534351-14417881 | 655360 | 5*2^17 |\n| 14417927-22020091 | 1048576 | 2^20 |\n| 22020127-27525109 | 1310720 | 5*2^18 |\n| 27525131-44040187 | 2097152 | 2^21 |\n| 44040253-55050217 | 2621440 | 5*2^19 |\n| 55050253-83886053 | 4194304 | 2^22 |\n| 83886091-104857589 | 5242880 | 5*2^20 |\n| 104857601-167772107 | 8388608 | 2^23 |\n| 167772161-209715199 | 10485760 | 5*2^21 |\n| 209715263-318767093 | 16777216 | 2^24 |\n| 318767107-398458859 | 20971520 | 5*2^22 |\n| 398458889-637534199 | 33554432 | 2^25 |\n| 637534277-796917757 | 41943040 | 5*2^23 |\n| 796917763-1207959503 | 67108864 | 2^26 |\n| 1207959559-1509949421 | 83886080 | 5*2^24 |\n| 1509949440 and above, including MM31 | 167772160 | 5*2^25 |\n\n\nNote: for MM31 (`p = 2147483647`), the valid Marin transform size is `167772160 = 5*2^25`. Pure `2^27` is not valid for the Goldilocks root layout used here.\n\n## Benchmarks\n\nPerformance depends on GPU, clocks, power limits, OpenCL driver, thermal behavior and PrMers version. Treat the following values as rough guidance.\n\nMersenne Forum discussion:\n\nhttps://www.mersenneforum.org/node/1086124/page3\n\n### Quick PRP overview, Marin backend\n\nPRP throughput for `p` near `136279841`.\n\n| GPU | User or system | PRMERS_SCORE | Iter/s | Approx PRP ETA | Notes |\n|---|---:|---:|---:|---:|---|\n| NVIDIA GeForce RTX 5090 | Resolver, vast.ai | n/a | about 2230 | about 17 h | High-end NVIDIA |\n| NVIDIA GeForce RTX 4090 | Resolver | 100.00/100 | about 1225 | about 31 h | Reference score |\n| NVIDIA GeForce RTX 5070 Laptop | beepthebee | 62.69/100 | about 356 | about 4.5 d | OC reported |\n| NVIDIA GeForce RTX 4060 Ti | Lorenzo | 69.14/100 | about 318 | about 5 d | Desktop midrange |\n| NVIDIA GeForce RTX 4070 Laptop | Phantomas | 52.24/100 | about 255 | about 6 d | Laptop GPU |\n| NVIDIA GeForce RTX 2060 | hwt, Artoria2e5 | 45.76/100 | about 240-259 | about 6 d | Some undervolt or power cap runs |\n| NVIDIA GeForce GTX 1660 Ti | Phantomas | n/a | about 234 | about 6.8 d | Older Turing GPU |\n| AMD Radeon VII | cherubrock | 50.57/100 | about 350 | about 4.5 d | Development card |\n| Apple M4 Pro | wigglefruit | 30.29/100 | about 164 | about 9.6 d | Apple silicon |\n| Apple M2 | cherubrock | n/a | about 25 | about 62 d | MacBook Air 8 GB |\n\n### Detailed examples\n\n| GPU | p = 57885161 | p = 74207281 | p = 82589933 | p = 136279841 |\n|---|---:|---:|---:|---:|\n| RTX 5090 | about 2350 iter/s | about 2230 iter/s | about 1970 iter/s | about 2230 iter/s |\n| Radeon VII | about 510 iter/s | about 436 iter/s | about 402 iter/s | about 350 iter/s |\n| RTX 4090 | about 1030 iter/s | about 910 iter/s | about 840 iter/s | about 1225 iter/s |\n| RTX 4060 Ti | about 420 iter/s | about 366 iter/s | about 337 iter/s | about 318 iter/s |\n| RTX 4070 Laptop | about 370 iter/s | about 320 iter/s | about 283 iter/s | about 255 iter/s |\n| GTX 1660 Ti | about 330 iter/s | about 288 iter/s | about 262 iter/s | about 234 iter/s |\n| RTX 5070 Laptop | about 858 iter/s | about 882 iter/s | about 875 iter/s | about 356 iter/s |\n| Apple M4 Pro | about 264 iter/s | about 231 iter/s | about 213 iter/s | about 164 iter/s |\n| Apple M2 | about 42 iter/s | about 38 iter/s | about 32 iter/s | about 25 iter/s |\n\n## Backend and code\n\n- Marin backend by Yves Gallot\n  - https://github.com/galloty/marin\n- Integer NTT and IBDWT techniques\n  - PrMers uses integer modular arithmetic modulo `2^64 - 2^32 + 1`.\n  - The transform and weighting ideas are inspired by DWT and IBDWT work for Mersenne arithmetic.\n- Gerbicz-Li proof scheme\n  - Used for PRP error checking and safe long exponentiation workflows.\n\n## Related inspiration\n\n- GPUOwl by Preda\n  - https://github.com/preda/gpuowl\n- Genefer22 by Yves Gallot\n  - https://github.com/galloty/genefer22\n- Marin by Yves Gallot\n  - https://github.com/galloty/marin\n- GIMPS and the Mersenne Forum community\n  - https://www.mersenne.org/\n  - https://www.mersenneforum.org/\n- GMP-ECM\n  - https://gitlab.inria.fr/zimmerma/ecm\n- Yves Gallot repositories\n  - https://github.com/galloty\n  - https://github.com/galloty/f12ecm\n  - https://github.com/galloty/FastMultiplication\n- Nick Craig-Wood work\n  - IOCCC 2012 entry: https://github.com/ncw/ioccc2012\n  - GitHub: https://github.com/ncw/\n  - ARM Prime Math: https://www.craig-wood.com/nick/armprime/math/\n\n## Must read papers\n\n### Multiplication by FFT and weighted transforms\n\nDiscrete Weighted Transforms and Large Integer Arithmetic  \nRichard Crandall and Barry Fagin, 1994  \nhttps://www.ams.org/journals/mcom/1994-62-205/S0025-5718-1994-1185244-1/S0025-5718-1994-1185244-1.pdf\n\nRapid Multiplication Modulo the Sum And Difference of Highly Composite Numbers  \nColin Percival, 2002  \nhttps://www.daemonology.net/papers/fft.pdf\n\n### P-1 factoring\n\nAn FFT Extension to the P-1 Factoring Algorithm  \nPeter L. Montgomery and Robert D. Silverman, 1990  \nhttps://www.ams.org/journals/mcom/1990-54-190/S0025-5718-1990-1011444-3/S0025-5718-1990-1011444-3.pdf\n\nImproved Stage 2 to P+/-1 Factoring Algorithms  \nPeter L. Montgomery and Alexander Kruppa, 2008  \nhttps://inria.hal.science/inria-00188192v3/document\n\n### Proof schemes\n\nAn Efficient Modular Exponentiation Proof Scheme  \nDarren Li and Yves Gallot, 2022-2023  \nhttps://arxiv.org/abs/2209.15623\n\nThe paper describes a proof scheme for left-to-right modular exponentiation, generalizing the Gerbicz-Pietrzak approach to arbitrary exponents. It is relevant to long PRP runs and validation of large modular exponentiations.\n\n## Cleaning and uninstall\n\n```bash\nmake clean\nsudo make uninstall\n```\n\n## Contributing and issues\n\nBug reports, feature requests and pull requests are welcome:\n\nhttps://github.com/cherubrock-seb/PrMers/issues\n\nWhen reporting a problem, include:\n\n- OS and GPU\n- OpenCL driver version\n- Full command line\n- Relevant `worktodo.txt` line, if any\n- Last lines of terminal output and `prmers.log`\n\n## Author\n\nPrMers is developed by cherubrock-seb, with feedback and contributions from users on GitHub and mersenneforum.org.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcherubrock-seb%2Fprmers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcherubrock-seb%2Fprmers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcherubrock-seb%2Fprmers/lists"}