Punctured K=9 soft Viterbi decoding with a-priori input
/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
Soft-decision maximum-likelihood (Viterbi) decoding of a batch of independent frames sent over a
noisy channel with a punctured, terminated, rate-1/2 convolutional code of constraint length 9
(256 trellis states). Everything is generated inside the program from the seed with the
counter-based hash hkey(seed, tag, f, j) = mix64(seed + ((tag << 56) | (f << 14) | j)).
For frame f:
hf = hkey(seed, 0, f, 0); lengthL = LMIN + hf % (LMAX - LMIN + 1)info bits; puncturing patternpats[(hf >> 40) % NP].- Info bits: word
jishkey(seed, 1, f, j)(bittof the frame is bitt % 64of wordt / 64). Eight zero tail bits follow, so the trellis hasT = L + 8steps and starts and ends in state 0. - Encoder: the 9-bit window at step
tisw = (u_t << 8) | (u_{t-1} << 7) | ... | u_{t-8}; coded bitsc0 = parity(w & G0),c1 = parity(w & G1). - Channel (per step,
hn = hkey(seed, 2, f, t)):r = clamp(±AMP + floor(g * NOISE / 128), -127, 127)(+AMPfor a 0 bit) wheregis the sum of four bytes ofhnminus 510 (bytes 0-3 forc0, bytes 4-7 forc1). The decoder seesq = compress(r)(magnitudes above 48 are halved beyond 48), or 0 where the puncturing pattern drops the bit (pattern positiont % P). - A-priori value for info bit
t < L:clamp(±APRI + floor(g' * APRI / 64), -31, 31)from bytes 2-5 ofhkey(seed, 3, f, t); 0 for tail steps.
Decoder: path metrics are maximised; the branch metric into state s' from predecessor
p = ((s' << 1) & 255) | b is ±q0 ±q1 ±a (sign - when the corresponding coded bit, or the input
bit u = s' >> 7, is 1). Metrics are 32-bit integers, start at 0 for state 0 and -2^28 elsewhere,
are never normalised, and states with u = 1 are forced to -2^28 during the 8 tail steps. On a tie
the even predecessor (b = 0) wins. Traceback starts from state 0 at step T. Per frame the program
records the final metric of state 0, the number of decoded info bits that differ from the
transmitted ones, and hash = sum_j mix64(dw_j ^ (j * 0x9E3779B97F4A7C15)) over the decoded info
words dw_j (same packing as the info words), all modulo 2^64.
The six puncturing patterns (positions 0,1,2,... of the two coded streams) are:
0 rate 1/2 (1/1), 1 rate 2/3 (11/10), 2 rate 3/4 (101/110), 3 rate 4/5
(1011/1100), 4 rate 5/6 (10101/11010), 5 rate 7/8 (1000101/1111010).
Input format
NF SEED
G0 G1
LMIN LMAX
AMP NOISE APRI
NP p_1 ... p_NP
G0, G1 are octal. p_i are pattern ids in 0..5.
Output format
frames NF infobits B
biterrors E frameerrors FE
metricsum S
framehash H
pattern p frames n biterrors e frameerrors fe metricsum s (one line per pattern used, ascending p)
errhist n0 n1 n2 n3 n4 n5
worst f errors e (omitted when NF = 0)
frame f L L pattern p metric m errors e hash h (frames 0..min(NF,8)-1)
B is the total number of info bits, E the total bit errors, FE the number of frames with at
least one error, S the sum of final metrics, H = sum_f mix64(hash_f + f * 0xD1B54A32D192ED03)
mod 2^64. errhist counts frames with 0, 1-3, 4-15, 16-63, 64-255 and 256+ bit errors. worst is
the first frame with the largest number of errors.
Hidden inputs
0 <= NF <= 400000,1 <= LMIN <= LMAX <= 8192,0 <= AMP <= 127,0 <= NOISE <= 64,0 <= APRI <= 31,1 <= NP <= 6; generator pairs have taps 0 and 8 set and free distance 12.- Correctness inputs include
NF = 0, a single 1-bit frame, frames of length 1-9, a noiseless channel, very noisy channels with hundreds of errors per frame, saturating amplitudes, frames of the maximum length 8192 and random mixes of patterns. - The timing input has about 260000 frames with
Luniform in [2048, 8192],AMP = 32,NOISEin [14, 18],APRIin [2, 6] and all six patterns (a few percent bit errors on the high-rate patterns, none on rate 1/2).
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 has about 260000 frames with 2048-8192 info bits each (about 1.3G trellis steps), all six puncturing patterns and a noise level that leaves a few percent bit errors on the high-rate patterns. 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.