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 / gemm_pipeline.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Compose: om/gemm-any/host.om ollm.om gemm_ir.om tests/gemm_pipeline.om. |
| 3 | text GPOK "GEMM PIPELINE PASS (27 tensor geometries, 3 kernels each; 72 own-model plans; FP32 accumulator widths; held barriers 3/4)\n" |
| 4 | fn gpcheck cfg view ulong 8 kind ulong to bool |
| 5 | ins = new ulong 8192 0 |
| 6 | meta = new ulong 512 0 |
| 7 | rc = gemm_any_ir cfg kind ins meta |
| 8 | if or ne rc 0 ne get meta 4 0 |
| 9 | ret false |
| 10 | end |
| 11 | if ne kind 2 |
| 12 | ret gt get meta 0 0 |
| 13 | end |
| 14 | found = uint 0 |
| 15 | for i ulong get meta 0 |
| 16 | at = mul i 8 |
| 17 | op = get ins at |
| 18 | if or eq op 15 eq op 16 |
| 19 | v = get ins add at 1 |
| 20 | if ne get meta add 64 v 4 |
| 21 | ret false |
| 22 | end |
| 23 | end |
| 24 | if eq op 57 |
| 25 | ctrl = shr get ins add at 6 32 |
| 26 | sb = and shr ctrl 14 7 |
| 27 | if eq sb 3 |
| 28 | found = or found 1 |
| 29 | end |
| 30 | if eq sb 4 |
| 31 | found = or found 2 |
| 32 | end |
| 33 | end |
| 34 | end |
| 35 | ret and eq found 3 eq get meta 7 0 |
| 36 | end |
| 37 | fn gpgeom to bool |
| 38 | cfg = new ulong 8 0 |
| 39 | put cfg 3 2 |
| 40 | put cfg 4 4 |
| 41 | put cfg 5 4 |
| 42 | put cfg 7 8 |
| 43 | for ty ulong 3 |
| 44 | put cfg 0 ty |
| 45 | for a ulong 3 |
| 46 | put cfg 1 shl ulong 1 a |
| 47 | for b ulong 3 |
| 48 | put cfg 2 shl ulong 1 b |
| 49 | for k ulong 3 |
| 50 | if not gpcheck cfg k |
| 51 | ret false |
| 52 | end |
| 53 | end |
| 54 | end |
| 55 | end |
| 56 | end |
| 57 | ret true |
| 58 | end |
| 59 | fn gpplan d ulong n ulong k ulong rows ulong to bool |
| 60 | x = new ulong 32 0 |
| 61 | p = new ulong 64 0 |
| 62 | put x 8 rows |
| 63 | put x 9 n |
| 64 | put x 10 k |
| 65 | if ne gemm_ollm_cfg x 1 0 |
| 66 | ret false |
| 67 | end |
| 68 | if ne gemm_host_plan x p 0 |
| 69 | ret false |
| 70 | end |
| 71 | if or lt get p 0 rows lt get p 1 n |
| 72 | ret false |
| 73 | end |
| 74 | if lt get p 2 k |
| 75 | ret false |
| 76 | end |
| 77 | if eq rows 1 |
| 78 | if or ne get x 1 1 ne get x 2 1 |
| 79 | ret false |
| 80 | end |
| 81 | if ne get p 0 16 |
| 82 | ret false |
| 83 | end |
| 84 | end |
| 85 | note Whole-vocabulary logits are split in two 16384-column chunks. D is included to bind the model. |
| 86 | ret and gt d 0 eq rem get p 2 64 0 |
| 87 | end |
| 88 | fn gpmodels to bool |
| 89 | for s ulong 3 |
| 90 | d = shl ulong 256 s |
| 91 | if eq s 0 |
| 92 | d = ulong 384 |
| 93 | end |
| 94 | for q ulong 6 |
| 95 | rows = shl ulong 128 q |
| 96 | if eq q 0 |
| 97 | rows = ulong 1 |
| 98 | end |
| 99 | if not gpplan d d d rows |
| 100 | ret false |
| 101 | end |
| 102 | if not gpplan d mul d 4 d rows |
| 103 | ret false |
| 104 | end |
| 105 | if not gpplan d d mul d 4 rows |
| 106 | ret false |
| 107 | end |
| 108 | if not gpplan d 16384 d rows |
| 109 | ret false |
| 110 | end |
| 111 | end |
| 112 | end |
| 113 | ret true |
| 114 | end |
| 115 | fn main to int |
| 116 | if not gpgeom |
| 117 | ret 1 |
| 118 | end |
| 119 | if not gpmodels |
| 120 | ret 2 |
| 121 | end |
| 122 | n = write 1 GPOK 0 len GPOK |
| 123 | if ne n long len GPOK |
| 124 | ret 4 |
| 125 | end |
| 126 | ret 0 |
| 127 | end |