Power iteration on D^dagger D for a twisted anisotropic Wilson-Dirac operator
/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
Power iteration on D^dagger D, where D is an anisotropic Wilson-Dirac operator with SU(3) gauge
links, twisted boundary phases and a site-dependent mass on a periodic 4D lattice
LX x LY x LZ x LT (FP64 complex throughout). The CPU source is the exact specification.
- Fields. Site
i = x + LX*(y + LY*(z + LZ*t)). A spinor has 4 spins x 3 colours (24 reals); each site has 4 linksU_mu(i)(mu = 0..3 for x, y, z, t), 3x3 complex. Withuval(key, n) = (mix64(key ^ (n * 0xD6E8FEB86659FD93)) >> 11) * 2^-52 - 1(mix64= SplitMix64 finaliser) and keysKL, KM, KV = mix64(seed ^ 0x1111111111111111 / 0x2222222222222222 / 0x3333333333333333):- link
U_mu(i)starts fromA = I + EPS * (R + i R')with entriesuval(KL, 18*(4i+mu) + 2*(3a+b))(real) and... + 1(imaginary); rows 0 and 1 are Gram-Schmidt orthonormalised and row 2 is the complex conjugate ofrow0 x row1, so every link is an exact SU(3) matrix; - mass
m_i = 1 + MASS_AMP * uval(KM, i); - start vector
x_i[s][a] = uval(KV, 24i + 2(3s+a)) + i * uval(KV, 24i + 2(3s+a) + 1), normalised.
- link
- Operator.
`(D psi)(i) = m_i psi(i) - sum_mu kappa_mu [ (1 - gamma_mu) U_mu(i) psi(i+mu) f_mu^+(i)
- (1 + gamma_mu) U_mu(i-mu)^dagger psi(i-mu) f_mu^-(i) ]
, wheref^+ = exp(+i theta_mu)when the forward hop wraps around the lattice (c_mu = L_mu - 1),f^- = exp(-i theta_mu)when the backward hop wraps (c_mu = 0), and 1 otherwise, withtheta_mu = 2 pi P_mu / 128(P = 64is antiperiodic).D^daggeris the same expression with(1 - gamma_mu)and(1 + gamma_mu)exchanged. The gamma matrices are a Euclidean chiral basis given in the source (GPERM,GPH: rowsofgamma_muhas one nonzero entry), withgamma_5 = diag(1, 1, -1, -1). Since(1 -+ gamma_mu)` has rank 2, only two spin components per hop are multiplied by the link (spin projection).
- (1 + gamma_mu) U_mu(i-mu)^dagger psi(i-mu) f_mu^-(i) ]
- Iteration.
v_0 = x / |x|; fork = 1..K:w = D v_{k-1},lambda_k = |w|^2,x = D^dagger w,nu_k = |x|,v_k = x / nu_k. - Final vector. Per time slice
t:norm_t = sum |v_K|^2andchirality_t = sum (|spins 0,1|^2 - |spins 2,3|^2)over the slice's sites. Eight sampled components: fork = 0..7,h = mix64(seed ^ ((0xC0C0A0A0 + k) * 0x9E3779B97F4A7C15)), siteh mod V, spin(h >> 40) & 3, colour(h >> 44) mod 3, printed asv_K * sqrt(12 V)(real and imaginary part).
The CPU program applies each operator as one parallel pass and sums |.|^2 over fixed
(t, z) slabs in a fixed order, so its output does not depend on the thread count.
Input format
LX LY LZ LT K SEED
KAPPA_X KAPPA_Y KAPPA_Z KAPPA_T
P_X P_Y P_Z P_T
EPS MASS_AMP
All extents are even and at least 2; SEED is an unsigned 64-bit integer; P_mu are integers.
Output format
lattice LX LY LZ LT iterations K
rq k LAMBDA_k NU_k (k = 1..K)
slice t NORM CHIRALITY (t = 0..LT-1)
comp SITE SPIN COLOUR RE IM (8 lines)
Floating-point values are printed with %.12e and compared with a relative tolerance of 1e-8
plus an absolute tolerance of 1e-10; integer tokens and words must match exactly. FP64 arithmetic
is required (any summation order or FMA use is fine; storing links or spinors in FP32/FP16 will
not meet the tolerance). Reconstructing links from two stored rows is exact up to rounding.
Hidden inputs
2 <= LX, LY, LZ <= 32, 2 <= LT <= 64 (all even), 0 <= K <= 130, KAPPA_mu in
[0.05, 0.14], P_mu in [0, 127], EPS in [0, 1.5], MASS_AMP in [0, 0.3], at most
32^3 x 64 sites. Correctness inputs include K = 0, the 2^4 lattice (both neighbours in a
direction are the same site), the free field (EPS = 0, MASS_AMP = 0, no twist), unit links
with an antiperiodic time direction, elongated lattices (4x4x4x64, 32x2x2x2, 2x32x30x4) and
lattices up to 16^4. The timing input is a 32^3 x 44 or 32^3 x 48 lattice with 110-130
iterations, equal spatial hopping parameters and a different temporal one.
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-08 and atol = 1e-10; every other token must be identical. Any mismatch, crash or timeout gives reward 0. - Speed: The timing input is a 32^3 x 44 or 32^3 x 48 lattice (about 1.5 GB of links and spinors in FP64) with 110 to 130 power iterations, i.e. 220 to 260 Dirac-operator applications. 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.