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
CUDApp / tests / model_graphs_lists.py
| 1 | #!/usr/bin/env python3 |
| 2 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | """Build both actual graph TUs; compare actual list banks/QMDs on a fake platform. |
| 4 | Run only in the device-free namespace documented in om/graph/CHIP.md. |
| 5 | """ |
| 6 | import os |
| 7 | from pathlib import Path |
| 8 | import shlex |
| 9 | import subprocess |
| 10 | ROOT=Path(__file__).resolve().parents[1] |
| 11 | os.chdir(ROOT) |
| 12 | OUT=ROOT/'build/model-graphs-lists' |
| 13 | OUT.mkdir(parents=True,exist_ok=True) |
| 14 | CC=shlex.split(os.environ.get('CC','cc')) |
| 15 | flags=['-std=gnu11','-D_GNU_SOURCE','-O2','-Wall','-Wextra','-Werror','-Wno-unused-function','-ffunction-sections','-fdata-sections','-Isrc','-Itests','-Im16','-Invrm'] |
| 16 | def run(cmd): |
| 17 | print('+',shlex.join(map(str,cmd)),flush=True) |
| 18 | subprocess.run(list(map(str,cmd)),check=True) |
| 19 | objects=[] |
| 20 | for family in ['q36','q38','decode']: |
| 21 | for mode in ['old','new']: |
| 22 | obj=OUT/f'{family}-{mode}.o' |
| 23 | run(CC+flags+(['-DCUDAPP_MIGRATION_PENDING_C_GRAPHS=1'] if mode=='old' else [])+['-c',f'tests/model_graphs_{family}_fixture.c','-o',obj]) |
| 24 | symbols=subprocess.check_output(['nm','--defined-only','--extern-only',str(obj)],text=True) |
| 25 | args=[] |
| 26 | for line in symbols.splitlines(): |
| 27 | name=line.split()[-1] |
| 28 | args+=['--redefine-sym',f'{name}={mode}_{name}'] |
| 29 | run(['objcopy',*args,obj]) |
| 30 | objects.append(obj) |
| 31 | wrappers=(ROOT/'tests/model_graphs_wraps.txt').read_text().splitlines() |
| 32 | binary=OUT/'check' |
| 33 | run(CC+flags+['tests/test_model_graphs_lists.c',*objects,'build/libomega_gpu.a','-Wl,--gc-sections',*[f'-Wl,--wrap={s}' for s in wrappers],'-lpthread','-lm','-o',binary]) |
| 34 | run([binary]) |