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/omega-mv/blob/main/gpu/qual/non_nvidia_qual.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / gpu / qual / non_nvidia_qual.om` 259 lines ยท 5598 bytes Raw Blame History 1 om2 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note gpu/qual/non_nvidia_qual.om: pure-Omega non-NVIDIA physical GPU discovery & qualification runner. 4 note Compiles for BOTH AArch64 Linux and target x86linux (prefix 'target x86linux' before om2). 5 note Compose after seed/ng/sha256.om: 6 note { printf 'om2\n'; cat seed/ng/sha256.om gpu/qual/non_nvidia_qual.om | grep -v '^om2$'; } | seed/out/omc > non_nvidia_qual 7 note 8 note Usage: 9 note non_nvidia_qual [--root DIR] 10 note 11 note Scans PCI devices (/sys/bus/pci/devices), AMD KFD (/dev/kfd), 12 note DRM render nodes (/dev/dri/renderD128), and OpenCL/Vulkan ICD directories to verify 13 note physical non-NVIDIA GPU attachment (AMD 0x1002, Intel 0x8086, Apple/other non-0x10de). 14 note Never mislabels NVIDIA-only or CPU-only hosts as non-NVIDIA GPU qualification! 15 note 16 note Exit codes: 17 note 0 PHYSICAL_NON_NVIDIA_DETECTED (AMD KFD and/or Intel Xe / non-NVIDIA DRM render node ready) 18 note 2 usage error 19 note 3 BLOCKED_HARDWARE (no physical non-NVIDIA GPU attached on this host) 20 21 text nq_froot "--root" 22 text nq_ppci "/sys/bus/pci/devices" 23 text nq_pven "/vendor" 24 text nq_pdev "/device" 25 text nq_pcls "/class" 26 text nq_pkfd "/dev/kfd" 27 text nq_pdri "/dev/dri/renderD128" 28 text nq_pocl "/etc/OpenCL/vendors" 29 text nq_hdr "OMEGA-NON-NVIDIA-GPU-QUAL v1\n" 30 text nq_amd "GPU_AMD_PCI count=" 31 text nq_int "GPU_INTEL_PCI count=" 32 text nq_nv "GPU_NVIDIA_PCI count=" 33 text nq_kfd "DEV_KFD=" 34 text nq_dri "DEV_DRI_RENDERD128=" 35 text nq_ocl "OPENCL_ICD_DIR=" 36 text nq_yes "present\n" 37 text nq_no "absent\n" 38 text nq_ready "VERDICT=NON_NVIDIA_HARDWARE_PRESENT (run vendor hardware gate: gpu/amd or gpu/intel or gpu/spirv)\n" 39 text nq_blk "VERDICT=BLOCKED_HARDWARE reason=no_physical_non_nvidia_gpu_attached\n" 40 text nq_use "usage: non_nvidia_qual [--root DIR]\n" 41 42 global nq_root uchar 2048 43 global nq_rlen ulong 1 44 global nq_path uchar 4096 45 global nq_tmp uchar 4096 46 global nq_dents uchar 16384 47 global nq_cnt ulong 8 48 global nq_num uchar 24 49 50 fn nq_wnum v ulong to void 51 n = ulong 0 52 x = v 53 while true bound 20 54 put nq_num sub 23 n uchar add 48 rem x 10 55 n = add n 1 56 x = div x 10 57 if eq x 0 58 break 59 end 60 end 61 r = write 1 nq_num sub 24 n n 62 nl = new uchar 1 10 63 r = write 1 nl 0 1 64 end 65 66 fn nq_mkpath suffix view uchar * to ulong 67 rl = get nq_rlen 0 68 for i ulong rl bound 2048 69 put nq_path i get nq_root i 70 end 71 for i ulong len suffix bound 2048 72 put nq_path add rl i get suffix i 73 end 74 ret add rl len suffix 75 end 76 77 fn nq_readhex plen ulong to ulong 78 fd = fopen nq_path 0 plen 0 0 79 if lt fd 0 80 ret 0 81 end 82 got = read int fd nq_tmp 0 64 83 r = fclose int fd 84 if le got 0 85 ret 0 86 end 87 p = ulong 0 88 if ge got 2 89 if and eq get nq_tmp 0 48 or eq get nq_tmp 1 120 eq get nq_tmp 1 88 90 p = ulong 2 91 end 92 end 93 v = ulong 0 94 while lt p ulong got bound 32 95 c = ulong get nq_tmp p 96 if and ge c 48 le c 57 97 v = add mul v 16 sub c 48 98 else 99 if and ge c 97 le c 102 100 v = add mul v 16 add 10 sub c 97 101 else 102 if and ge c 65 le c 70 103 v = add mul v 16 add 10 sub c 65 104 else 105 break 106 end 107 end 108 end 109 p = add p 1 110 end 111 ret v 112 end 113 114 global nq_bdf uchar 64 115 116 fn nq_check_bdf nl ulong to void 117 if eq nl 0 118 ret 119 end 120 if and eq nl 1 eq get nq_bdf 0 46 121 ret 122 end 123 if and eq nl 2 and eq get nq_bdf 0 46 eq get nq_bdf 1 46 124 ret 125 end 126 bp = nq_mkpath nq_ppci 127 put nq_path bp 47 128 bp = add bp 1 129 for k ulong nl bound 64 130 put nq_path add bp k get nq_bdf k 131 end 132 bp = add bp nl 133 for k ulong len nq_pcls 134 put nq_path add bp k get nq_pcls k 135 end 136 cls = nq_readhex add bp len nq_pcls 137 basecls = shr cls 16 138 if ne basecls 3 139 ret 140 end 141 for k ulong len nq_pven 142 put nq_path add bp k get nq_pven k 143 end 144 ven = nq_readhex add bp len nq_pven 145 if eq ven 4098 146 put nq_cnt 0 add get nq_cnt 0 1 147 ret 148 end 149 if eq ven 32902 150 put nq_cnt 1 add get nq_cnt 1 1 151 ret 152 end 153 if eq ven 4318 154 put nq_cnt 2 add get nq_cnt 2 1 155 end 156 end 157 158 fn nq_scan_pci to void 159 plen = nq_mkpath nq_ppci 160 fd = fopen nq_path 0 plen 0 0 161 if lt fd 0 162 ret 163 end 164 while true bound 256 165 got = getdnts int fd nq_dents 0 16384 166 if le got 0 167 break 168 end 169 pos = ulong 0 170 while lt pos ulong got bound 1024 171 reclen = or ulong get nq_dents add pos 16 shl ulong get nq_dents add pos 17 8 172 if eq reclen 0 173 break 174 end 175 ns = add pos 19 176 nl = ulong 0 177 while lt add ns nl add pos reclen bound 64 178 b = get nq_dents add ns nl 179 if eq b 0 180 break 181 end 182 put nq_bdf nl b 183 nl = add nl 1 184 end 185 nq_check_bdf nl 186 pos = add pos reclen 187 end 188 end 189 r = fclose int fd 190 end 191 192 fn main to int 193 ac = argcnt 194 if eq ac 3 195 n1 = argread 1 nq_tmp 0 64 196 if ne n1 long len nq_froot 197 r = write 2 nq_use 0 len nq_use 198 ret 2 199 end 200 for i ulong len nq_froot 201 if ne get nq_tmp i get nq_froot i 202 r = write 2 nq_use 0 len nq_use 203 ret 2 204 end 205 end 206 n2 = argread 2 nq_root 0 2048 207 if lt n2 0 208 r = write 2 nq_use 0 len nq_use 209 ret 2 210 end 211 put nq_rlen 0 ulong n2 212 else 213 if ne ac 1 214 r = write 2 nq_use 0 len nq_use 215 ret 2 216 end 217 put nq_rlen 0 0 218 end 219 220 nq_scan_pci 221 has_kfd = eq faccess nq_path 0 nq_mkpath nq_pkfd 0 0 222 has_dri = eq faccess nq_path 0 nq_mkpath nq_pdri 0 0 223 has_ocl = eq faccess nq_path 0 nq_mkpath nq_pocl 0 0 224 225 r = write 1 nq_hdr 0 len nq_hdr 226 r = write 1 nq_amd 0 len nq_amd 227 nq_wnum get nq_cnt 0 228 r = write 1 nq_int 0 len nq_int 229 nq_wnum get nq_cnt 1 230 r = write 1 nq_nv 0 len nq_nv 231 nq_wnum get nq_cnt 2 232 r = write 1 nq_kfd 0 len nq_kfd 233 if has_kfd 234 r = write 1 nq_yes 0 len nq_yes 235 else 236 r = write 1 nq_no 0 len nq_no 237 end 238 r = write 1 nq_dri 0 len nq_dri 239 if has_dri 240 r = write 1 nq_yes 0 len nq_yes 241 else 242 r = write 1 nq_no 0 len nq_no 243 end 244 r = write 1 nq_ocl 0 len nq_ocl 245 if has_ocl 246 r = write 1 nq_yes 0 len nq_yes 247 else 248 r = write 1 nq_no 0 len nq_no 249 end 250 251 amd_ready = and gt get nq_cnt 0 0 has_kfd 252 intel_ready = and gt get nq_cnt 1 0 has_dri 253 if or amd_ready intel_ready 254 r = write 1 nq_ready 0 len nq_ready 255 ret 0 256 end 257 r = write 1 nq_blk 0 len nq_blk 258 ret 3 259 end