Turbo-code link simulation with a fixed-point log-MAP iterative decoder
/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 link-level Monte Carlo simulation of a turbo code with an iterative log-MAP (BCJR) decoder,
as run for every point of a frame-error-rate curve. For each operating point
(K, MODE, AMP, F, IMAX) (mix64 is the SplitMix64 finaliser in the CPU source, all
arithmetic is integer):
- Interleaver.
pseed = mix64(SEED ^ 0x6A09E667F3BCC909 * (p+1)). Quadratic permutation polynomialpi(i) = (f1 i + f2 i^2) mod Kwithf2 = rad(K) * (1 + (pseed & 3))(rad= product of the distinct primes ofK) andf1= the first value>= ((pseed >> 8) mod K) | 1in steps of 2 that is coprime toK. - Per frame
fr.fs = mix64(pseed ^ 0xBB67AE8584CAA73B * (fr+1)).D = K - 16data bits (top bit ofmix64(fs ^ C * (i+1))), followed by a CRC-16 (polynomial 0x8BB7, init 0, MSB first). Two identical 8-state recursive systematic encoders (states = r1 | r2<<1 | r3<<2, feedbacka = u ^ r1 ^ r3, paritya ^ r2 ^ r3, next statea | r1<<1 | r2<<2) encode the block and the interleaved blockc[pi[k]]; each is terminated by 3 tail steps with inputr1 ^ r3, whose systematic and parity bits are sent. Puncturing of the parities (tails never punctured): MODE 0 keeps all (rate 1/3); MODE 1 keeps parity 1 at evenkand parity 2 at oddk; MODE 2 keeps parity 1 atk % 4 == 0and parity 2 atk % 4 == 2. Punctured LLRs are 0. - Channel. Symbol index:
3k,3k+1,3k+2for systematic/parity1/parity2 of stepk,3K + 2q (+1)and3K + 6 + 2q (+1)for the tails.y = (bit ? -AMP : AMP) + noise(four 16-bit fields ofmix64(fs ^ ... ^ C * (idx+1))minus 131070), LLRclamp(floor(y / 2048), -63, 63)(positive means bit 0). - Decoding. Up to
IMAXiterations of two half-iterations. A half-iteration is a log-MAP pass overK + 3trellis steps with branch metric-(u ? sys + apr : 0) - (parity ? par : 0)(tail steps: tail LLRs, no a-priori),max*(a,b) = max(a,b) + max(0, 18 - |a-b|) / 3(integer division), forward metrics starting in state 0 (others-2^24), backward metrics ending in state 0, both normalised after every step by subtracting the metric of state 0. The a-posteriori LLR of stepkisM0 - M1, eachMfolded over the 8 states asmax*(max*(max*(m0,m1), max*(m2,m3)), max*(max*(m4,m5), max*(m6,m7)))(the fold order matters). Extrinsicclamp(floor((11 (LLR - sys - apr) + 8) / 16), -127, 127). Decoder 1 uses the natural order and the deinterleaved extrinsic of decoder 2 as a-priori; decoder 2 usessys[pi[k]],ext1[pi[k]]and its own parities. After every iteration the hard decisionsLLR2 < 0(deinterleaved) are CRC-checked; the frame stops at the first passing iteration. - Statistics. Data-bit errors, frame errors, undetected errors (CRC passed but data
wrong), executed iterations, a histogram of the stopping iteration (1..IMAX, then "CRC
never passed"), and the checksum
sum of mix64((fr << 13) ^ i ^ pseed)over decided data bits equal to 1 (mod 2^64).
Input format
P SEED
K MODE AMP F IMAX (P lines)
24 <= K <= 6144, K % 8 == 0, MODE in {0, 1, 2}, 0 <= AMP <= 10^6, 0 <= F,
1 <= IMAX <= 16, SEED unsigned 64-bit.
Output format
One line per point:
pt p K K mode MODE amp AMP frames F imax IMAX biterr BE frameerr FE undetected UE iters IT hist h1 .. h(IMAX+1) check XXXXXXXXXXXXXXXX
then total biterr SUM frameerr SUM iters SUM check XXXXXXXXXXXXXXXX (sums mod 2^64). The
output must match exactly.
Hidden inputs
Correctness inputs (10 files, 1 to 4 points each) include K = 24, 32, 40, K = 6144,
AMP = 0 (pure noise), AMP = 10^6, F = 0, IMAX = 1 and 16, seeds 0 and 2^64-1, and
random points with 24 <= K <= 2048, all modes and amplitudes near the waterfall
(AMP = {33000, 43000, 56000}[MODE] + [-1500, 3000]). The timing input has 6 points (each
mode twice), K uniform over multiples of 8 in [2048, 6144], IMAX = 8,
AMP = {33000, 43000, 56000}[MODE] + [-800, 2500] (frame error rates from about 70 % down to
0, 3-7 iterations on average) and about 6 000-15 000 frames per point (about 50 000 frames).
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. - This sandbox has no GPU.
nvccworks here for compiling. To run on the GPU, use/app/bin/gpu_run [--repeat N] [--quiet] SOURCE.cu INPUT_FILE...: it compiles the file with the flags above on a remote H100 worker, runs it on each input, and prints stdout, exit code and wall-clock time. Grading also runs your code on an H100 worker, one job per GPU at a time. 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 be identical to the CPU program's output (trailing whitespace ignored). Any mismatch, crash or timeout gives reward 0.
- Speed: The timing input has 6 operating points (each puncturing mode twice), K between 2048 and 6144, at most 8 iterations, waterfall-region amplitudes (FER from ~70% to 0, 3-7 iterations on average) and about 50,000 frames in total. 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.