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/graph/hello-plan.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 / graph / hello-plan.om` 147 lines · 2549 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note mode 0 chunk plan, mode 1 scoreboard control. Parameters are source constants. 3 fn hplan mode ulong c view ulong 16 d edit ulong 16 to ulong 4 if eq mode 0 5 base = get c 0 6 n = sub get c 1 base 7 if gt n get c 2 8 n = get c 2 9 end 10 if and ne get c 4 0 eq add base n get c 1 11 if eq get c 4 1 12 n = add n 1 13 else 14 n = sub n 1 15 end 16 end 17 put d 0 mul base 4 18 put d 1 n 19 put d 2 div sub add n get c 3 1 get c 3 20 put d 3 div sub add get c 1 get c 2 1 get c 2 21 put d 4 mul n 8 22 put d 5 mul n 4 23 ret 1 24 end 25 if eq mode 1 26 kind = get c 0 27 pend = get c 1 28 stall = ulong 6 29 wb = ulong 7 30 rb = ulong 7 31 np = ulong 0 32 if eq kind 1 33 stall = 14 34 end 35 if eq kind 2 36 stall = 4 37 wb = 0 38 np = 1 39 end 40 if eq kind 3 41 stall = 4 42 wb = 2 43 np = 4 44 end 45 if eq kind 4 46 stall = 4 47 rb = 1 48 np = 2 49 end 50 if or eq kind 5 eq kind 6 51 stall = 5 52 end 53 if eq kind 6 54 np = pend 55 end 56 v = or shl stall 9 shl wb 14 57 v = or v shl rb 17 58 v = or v shl pend 20 59 if and ge kind 2 le kind 4 60 v = or v 8192 61 end 62 put d 0 v 63 put d 1 np 64 ret 1 65 end 66 if eq mode 2 67 total = add get c 1 get c 2 68 floor = f64 0 69 if eq get c 0 121 70 floor = div f64 total mul 195.1f64 1000.0f64 71 end 72 measured = bitcast f64 get c 3 73 pct = f64 0 74 if gt measured 0.0f64 75 pct = div mul 100.0f64 floor measured 76 end 77 put d 0 total 78 put d 1 bitcast ulong floor 79 put d 2 bitcast ulong pct 80 ret 1 81 end 82 if eq mode 3 83 elem = sub add get c 0 get c 1 1 84 rel = sub elem get c 0 85 put d 0 elem 86 put d 1 div rel get c 2 87 put d 2 rem rel get c 2 88 put d 3 add get c 3 mul elem 4 89 ret 1 90 end 91 if eq mode 4 92 near = ulong 0 93 dist = ulong `18446744073709551615` 94 past = ulong 1 95 for k ulong 3 96 lo = get c mul k 2 97 hi = get c add mul k 2 1 98 dd = ulong 0 99 pst = ulong 1 100 if ge get c 6 hi 101 dd = sub get c 6 hi 102 else 103 if le add get c 6 get c 7 lo 104 dd = sub lo add get c 6 get c 7 105 pst = 0 106 end 107 end 108 if lt dd dist 109 dist = dd 110 near = k 111 past = pst 112 end 113 end 114 put d 0 near 115 put d 1 dist 116 put d 2 past 117 pos = mul near 2 118 low = get c pos 119 high = get c add pos 1 120 put d 3 div sub high add low get c 8 4 121 ret 1 122 end 123 note mode 5 D8 overhead: c0..c2 resident KiB before open, after open, with buffers; c3 own buffer bytes; c4 driver allocation bytes. 124 note d0 own KiB rounded up, d1 d2 open cost magnitude and sign (1 negative), d3 d4 resident beyond own buffers, d5 driver KiB. 125 if eq mode 5 126 ownk = div add get c 3 1023 1024 127 put d 0 ownk 128 if ge get c 1 get c 0 129 put d 1 sub get c 1 get c 0 130 put d 2 0 131 else 132 put d 1 sub get c 0 get c 1 133 put d 2 1 134 end 135 kb = add get c 0 ownk 136 if ge get c 2 kb 137 put d 3 sub get c 2 kb 138 put d 4 0 139 else 140 put d 3 sub kb get c 2 141 put d 4 1 142 end 143 put d 5 div add get c 4 1023 1024 144 ret 1 145 end 146 ret 0 147 end