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 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: Sixteen flow-shop instances with 150 to 250 jobs, 10 to 30 machines, and two reinsertion passes.
/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.