omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / gpu / qual / qual_test.om
| 1 | om2 |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | note gpu/qual/qual_test.om: pure-Omega host test for non-NVIDIA GPU & x86 qualification classification. |
| 4 | note Verifies synthetic PCI vendor/class/node classification: |
| 5 | note 1. AMD MI300X (0x1002:0x74a1, class 0x038000, /dev/kfd present) -> READY |
| 6 | note 2. Intel Xe3 Panther Lake (0x8086:0xb080, class 0x030000, /dev/dri/renderD128 present) -> READY |
| 7 | note 3. NVIDIA-only GB10 (0x10de:0x2e12, class 0x030000, no AMD/Intel) -> BLOCKED_HARDWARE |
| 8 | note 4. Non-display PCI device (0x8086, class 0x060000 host bridge) -> ignored (BLOCKED_HARDWARE) |
| 9 | note 5. Emulated x86-64 on AArch64 kernel -> EMULATED (BLOCKED_HARDWARE), physical x86_64 -> PHYSICAL |
| 10 | |
| 11 | text qt_pass "PASS gpu/qual classification and negative controls (hardware=NOT_RUN)\n" |
| 12 | text qt_fail "FAIL gpu/qual\n" |
| 13 | |
| 14 | fn qt_non_nvidia_verdict pci_cls ulong ven ulong has_kfd bool has_dri bool to ulong |
| 15 | note Returns 0 READY, 3 BLOCKED_HARDWARE |
| 16 | basecls = shr pci_cls 16 |
| 17 | if ne basecls 3 |
| 18 | ret 3 |
| 19 | end |
| 20 | if and eq ven 4098 has_kfd |
| 21 | ret 0 |
| 22 | end |
| 23 | if and eq ven 32902 has_dri |
| 24 | ret 0 |
| 25 | end |
| 26 | ret 3 |
| 27 | end |
| 28 | |
| 29 | fn qt_x86_exec_class kernel_is_x86 bool has_qemu_map bool has_x86_vendor bool to ulong |
| 30 | note Returns 0 PHYSICAL_X86_64, 3 EMULATED/BLOCKED_HARDWARE |
| 31 | if not kernel_is_x86 |
| 32 | ret 3 |
| 33 | end |
| 34 | if has_qemu_map |
| 35 | ret 3 |
| 36 | end |
| 37 | if not has_x86_vendor |
| 38 | ret 3 |
| 39 | end |
| 40 | ret 0 |
| 41 | end |
| 42 | |
| 43 | fn main to int |
| 44 | note 1. AMD MI300X (class 0x038000 = 229376, vendor 0x1002 = 4098, /dev/kfd present) -> 0 |
| 45 | if ne qt_non_nvidia_verdict 229376 4098 true false 0 |
| 46 | r = write 2 qt_fail 0 len qt_fail |
| 47 | ret 1 |
| 48 | end |
| 49 | note 2. AMD MI300X without /dev/kfd -> 3 (BLOCKED_HARDWARE) |
| 50 | if ne qt_non_nvidia_verdict 229376 4098 false false 3 |
| 51 | r = write 2 qt_fail 0 len qt_fail |
| 52 | ret 2 |
| 53 | end |
| 54 | note 3. Intel Xe3 Panther Lake (class 0x030000 = 196608, vendor 0x8086 = 32902, renderD128 present) -> 0 |
| 55 | if ne qt_non_nvidia_verdict 196608 32902 false true 0 |
| 56 | r = write 2 qt_fail 0 len qt_fail |
| 57 | ret 3 |
| 58 | end |
| 59 | note 4. NVIDIA GB10 (class 0x030000, vendor 0x10de = 4318) -> 3 (must NEVER pass non-NVIDIA qual!) |
| 60 | if ne qt_non_nvidia_verdict 196608 4318 true true 3 |
| 61 | r = write 2 qt_fail 0 len qt_fail |
| 62 | ret 4 |
| 63 | end |
| 64 | note 5. Intel host bridge (class 0x060000 = 393216, vendor 0x8086) -> 3 (not a display/GPU class) |
| 65 | if ne qt_non_nvidia_verdict 393216 32902 false true 3 |
| 66 | r = write 2 qt_fail 0 len qt_fail |
| 67 | ret 5 |
| 68 | end |
| 69 | note 6. x86 physical vs emulated classification |
| 70 | if ne qt_x86_exec_class true false true 0 |
| 71 | r = write 2 qt_fail 0 len qt_fail |
| 72 | ret 6 |
| 73 | end |
| 74 | if ne qt_x86_exec_class false false false 3 |
| 75 | r = write 2 qt_fail 0 len qt_fail |
| 76 | ret 7 |
| 77 | end |
| 78 | if ne qt_x86_exec_class true true true 3 |
| 79 | r = write 2 qt_fail 0 len qt_fail |
| 80 | ret 8 |
| 81 | end |
| 82 | |
| 83 | r = write 1 qt_pass 0 len qt_pass |
| 84 | ret 0 |
| 85 | end |