Restarted GMRES(m) with an invented polynomial preconditioner
/app/cpu/main.cpp is a multicore CPU program (C++17, OpenMP). It is built as
/app/bin/cpu_baseline with g++ -O3 -march=native -fopenmp -std=c++17 and run as
cpu_baseline INPUT_FILE
It reads one input file and writes its result to stdout.
What the program computes
The program solves a generated nonsymmetric sparse linear system A x = b with
restarted GMRES(m), right-preconditioned by an invented polynomial preconditioner,
running a fixed number of restart cycles (no convergence-based stopping).
Operator. For N unknowns each row i has one strong convective link to column
(i+1) mod N and R weak random links. Writing D for the diagonal, the scaled
operator D^{-1}A equals I + CONV*(forward shift) + (weak random links) with
CONV = 0.985 and each weak scaled link drawn uniformly from [-WEAK, WEAK],
WEAK = 0.06. The diagonal is d_i = 2 + u with u a hashed value in [0,1); every
off-diagonal value is d_i times its scaled weight. The right-hand side b_i is a
hashed value of order one. All data come from a SplitMix64-style counter hash of the
seed, so element i is reproducible independently. This operator is strongly
non-normal, so GMRES(m) only partially converges in the fixed budget.
Preconditioner (invented). M^{-1} r is four damped-Jacobi residual-correction
steps started from zero with the fixed relaxation schedule
omega = {0.80, 1.15, 0.60, 1.05}:
z_0 = omega_0 D^{-1} r, then z_k = z_{k-1} + omega_k D^{-1}(r - A z_{k-1}).
GMRES(m). Each of the cycles outer cycles: compute the true residual
r = b - A x, beta = ||r||, v_1 = r/beta; run exactly m Arnoldi steps with
modified Gram-Schmidt (w = A M^{-1} v_j, orthogonalise against v_1..v_j,
normalise to get v_{j+1}); maintain the least-squares solution with Givens
rotations on the (m+1)-by-m Hessenberg; back-substitute and update
x += M^{-1}(V_m y) (right preconditioning).
Floating-point reductions (dot products and norms) are accumulated in a fixed, thread-count-independent order.
Input format
N R m cycles seed
One line. N >= 1 unknowns, R >= 0 weak links per row, restart dimension m >= 1,
cycles >= 1, and a 64-bit seed.
Output format
n <N> nnz <nnz> m <m> cycles <cycles>
residual_norm <||b - A x||_2>
rhs_norm <||b||_2>
sol_norm <||x||_2>
sum_x <sum_i x_i>
sum_abs_x <sum_i |x_i|>
sample <i0> <x_i0>
... (8 sampled solution entries)
Floating-point fields use %.10e. Comparison is numeric with rtol = 1e-5,
atol = 1e-6.
Hidden inputs
Correctness inputs (10 files, one query each) include N = 1, 2, 3, 5 (tiny, where the
basis saturates), N = 100, 1000, 4096, a random N in [30000, 60000], and
N = 120000 and N = 250000, with R in [0, 9], m in [4, 24] and cycles in
[2, 4]. The timing input has N about 5,000,000, R = 7, m = 32 and
7 cycles (about 40 million off-diagonal entries).
Your task
Port this program to CUDA in /app/gpu/main.cu: same command line (PROGRAM INPUT_FILE),
same output on stdout. Then make it as fast as you can on the GPU while keeping the output correct.
The CPU source is the specification: when this text and the code disagree, the code wins.
How you are scored
- Only
/app/gpu/main.cuis collected. It is compiled withnvcc -O3 -arch=sm_90 -std=c++17 -o port /app/gpu/main.cu; no extra libraries are linked. The CUDA runtime and the header-only libraries that ship with the CUDA toolkit (CUB, Thrust, libcu++) are allowed. - Your source must not contain any of:
system(,popen(,fork(,exec*,dlopen(,getenv(,#include <filesystem>,/tests/,/proc/. The program may read only the input file it is given. - Grading runs on one H100 in a fresh container without network. Inputs are generated with a new random seed at grading time, so they cannot be known in advance.
- Correctness: every hidden input (small edge cases plus the timing input) must pass.
Your output must have the same tokens as the CPU program's output. Numeric tokens may differ by at most
atol + rtol*|expected|with rtol = 1e-05 and atol = 1e-06; every other token must be identical. Any mismatch, crash or timeout gives reward 0. - Speed: The timing input has N about 5,000,000 unknowns, 7 weak random links plus one convective link per row (about 40 million off-diagonal entries), restart dimension m=32 and 7 restart cycles. Your port and our GPU reference are each run on it
once to warm up and then 5 times, interleaved; the time is the wall clock of the whole process
(including CUDA initialisation, input parsing and output). When correct,
reward = min(2, t_reference / t_yours)using the medians. /app/inputs/holds a few public inputs./app/bin/run_public.shcompiles your port with the flags above and compares it against the CPU baseline on each of them.