Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/compat/cuda/README.md # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / compat / cuda / README.md` 142 lines · 8756 bytes Raw Blame History Rendered 1 # C0 frozen CUDA compatibility profile (CUDApp#184) 2 3 Status: IMPLEMENTED and host-EXERCISED (static admission only). Device execution is NOT_RUN. This directory 4 pins one CUDA Driver API application, its PTX module, and the exact surface either may use. Later gates 5 (Bridge#42 C1 ABI, CUDApp#185 C2 translate, CUDApp#186 runner) check against these files and do not 6 redefine them. 7 8 | File | Role | 9 |---|---| 10 | `fixture/vadd_drv.c` | Driver API application written for this gate: one context, one PTX module, three buffers, one launch, host-side verification. | 11 | `fixture/vadd_u32.ptx` | The module it loads, written by hand from the PTX ISA (class A, PROVENANCE.md section 2). | 12 | `build.sh OUT` | Rebuilds the aarch64 and x86_64 executables. A link-only stub `libcuda.so.1` (each cu* symbol defined as 0, no code) satisfies the link; it is never a runtime library. | 13 | `profile-c0-aarch64-v1.tsv`, `profile-c0-x86_64-v1.tsv` | Original frozen identities, retained byte-identical. | 14 | `profile-c0-aarch64-v2.tsv`, `profile-c0-x86_64-v2.tsv` | Historical standalone-oracle identities, retained byte-identical. | 15 | `profile-c0-aarch64-v3.tsv`, `profile-c0-x86_64-v3.tsv` | Active standalone-oracle identities regenerated under merged bridge #77 (``29d9cff7``). | 16 | `c0_check.om` | Seeded Omega admission checker, composed after `om/cache/digest.om` (SHA-256). | 17 | `test.sh [WORKDIR]` | Rebuilds twice (hashes must match), proves the v1/v2/v3 CUDA import sets identical, admits both v3 profiles, then requires 14 negative controls to refuse. `make test-cuda-c0-profile`. | 18 19 The v2 identity change moves the fixture's reference inputs, vector-add reference, 20 grid size, checksum and failure aggregation to `om/standalone-oracles/oracles.om`. 21 The host executable hashes change; the PTX and the CUDA import sets do not. The 22 generated seeded bridge adds libc trap-handling imports, recorded in v2. 23 The old v1/v2 profiles are not revised or used to admit the changed executables. 24 `build.sh` only builds artifacts. Neither it nor `test.sh` executes the CUDA fixture 25 on a GPU; the lane's separate host transport exercise is not device qualification. 26 27 ## Checker 28 29 ``` 30 c0_check check PROFILE EXE PTX RUNISA # RUNISA: aarch64 | x86_64 | static 31 c0_check emit PROFILE EXE PTX # print the records read from the artifacts (authoring aid, never admission) 32 ``` 33 34 Exit 0 prints `CUDA-C0-PROFILE PASS records=N imports=I ptxops=P`. Exit 1 prints one 35 `CUDA-C0-PROFILE REFUSED [kind] ` line for each refusal. Exit 2 means a usage error and 36 exit 3 an unreadable or oversized input (profile and PTX at most 64 KiB, executable at most 1 MiB). The 37 checker reads the three files and writes only to stdout. It never runs the artifact. 38 39 Admission requires all of the following: 40 41 - The profile is canonical. Lines end in LF, fields are separated by TAB, there are at most 8 non-empty 42 printable-ASCII fields, the record kind is known, its arity is exact, and the first record is 43 `schema AIEN_CUDA_COMPAT_PROFILE 1`. `schema`, `profile`, `host` and `ptx` each appear once, and there 44 are exactly two `artifact` rows. Duplicate keys refuse. 45 - The SHA-256 of the executable and of the PTX equal the `artifact` rows. 46 - The ELF64 little-endian header is valid, and `e_machine` equals the `host` ISA (AArch64 183, 47 x86-64 62). `RUNISA` must equal the host ISA unless it is `static`. An ARM64 profile is therefore never 48 admitted on an x86-64 runner, and the reverse. 49 - Each of the following must equal its profile rows exactly, in both directions, so that a missing or 50 extra item refuses: 51 - DT_NEEDED; 52 - undefined `.dynsym` symbols, with a weak binding if and only if the status is `weak`; 53 - GNU verneed (version, file) pairs; 54 - the PTX entry and its parameter count; 55 - PTX directives, opcodes and special registers. 56 - A `cuda` import must be `supported`. Any import marked `unsupported` refuses. 57 - No import starts with a `lookup absent` prefix (`dlopen`, `dlmopen`, `dlsym`, `dlvsym`, 58 `cuGetProcAddress`, `cuGetExportTable`). Every entry point the executable can reach is therefore in the 59 static import list. Runtime-discovered calls are statically excluded; a runtime trace is the C3 arm 60 below. 61 - The `host` libc floor equals the highest `GLIBC_` version the executable requires. 62 - The PTX `.version`, `.target` and `.address_size` match the `ptx` row, and each appears once. 63 - Every PTX instruction line holds exactly one `;`. No opcode root matches a `deny` row. 64 65 ## Profile record kinds 66 67 `schema`, `profile C0`, `host ELF64 `, 68 `toolchain `, `artifact `, 69 `needed `, `verneed `, 70 `import `, `lookup absent `, 71 `ptx
`, `entry `, `regprefix

