CUDA bounded point search for hyperelliptic curves.
This project provides a CUDA implementation with a command-line and output interface compatible with Michael Stoll's ratpoints. Many thanks to Michael Stoll for developing and publishing ratpoints. See Documentation for the ratpoints program, arXiv:0803.3165.
For a curve
the program searches reduced
- CUDA rejects candidates with a modular square sieve.
- GMP verifies every surviving point exactly.
Results are exhaustive within the requested bounds only.
This fork supports native multi-GPU search in one process. By default it
uses all CUDA-visible GPUs; select a subset with --devices 0,1, or use
--devices 0 for a single-GPU baseline. Run ./ratpoints_gpu --list-devices
first. See Multi-GPU usage and benchmarks.
The following are historical upstream single-GPU measurements, not new
measurements of this fork. Measure local scaling with make benchmark DEVICES=0,1 HEIGHT=1000000 (run this command on one line).
Measurements used
Stoll's record curve
and equal-height boxes
GPU: NVIDIA RTX 2000 Ada Generation Laptop GPU (24 SM, 8 GB).
| Backend | Sites ( |
Elapsed | Gsite/s | |
|---|---|---|---|---|
| ratpoints 2.1.3 | 300,000 | 180 billion | 54.84 s | 3.28 |
| ratpoints_gpu | 5,000,000 | 50 trillion | 56.85 s | 879.5 |
The measured end-to-end speedup was
Enable metrics with -v or RATPOINTS_GPU_BENCHMARK=1.
- Degrees from 1 through 100
- Arbitrary-size integer coefficients
- Exact squarefreeness check before search
- Independent numerator and denominator bounds
- Unions of closed real intervals for
$x$ - Weighted projective output compatible with ratpoints
- Points at infinity
- Exact GMP verification
- Ratpoints custom output formats
- Nonzero exit status for invalid input and CUDA errors
Coefficients are listed from constant to leading term.
./ratpoints_gpu 'c0 c1 ... cn' HEIGHT [OPTIONS]| Option | Action |
|---|---|
--devices all or --devices 0,1
|
Select visible GPUs (default: all) |
--batch-size N |
Denominators per GPU batch, 1 through 65,536 |
--list-devices |
List GPUs and exit; use without a curve |
-dl B, -du B
|
Set denominator bounds |
--square-denominators |
Interpret -dl and -du as bounds on |
-l L, -u U
|
Restrict |
-1 |
Stop after the first point |
-i, -I
|
Suppress or restore points at infinity |
-y, -Y
|
Suppress or restore ordinates |
-z, -Z
|
Suppress or restore point output |
-q |
Quiet output |
-v |
Print timing and survivor metrics |
-f FORMAT |
Set the point format with %x, %y, and %z markers |
-fs TEXT, -fm TEXT, -fe TEXT
|
Set text before, between, and after points |
-s, -k, -K, -j, -J
|
Accepted with no effect on the CUDA search |
--help |
Print usage and supported options |
Interval pairs may be repeated. The first -l and final -u are optional.
Unsupported options return an error.
Square-denominator mode searches the stated finite set of rational arguments;
it is useful for x-coordinates on integral Weierstrass models. The output
denominator is the actual
- Sieve-tuning options
-n,-N,-p,-F, and-Sare not supported. - Unchecked-survivor output via
-xis not supported. - CUDA is required. There is no CPU fallback.
- Multi-GPU execution partitions denominators across independent GPU workers. No NVLink, peer access, or shared VRAM is required.
- Ratpoints optimizations based on Sturm isolation, coefficient reversal, forbidden divisors, and Jacobi symbols are not implemented. These omissions can affect performance and diagnostics, but not the searched set.
Build and runtime dependencies:
- Linux
- NVIDIA GPU with a compatible driver
- CUDA Toolkit with
nvccand C++14 support - GMP headers and library
- GNU Make
- Host C++ compiler supported by the installed CUDA Toolkit
Tests require Python 3. Only make test needs ratpoints 2.1.3 or newer;
make test-multi-gpu does not. make test-host needs a host C++ compiler and
GMP but no CUDA toolkit, driver, or GPU.
Debian or Ubuntu packages, excluding CUDA and the NVIDIA driver:
sudo apt install build-essential make libgmp-dev python3 ratpointsFedora packages, excluding CUDA, the driver, and ratpoints:
sudo dnf install gcc-c++ make gmp-devel python3makeThe default -arch=native targets GPUs visible during compilation. Override it
for a deployment target:
make clean
make ARCH_FLAGS='-arch=sm_75'Build a multi-architecture binary with PTX fallback:
make clean
make ARCH_FLAGS='-gencode arch=compute_80,code=sm_80 \
-gencode arch=compute_89,code=sm_89 \
-gencode arch=compute_80,code=compute_80'Run make print-config to inspect active build variables.
Install under /usr/local/bin:
sudo make installStage a package without root:
make DESTDIR="$PWD/pkg" PREFIX=/usr installSupported overrides are NVCC, NVCCFLAGS, WARNING_FLAGS, ARCH_FLAGS,
CPPFLAGS, LDFLAGS, LDLIBS, PREFIX, and DESTDIR.
Michael Stoll's record genus-2 curve is
Search it to projective height
./ratpoints_gpu \
'247747600 -985905640 567207969 2396040466 52485681 -470135160 82342800' \
1000000 -qThe search covers primitive pairs with
Both signs are printed when
Set -du explicitly for large heights. Runtime is approximately linear in the
total number of sites: (numerator range width) times (denominator count).
make test-host
make test-multi-gpu DEVICES=0,1
make benchmark DEVICES=0,1 HEIGHT=1000000 REPEATS=3test-host uses an explicitly mocked CUDA backend and real GMP arithmetic;
it does not validate CUDA kernels or measure GPU performance. The multi-GPU
test compares ordered results against an independent integer oracle and checks
single/multiple-device equivalence. The benchmark checks identical point output
and survivor counts before reporting scaling. See MULTI_GPU.md.
make test requires ratpoints 2.1.3 or newer installed and available on PATH.
make testThe tests compare complete CPU and GPU point sets for odd and even degrees through 100, intervals, denominator ranges, points at infinity, and squarefree input validation.
Check the published record-curve points through height
make record-checkThe repository includes Stoll's published list. Of its 321
src/sieve.cucontains the modular square sieve and CUDA orchestrationsrc/sieve_plan.cppbuilds prime tables and denominator-specific sieve planssrc/point_search.cppschedules ordered multi-GPU batches and exact verificationsrc/gpu_devices.cpphandles CUDA device discovery and selectionsrc/exact_polynomial.cppcontains exact GMP polynomial arithmeticsrc/command_line.cppparses and validates command-line argumentssrc/output_formatter.cppimplements ratpoints-compatible outputinclude/contains the interfaces shared between those modulestests/compare_with_ratpoints.pyruns CPU and GPU comparison teststests/verify_record_curve.pychecks Stoll's published record-curve pointstests/test_multi_gpu.pychecks multi-GPU orchestration and ordered outputtests/benchmark_multi_gpu.pymeasures validated single/multi-GPU scaling
ratpoints_gpu was written independently. The original ratpoints source code
was never consulted or referenced while writing this repository, and no source
code was copied or adapted. Compatibility is limited to the command-line and
output interface. ratpoints_gpu is distributed under GPL-2.0-or-later. See
COPYING and NOTICE. Original ratpoints is copyright (C) 2008, 2009 Michael
Stoll and is licensed GPL-2.0-or-later.
The record curve and bundled point data are documented by J. Steffen Müller and Michael Stoll in Canonical Heights on Genus Two Jacobians, Algebra & Number Theory 10 (2016), 2153-2234.