interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / evidence / graph-residue-20261106 / runtime-graph-oracle.gcov

179 lines · 8257 bytes Raw Blame History
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
16function 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();
20call 0 returned 8
21branch 1 taken 0 (fallthrough)
22branch 2 taken 8
23call 3 never executed
24 8: 15: return result;
25 -: 16:}
26function 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;
30branch 0 taken 522 (fallthrough)
31branch 1 taken 135720
32 136242: 20: return limit <= hw && peak <= limit && declared_ok;
33branch 0 taken 128934 (fallthrough)
34branch 1 taken 7308
35branch 2 taken 61508 (fallthrough)
36branch 3 taken 67426
37branch 4 taken 30754 (fallthrough)
38branch 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:}
44function omega_graph_timeline called 53 returned 100% blocks executed 100%
45 53: 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 53: 28: const uint32_t skip = used ? 1 : 0;
48 53: 29: if (used > cap || (count > skip && count - skip > cap - used)) return 0;
49branch 0 taken 45 (fallthrough)
50branch 1 taken 8
51branch 2 taken 39 (fallthrough)
52branch 3 taken 6
53branch 4 taken 18 (fallthrough)
54branch 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:}
62function 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;
66branch 0 taken 262097 (fallthrough)
67branch 1 taken 43753
68branch 2 taken 301409 (fallthrough)
69branch 3 taken 4441
70branch 4 taken 294017 (fallthrough)
71branch 5 taken 11833
72branch 6 taken 254817 (fallthrough)
73branch 7 taken 51033
74branch 8 taken 229337 (fallthrough)
75branch 9 taken 76513
76 305850: 40: if (hd%1024 || hd>5120 || !in || in%256 || in>17408 || qh>24 || qh%kv || qh/kv>8 ||
77branch 0 taken 305837 (fallthrough)
78branch 1 taken 13
79branch 2 taken 262156 (fallthrough)
80branch 3 taken 43681
81branch 4 taken 262156 (fallthrough)
82branch 5 taken 0
83branch 6 taken 262144 (fallthrough)
84branch 7 taken 12
85branch 8 taken 258400 (fallthrough)
86branch 9 taken 3744
87branch 10 taken 248448 (fallthrough)
88branch 11 taken 9952
89branch 12 taken 107671 (fallthrough)
90branch 13 taken 140777
91branch 14 taken 71238 (fallthrough)
92branch 15 taken 36433
93branch 16 taken 53436 (fallthrough)
94branch 17 taken 17802
95 305850: 41: (gh!=32 && gh!=48) || qh*256!=gh*128) return 0;
96branch 0 taken 35617 (fallthrough)
97branch 1 taken 17819
98branch 2 taken 47196 (fallthrough)
99branch 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:}
108function 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;
113branch 0 taken 31220 (fallthrough)
114branch 1 taken 480
115branch 2 taken 30739 (fallthrough)
116branch 3 taken 481
117branch 4 taken 28818 (fallthrough)
118branch 5 taken 1921
119branch 6 taken 28810 (fallthrough)
120branch 7 taken 8
121branch 8 taken 25930 (fallthrough)
122branch 9 taken 2880
123branch 10 taken 2881 (fallthrough)
124branch 11 taken 23049
125 23049: 54: if (usemask && layers < 64 && mask >> layers) return 0;
126branch 0 taken 15369 (fallthrough)
127branch 1 taken 7680
128branch 2 taken 15129 (fallthrough)
129branch 3 taken 240
130branch 4 taken 7560 (fallthrough)
131branch 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:}
139function 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:/* Runtime-extent uint view writes directly into the real allocation. */
151function omega_graph_table called 85 returned 100% blocks executed 80%
152 85: 73:static inline void omega_graph_table(unsigned mode, unsigned qh, unsigned kv,
153 -: 74: uint32_t *dst, uint32_t n) {
154 85: 75: uint64_t result = 0;
155 85*: 76: if (omega_grtable(&result, mode, qh, kv, dst, n) != OMEGA_OK || result != 1) abort();
156call 0 returned 85
157branch 1 taken 85 (fallthrough)
158branch 2 taken 0
159branch 3 taken 0 (fallthrough)
160branch 4 taken 85
161call 5 never executed
162 85: 77:}
163function omega_graph_shape called 17 returned 100% blocks executed 100%
164 17: 78:static inline int omega_graph_shape(uint32_t ae, uint32_t an, uint32_t ak,
165 -: 79: uint32_t e, uint32_t n, uint32_t k) {
166 -: 80:#if CUDAPP_MIGRATION_PENDING_GRAPH_RESIDUE
167 17: 81: return ae == e && an == n && ak == k;
168branch 0 taken 5 (fallthrough)
169branch 1 taken 12
170branch 2 taken 2 (fallthrough)
171branch 3 taken 3
172branch 4 taken 1 (fallthrough)
173branch 5 taken 1
174 -: 82:#else
175 -: 83: const uint64_t c[16] = {ae, an, ak, e, n, k}; uint64_t d[16];
176 -: 84: return (int)omega_graph_meta(5, c, d);
177 -: 85:#endif
178 -: 86:}
179 -: 87:#endif