Flow-line scheduling by NEH insertion with an idle-cost penalty
/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
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 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. - This sandbox has no GPU.
nvccworks here for compiling. To run on the GPU, use/app/bin/gpu_run [--repeat N] [--quiet] SOURCE.cu INPUT_FILE...: it compiles the file with the flags above on a remote H100 worker, runs it on each input, and prints stdout, exit code and wall-clock time. Grading also runs your code on an H100 worker, one job per GPU at a time. 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: 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 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.