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 / evidence / graph-residue-20261106 / graph-oracle.gcov
| 1 | -: 0:Source:src/omega_gpu_graph_residue.h |
| 2 | -: 0:Graph:build/graph-residue-oracle-test_graph_residue.gcno |
| 3 | -: 0:Data:build/graph-residue-oracle-test_graph_residue.gcda |
| 4 | -: 0:Runs:1 |
| 5 | -: 1:/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 6 | -: 2:#ifndef OMEGA_GPU_GRAPH_RESIDUE_H |
| 7 | -: 3:#define OMEGA_GPU_GRAPH_RESIDUE_H |
| 8 | -: 4:#include "cudapp_native.h" |
| 9 | -: 5:#include <stdint.h> |
| 10 | -: 6:#include <stdlib.h> |
| 11 | -: 7:#include <string.h> |
| 12 | -: 8:/* The C oracle is present only in migration builds, OFF in the library. */ |
| 13 | -: 9:#ifndef CUDAPP_MIGRATION_PENDING_GRAPH_RESIDUE |
| 14 | -: 10:#define CUDAPP_MIGRATION_PENDING_GRAPH_RESIDUE 0 |
| 15 | -: 11:#endif |
| 16 | function omega_graph_meta called 8 returned 100% blocks executed 80% |
| 17 | 8: 12:static inline uint64_t omega_graph_meta(unsigned mode, const uint64_t c[16], uint64_t d[16]) { |
| 18 | 8: 13: uint64_t result = 0; |
| 19 | 8*: 14: if (omega_grmeta(&result, mode, c, 16, d, 16) != OMEGA_OK) abort(); |
| 20 | call 0 returned 8 |
| 21 | branch 1 taken 0 (fallthrough) |
| 22 | branch 2 taken 8 |
| 23 | call 3 never executed |
| 24 | 8: 15: return result; |
| 25 | -: 16:} |
| 26 | function omega_graph_budget called 136242 returned 100% blocks executed 100% |
| 27 | 136242: 17:static inline int omega_graph_budget(uint32_t peak, uint32_t limit, uint32_t max, uint32_t hw, int declared_ok) { |
| 28 | -: 18:#if CUDAPP_MIGRATION_PENDING_GRAPH_RESIDUE |
| 29 | 136242: 19: if (!limit) limit = max - 2u; |
| 30 | branch 0 taken 522 (fallthrough) |
| 31 | branch 1 taken 135720 |
| 32 | 136242: 20: return limit <= hw && peak <= limit && declared_ok; |
| 33 | branch 0 taken 128934 (fallthrough) |
| 34 | branch 1 taken 7308 |
| 35 | branch 2 taken 61508 (fallthrough) |
| 36 | branch 3 taken 67426 |
| 37 | branch 4 taken 30754 (fallthrough) |
| 38 | branch 5 taken 30754 |
| 39 | -: 21:#else |
| 40 | -: 22: const uint64_t c[16] = {peak, limit, max, hw, (uint64_t)declared_ok}; uint64_t d[16]; |
| 41 | -: 23: return (int)omega_graph_meta(7, c, d); |
| 42 | -: 24:#endif |
| 43 | -: 25:} |
| 44 | function omega_graph_timeline called 52 returned 100% blocks executed 100% |
| 45 | 52: 26:static inline int omega_graph_timeline(uint32_t used, uint32_t count, uint32_t cap, int *from) { |
| 46 | -: 27:#if CUDAPP_MIGRATION_PENDING_GRAPH_RESIDUE |
| 47 | 52: 28: const uint32_t skip = used ? 1 : 0; |
| 48 | 52: 29: if (used > cap || (count > skip && count - skip > cap - used)) return 0; |
| 49 | branch 0 taken 45 (fallthrough) |
| 50 | branch 1 taken 7 |
| 51 | branch 2 taken 39 (fallthrough) |
| 52 | branch 3 taken 6 |
| 53 | branch 4 taken 18 (fallthrough) |
| 54 | branch 5 taken 21 |
| 55 | 27: 30: *from = (int)skip; return 1; |
| 56 | -: 31:#else |
| 57 | -: 32: const uint64_t c[16] = {used, count, cap}; uint64_t d[16]; |
| 58 | -: 33: if (!omega_graph_meta(6, c, d)) return 0; |
| 59 | -: 34: *from = (int)d[0]; return 1; |
| 60 | -: 35:#endif |
| 61 | -: 36:} |
| 62 | function omega_graph_q38 called 305850 returned 100% blocks executed 100% |
| 63 | 305850: 37:static inline int omega_graph_q38(const uint64_t c[16], uint64_t d[16]) { |
| 64 | -: 38:#if CUDAPP_MIGRATION_PENDING_GRAPH_RESIDUE |
| 65 | 305850: 39: uint64_t hd=c[0]?c[0]:5120, in=c[1]?c[1]:17408, qh=c[2]?c[2]:24, kv=c[3]?c[3]:4, gh=c[4]?c[4]:48; |
| 66 | branch 0 taken 262097 (fallthrough) |
| 67 | branch 1 taken 43753 |
| 68 | branch 2 taken 301409 (fallthrough) |
| 69 | branch 3 taken 4441 |
| 70 | branch 4 taken 294017 (fallthrough) |
| 71 | branch 5 taken 11833 |
| 72 | branch 6 taken 254817 (fallthrough) |
| 73 | branch 7 taken 51033 |
| 74 | branch 8 taken 229337 (fallthrough) |
| 75 | branch 9 taken 76513 |
| 76 | 305850: 40: if (hd%1024 || hd>5120 || !in || in%256 || in>17408 || qh>24 || qh%kv || qh/kv>8 || |
| 77 | branch 0 taken 305837 (fallthrough) |
| 78 | branch 1 taken 13 |
| 79 | branch 2 taken 262156 (fallthrough) |
| 80 | branch 3 taken 43681 |
| 81 | branch 4 taken 262156 (fallthrough) |
| 82 | branch 5 taken 0 |
| 83 | branch 6 taken 262144 (fallthrough) |
| 84 | branch 7 taken 12 |
| 85 | branch 8 taken 258400 (fallthrough) |
| 86 | branch 9 taken 3744 |
| 87 | branch 10 taken 248448 (fallthrough) |
| 88 | branch 11 taken 9952 |
| 89 | branch 12 taken 107671 (fallthrough) |
| 90 | branch 13 taken 140777 |
| 91 | branch 14 taken 71238 (fallthrough) |
| 92 | branch 15 taken 36433 |
| 93 | branch 16 taken 53436 (fallthrough) |
| 94 | branch 17 taken 17802 |
| 95 | 305850: 41: (gh!=32 && gh!=48) || qh*256!=gh*128) return 0; |
| 96 | branch 0 taken 35617 (fallthrough) |
| 97 | branch 1 taken 17819 |
| 98 | branch 2 taken 47196 (fallthrough) |
| 99 | branch 3 taken 6223 |
| 100 | 6223: 42: d[0]=hd; d[1]=in; d[2]=qh; d[3]=kv; d[4]=gh; |
| 101 | 6223: 43: d[5]=(32+gh)*128; d[6]=d[5]+gh*128; d[7]=2*gh; |
| 102 | 6223: 44: d[8]=(qh+kv)*512; d[9]=qh*256+kv*512; d[10]=qh*256; |
| 103 | 6223: 45: return 1; |
| 104 | -: 46:#else |
| 105 | -: 47: return (int)omega_graph_meta(0, c, d); |
| 106 | -: 48:#endif |
| 107 | -: 49:} |
| 108 | function omega_graph_config called 31700 returned 100% blocks executed 100% |
| 109 | 31700: 50:static inline uint32_t omega_graph_config(uint32_t layers, uint32_t maxlayers, |
| 110 | -: 51: uint32_t vocab, uint32_t span, uint32_t heads, uint32_t maxheads, uint64_t mask, int usemask) { |
| 111 | -: 52:#if CUDAPP_MIGRATION_PENDING_GRAPH_RESIDUE |
| 112 | 31700: 53: if (!layers || layers > maxlayers || !vocab || vocab > span * span || !heads || heads > maxheads) return 0; |
| 113 | branch 0 taken 31220 (fallthrough) |
| 114 | branch 1 taken 480 |
| 115 | branch 2 taken 30739 (fallthrough) |
| 116 | branch 3 taken 481 |
| 117 | branch 4 taken 28818 (fallthrough) |
| 118 | branch 5 taken 1921 |
| 119 | branch 6 taken 28810 (fallthrough) |
| 120 | branch 7 taken 8 |
| 121 | branch 8 taken 25930 (fallthrough) |
| 122 | branch 9 taken 2880 |
| 123 | branch 10 taken 2881 (fallthrough) |
| 124 | branch 11 taken 23049 |
| 125 | 23049: 54: if (usemask && layers < 64 && mask >> layers) return 0; |
| 126 | branch 0 taken 15369 (fallthrough) |
| 127 | branch 1 taken 7680 |
| 128 | branch 2 taken 15129 (fallthrough) |
| 129 | branch 3 taken 240 |
| 130 | branch 4 taken 7560 (fallthrough) |
| 131 | branch 5 taken 7569 |
| 132 | 15489: 55: return (vocab + span - 1) / span; |
| 133 | -: 56:#else |
| 134 | -: 57: const uint64_t c[16] = {layers, maxlayers, vocab, span, heads, maxheads, mask, (uint64_t)usemask}; |
| 135 | -: 58: uint64_t d[16]; |
| 136 | -: 59: return omega_graph_meta(1, c, d) ? (uint32_t)d[0] : 0; |
| 137 | -: 60:#endif |
| 138 | -: 61:} |
| 139 | function omega_graph_layer called 64 returned 100% blocks executed 100% |
| 140 | 64: 62:static inline void omega_graph_layer(uint64_t mask, uint32_t layer, uint64_t counts[2], int *attn, uint32_t *index) { |
| 141 | -: 63:#if CUDAPP_MIGRATION_PENDING_GRAPH_RESIDUE |
| 142 | 64: 64: *attn = (int)((mask >> layer) & 1u); |
| 143 | 64: 65: *index = (uint32_t)counts[*attn ? 0 : 1]++; |
| 144 | -: 66:#else |
| 145 | -: 67: const uint64_t c[16] = {mask, layer, counts[0], counts[1]}; uint64_t d[16]; |
| 146 | -: 68: if (!omega_graph_meta(2, c, d)) abort(); |
| 147 | -: 69: *attn = (int)d[0]; *index = (uint32_t)d[1]; counts[0] = d[2]; counts[1] = d[3]; |
| 148 | -: 70:#endif |
| 149 | 64: 71:} |
| 150 | -: 72:/* Only convert the checked scalar representation to the public uint32_t buffer. |
| 151 | -: 73: * Fixed blocks keep the bridge view's advertised extent within real storage. */ |
| 152 | function omega_graph_table called 75 returned 100% blocks executed 91% |
| 153 | 75: 74:static inline void omega_graph_table(unsigned mode, unsigned qh, unsigned kv, |
| 154 | -: 75: uint32_t *dst, uint32_t n) { |
| 155 | 1397: 76: for (uint32_t base = 0; base < n;) { |
| 156 | branch 0 taken 1322 |
| 157 | branch 1 taken 75 (fallthrough) |
| 158 | 1322: 77: uint64_t words[512], result = 0; |
| 159 | 1322: 78: uint32_t count = n - base < 512 ? n - base : 512; |
| 160 | 1322*: 79: if (omega_grtable(&result, mode, qh, kv, base, count, words, 512) != OMEGA_OK || result != 1) abort(); |
| 161 | call 0 returned 1322 |
| 162 | branch 1 taken 1322 (fallthrough) |
| 163 | branch 2 taken 0 |
| 164 | branch 3 taken 0 (fallthrough) |
| 165 | branch 4 taken 1322 |
| 166 | call 5 never executed |
| 167 | 678186: 80: for (uint32_t i = 0; i < count; ++i) dst[base + i] = (uint32_t)words[i]; |
| 168 | branch 0 taken 676864 |
| 169 | branch 1 taken 1322 (fallthrough) |
| 170 | 1322: 81: base += count; |
| 171 | -: 82: } |
| 172 | 75: 83:} |
| 173 | function omega_graph_shape called 17 returned 100% blocks executed 100% |
| 174 | 17: 84:static inline int omega_graph_shape(uint32_t ae, uint32_t an, uint32_t ak, |
| 175 | -: 85: uint32_t e, uint32_t n, uint32_t k) { |
| 176 | -: 86:#if CUDAPP_MIGRATION_PENDING_GRAPH_RESIDUE |
| 177 | 17: 87: return ae == e && an == n && ak == k; |
| 178 | branch 0 taken 5 (fallthrough) |
| 179 | branch 1 taken 12 |
| 180 | branch 2 taken 2 (fallthrough) |
| 181 | branch 3 taken 3 |
| 182 | branch 4 taken 1 (fallthrough) |
| 183 | branch 5 taken 1 |
| 184 | -: 88:#else |
| 185 | -: 89: const uint64_t c[16] = {ae, an, ak, e, n, k}; uint64_t d[16]; |
| 186 | -: 90: return (int)omega_graph_meta(5, c, d); |
| 187 | -: 91:#endif |
| 188 | -: 92:} |
| 189 | -: 93:#endif |