BGP path-vector convergence and link-failure impact study
/app/cpu/main.cpp is the source of a multicore CPU program (C++17, OpenMP).
The program takes one input-file path (PROGRAM INPUT_FILE) and writes its result to stdout.
What the program computes
An inter-domain routing study: route propagation under a BGP-like path-vector protocol on a generated AS topology, run once on the intact network and once after a set of link failures.
- Topology.
Nautonomous systems (ids0..N-1). The firstT1form a full peer mesh. Every later ASibuys transit from 1-3 providersj < ipicked with a preferential bias toward low ids, and with probability 1/4 adds 1-2 lateral peer links to ASes in[max(T1, i-64), i). Each link gets per-direction policy hashes (link preference, prepending, MED).Flink ids are drawn by hash and marked failed (duplicates collapse; the effective count is printed). - Base epoch. For each prefix
p(origin AS and an 8-bit origin community tag come from hashes ofp), synchronous rounds are run: in roundtevery AS recomputes its best route from its neighbours' roundt-1routes. A neighbourvadvertises its route toronly if it is valley-free (learned from a customer or originated, orrisv's customer) and the route's no-export community (tag & 0xE0 == 0xE0) does not forbid it. Advertisements to providers may be prepended 1 or 2 extra times.rrejects routes containing its own AS (loop detection) or longer than 20 hops. Candidates are ranked lexicographically by local preference (relationship base 300/200/100 + link preference 0..31, minus 24 when the transformed tag's low nibble matchesr's low nibble), then AS-path length, then MED, then neighbour id. Iteration stops at the first round in which no AS changes (route, tag and AS path) or after 64 rounds. - Failure epoch. Starting from the converged base state, every route whose next hop crosses a failed link is withdrawn, failed links are removed and rounds are run again to convergence.
- Analytics. Per epoch: convergence-round histogram, reachability, learned-from class counts, AS-path length histogram, the 10 ASes that appear most often as transit in best paths (each AS counted once per path, the origin excluded), and an order-independent digest of all RIB entries; then how many (prefix, AS) entries changed / lost / gained reachability, and 8 sample prefixes.
The CPU source is the exact specification of every hash, rule and tie-break.
Input format
One line: N T1 P F seed — number of ASes, tier-1 mesh size, number of prefixes, number of link
failures drawn, 64-bit seed. 1 <= T1 <= min(N, 32), N <= 20000, P >= 0, 0 <= F <= 64.
Output format
A topology line, then for base and fail the lines converged/nonconverged/round_sum,
rounds r:count ..., reach ... cust peer prov, len l:count ..., transit_top as:count ...,
digest=<16 hex>; then [diff] changed lost gained and up to 8 sample lines. Exact match.
Hidden inputs
Correctness inputs (12 files) include N = 1, N = 2 with its only link failing, a pure 16-AS
tier-1 mesh, P = 0, F = 0, seeds 0 and 2^64-1, N up to 3000 and random cases with
20 <= N <= 1200, 1 <= P <= 300. The timing input has N uniform in [5000, 6000],
T1 in [10, 16], P = 30000 prefixes and F in [16, 48].
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.
This sandbox is for writing the source only: it has g++ and the CPU program, but no CUDA
compiler and no GPU. Compilation, execution and verification happen later on an H100 in a
separate verifier, and a port that does not compile is rejected, so check your logic against
the CPU program before you finish (for example by emulating your kernels on the host).
How your port is verified
- 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. - Verification runs on one H100 in a fresh container without network. Hidden inputs are generated with a fresh random seed at verification time.
- Correctness: every hidden input (small edge cases plus a large timing input) must pass. Your output must be identical to the CPU program's output (trailing whitespace ignored). Any mismatch, crash or timeout is rejected.
- GPU execution is checked: a port that computes its answer on the CPU is rejected even when its output is correct.
- Speed: The timing input has 5000-6000 ASes (about 12-15k links), 30000 prefixes and 16-48 failed links; every prefix converges in about 10-25 base rounds plus a shorter failure re-convergence.
/app/inputs/timing_example.inhas the shape and size of the hidden timing input. Your port is timed against a reference GPU port on it; the faster your port, the higher its score. /app/inputs/holds public input examples for understanding the input format.