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 / model_graphs_lists.py

34 lines · 1615 bytes Raw Blame History
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.
4Run only in the device-free namespace documented in om/graph/CHIP.md.
5"""
6import os
7from pathlib import Path
8import shlex
9import subprocess
10ROOT=Path(__file__).resolve().parents[1]
11os.chdir(ROOT)
12OUT=ROOT/'build/model-graphs-lists'
13OUT.mkdir(parents=True,exist_ok=True)
14CC=shlex.split(os.environ.get('CC','cc'))
15flags=['-std=gnu11','-D_GNU_SOURCE','-O2','-Wall','-Wextra','-Werror','-Wno-unused-function','-ffunction-sections','-fdata-sections','-Isrc','-Itests','-Im16','-Invrm']
16def run(cmd):
17 print('+',shlex.join(map(str,cmd)),flush=True)
18 subprocess.run(list(map(str,cmd)),check=True)
19objects=[]
20for 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)
31wrappers=(ROOT/'tests/model_graphs_wraps.txt').read_text().splitlines()
32binary=OUT/'check'
33run(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])
34run([binary])