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
Comparing a4ffab1d55b4019b4349e03a23b55844122a20f1 ... 67427b39697d704237b6eba879a354c59bf2be9d
- Merge branch 'staging/api-shell-mutants-20261120' of /home/drakestapleton/git/CUDApp into HEAD
- Isolate API shell mutants during parallel host checks
- Record Spark allocation and marker qualification
- Use seeded Omega for allocation alignment and marker ordering
6 files changed, +92 -23
evidence/native-marker-alignment/spark.ee14526843358d1c0c641e5d26c3b157c273e91d791df1e1204b1543afc33be7.txt
| new file mode 100644 | ||
| @@ -0,0 +1,41 @@ | ||
| 1 | +CUDApp native allocation and marker ordering | |
| 2 | + | |
| 3 | +2ec7a97ca59677722c21b9e9dfffeee0b902200a | |
| 4 | +20261120T124316Z-694d94 | |
| 5 | +name, driver_version | |
| 6 | +NVIDIA GB10, 580.173.02 | |
| 7 | +7eb0c4140ae75318ce1e5c2b1611f768fb2b87e4e5834deeded423a0cf1868a4 m16_requalify | |
| 8 | + | |
| 9 | +Build from the repository root | |
| 10 | + gcc -O2 -Wall -Wextra -Werror \ | |
| 11 | + -DCUDAPP_MIGRATION_PENDING_C_NVRM="${CUDAPP_MIGRATION_PENDING_C_NVRM:-0}" \ | |
| 12 | + -DCUDAPP_MIGRATION_PENDING_C_NVRM_ALLOC="${CUDAPP_MIGRATION_PENDING_C_NVRM_ALLOC:-0}" \ | |
| 13 | + -I./src -I./nvrm -I./m16 \ | |
| 14 | + -I./third_party/nvidia-open-580.173.02/src/common/sdk/nvidia/inc \ | |
| 15 | + -I./third_party/nvidia-open-580.173.02/kernel-open/common/inc \ | |
| 16 | + -I./third_party/nvidia-open-580.173.02/kernel-open/nvidia-uvm \ | |
| 17 | + -I./third_party/nvidia-open-580.173.02/src/nvidia/arch/nvalloc/unix/include \ | |
| 18 | + nvrm/nvrm.c m16/m16_native.c m16/m16_requalify.c \ | |
| 19 | + -I./src src/omega_ampere_qmd.c src/omega_gpu_chip.c src/cudapp_om_amp_runtime.c src/cudapp_om_amp_qmd.c src/cudapp_om_eng.c src/cudapp_om_chip_admit.c src/cudapp_om_chip_enum.c src/cudapp_om_nvrm_*.c src/cudapp_om_fixture_text.c -o m16/m16_requalify | |
| 20 | + | |
| 21 | +Hardware command (binary moved outside the checkout before execution) | |
| 22 | +spark-window run ../m16_requalify | |
| 23 | +Exit 0. Selected output follows. | |
| 24 | +[OBSERVED] Marker after 100ms without doorbell: 0x00000000 (expected 0x00000000) | |
| 25 | +NEGATIVE_CONTROL_PASS: Marker strictly remained 0x00000000 while doorbell was withheld. | |
| 26 | +[OBSERVED] Marker after doorbell rung: 0x16c0ffee (expected 0x16c0ffee) | |
| 27 | +POSITIVE_CONTROL_PASS: Marker successfully updated to 0x16c0ffee upon doorbell store. | |
| 28 | +NO_LIBCUDA_PASS: Zero libcuda / libcudart mappings present in live process. | |
| 29 | +CAUSALITY_VERIFICATION_PASS: Doorbell causality strictly confirmed. | |
| 30 | +M16_REQUALIFICATION_PASS: Milestone 16 native execution verified. | |
| 31 | + | |
| 32 | +Host command | |
| 33 | +bwrap --bind / / --dev /dev make -j2 test-om-eng-diff test-om-eng-red | |
| 34 | +Exit 0. Selected output follows. | |
| 35 | +om build: 44584 records, 110767 unit calls, all 28 ops reached | |
| 36 | +C build: 44584 records, 0 unit calls | |
| 37 | +PASS om eng diff: 44584 records identical (om vs C) | |
| 38 | +om build: 44584 records, 110770 unit calls, all 28 ops reached | |
| 39 | +C build: 44584 records, 0 unit calls | |
| 40 | +FAIL om eng diff: record 136 differs | |
| 41 | +PASS red: flipped unit answer detected |
m16/m16_native.c
| @@ -113,17 +113,27 @@ int m16_native_wait_marker(volatile uint32_t *marker, uint32_t expected, uint64_ | ||
| 113 | 113 | return m16_native_wait_marker_ge(marker, expected, timeout_ms); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | +static int marker_reached(uint32_t observed, uint32_t target) { | |
| 117 | + if (eng_on()) { | |
| 118 | + uint64_t in[2] = {observed, target}, w[16]; | |
| 119 | + if (eng_ask(ENG_OP_SEQGE, in, 2, w) != 0) return -1; | |
| 120 | + return w[0] == 1; | |
| 121 | + } | |
| 122 | + return (int32_t)(observed - target) >= 0; | |
| 123 | +} | |
| 124 | + | |
| 116 | 125 | int m16_native_wait_marker_ge(volatile uint32_t *marker, uint32_t target, uint64_t timeout_ms) { |
| 117 | 126 | if (!marker) return -1; |
| 118 | 127 | uint64_t duration, end; |
| 119 | 128 | if (__builtin_mul_overflow(timeout_ms, 1000000ull, &duration) || |
| 120 | 129 | __builtin_add_overflow(now_ns(), duration, &end)) end = UINT64_MAX; |
| 121 | 130 | while (now_ns() < end) { |
| 122 | - if ((int32_t)(*marker - target) >= 0) return 0; | |
| 131 | + int reached = marker_reached(*marker, target); | |
| 132 | + if (reached != 0) return reached == 1 ? 0 : -1; | |
| 123 | 133 | usleep(50); |
| 124 | 134 | nvrm_cpu_relax(); |
| 125 | 135 | } |
| 126 | - return ((int32_t)(*marker - target) >= 0) ? 0 : -1; | |
| 136 | + return marker_reached(*marker, target) == 1 ? 0 : -1; | |
| 127 | 137 | } |
| 128 | 138 | |
| 129 | 139 | int m16_native_close(M16NativeContext *ctx) { |
nvrm/nvrm.c
| @@ -996,7 +996,8 @@ int nvrm_vram_info(Nvrm *rm, uint64_t *free_bytes, uint64_t *total_bytes) { | ||
| 996 | 996 | static int alloc_with_cacheability(Nvrm *rm, uint64_t size, NvrmMem *out, uint32_t gpu_cacheable, int local) { |
| 997 | 997 | if (!rm || !out || !size || rm->faulted || size > SIZE_MAX - 0xfffULL) |
| 998 | 998 | return rm ? fail(rm, "invalid or overflowed allocation size") : -1; |
| 999 | - size = (size + 0xfff) & ~0xfffull; | |
| 999 | + size = nvrm_policy_palign(size, 0x1000); | |
| 1000 | + if (!size) return fail(rm, "invalid or overflowed allocation size"); | |
| 1000 | 1001 | if (rm->live_count >= NVRM_MAX_LIVE) return fail(rm, "live allocation table full (%d)", NVRM_MAX_LIVE); |
| 1001 | 1002 | uint64_t va = va_take(rm, size, 0x1000); |
| 1002 | 1003 | if (!va) return fail(rm, "GPU VA exhausted: this client's VA slot is full (the next slot belongs to another client) or the VA overflowed"); |
tests/api_shells_mutants.py
| @@ -54,25 +54,18 @@ def main() -> int: | ||
| 54 | 54 | if count != 1: |
| 55 | 55 | print(f"FAIL mutant {name}: site count {count}") |
| 56 | 56 | return 1 |
| 57 | - with open(full, "w") as fh: | |
| 58 | - fh.write(src.replace(old, new, 1)) | |
| 59 | - try: | |
| 60 | - with tempfile.TemporaryDirectory(prefix="api-shells-mutant-") as out: | |
| 61 | - env = dict(os.environ, OUT_DIR=out) | |
| 62 | - r = subprocess.run( | |
| 63 | - ["bash", script, "regen"], | |
| 64 | - cwd=ROOT, | |
| 65 | - env=env, | |
| 66 | - stdout=subprocess.PIPE, | |
| 67 | - stderr=subprocess.STDOUT, | |
| 68 | - text=True, | |
| 69 | - ) | |
| 70 | - finally: | |
| 71 | - with open(full, "w") as fh: | |
| 72 | - fh.write(src) | |
| 73 | - if r.returncode == 0: | |
| 74 | - tail = r.stdout[-400:] | |
| 75 | - print(f"FAIL mutant {name} survived\n{tail}") | |
| 57 | + with tempfile.TemporaryDirectory(prefix="api-shells-mutant-") as out: | |
| 58 | + mutant = os.path.join(out, os.path.basename(path)) | |
| 59 | + with open(mutant, "w") as fh: | |
| 60 | + fh.write(src.replace(old, new, 1)) | |
| 61 | + env = dict(os.environ, OUT_DIR=out, API_SHELLS_MUTANT=mutant) | |
| 62 | + r = subprocess.run( | |
| 63 | + ["bash", script, "regen"], cwd=ROOT, env=env, | |
| 64 | + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, | |
| 65 | + ) | |
| 66 | + if r.returncode != 1 or "FAIL api-shells checks=" not in r.stdout: | |
| 67 | + print(f"FAIL mutant {name}: expected a differential mismatch, " | |
| 68 | + f"got rc={r.returncode}\n{r.stdout[-400:]}") | |
| 76 | 69 | return 1 |
| 77 | 70 | print(f"KILLED {name} rc={r.returncode}") |
| 78 | 71 | killed += 1 |
tests/api_shells_run.sh
| @@ -10,7 +10,15 @@ mkdir -p "$OUT" | ||
| 10 | 10 | if [[ "${1:-}" == "regen" ]]; then |
| 11 | 11 | export OMEGA_OMC="${OMEGA_OMC:-$HOME/work/cudastack/omega-mv/seed/out/omc}" |
| 12 | 12 | export OMEGA_BRIDGE="${OMEGA_BRIDGE:-$HOME/work/cudastack/omega-bridge}" |
| 13 | - export OMEGA_UNITS="om/api/apish_shp.om om/api/apish_pack.om om/api/apish_slot.om om/api/apish_blk.om om/api/apish_trit.om" | |
| 13 | + units=() | |
| 14 | + for name in shp pack slot blk trit; do | |
| 15 | + source_file="om/api/apish_$name.om" | |
| 16 | + if [[ "${API_SHELLS_MUTANT:-}" == */"apish_$name.om" ]]; then | |
| 17 | + source_file="$API_SHELLS_MUTANT" | |
| 18 | + fi | |
| 19 | + units+=("$source_file") | |
| 20 | + done | |
| 21 | + export OMEGA_UNITS="${units[*]}" | |
| 14 | 22 | export OMEGA_UNITS_DEST="$OUT/gen" |
| 15 | 23 | mkdir -p "$OMEGA_UNITS_DEST" |
| 16 | 24 | bash om/units.sh |
tests/om_eng_diff_test.c
| @@ -711,6 +711,22 @@ int main(int argc, char **argv) { | ||
| 711 | 711 | if (omega_gpu_platform_linux_test_set_meminfo(g_meminfo) != 0) return 2; |
| 712 | 712 | omega_gpu_engine_set_backend(&g_be); |
| 713 | 713 | omega_gpu_engine_test_set_clock(eng_now); |
| 714 | + /* A zero timeout still samples the marker. Check the public wrapper and | |
| 715 | + * both sides of the serial half-range through the production binding. */ | |
| 716 | + static const struct { uint32_t observed, target; int expected; } markers[] = { | |
| 717 | + {7, 7, 0}, {0, UINT32_MAX, 0}, {UINT32_MAX, 0, -1}, | |
| 718 | + {0x7fffffffu, 0, 0}, {0x80000000u, 0, -1} | |
| 719 | + }; | |
| 720 | + uint64_t before = g_opn[ENG_OP_SEQGE]; | |
| 721 | + for (size_t j = 0; j < sizeof markers / sizeof markers[0]; j++) { | |
| 722 | + volatile uint32_t marker = markers[j].observed; | |
| 723 | + if (m16_native_wait_marker(&marker, markers[j].target, 0) != markers[j].expected) | |
| 724 | + return 1; | |
| 725 | + } | |
| 726 | + if (eng_on() && g_opn[ENG_OP_SEQGE] == before) { | |
| 727 | + fputs("M16 marker wait bypassed Omega serial ordering\n", stderr); | |
| 728 | + return 1; | |
| 729 | + } | |
| 714 | 730 | int i; |
| 715 | 731 | for (i = 0; i < 3000; i++) trace_engine(); |
| 716 | 732 | for (i = 0; i < 2000; i++) trace_wait(0); |