interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / tests / runtime / cm_route_mutants.py

37 lines · 1921 bytes Raw Blame History
1#!/usr/bin/env python3
2"""Compile each source mutant with the pinned seeded bridge; never edit generated C."""
3import os
4from pathlib import Path
5import subprocess
6import tempfile
7root = Path(__file__).resolve().parents[2]
8source = (root / 'om/components/cm_route.om').read_text()
9mutants = (
10 ('block-divisor', 'put data 1 div nbytes 64', 'put data 1 div nbytes 63'),
11 ('tail-divisor', 'put data 2 rem nbytes 64', 'put data 2 rem nbytes 63'),
12 ('tail-offset', 'put data 3 mul div nbytes 64 64', 'put data 3 mul div nbytes 64 63'),
13 ('layout-count', 'for i ulong 6', 'for i ulong 5'),
14 ('layout-add', 'total = add total get data i', 'total = sub total get data i'),
15 ('dispatch', 'if eq mode 0', 'if eq mode 2'),
16)
17with tempfile.TemporaryDirectory(prefix='cm-route-mutants-') as temp:
18 temp = Path(temp)
19 for name, old, new in mutants:
20 if source.count(old) != 1:
21 raise SystemExit('FAIL ambiguous mutation site: ' + name)
22 om = temp / (name + '.om')
23 c = temp / (name + '.c')
24 exe = temp / name
25 om.write_text(source.replace(old, new))
26 with c.open('w') as output:
27 env = dict(os.environ, OMEGA_SEEDED_OMC=os.environ['OMEGA_OMC'])
28 subprocess.run(['sh', os.environ['OMEGA_BRIDGE'] + '/tools/bridge-seeded',
29 'c', str(om)], stdout=output, env=env, check=True)
30 subprocess.run(['cc','-std=c11','-O2','-ffp-contract=off','-I'+str(root/'src'),
31 '-DCM_ROUTE_IMPL="'+str(c)+'"', str(root/'tests/runtime/cm_route_unit.c'),
32 '-o',str(exe)],check=True)
33 p=subprocess.run([str(exe)],capture_output=True,text=True)
34 if p.returncode == 0 or 'FAIL cm route' not in p.stderr:
35 raise SystemExit('FAIL survived or invalid mutant: ' + name + ': ' + p.stderr)
36 print('KILLED ' + name)
37print('PASS cm route mutants (6 killed)')