Capacity planning by exact multi-class Mean Value Analysis
/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
Capacity planning for a batch of B candidate multi-tier deployments. Each deployment is a
closed, multi-class, product-form queueing network with K stations and C customer classes
(N_c customers of class c circulate between think time Z_c and the stations). Everything
is generated from the seed and the deployment index b with the SplitMix64-based hashes hh
and u01 of the CPU source (build_model):
- Model generation. Station
kis a delay station (infinite server) when its hash says so ((h & 7) < dcode), otherwise a load-independent queueing station; it has a speed factor. For every class: a think timeZ_c, a routing matrixP_c(from each station 3 hashed successors, an exit probability in[0.25, 0.6)), two entry stations with weights 0.7 / 0.3, and service times per station. - Operational analysis. Visit ratios solve the traffic equations
(I - P_c^T) V_c = e_cby Gaussian elimination without pivoting (the matrix is strictly column diagonally dominant), thenD[c][k] = V_c[k] * S_c[k](times 4 for delay stations). - Exact MVA over the full population lattice
0 <= n_c <= N_c(n = 0excluded): for every class withn_c >= 1R[k][c](n) = D[c][k] * (1 + Q_k(n - e_c))(queueing) orD[c][k](delay),X_c(n) = n_c / (Z_c + sum_k R[k][c](n)), andQ_k(n) = sum_c X_c(n) R[k][c](n), withQ(0) = 0. The CPU walks the lattice in lexicographic order with a ring buffer of queue-length vectors; any order that respectsn - e_c -> ngives the same numbers. - Approximate MVA. 64 Jacobi iterations of the Bard–Schweitzer fixed point at the full
population (start
Q[c][k] = N_c / K), and the relative throughput errorAE_c = (X_c^AMVA - X_c(N)) / X_c(N). - Report per deployment: the exact throughputs
X_c(N), response timesR_c = N_c / X_c(N) - Z_c, the peak queueing-station utilisationU = max_k sum_c X_c(N) D[c][k], the total queueQ = sum_k Q_k(N), and two lattice-wide integralsS1 = sum_n sum_c X_c(n)andS2 = sum_n sum_k (k mod 7 + 1) Q_k(n). Classes withN_c = 0report 0 forX,RandAE.
All arithmetic is IEEE double precision.
Input format
B SEED
K_1 C_1 dcode_1 N_1,1 ... N_1,C_1
...
K_B C_B dcode_B N_B,1 ... N_B,C_B
1 <= K <= 512, 1 <= C <= 4, 0 <= dcode <= 8 (8 makes every station a delay station),
0 <= N_c <= 3000, the lattice size prod_c (N_c + 1) is at most 2*10^6, and
K * prod_{c >= 1} (N_c + 1) is at most 2^24. SEED is an unsigned 64-bit integer.
Output format
One line per deployment:
net b K <K> C <C> N <N_1..N_C> X <X_1..X_C> R <R_1..R_C> U <U> Q <Q> S1 <S1> S2 <S2> AE <AE_1..AE_C>
then total S1 <sum S1> S2 <sum S2> X <sum of all X_c>. Reals are printed with %.12e and
compared with a relative tolerance of 1e-8 (absolute 1e-10), so any summation order is
fine, but reduced precision (FP32) is not.
Hidden inputs
Correctness inputs (9 files, 2 to 7 deployments each) include N = 0 for some or all
classes, single-customer and single-station networks, all-delay networks (dcode = 8), a
single class with 2000 customers, K = 511 and K = 512, and random deployments with
lattices of up to 30000 points. The timing input has about 150 deployments with
K uniform in [192, 320] and dcode = 1; 75 % have 4 classes with N_c uniform in
[24, 32], the rest 3 classes with N_c uniform in [70, 95].
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 have the same tokens as the CPU program's output. Numeric tokens may differ by at most
atol + rtol*|expected|with rtol = 1e-08 and atol = 1e-10; every other token must be identical. 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 150 deployments with 192-320 stations each; most have 4 classes with 24-32 customers per class (lattices of 0.4-1.2 million population vectors), the rest 3 classes with 70-95 customers per class. 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.