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/gdn/admit.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 / gdn / admit.om` 177 lines · 3260 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note admit.om: the admission and layout decisions of src/omega_gpu_gdn_api.c in seeded Omega. 3 note Entry gdn_admit op a b c o: result 0 admitted, 1 refused (OMEGA_GPU_GDN_BAD_ARGS / shape -1). 4 note op 1 SHAPE a=ratio b=state_bf16: o[0..9] = r vh conv vdim par_scal par_norm par_bytes tail state post_y. 5 note op 2 ALLOC a=layers b=ratio c=state_bf16: 1 <= layers <= 64, then SHAPE. 6 note op 3 LAYER a=layer b=layers: layer < layers. 7 note op 4 FINITE a=eps_l2|eps_norm<<32 b=in_scale|out_scale<<32 (f32 bits): all four finite. 8 note op 5 MULTI a=layer b=layers c=tokens, o[0..6] = qkv z ab out xstride abstride ostride. 9 note op 6 TOKENS a=T: OMEGA_GDN_PF_MIN_T 3 <= T <= OMEGA_GPU_GDN_PF_MAX_T 65536. 10 note op 7 PFLAYOUT a=T b=ratio: o[0..5] the six section offsets, o[6] the total bytes. 11 note op 8 MOVE a=kind b=bytes c=dst: kind 4 COPY or 5 ZERO, dst nonzero, bytes a nonzero multiple of 4096 with 12 note bytes/4096 <= 0x7fffffff; o[0] = the grid. 13 const MASK32 ulong `4294967295` 14 fn shape r ulong bf ulong o edit ulong 16 to ulong 15 if eq r 0 16 r = ulong 3 17 end 18 if or lt r 1 gt r 3 19 ret 1 20 end 21 vh = mul r 16 22 vdim = mul vh 128 23 conv = add 4096 vdim 24 put o 0 r 25 put o 1 vh 26 put o 2 conv 27 put o 3 vdim 28 put o 4 mul conv 16 29 put o 5 add mul conv 16 mul vh 8 30 put o 6 add add mul conv 16 mul vh 8 512 31 put o 7 mul vh 6144 32 st = mul vh 65536 33 if ne bf 0 34 st = mul vh 32768 35 end 36 put o 8 st 37 put o 9 div vh 8 38 ret 0 39 end 40 fn fin32 x ulong to ulong 41 if eq and shr x 23 255 255 42 ret 1 43 end 44 ret 0 45 end 46 fn finite a ulong b ulong to ulong 47 if ne fin32 and a MASK32 0 48 ret 1 49 end 50 if ne fin32 shr a 32 0 51 ret 1 52 end 53 if ne fin32 and b MASK32 0 54 ret 1 55 end 56 if ne fin32 shr b 32 0 57 ret 1 58 end 59 ret 0 60 end 61 fn multi a ulong b ulong c ulong o edit ulong 16 to ulong 62 if ge a b 63 ret 1 64 end 65 if eq c 0 66 ret 1 67 end 68 if eq get o 0 0 69 ret 1 70 end 71 if eq get o 1 0 72 ret 1 73 end 74 if eq get o 2 0 75 ret 1 76 end 77 if eq get o 3 0 78 ret 1 79 end 80 m16 = or get o 0 get o 1 81 m16 = or m16 get o 3 82 m16 = or m16 get o 4 83 m16 = or m16 get o 6 84 if ne and m16 15 0 85 ret 1 86 end 87 if ne and or get o 2 get o 5 7 0 88 ret 1 89 end 90 ret 0 91 end 92 fn r256 x ulong to ulong 93 ret shl shr add x 255 8 8 94 end 95 fn layout t ulong r ulong o edit ulong 16 to ulong 96 if gt t 65536 97 ret 1 98 end 99 sh = new ulong 16 0 100 if ne shape r 0 sh 0 101 ret 1 102 end 103 vh = get sh 1 104 conv = get sh 2 105 vdim = get sh 3 106 t8 = mul div add t 7 8 8 107 at = ulong 0 108 put o 0 at 109 at = add at r256 mul mul t conv 4 110 put o 1 at 111 at = add at r256 mul mul t vdim 4 112 put o 2 at 113 at = add at r256 mul mul t vh 8 114 put o 3 at 115 at = add at r256 mul mul t vdim 4 116 put o 4 at 117 at = add at r256 mul mul t vdim 4 118 put o 5 at 119 at = add at r256 mul mul t8 vh 1552 120 put o 6 at 121 ret 0 122 end 123 fn move k ulong by ulong dst ulong o edit ulong 16 to ulong 124 if and ne k 4 ne k 5 125 ret 1 126 end 127 if eq dst 0 128 ret 1 129 end 130 if eq by 0 131 ret 1 132 end 133 if ne rem by 4096 0 134 ret 1 135 end 136 if gt div by 4096 `2147483647` 137 ret 1 138 end 139 put o 0 div by 4096 140 ret 0 141 end 142 fn gdn_admit op ulong a ulong b ulong c ulong o edit ulong 16 to ulong 143 if eq op 1 144 ret shape a b o 145 end 146 if eq op 2 147 if or eq a 0 gt a 64 148 ret 1 149 end 150 ret shape b c o 151 end 152 if eq op 3 153 if ge a b 154 ret 1 155 end 156 ret 0 157 end 158 if eq op 4 159 ret finite a b 160 end 161 if eq op 5 162 ret multi a b c o 163 end 164 if eq op 6 165 if or lt a 3 gt a 65536 166 ret 1 167 end 168 ret 0 169 end 170 if eq op 7 171 ret layout a b o 172 end 173 if eq op 8 174 ret move a b c o 175 end 176 ret 1 177 end