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 / src / omega_sm121_disasm.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | /* omega_sm121_disasm.h -- Omega's own sm_121 (GB10) disassembler (C6 of docs/OMEGA.md). |
| 3 | * |
| 4 | * Turns one 128-bit instruction word into the text nvdisasm prints for it, so no NVIDIA tool is needed to read |
| 5 | * machine code back. It knows the instruction forms Omega's own builders emit (src/omega_blackwell_codegen*.c, |
| 6 | * src/omega_osc_gpu.c), each as an exact template: the fixed bits must match exactly and only the operand fields |
| 7 | * vary. A word that matches no template is printed as "?? <hex>" and reported, never guessed, so a comparison |
| 8 | * with nvdisasm fails on any form this file does not know. The control bits (stall, barriers, yield, reuse: |
| 9 | * bits 105..127) are not part of the text, as in nvdisasm's default listing. |
| 10 | * |
| 11 | * The decoder is the seeded Omega unit om/disasm/sm121_dis.om (generated src/cudapp_om_sm121_dis.c, om/units.sh). |
| 12 | * The C decoder it replaces stays in src/omega_sm121_disasm.c as the differential oracle: make CUDAPP_DISASM=om |
| 13 | * (the default) calls the Omega unit, CUDAPP_DISASM=c the C (CUDAPP_MIGRATION_PENDING_C_DISASM), CUDAPP_DISASM=diff |
| 14 | * both, failing on any difference; make test-om-disasm checks that they agree. |
| 15 | * |
| 16 | * tools/sm121dis/sm121dis.c is the command line (a listing in nvdisasm's layout); tools/sm121dis/check.sh compares |
| 17 | * it with nvdisasm, the oracle, on every kernel the library builds (captured with OMEGA_KERNEL_DUMP_DIR). */ |
| 18 | #ifndef OMEGA_SM121_DISASM_H |
| 19 | #define OMEGA_SM121_DISASM_H |
| 20 | |
| 21 | #include <stddef.h> |
| 22 | #include <stdint.h> |
| 23 | #include <stdio.h> |
| 24 | |
| 25 | /* Writes the text of the instruction (lo = bits 0..63, hi = bits 64..127) at byte address pc into out, without the |
| 26 | * trailing " ;". Returns 0 when the word matched a known form, -1 when it did not (out then holds "?? 0x<hi><lo>"), |
| 27 | * -2 for a NULL or too small buffer. */ |
| 28 | int omega_sm121_disasm(uint64_t lo, uint64_t hi, uint64_t pc, char *out, size_t outn); |
| 29 | |
| 30 | /* Writes a listing of a whole kernel (len bytes, a whole number of 16-byte words) to out in nvdisasm's layout |
| 31 | * (one line per word: the address in a comment, then TEXT ;), the form the listing checks in tests/ read. Returns |
| 32 | * the number of words that matched no known form (printed "?? ..."), or -1 for a bad argument or a length that is |
| 33 | * not whole words. */ |
| 34 | int omega_sm121_listing(const uint8_t *code, size_t len, FILE *out); |
| 35 | |
| 36 | /* The byte offset where a kernel's padding starts: just after its last EXIT (0 when it has none). nvdisasm prints the |
| 37 | * words from there on (the branch to itself and the NOPs) as "TEXT;" with no space before the semicolon, and every |
| 38 | * word before as "TEXT ;" (so on every library kernel tools/sm121dis/check.sh compares). */ |
| 39 | size_t omega_sm121_padding_start(const uint8_t *code, size_t len); |
| 40 | |
| 41 | #endif /* OMEGA_SM121_DISASM_H */ |