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
CUDApp / tests / host-trace / launch-test.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Host check of native/trace/htlaunch.om over tests/host-trace/fakenv.om (no device). Compose: |
| 3 | note fakenv.om vector.om launch.om htrec.om htlaunch.om launch-test.om. With a path in argv 1 it |
| 4 | note writes the OTR1 dump there. Prints HOSTTRACE_LAUNCH_PASS <checks> or _FAIL <failures>. |
| 5 | global tally ulong 2 |
| 6 | global digits uchar 32 |
| 7 | global path uchar 4096 |
| 8 | text passmsg "HOSTTRACE_LAUNCH_PASS " |
| 9 | text failmsg "HOSTTRACE_LAUNCH_FAIL " |
| 10 | text appnames "launch-test:main|host.upload:a.b|host.verify" |
| 11 | fn number n ulong to void |
| 12 | if ge n 10 |
| 13 | number div n 10 |
| 14 | end |
| 15 | put digits 0 uchar add 48 rem n 10 |
| 16 | w = write 1 digits 0 1 |
| 17 | end |
| 18 | fn ck yes bool to void |
| 19 | put tally 0 add get tally 0 1 |
| 20 | if not yes |
| 21 | put tally 1 add get tally 1 1 |
| 22 | number get tally 0 |
| 23 | put digits 0 10 |
| 24 | w = write 1 digits 0 1 |
| 25 | end |
| 26 | end |
| 27 | fn appname to bool |
| 28 | id = uint 201 |
| 29 | ok = htnbeg id |
| 30 | for i ulong len appnames |
| 31 | b = get appnames i |
| 32 | if eq b 124 |
| 33 | ok = and ok htnend |
| 34 | id = add id 1 |
| 35 | ok = and ok htnbeg id |
| 36 | else |
| 37 | ok = and ok htnbyte b |
| 38 | end |
| 39 | end |
| 40 | ret and ok htnend |
| 41 | end |
| 42 | fn aval i ulong to ulong |
| 43 | ret and add mul i 2654435761 7 4294967295 |
| 44 | end |
| 45 | fn bval i ulong to ulong |
| 46 | ret and xor mul i 2246822519 3266489917 4294967295 |
| 47 | end |
| 48 | fn upload n uint to void |
| 49 | s = htbeg 6 202 |
| 50 | for i ulong ulong n |
| 51 | r = mapset get gbmem 5 mul i 4 4 aval i |
| 52 | r = mapset get gbmem 6 mul i 4 4 bval i |
| 53 | r = mapset get gbmem 7 mul i 4 4 0 |
| 54 | end |
| 55 | b = htend s mul ulong n 8 1 0 |
| 56 | end |
| 57 | fn readback n uint to ulong |
| 58 | s = htbeg 6 106 |
| 59 | bad = ulong 0 |
| 60 | for i ulong ulong n |
| 61 | c = mapget get gbmem 7 mul i 4 4 |
| 62 | if ne c and add aval i bval i 4294967295 |
| 63 | bad = add bad 1 |
| 64 | end |
| 65 | end |
| 66 | b = htend s mul ulong n 4 2 long bad |
| 67 | ret bad |
| 68 | end |
| 69 | note count launch spans that ended with stage st and status rc |
| 70 | fn spans st ulong rc long to ulong |
| 71 | k = ulong 0 |
| 72 | n = get htst 1 |
| 73 | for i ulong n |
| 74 | if eq get htkind i 4 |
| 75 | if eq get hta1 i st |
| 76 | if eq get htrc i rc |
| 77 | k = add k 1 |
| 78 | end |
| 79 | end |
| 80 | end |
| 81 | end |
| 82 | ret k |
| 83 | end |
| 84 | fn kinds k uint to ulong |
| 85 | c = ulong 0 |
| 86 | for i ulong get htst 1 |
| 87 | if eq get htkind i k |
| 88 | c = add c 1 |
| 89 | end |
| 90 | end |
| 91 | ret c |
| 92 | end |
| 93 | fn opened to void |
| 94 | ck htopen 4097 |
| 95 | ck eq get fkn 0 8 |
| 96 | for i ulong 8 |
| 97 | ck eq get fksz i htgbsz i 4097 |
| 98 | end |
| 99 | ck eq kinds 5 8 |
| 100 | note event 0 is the launch-test:main span, event 1 the gpu.open span |
| 101 | ck eq get htkind 1 3 |
| 102 | ck eq get hta1 1 get gblen 0 |
| 103 | ck eq get htrc 1 0 |
| 104 | end |
| 105 | fn launched to void |
| 106 | upload 4097 |
| 107 | ck htlaunch 4097 |
| 108 | ck eq readback 4097 0 |
| 109 | ck eq spans 43 0 1 |
| 110 | put fkmode 0 1 |
| 111 | ck not htlaunch 64 |
| 112 | ck eq spans 41 -5 1 |
| 113 | put fkmode 0 2 |
| 114 | ck not htlaunch 64 |
| 115 | ck eq spans 42 -110 1 |
| 116 | put fkmode 0 3 |
| 117 | ck not htlaunch 64 |
| 118 | ck eq spans 43 -5 1 |
| 119 | ck eq get nvfault 0 1 |
| 120 | put fkmode 0 0 |
| 121 | ck not htlaunch 64 |
| 122 | ck eq spans 0 -22 1 |
| 123 | ck eq get nvstage 0 43 |
| 124 | ck not htlaunch 0 |
| 125 | ck eq spans 0 -22 2 |
| 126 | end |
| 127 | fn dumpto to void |
| 128 | if lt argcnt 2 |
| 129 | ret |
| 130 | end |
| 131 | n = argread 1 path 0 4095 |
| 132 | ck gt n 0 |
| 133 | fd = fopen path 0 ulong n 577 384 |
| 134 | ck ge fd 0 |
| 135 | r = htdump int fd |
| 136 | ck gt r 0 |
| 137 | c = fclose int fd |
| 138 | end |
| 139 | fn main to int |
| 140 | ck appname |
| 141 | ck htlname |
| 142 | ck not htlive |
| 143 | ck htinit |
| 144 | m = htbeg 9 201 |
| 145 | opened |
| 146 | launched |
| 147 | ck eq kinds 4 6 |
| 148 | ck eq kinds 11 5 |
| 149 | ck eq kinds 6 2 |
| 150 | ck htend m 0 0 0 |
| 151 | ck eq get htst 7 0 |
| 152 | ck eq get htst 3 0 |
| 153 | ck eq get htst 2 0 |
| 154 | dumpto |
| 155 | htstop |
| 156 | ck not htlaunch 64 |
| 157 | ck eq kinds 4 6 |
| 158 | if ne get tally 1 0 |
| 159 | w = write 1 failmsg 0 len failmsg |
| 160 | number get tally 1 |
| 161 | put digits 0 10 |
| 162 | w = write 1 digits 0 1 |
| 163 | ret 1 |
| 164 | end |
| 165 | w = write 1 passmsg 0 len passmsg |
| 166 | number get tally 0 |
| 167 | put digits 0 10 |
| 168 | w = write 1 digits 0 1 |
| 169 | ret 0 |
| 170 | end |