Dense nonsymmetric solve by FP32 blocked LU with partial pivoting and FP64 iterative refinement
/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
One dense nonsymmetric linear system A X = B with N unknowns and NRHS right-hand sides,
solved to FP64 accuracy by mixed-precision iterative refinement: an FP32 LU factorisation with
partial pivoting (blocked, right-looking, 64-column panels, full row interchanges), then 8
refinement steps, each R = B - A X in FP64 with the exact matrix, a correction from the FP32
LU factors, and X += correction. The program prints norms, a signed sum and sampled entries
of each solution column.
Matrix and right-hand sides (mix64 is the SplitMix64 finaliser of the CPU source,
arithmetic mod 2^64). A = D + K, all entries integers and exact in FP32:
A[i][i] = D0 + (mix64(SEED ^ 0x1234567 ^ i) mod D0);- for
i != j, withlo = min(i, j),hi = max(i, j):v = (mix64(SEED ^ (lo*N + hi)) mod (2R+1)) - RandA[i][j] = vifi < j,-vifi > j(soKis skew-symmetric). B[i][r] = 64 * D0 * (2 * (mix64(SEED ^ 0xB0B0B0B0 ^ (r << 40) ^ i) >> 11) * 2^-53 - 1)in FP64.
The symmetric part of A is D, so sigma_min(A) >= D0 and A is nonsingular; its condition
number is about 2*sqrt(N/3)*R/D0. The hidden inputs keep it between 1,000 and 8,000 (except the
trivially conditioned edge cases), where FP32 alone gives only 3-4 correct digits and the
refined solution is accurate to about 1e-12 relative.
Refinement as done by the CPU. X = 0. Each of the 8 steps computes R = B - A X in FP64
(FP32 entries of A widened to FP64), then per column r: e = binary exponent of
max_i |R[i][r]| (frexp), y = float(R[:, r] * 2^-e), apply the row interchanges, solve
L y = y and U z = y in FP32, and add z * 2^e to X[:, r] in FP64 (a column with
R = 0 is left unchanged). The refinement has converged to FP64 accuracy (corrections around
1e-13 relative) after 3-5 steps.
Any method that reaches the same solution within the tolerance below is fine: other blockings and pivot orders, FP64 or tensor-core (TF32/FP16/BF16, with scaling or split-precision tricks) factorisations, other refinement schemes (e.g. GMRES-based), or stopping early once converged. FP32 accuracy alone, or a single refinement step, is not enough.
Input format
One line: N NRHS SEED D0 R with 1 <= N <= 32768, 1 <= NRHS <= 8, SEED unsigned 64-bit,
1 <= D0 <= 2^22, 0 <= R <= 2^22.
Output format
n N nrhs NRHS D0 D0 R R
rhs r norm2 S wsum T maxabs M (two lines per right-hand side r = 0..NRHS-1)
rhs r x x_0 x_1 x_2 x_3 x_4 x_5
S = sqrt(sum_i X[i][r]^2), T = sum_i sign_i * X[i][r] with sign_i = +1 if
mix64(SEED ^ 0x5EED5EED ^ i) is odd and -1 otherwise, M = max_i |X[i][r]|, and the six
sampled entries are X[idx_s][r] with idx_s = floor(N*s/6) + (7s mod (N - floor(N*s/6))),
s = 0..5. All values are printed with %.12e. Outputs are compared numerically with
rtol = 1e-9 and atol = 1e-9 per value (solution entries are mostly of order 0.01-10 and at
most about 64 in absolute value).
Hidden inputs
Correctness inputs (17): N = 1 and a 3x3 diagonal system (R = 0), N = 2 with 8 right-hand
sides, N = 17, 63, 64, 65, 129, 300, 500, 777, 1024, 2000 with condition numbers 50-8,000,
R = 2^22 (largest entries), D0 = 1 with R = 3, and three random systems with
2 <= N <= 1500, 1-8 right-hand sides and condition number 1,000-8,000. R is between 2^19
and 2^21 unless stated. The timing input has N from 15,000 to 16,384 (about 2 GB for A and
its FP32 LU), 4-8 right-hand sides, R in [2^19, 2^21] and condition number 2,000-6,000.
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 main computation must execute on the GPU. Renaming CPU code to .cu, running a
CPU fallback, or launching a dummy kernel while computing the answer on the CPU does not satisfy this task.
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. - GPU verification uses the backend selected for this run: an H100 attached to the separate verifier, or a remote H100 worker. Hidden inputs use a fresh random seed.
- For public GPU experiments, use
/app/bin/gpu_run [--backend auto|local|remote] [--repeat N] [--quiet] SOURCE.cu INPUT_FILE.... The default usesGPU_RUNNER_URLwhen configured, otherwise a GPU attached to this sandbox. Sandbox GPU access is configured independently from verification; a CPU-only sandbox needs a runner URL. - 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-09 and atol = 1e-09; every other token must be identical. Any mismatch, crash or timeout gives reward 0. - GPU execution: a separate, untimed CUPTI check must observe completed GPU kernel activity on the hidden timing input. A CPU-only submission receives reward 0 even if its output is correct.
- Speed: One system with 15,000 to 16,384 unknowns (about 2 GB for A and its FP32 factors), 4-8 right-hand sides and condition number 2,000-6,000; the FP32 factorisation (about 2.5e12 flops) dominates. 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.