-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (65 loc) · 2.54 KB
/
Copy pathci.yml
File metadata and controls
79 lines (65 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: MPI build and TSPLIB validation
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
jobs:
build-and-validate:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install OpenMPI
run: |
sudo apt-get update
sudo apt-get install -y openmpi-bin libopenmpi-dev
- name: Build production solver
run: make
- name: Verify the official Berlin52 optimal-tour weight
run: |
output=$(mpirun --oversubscribe -np 1 ./tsp_solver \
data/berlin52.tsp \
--evaluate-tour data/berlin52.opt.tour)
printf '%s\n' "$output"
test "$output" = "Tour weight (TSPLIB EUC_2D): 7542"
- name: Build reduced smoke-test binary
run: |
python3 - <<'PY'
from pathlib import Path
source = Path('script/tsp_mpi.c').read_text(encoding='utf-8')
production = '#define TOTAL_SWAP_ATTEMPTS 5000'
smoke = '#define TOTAL_SWAP_ATTEMPTS 5'
if production not in source:
raise SystemExit('Could not locate the production swap-attempt setting.')
Path('/tmp/tsp_mpi_smoke.c').write_text(
source.replace(production, smoke, 1),
encoding='utf-8',
)
PY
mpicc -O2 -std=c99 -Wall -Wextra /tmp/tsp_mpi_smoke.c -o /tmp/tsp_solver_smoke -lm
- name: Run deterministic two-rank MPI smoke case
run: |
timeout 60s mpirun --oversubscribe -np 2 \
/tmp/tsp_solver_smoke data/berlin52.tsp --seed 20260720
- name: Verify MPI outputs
run: |
test -x tsp_solver
test -s solution.txt
test -s my_route.txt
python3 - <<'PY'
from math import isfinite
from pathlib import Path
text = Path('solution.txt').read_text(encoding='utf-8').strip()
distance = float(text)
if not isfinite(distance) or distance <= 0.0 or not distance.is_integer():
raise SystemExit(f'Invalid TSPLIB route length: {text}')
route = [int(value) for value in Path('my_route.txt').read_text(encoding='utf-8').split()]
expected = list(range(52))
if len(route) != 52 or sorted(route) != expected:
raise SystemExit('The MPI result is not a valid permutation of the 52 cities.')
print(f'Verified deterministic two-rank MPI output with route length {distance:.0f}.')
PY