`, 72 `ptxdir|ptxop|sreg supported`, `deny `, 73 `feature `, `numeric `, `launch `, 74 `expect `, `runner `. 75 76 The C0 surface consists of these Driver API calls: cuInit, cuDeviceGet, cuCtxCreate (`_v4`), 77 cuModuleLoadData, cuModuleGetFunction, cuMemAlloc (`_v2`), cuMemcpyHtoD/DtoH (`_v2`), cuLaunchKernel, 78 cuCtxSynchronize, cuMemFree (`_v2`), cuModuleUnload and cuCtxDestroy (`_v2`). The PTX side is integer 79 global-memory arithmetic only. 80 81 The following are unsupported in C0, and each is either refused or absent: 82 83 - the runtime API; 84 - cubin and fatbin loading; 85 - streams and events; 86 - shared memory; 87 - warp collectives, barriers, atomics and fences; 88 - textures and surfaces; 89 - floating point, conversions and integer division; 90 - unified memory; 91 - peer access; 92 - graphs. 93 94 `numeric` rows fix the integer semantics (wrap modulo 2^32). 95 96 ## Launch values (Wolfram) 97 98 `WolframLanguageEvaluator: With[{n=4099,blk=256}, ... a=Mod[i*`2654435761`,2^32], b=Mod[(2^32-1)-Mod[7i,2^32],2^32], c=Mod[a+b,2^32] ...]` 99 gives grid 17, 4352 threads, 253 idle tail threads, checksum `8806203976955` (fits in u64), and 4098 wrapped 100 sums. 101 102 ## Provenance 103 104 - `fixture/*` are class A, written for this gate. 105 - `cuda.h` (CUDA 13.0, `CUDA_VERSION 13000`) is read from the local install at build time and is not 106 committed. 107 - No NVIDIA binary is opened, linked or run. The stub `libcuda.so.1` is generated from my own object. 108 - The optional syntax check `ptxas -arch=sm_121 fixture/vadd_u32.ptx -o /dev/null` (ptxas V13.0.88) runs 109 class B on my own input. Nothing learned from it feeds a non-NVIDIA target, and its output is never 110 stored. 111 - The x86_64 executable is a cross-built candidate (x86_64-linux-gnu-gcc 13.3.0 on the Spark). It has been 112 checked statically and never run. 113 114 ## Runner inventory (observed 2026-10-29) 115 116 | Runner | Gate | State | Evidence | 117 |---|---|---|---| 118 | Spark host (aarch64, glibc 2.39) | C0 static | EXERCISED by `test.sh` | `evidence/CUDA-C0-PROFILE-`20261029`/` | 119 | Spark GB10 (10de:2e12 rev a1, NVRM 580.173.02 open, VBIOS 9a.0b.2d.00.00) | C3 device | BLOCKED_GPU_WINDOW | `/proc/driver/nvidia`, lspci; needs a spark-window and Drake's authorization | 120 | arm64 AMD / Intel GPU | C4 | BLOCKED_HARDWARE | none attached to the Spark | 121 | x86_64 NVIDIA / AMD / Intel host | C4 | BLOCKED_HARDWARE | no x86 GPU host in inventory | 122 | Stock NVIDIA cuda-samples (v13.4) | C3 | BLOCKED_DECISION | building them needs nvcc on NVIDIA's inputs, outside PROVENANCE class B | 123 124 ## GPU arms (NOT_RUN; each needs a spark-window and Drake's authorization) 125 126 ``` 127 # C3: run the C0 fixture on GB10 against the CUDApp replacement libcuda, with a binding trace 128 spark-window open --gb10 shared --quiet none # coordinator-approved ledger only 129 compat/cuda/build.sh /tmp/c0 && cd /tmp/c0/aarch64 130 LD_LIBRARY_PATH= LD_DEBUG=bindings ./vadd_drv ../vadd_u32.ptx 2> bindings.log 131 # expect: exit 0, stdout "VADD_U32 PASS n=4099 grid=17 block=256 checksum=`8806203976955`", 132 # every cu* binding resolved in the replacement library, and none in an NVIDIA libcuda 133 spark-window close 134 ``` 135 136 - Bridge#42 (C1): check the replacement library's SONAME and exports against the `import ... cuda` rows, 137 refuse a wrong-ISA library (`e_machine` against `host`), and propagate CUresult. Host part: ELF 138 inspection. The device part follows the C3 arm. 139 - CUDApp#185 (C2): translate `fixture/vadd_u32.ptx` with exactly the `ptxop` and `sreg` rows. Every 140 `deny` root must be refused. 141 - CUDApp#186: `build/cuda-compat-check --manifest compat/cuda/profile-c0--v3.tsv --gate C0` wraps 142 `c0_check`. The manifest is this TSV, not JSON. NOT_RUN rows stay NOT_RUN.