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 / native / trace / htlaunch.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Traced entry points for native/blackwell/launch.om. Compose after context.om (or a host |
| 3 | note stand-in), vector.om, launch.om and native/trace/htrec.om. launch.om itself is not changed, so a |
| 4 | note unit that does not include this file and htrec.om is byte-identical to before. |
| 5 | note |
| 6 | note htopen and htlaunch behave exactly like gbopen and gblaunch and return the same result. While |
| 7 | note recording is off they make one flag test and call through. While it is on they record: |
| 8 | note gpu.open span launch.om:gbopen a0 bytes allocated, a1 code bytes uploaded, status nverr |
| 9 | note mem.alloc instants launch.om:gbmem a0 bytes, a1 buffer slot 0..7, status the handle sign |
| 10 | note kernel.launch span VECTOR_1D a0 elements n, a1 last stage reached, status nverr |
| 11 | note mem.moved instant launch.om:gbcmd a0 command bytes written to buffer 0, a1 direction 1 |
| 12 | note The launch span covers command build, upload, submission, the host wait for the completion |
| 13 | note mark and the readback checks; launch.om has no hook between them, so the span records the last |
| 14 | note stage reached (nvstage 40 build/upload, 41 submit, 42 host wait, 43 completion checks). |
| 15 | note Name ids 101..106 are reserved for this file. |
| 16 | text htlnames "launch.om:gbopen|kernel:VECTOR_1D/vector.om:gbvec|launch.om:gbmem|launch.om:gbcmd|launch.om:gbcode|host.readback" |
| 17 | fn htlname to bool |
| 18 | id = uint 101 |
| 19 | ok = htnbeg id |
| 20 | for i ulong len htlnames |
| 21 | b = get htlnames i |
| 22 | if eq b 124 |
| 23 | ok = and ok htnend |
| 24 | id = add id 1 |
| 25 | ok = and ok htnbeg id |
| 26 | else |
| 27 | ok = and ok htnbyte b |
| 28 | end |
| 29 | end |
| 30 | ret and ok htnend |
| 31 | end |
| 32 | note htgbsz: the size launch.om gbopen requests for buffer i (launch.om lines 240-246). The host test |
| 33 | note checks it against the sizes the stand-in nvalloc actually received. |
| 34 | fn htgbsz i ulong n uint to ulong |
| 35 | if ge i 5 |
| 36 | ret mul ulong n 4 |
| 37 | end |
| 38 | if or eq i 0 eq i 2 |
| 39 | ret 65536 |
| 40 | end |
| 41 | ret 4096 |
| 42 | end |
| 43 | fn htopen n uint to bool |
| 44 | if not htlive |
| 45 | ret gbopen n |
| 46 | end |
| 47 | s = htbeg 3 101 |
| 48 | ok = gbopen n |
| 49 | total = ulong 0 |
| 50 | for i ulong 8 |
| 51 | m = get gbmem i |
| 52 | if and ok gt m 0 |
| 53 | sz = htgbsz i n |
| 54 | total = add total sz |
| 55 | b = htmark 5 103 sz i 0 |
| 56 | end |
| 57 | end |
| 58 | code = ulong 0 |
| 59 | rc = long 0 |
| 60 | if ok |
| 61 | code = get gblen 0 |
| 62 | b = htmark 11 105 code 1 0 |
| 63 | else |
| 64 | rc = get nverr 0 |
| 65 | end |
| 66 | b = htend s total code rc |
| 67 | ret ok |
| 68 | end |
| 69 | fn htlaunch n uint to bool |
| 70 | if not htlive |
| 71 | ret gblaunch n |
| 72 | end |
| 73 | note gblaunch writes nvstage 40 before any work; it is cleared here only to see whether that |
| 74 | note happened, and restored when gblaunch refused its arguments first, so state matches gblaunch. |
| 75 | prev = get nvstage 0 |
| 76 | put nvstage 0 0 |
| 77 | s = htbeg 4 102 |
| 78 | ok = gblaunch n |
| 79 | st = ulong get nvstage 0 |
| 80 | if eq st 0 |
| 81 | put nvstage 0 prev |
| 82 | end |
| 83 | if ge st 41 |
| 84 | b = htmark 11 104 get gbused 0 1 0 |
| 85 | end |
| 86 | rc = long 0 |
| 87 | if not ok |
| 88 | rc = get nverr 0 |
| 89 | end |
| 90 | b = htend s ulong n st rc |
| 91 | ret ok |
| 92 | end |