Block LOBPCG lowest-k eigenpairs with an invented 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 finds the lowest k eigenpairs of a generated sparse SPD operator with a
block LOBPCG iteration and an invented preconditioner, running a fixed number of
iterations (no convergence stop). It reports the Ritz values and residual norms.
Operator (invented, SPD). On a GX x GY grid (N = GX*GY) the operator is a
Schrodinger-like anisotropic 5-point Laplacian plus a potential:
A[i][i] = (sum of incident edge weights) + POT0 + trap(i) + hash(i), off-diagonals
A[i][j] = -w_ij. Edge weights w_ij in [0.5, 1.5] come from a symmetric SplitMix64
hash; a-direction edges are scaled by 1.25 (anisotropy). An invented anisotropic
harmonic trap trap = 6*(1.3*sa^2 + 0.7*sb^2) (with sa, sb the centred coordinates)
makes the low eigenvalues well separated. Two reflection/shift involution links
(j = N-1-i and j = (i+N/2) mod N, weak, weight scaled by 0.12) add long-range
coupling. The matrix is symmetric and diagonally dominant with a positive diagonal, hence
SPD.
Preconditioner (invented). T r is three damped-Jacobi residual-correction steps
from zero with the fixed schedule omega = {0.70, 1.10, 0.60} (a degree-3 polynomial in
the Jacobi-scaled operator).
LOBPCG. The initial block X (N x k, hashed) is orthonormalised by Cholesky-QR.
Each iteration: Ritz values lambda_c = X_c^T A X_c; residuals R = AX - X diag(lambda);
preconditioned directions W = T R, column-normalised; subspace S = [X, W, P]
([X, W] on the first iteration); Gram matrices S^T S and S^T A S; a tiny dense
Rayleigh-Ritz generalized eigenproblem (Cholesky of S^T S, then a fixed-sweep cyclic
Jacobi symmetric eigensolve) selecting the k smallest; and block updates of X and the
search direction P. All full-length reductions use a fixed order (thread-count
independent); the dense eigensolve uses a fixed sweep count.
Input format
GX GY k iters seed
One line: grid GX, GY >= 1, block size k >= 1 with 3k <= N, iteration count
iters >= 1, and a 64-bit seed.
Output format
n <N> gx <GX> gy <GY> k <k> iters <iters>
trace <sum of the k Ritz values>
frob_residual <Frobenius norm of the block residual>
ritz <c> <lambda_c> (k lines, ascending)
resid <c> <||A x_c - lambda_c x_c||> (k lines)
Floating-point fields use %.10e. Comparison is numeric with rtol = 1e-5,
atol = 1e-6.
Hidden inputs
Correctness inputs (10 files) include tiny grids (6x6, 8x8), 1D lines (1x30,
30x1), squares up to 100x90, and a random rectangle, with k in [4, 16] and
iters in [8, 16] (always 3k <= N). The timing input is a 1265 x 1265 operator
(about 1.6 million unknowns) solving for the lowest 16 eigenpairs with 18 iterations.
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 is a 1265 x 1265 operator (about 1.6 million unknowns, up to 6 nonzeros per row) solving for the lowest 16 eigenpairs with 18 LOBPCG iterations. 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.