Fixed-point multiscale Hogbom CLEAN imaging pipeline
/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
A complete (synthetic) radio-interferometric imaging job in exact integer arithmetic: build the
dirty beam from a uv coverage, form a dirty image of a generated sky, deconvolve it with a
three-scale Högbom CLEAN, restore it and report what a radio astronomer would check.
cpu.cpp is the full specification; the stages are:
- uv coverage and PSF.
NUVsamples(u_k, v_k)with taper weightstw_kare generated from a counter-based hash. The PSF patchP(l, m)for|l|, |m| <= Hp = H + 2*R2is the direct integer DFTsum_k tw_k * cosT[(u_k*l + v_k*m) mod N](cosTis an integer-only Q30 cosine table), normalised toP(0,0) = 32768with round-half-away-from-zero. - Sky and dirty image.
NPTpoint sources andNEXTparabolic-squared blobs are generated; the dirty image isD = round((sky (*) P) / 2^15) + noisewhere the convolution is truncated to theHppatch and the noise is a per-pixel hash with amplitudeNOISE. - Scales. Scale 0 is a delta, scales 1 and 2 are paraboloids
R^2 - |e|^2of radiusR1,R2(weight sumsW_s). The residual imagesI_s = round((B_s (*) D) / W_s)(int32, zero outside the image) and the 3x3 cross-scale PSF patchesP_st = round((B_s (*) B_t (*) P) / (W_s W_t))on|d| <= Hare computed. Each scale gets an integer selection weightw_s = min(511, (256 - BIAS*s)*32768 / P_ss(0))(0 ifP_ss(0) < 2048). - CLEAN. Up to
NITERiterations; each iteration picks the global maximum of|I_s(x)| * w_sover all three scales and all pixels (ties: smaller scale, then smaller pixel index), stops if that score is< 256*THRESH, otherwise records the componentalpha = trunc(I_s(x) * GAIN * 32768 / (P_ss(0) * 65536))and subtracts(alpha * P_st(d) + 16384) >> 15fromI_t(x + d)for all threetand all|d| <= Hinside the image (results clamped to +-(2^31-1)). Iterations are strictly sequential: each argmax depends on the previous subtraction. - Restore. The per-scale model images are convolved with
K_s = round((B_s (*) beam) / W_s)(beam: parabolic-squared, radiusRB, peak 32768) and added to the scale-0 residual. - Report. Iterations and stop reason, components and total flux per scale, the first six
components, residual max/sum/sum of squares, restored-image flux and brightest pixel,
the number of strict 3x3 local maxima
>= 4*THRESH(ties broken by pixel index) and the ten brightest of them, and checksums of the restored image and of the component sequence.
All sums are integer; 64-bit sums of squares and hashes wrap modulo 2^64.
Input format
One line with 14 integers:
N H R1 R2 RB NUV NPT NEXT NOISE GAIN BIAS NITER THRESH SEED
Output format
ITERS <iters> STOP <0|1> PSF0 <P_raw(0,0)> PSS <P_00(0)> <P_11(0)> <P_22(0)> W <w_0> <w_1> <w_2>
SCALE <s> <components> <sum of alpha> (s = 0, 1, 2)
COMP <iteration> <scale> <x> <y> <alpha> (first min(6, iters) components)
RESID <max |I_0|> <sum I_0> <sum I_0^2 mod 2^64>
RESTORED <sum> <peak value> <peak x> <peak y> <number of local maxima>
PEAK <value> <x> <y> (up to 10 lines)
CHECK <restored-image hash> <component-sequence hash>
Hidden inputs
32 <= N <= 1024; 2 <= H, 1 <= R1 <= R2 <= 14 and H + 2*R2 <= N/2 - 1; 1 <= RB <= 5;
1 <= NUV <= 5000; 0 <= NPT <= 2048; 0 <= NEXT <= 64; 0 <= NOISE <= 256;
1 <= GAIN <= 32768; 0 <= BIAS <= 100; 0 <= NITER <= 40000; THRESH >= 1; SEED < 2^63.
Correctness inputs (10 files) have N <= 512 and include an empty noiseless sky (immediate
stop), a single-baseline fringe PSF, NITER = 0, a non-power-of-two size, GAIN = 32768 with
BIAS = 0, a blob-dominated sky with BIAS = 100, a run that ends on the threshold and a
noise-dominated image. The timing input has N = 1024, H in [40, 56], R1 in [3, 5], R2
in [9, 14], 3000-5000 uv samples, 1200-2000 point sources, 32-64 blobs, THRESH = 1 and
NITER = 36000, so all 36000 sequential iterations run.
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 be identical to the CPU program's output (trailing whitespace ignored). 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: The timing input is a 1024x1024 image with a 81-113 pixel PSF patch, scales of radius 3-5 and 9-14, 3000-5000 uv samples, 1200-2000 point sources and 32-64 extended blobs; CLEAN runs all 36000 iterations (threshold 1). 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.