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/om/blackwell/scalar.om # 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 / om / blackwell / scalar.om` 141 lines · 2284 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note Pure import-free policy shared by hosted and freestanding callers. 3 note Operations preserve the original uint32 wire and IEEE bit semantics. 4 const BEXP ulong 113 5 fn bw_sub m ulong to ulong 6 if lt m 2 7 ret or shl sub BEXP 10 23 shl and shl m 10 1023 13 8 end 9 if lt m 4 10 ret or shl sub BEXP 9 23 shl and shl m 9 1023 13 11 end 12 if lt m 8 13 ret or shl sub BEXP 8 23 shl and shl m 8 1023 13 14 end 15 if lt m 16 16 ret or shl sub BEXP 7 23 shl and shl m 7 1023 13 17 end 18 if lt m 32 19 ret or shl sub BEXP 6 23 shl and shl m 6 1023 13 20 end 21 if lt m 64 22 ret or shl sub BEXP 5 23 shl and shl m 5 1023 13 23 end 24 if lt m 128 25 ret or shl sub BEXP 4 23 shl and shl m 4 1023 13 26 end 27 if lt m 256 28 ret or shl sub BEXP 3 23 shl and shl m 3 1023 13 29 end 30 if lt m 512 31 ret or shl sub BEXP 2 23 shl and shl m 2 1023 13 32 end 33 ret or shl sub BEXP 1 23 shl and shl m 1 1023 13 34 end 35 fn bw_half h ulong to ulong 36 sign = shl and h 32768 16 37 exp = and shr h 10 31 38 mant = and h 1023 39 if eq exp 0 40 if eq mant 0 41 ret sign 42 end 43 ret or sign bw_sub mant 44 else 45 if eq exp 31 46 ret or sign or `2139095040` shl mant 13 47 end 48 end 49 ret and or sign or shl add exp 112 23 shl mant 13 `4294967295` 50 end 51 fn bw_scalar op ulong x ulong y ulong z ulong w ulong v ulong to ulong 52 if eq op 1 53 ret bw_half x 54 end 55 if eq op 2 56 ret shl and x 65535 16 57 end 58 if eq op 3 59 if and eq and x `2139095040` `2139095040` ne and x `8388607` 0 60 ret or shr x 16 64 61 end 62 ret and shr and add add x 32767 and shr x 16 1 `4294967295` 16 65535 63 end 64 if eq op 4 65 if gt x sub sub `18446744073709551615` y 4095 66 ret 0 67 end 68 b = and add add x y 4095 `18446744073709547520` 69 if lt b 4096 70 ret 4096 71 end 72 ret b 73 end 74 if eq op 7 75 if eq y 0 76 ret x 77 end 78 ret `18446744073709551615` 79 end 80 if eq op 8 81 if and eq x 0 eq y 0 82 ret 0 83 end 84 ret `18446744073709551615` 85 end 86 if eq op 9 87 if and gt x 0 lt x `9223372036854775808` 88 ret sub x 1 89 end 90 ret `18446744073709551615` 91 end 92 if eq op 10 93 if ne x 0 94 ret 2 95 end 96 ret 3 97 end 98 if eq op 11 99 if ne x 0 100 ret 14 101 end 102 ret 13 103 end 104 if eq op 12 105 if eq y 0 106 ret x 107 end 108 ret 0 109 end 110 if eq op 13 111 if ne x 0 112 ret 1 113 end 114 ret 0 115 end 116 if eq op 14 117 if or gt x 32768 gt y 16384 118 ret 0 119 end 120 if or ne z 384 or ne w 384 gt v 128 121 ret 0 122 end 123 ret 1 124 end 125 if eq op 15 126 if le x 4096 127 ret 1 128 end 129 ret 0 130 end 131 if eq op 16 132 if or eq x 0 or eq y 0 eq z 0 133 ret 0 134 end 135 ret 1 136 end 137 if eq op 17 138 ret mul x y 139 end 140 ret `18446744073709551615` 141 end