Polar-code link simulation with dynamic frozen bits and SC decoding
/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 polar code, the kind of job run for every point of a
frame-error-rate curve. For each operating point (n, K, DYN, AMP, F) (block length
N = 2^n) the program does the following (mix64 is the SplitMix64 finaliser in the CPU
source, all arithmetic is integer):
- Code construction.
pseed = mix64(SEED ^ 0x5851F42D4C957F2D * (p+1))for pointp(0-based). WeightsW0 = 4096,W(j+1) = W(j) + floor(49 W(j) / 256). Indexigets the score64 * sum{W(j) : bit j of i set} + (mix64(pseed ^ C * (i+1)) & 63). Indices sorted by (score, index) ascending: the lastKare information positions, theDYNbefore them are dynamic frozen positions, all others are static frozen (value 0). A dynamic frozen positionihas three dependencies, each an information position< ipicked byinfo[mix64(...) % m](m= number of information positions belowi; none ifm = 0, then it behaves like a static frozen bit); its value is the XOR of the bits at the three dependencies (a repeated dependency cancels). - Per frame
fr(0..F-1). Frame seedfs = mix64(pseed ^ 0x9E3779B97F4A7C15 * (fr+1)). Information bitiis the top bit ofmix64(fs ^ C * (i+1)); dynamic frozen bits follow from their dependencies. Encoding is the natural-order polar transformx = u F^{(x)n}(for len = 1, 2, .. N/2: x[j] ^= x[j+len]on the first half of every block of2 len). - Channel.
y = (x ? -AMP : AMP) + noise, wherenoiseis the sum of the four 16-bit fields ofmix64(fs ^ ... ^ C * (i+1))minus 131070 (Irwin-Hall, sd ~ 37837). The channel LLR isclamp(floor(y / 2048), -63, 63). - Successive-cancellation decoding in the usual depth-first order (left child first),
with min-sum
f(a,b) = sign(a) sign(b) min(|a|,|b|)(sign of 0 is +),g(a,b,s) = clamp(s ? b - a : b + a, -127, 127), hard decisionu = (L < 0)at information leaves, 0 at static frozen leaves and the XOR of the already decided dependency bits at dynamic frozen leaves. Partial sums are combined as(left XOR right, right). - Statistics. Information-bit errors, frame errors, a 16-bin histogram of the first wrong
information position (
bin = (first * 16) >> n, frames with errors only), and the checksumsum over frames and decided information bits equal to 1 of mix64((fr << 13) ^ i ^ pseed)(mod 2^64).
Input format
P SEED
n K DYN AMP F (P lines)
1 <= n <= 12, 0 <= K <= 2^n, 0 <= DYN <= 2^n - K, 0 <= AMP <= 10^6, 0 <= F,
SEED is an unsigned 64-bit integer.
Output format
One line per point:
pt p N N K K dyn DYN amp AMP frames F biterr BE frameerr FE firsterr h0 .. h15 check XXXXXXXXXXXXXXXX
then total biterr SUM frameerr SUM check XXXXXXXXXXXXXXXX (checksums in 16 hex digits, sums
mod 2^64). The output must match exactly.
Hidden inputs
Correctness inputs (10 files, 1 to 6 points each) include n = 1, 2, 3, K = 0, K = N,
DYN = N - K, AMP = 0 (pure noise), AMP = 10^6 (no errors), F = 0, seeds 0 and
2^64-1, n = 12 with a few hundred frames, and random points with 3 <= n <= 11 and up to
about 1.5*10^7 / (N n) frames. The timing input has 6 points with n in {10, 11, 12}, the six
rates 1/4, 1/3, 1/2, 2/3, 3/4, 5/6 (K = round(R N)), DYN <= N/16, amplitudes in the
waterfall region (AMP = 18000 + 70000 R + [-4000, 2000]) and F = round(40 / (4.4e-9 N n)) frames per point (about 185 000 for n = 12 up to
890 000 for n = 10; every point has about the same F N n).
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 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 (N = 1024, 2048 or 4096, rates 1/4 to 5/6, waterfall-region amplitudes) with 185k-890k frames each, about the same FNlog2(N) per point. 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.