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/native/nvrm/counts.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 / native / nvrm / counts.om` 134 lines · 2095 bytes Raw Blame History 1 om2 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note sscanf decimal unsigned contract: optional sign, saturating overflow, prefix digits. 4 fn nc_space c uchar to bool 5 ret or eq c 32 and ge c 9 le c 13 6 end 7 fn nc_number b view uchar * pos ulong dst edit ulong 2 to bool 8 i = pos 9 while lt i len b bound 512 10 if not nc_space get b i 11 break 12 end 13 i = add i 1 14 end 15 minus = false 16 if lt i len b 17 if or eq get b i 43 eq get b i 45 18 minus = eq get b i 45 19 i = add i 1 20 end 21 end 22 start = i 23 v = ulong 0 24 ov = false 25 while lt i len b bound 512 26 c = get b i 27 if or lt c 48 gt c 57 28 break 29 end 30 d = ulong sub c 48 31 if gt v div sub ulong `18446744073709551615` d 10 32 ov = true 33 end 34 if not ov 35 v = add mul v 10 d 36 end 37 i = add i 1 38 end 39 if eq i start 40 ret false 41 end 42 if ov 43 v = ulong `18446744073709551615` 44 else 45 if minus 46 v = sub ulong 0 v 47 end 48 end 49 put dst 0 v 50 put dst 1 i 51 ret true 52 end 53 fn nc_mem b view uchar * key view uchar * state edit ulong 2 to ulong 54 dst = new ulong 2 0 55 if le len b len key 56 ret 0 57 end 58 for i ulong len key 59 if ne get b i get key i 60 ret 0 61 end 62 end 63 if ne get b len key 58 64 ret 0 65 end 66 put state 1 0 67 ok = nc_number b add len key 1 dst 68 if ok 69 put state 1 get dst 0 70 end 71 ret 1 72 end 73 fn nc_buddy b view uchar * state edit ulong 2 to ulong 74 dst = new ulong 2 0 75 p = ulong 0 76 found = false 77 while le add p 4 len b bound 512 78 if eq get b p 122 79 if and eq get b add p 1 111 eq get b add p 2 110 80 if eq get b add p 3 101 81 found = true 82 break 83 end 84 end 85 end 86 p = add p 1 87 end 88 if not found 89 ret 0 90 end 91 p = add p 4 92 while lt p len b bound 512 93 if ne get b p 32 94 break 95 end 96 p = add p 1 97 end 98 while lt p len b bound 512 99 if or eq get b p 0 eq get b p 32 100 break 101 end 102 p = add p 1 103 end 104 total = ulong 0 105 for o ulong 32 106 ok = nc_number b p dst 107 if not ok 108 break 109 end 110 if ge o get state 0 111 total = add total get dst 0 112 end 113 while lt p len b bound 512 114 if ne get b p 32 115 break 116 end 117 p = add p 1 118 end 119 while lt p len b bound 512 120 if or eq get b p 0 eq get b p 32 121 break 122 end 123 p = add p 1 124 end 125 end 126 put state 1 add get state 1 total 127 ret 0 128 end 129 fn nvrm_counts mode ulong b view uchar * key view uchar * state edit ulong 2 to ulong 130 if eq mode 0 131 ret nc_mem b key state 132 end 133 ret nc_buddy b state 134 end