Flow-line scheduling by NEH insertion with an idle-cost penalty
/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
Production scheduling for a batch of Q permutation flow lines. Line t has n jobs that
visit m machines in the same order; a schedule is a job permutation, every machine
processes the jobs in that order without preemption as early as possible. Data come from the
SplitMix64-based hash hh of the CPU source (solve):
- Data. Per machine a speed class
mult_kin 1..3 and an idle-cost weightv_kin 0..3; jobs belong to one ofF(1..5) families;p[j][k] = clamp(prof[fam][k] * mult_k / 2 + noise, 1, 255). - NEH order. Jobs sorted by
sum_k p[j][k] + max_k p[j][k]descending, ties by smaller id. - NEH construction. Jobs are inserted one by one (in that order) into the partial
sequence. For every position
ithe inserted job's completion timesf, the makespanM(i)of the extended sequence (Taillard: headseof the jobs beforei, tailsqof the jobs fromion,M(i) = max_k f[k] + q[i][k]) and the idle penaltypen(i) = sum_k v_k * (start_k - e[i-1][k])(idle time machinekwaits for the inserted job) are evaluated; the job goes to the position with the smallest8*M(i) + pen(i)(ties: smallest position). - Reinsertion passes (
Rof them). For every job in NEH order: remove it, evaluate allnpositions of the remaining sequence, pick the lexicographically smallest(M(i), pen(i), i); the move is made only if it strictly lowers the makespan, otherwise the job goes back to its old position. - Report per line: the makespan after NEH, the final makespan, the lower bound
max(max_j sum_k p[j][k], max_k (min_j head_k(j) + sum_j p[j][k] + min_j tail_k(j))), total flow time (sum of completion times on the last machine), the weighted machine idle timesum_k v_k * (C_last,k - S_first,k - sum_j p[j][k])and the sequence hashsum_i mix64((i << 32) ^ seq[i] ^ base)(mod2^64).
Input format
Q R SEED
n_1 m_1
...
n_Q m_Q
1 <= Q <= 2000, 0 <= R <= 3, 1 <= n <= 1500, 1 <= m <= 64; SEED is an unsigned
64-bit integer.
Output format
For every line t with t % max(1, Q/50) == 0:
inst t n <n> m <m> neh <C_neh> cmax <C> lb <LB> flow <F> widle <W> hash <H>
then total Q <Q> R <R> neh <sum> cmax <sum> lb <sum> flow <sum> widle <sum> hash <sum_t H_t*(2t+1)>
(sums over all lines). All values are integers and must match exactly.
Hidden inputs
Correctness inputs (10 files) include n = 1, m = 1, m = 64, R = 0 and R = 3,
lines with 1500 jobs on 1 and 2 machines, seeds 0 and 2^64-1, and random lines with
n <= 300. The timing input has about 2400 lines with n uniform in [400, 800], m uniform in
[20, 50] and R = 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.
This sandbox is for source generation only. Write /app/gpu/main.cu; compilation,
execution and verification are performed later in a separate verifier environment.
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.
- 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: Sixteen flow-shop instances with 150 to 250 jobs, 10 to 30 machines, and two reinsertion passes. 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 public input examples for understanding the input format.