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 / dagsim-parse-om / unpacker.gcov

2315 lines · 116888 bytes Raw Blame History
1 -: 0:Source:tools/dagsim/dagsim.c
2 -: 0:Graph:build/dagsim-parse/parser.gcno
3 -: 0:Data:build/dagsim-parse/parser.gcda
4 -: 0:Runs:9
5 -: 1:/*
6 -: 2: * dagsim.c -- offline resource-DAG cost evaluator (omega-mv#583).
7 -: 3: *
8 -: 4: * See dagsim.h and spec/offline-evidence-v1.md. The scheduler is a
9 -: 5: * deterministic fluid simulation: compute engines have slots, bandwidth
10 -: 6: * resources are shared equally among the ops streaming on them at any
11 -: 7: * instant, launches are serialized per launch resource, and an op finishes
12 -: 8: * when both its own busy time and its traffic are done (perfect overlap
13 -: 9: * inside one op, which is the issue's stated floor max(F/P, Q/B)). Ops are
14 -: 10: * dispatched in file order, so the same file always gives the same bytes.
15 -: 11: */
16 -: 12:#include "dagsim.h"
17 -: 13:#include "runtime/rx_costmodel.h"
18 -: 14:
19 -: 15:#include <ctype.h>
20 -: 16:#include <math.h>
21 -: 17:#include <stdio.h>
22 -: 18:#include <stdlib.h>
23 -: 19:#include <string.h>
24 -: 20:#include <time.h>
25 -: 21:#if !CUDAPP_MIGRATION_PENDING_C_DAGSIM_PARSE
26 -: 22:#include "dagsim_format.h"
27 -: 23:#endif
28 -: 24:
29 -: 25:/* ---------------------------------------------------------------- names */
30 -: 26:
31 -: 27:#if CUDAPP_MIGRATION_PENDING_C_DAGSIM_PARSE
32 -: 28:const char *ds_status_name(int s) {
33 -: 29: switch (s) {
34 -: 30: case DS_OK: return "OK";
35 -: 31: case DS_REFUSED_UNKNOWN: return "REFUSED_UNKNOWN";
36 -: 32: case DS_REFUSED_STALE: return "REFUSED_STALE";
37 -: 33: case DS_REFUSED_NO_CALIBRATION: return "REFUSED_NO_CALIBRATION";
38 -: 34: case DS_REFUSED_CAPACITY: return "REFUSED_CAPACITY";
39 -: 35: case DS_REFUSED_CYCLE: return "REFUSED_CYCLE";
40 -: 36: case DS_REFUSED_UNSUPPORTED: return "REFUSED_UNSUPPORTED";
41 -: 37: case DS_REFUSED_REMOVED_REQUIRED: return "REFUSED_REMOVED_REQUIRED";
42 -: 38: case DS_REFUSED_LIFETIME: return "REFUSED_LIFETIME";
43 -: 39: case DS_PARSE_ERROR: return "PARSE_ERROR";
44 -: 40: default: return "?";
45 -: 41: }
46 -: 42:}
47 -: 43:
48 -: 44:const char *ds_prov_name(int p) {
49 -: 45: switch (p) {
50 -: 46: case DS_PROV_UNKNOWN: return "unknown";
51 -: 47: case DS_PROV_SYNTHETIC: return "synthetic";
52 -: 48: case DS_PROV_FITTED: return "fitted";
53 -: 49: case DS_PROV_MEASURED: return "measured";
54 -: 50: case DS_PROV_SPECIFIED: return "specified";
55 -: 51: default: return "?";
56 -: 52: }
57 -: 53:}
58 -: 54:
59 -: 55:static int prov_from_name(const char *s) {
60 -: 56: if (!strcmp(s, "unknown")) return DS_PROV_UNKNOWN;
61 -: 57: if (!strcmp(s, "synthetic")) return DS_PROV_SYNTHETIC;
62 -: 58: if (!strcmp(s, "fitted")) return DS_PROV_FITTED;
63 -: 59: if (!strcmp(s, "measured")) return DS_PROV_MEASURED;
64 -: 60: if (!strcmp(s, "specified")) return DS_PROV_SPECIFIED;
65 -: 61: return -1;
66 -: 62:}
67 -: 63:
68 -: 64:/* days since 1970-01-01 for a civil date (Howard Hinnant's days_from_civil) */
69 -: 65:int ds_day_from_date(const char *s) {
70 -: 66: int y, m, d;
71 -: 67: if (!s || sscanf(s, "%d-%d-%d", &y, &m, &d) != 3) return -1;
72 -: 68: y -= m <= 2;
73 -: 69: int era = (y >= 0 ? y : y - 399) / 400;
74 -: 70: unsigned yoe = (unsigned)(y - era * 400);
75 -: 71: unsigned doy = (153u * (unsigned)(m + (m > 2 ? -3 : 9)) + 2u) / 5u + (unsigned)d - 1u;
76 -: 72: unsigned doe = yoe * 365u + yoe / 4u - yoe / 100u + doy;
77 -: 73: return era * 146097 + (int)doe - 719468;
78 -: 74:}
79 -: 75:#else
80function ds_status_name called 12 returned 100% blocks executed 100%
81 12: 76:const char *ds_status_name(int s) {
82 -: 77: static _Thread_local char out[256];
83 12: 78: uint64_t a[16] = {(uint32_t)s}; ds_fmt(0, a, out); return out;
84call 0 returned 12
85 -: 79:}
86function ds_prov_name called 7 returned 100% blocks executed 100%
87 7: 80:const char *ds_prov_name(int p) {
88 -: 81: static _Thread_local char out[256];
89 7: 82: uint64_t a[16] = {(uint32_t)p}; ds_fmt(1, a, out); return out;
90call 0 returned 7
91 -: 83:}
92function ds_day_from_date called 73 returned 100% blocks executed 100%
93 73: 84:int ds_day_from_date(const char *s) {
94 73: 85: if (!s) return -1;
95branch 0 taken 73 (fallthrough)
96branch 1 taken 0
97 -: 86: char in[256];
98 73: 87: uint64_t a[16] = {0};
99 81: 88: for (;;) {
100 154: 89: size_t n = strnlen(s, sizeof in);
101call 0 returned 154
102 -: 90: memcpy(in, s, n);
103 154: 91: a[0] = n; a[13] = n < sizeof in;
104 154: 92: uint64_t rc = ds_fmt(21, a, in);
105call 0 returned 154
106 154: 93: if (rc == 1) return (int32_t)a[12];
107branch 0 taken 65 (fallthrough)
108branch 1 taken 89
109 89: 94: if (rc == 2) return -1;
110branch 0 taken 81 (fallthrough)
111branch 1 taken 8
112 81: 95: s += n;
113 -: 96: }
114 -: 97:}
115 -: 98:#endif
116 -: 99:
117function ds_find_op called 0 returned 0% blocks executed 0%
118 #####: 100:int ds_find_op(const ds_model *m, const char *id) {
119 #####: 101: for (int i = 0; i < m->n_ops; i++) if (!strcmp(m->ops[i].id, id)) return i;
120branch 0 never executed (fallthrough)
121branch 1 never executed
122branch 2 never executed
123branch 3 never executed (fallthrough)
124 -: 102: return -1;
125 -: 103:}
126function ds_find_res called 0 returned 0% blocks executed 0%
127 #####: 104:int ds_find_res(const ds_model *m, const char *id) {
128 #####: 105: for (int i = 0; i < m->n_res; i++) if (!strcmp(m->res[i].id, id)) return i;
129branch 0 never executed (fallthrough)
130branch 1 never executed
131branch 2 never executed
132branch 3 never executed (fallthrough)
133 -: 106: return -1;
134 -: 107:}
135 -: 108:
136 -: 109:/* ---------------------------------------------------------------- parse */
137 -: 110:#if CUDAPP_MIGRATION_PENDING_C_DAGSIM_PARSE
138 -: 111:/* bounded string copy; ids and sources are truncated, never overflowed */
139 -: 112:static void sset(char *dst, size_t cap, const char *src) {
140 -: 113: size_t n = strlen(src);
141 -: 114: if (n >= cap) n = cap - 1;
142 -: 115: memcpy(dst, src, n); dst[n] = 0;
143 -: 116:}
144 -: 117:
145 -: 118:
146 -: 119:typedef struct { char key[32]; char val[DS_SRC]; int used; } kv;
147 -: 120:
148 -: 121:static int split_kv(char *line, char *keyword, size_t kwcap, kv *kvs, int maxkv, char *positional[], int *npos) {
149 -: 122: int n = 0; *npos = 0; keyword[0] = 0;
150 -: 123: char *p = strchr(line, '#'); if (p) *p = 0;
151 -: 124: char *save = NULL;
152 -: 125: char *tok = strtok_r(line, " \t\r\n", &save);
153 -: 126: if (!tok) return -1; /* empty */
154 -: 127: snprintf(keyword, kwcap, "%s", tok);
155 -: 128: while ((tok = strtok_r(NULL, " \t\r\n", &save))) {
156 -: 129: char *eq = strchr(tok, '=');
157 -: 130: if (!eq) { if (*npos < 8) positional[(*npos)++] = tok; continue; }
158 -: 131: if (n >= maxkv) return -2;
159 -: 132: *eq = 0;
160 -: 133: sset(kvs[n].key, sizeof kvs[n].key, tok);
161 -: 134: sset(kvs[n].val, sizeof kvs[n].val, eq + 1);
162 -: 135: kvs[n].used = 0;
163 -: 136: n++;
164 -: 137: }
165 -: 138: return n;
166 -: 139:}
167 -: 140:
168 -: 141:static const char *get(kv *kvs, int n, const char *key) {
169 -: 142: for (int i = 0; i < n; i++) if (!strcmp(kvs[i].key, key)) { kvs[i].used = 1; return kvs[i].val; }
170 -: 143: return NULL;
171 -: 144:}
172 -: 145:
173 -: 146:static int unused_key(kv *kvs, int n, char *out, size_t cap) {
174 -: 147: for (int i = 0; i < n; i++) if (!kvs[i].used) { snprintf(out, cap, "%s", kvs[i].key); return 1; }
175 -: 148: return 0;
176 -: 149:}
177 -: 150:
178 -: 151:static int parse_real(const char *s, double *out) {
179 -: 152: if (!s) return 0;
180 -: 153: char *end; double v = strtod(s, &end);
181 -: 154: if (end == s || *end) return 0;
182 -: 155: if (!(v == v) || v < 0) return 0;
183 -: 156: *out = v; return 1;
184 -: 157:}
185 -: 158:
186 -: 159:#define PERR(...) do { snprintf(err, errcap, "line %d: ", lineno); size_t _l = strlen(err); snprintf(err + _l, errcap - _l, __VA_ARGS__); return DS_PARSE_ERROR; } while (0)
187 -: 160:
188 -: 161:static int parse_prov_src(kv *kvs, int n, int *prov, char *src, size_t srccap, int required, char *err, size_t errcap, int lineno) {
189 -: 162: const char *p = get(kvs, n, "prov");
190 -: 163: const char *s = get(kvs, n, "src");
191 -: 164: if (!p) { if (required) PERR("prov= is required wherever a number appears"); *prov = -1; return DS_OK; }
192 -: 165: int v = prov_from_name(p);
193 -: 166: if (v < 0) PERR("prov=%s is not one of specified|measured|fitted|synthetic|unknown", p);
194 -: 167: *prov = v;
195 -: 168: if ((v == DS_PROV_MEASURED || v == DS_PROV_FITTED) && !s) PERR("prov=%s needs src=", p);
196 -: 169: snprintf(src, srccap, "%s", s ? s : "");
197 -: 170: return DS_OK;
198 -: 171:}
199 -: 172:
200 -: 173:int ds_parse_text(const char *text, ds_model *m, char *err, size_t errcap) {
201 -: 174: memset(m, 0, sizeof *m);
202 -: 175: err[0] = 0;
203 -: 176: int lineno = 0;
204 -: 177: const char *cur = text;
205 -: 178: int seen_oev = 0, seen_machine = 0, seen_build = 0;
206 -: 179: /* two-pass is not needed: ops before deps/buffers is the convention; we
207 -: 180: * resolve references at use and require definition before use. */
208 -: 181: while (*cur) {
209 -: 182: const char *nl = strchr(cur, '\n');
210 -: 183: size_t len = nl ? (size_t)(nl - cur) : strlen(cur);
211 -: 184: char line[1024];
212 -: 185: lineno++;
213 -: 186: if (len >= sizeof line) PERR("line too long");
214 -: 187: memcpy(line, cur, len); line[len] = 0;
215 -: 188: cur = nl ? nl + 1 : cur + len;
216 -: 189: char keyword[32]; kv kvs[24]; char *pos[8]; int npos;
217 -: 190: int n = split_kv(line, keyword, sizeof keyword, kvs, 24, pos, &npos);
218 -: 191: if (n == -1) continue;
219 -: 192: if (n == -2) PERR("too many fields");
220 -: 193: if (!strcmp(keyword, "oev")) {
221 -: 194: const char *v = get(kvs, n, "version");
222 -: 195: if (!v || strcmp(v, "1")) PERR("oev version=1 required");
223 -: 196: m->version = 1; seen_oev = 1;
224 -: 197: } else if (!strcmp(keyword, "machine")) {
225 -: 198: const char *v;
226 -: 199: if (!(v = get(kvs, n, "id"))) PERR("machine needs id=");
227 -: 200: sset(m->machine_id, sizeof m->machine_id, v);
228 -: 201: if ((v = get(kvs, n, "soc"))) sset(m->soc, sizeof m->soc, v);
229 -: 202: if ((v = get(kvs, n, "cores"))) m->cores = atoi(v);
230 -: 203: if ((v = get(kvs, n, "mem_bytes")) && !parse_real(v, &m->mem_bytes)) PERR("bad mem_bytes");
231 -: 204: int prov; char src[DS_SRC];
232 -: 205: int rc = parse_prov_src(kvs, n, &prov, src, sizeof src, 1, err, errcap, lineno); if (rc) return rc;
233 -: 206: seen_machine = 1;
234 -: 207: } else if (!strcmp(keyword, "build")) {
235 -: 208: const char *v;
236 -: 209: if ((v = get(kvs, n, "repo"))) sset(m->repo, sizeof m->repo, v);
237 -: 210: if (!(v = get(kvs, n, "sha")) || strlen(v) != 40) PERR("build needs sha=<40 hex>");
238 -: 211: sset(m->build_sha, sizeof m->build_sha, v);
239 -: 212: if ((v = get(kvs, n, "physics"))) sset(m->physics, sizeof m->physics, v);
240 -: 213: seen_build = 1;
241 -: 214: } else if (!strcmp(keyword, "calibration")) {
242 -: 215: const char *v;
243 -: 216: if (m->has_calibration) PERR("one calibration record only");
244 -: 217: if (!(v = get(kvs, n, "id"))) PERR("calibration needs id=");
245 -: 218: sset(m->cal_id, sizeof m->cal_id, v);
246 -: 219: if (!(v = get(kvs, n, "taken")) || (m->cal_taken_day = ds_day_from_date(v)) < 0) PERR("calibration needs taken=YYYY-MM-DD");
247 -: 220: if (!(v = get(kvs, n, "valid_days"))) PERR("calibration needs valid_days=");
248 -: 221: m->cal_valid_days = atoi(v);
249 -: 222: if (!(v = get(kvs, n, "load1")) || !parse_real(v, &m->cal_load1)) PERR("calibration needs load1=");
250 -: 223: if (!(v = get(kvs, n, "src"))) PERR("calibration needs src=");
251 -: 224: sset(m->cal_src, sizeof m->cal_src, v);
252 -: 225: if ((v = get(kvs, n, "model"))) sset(m->cal_model, sizeof m->cal_model, v);
253 -: 226: m->has_calibration = 1;
254 -: 227: } else if (!strcmp(keyword, "resource")) {
255 -: 228: if (m->n_res >= DS_MAX_RES) PERR("too many resources (max %d)", DS_MAX_RES);
256 -: 229: ds_resource *r = &m->res[m->n_res];
257 -: 230: memset(r, 0, sizeof *r);
258 -: 231: const char *v;
259 -: 232: if (!(v = get(kvs, n, "id"))) PERR("resource needs id=");
260 -: 233: if (ds_find_res(m, v) >= 0) PERR("duplicate resource %s", v);
261 -: 234: sset(r->id, sizeof r->id, v);
262 -: 235: if (!(v = get(kvs, n, "kind"))) PERR("resource needs kind=");
263 -: 236: if (!strcmp(v, "compute")) {
264 -: 237: r->kind = DS_RES_COMPUTE;
265 -: 238: if (!(v = get(kvs, n, "slots")) || (r->slots = atoi(v)) < 1) PERR("compute resource needs slots>=1");
266 -: 239: } else if (!strcmp(v, "bandwidth")) {
267 -: 240: r->kind = DS_RES_BANDWIDTH;
268 -: 241: if (!parse_real(get(kvs, n, "cap"), &r->cap) || r->cap <= 0) PERR("bandwidth resource needs cap>0");
269 -: 242: r->lo = r->hi = r->cap;
270 -: 243: if ((v = get(kvs, n, "lo")) && !parse_real(v, &r->lo)) PERR("bad lo");
271 -: 244: if ((v = get(kvs, n, "hi")) && !parse_real(v, &r->hi)) PERR("bad hi");
272 -: 245: if (r->lo > r->cap || r->hi < r->cap) PERR("need lo <= cap <= hi");
273 -: 246: } else if (!strcmp(v, "capacity")) {
274 -: 247: r->kind = DS_RES_CAPACITY;
275 -: 248: if (!parse_real(get(kvs, n, "cap"), &r->cap) || r->cap <= 0) PERR("capacity resource needs cap>0");
276 -: 249: } else if (!strcmp(v, "launch")) {
277 -: 250: r->kind = DS_RES_LAUNCH;
278 -: 251: } else PERR("resource kind=%s unknown", v);
279 -: 252: int rc = parse_prov_src(kvs, n, &r->prov, r->src, sizeof r->src, 1, err, errcap, lineno); if (rc) return rc;
280 -: 253: m->n_res++;
281 -: 254: } else if (!strcmp(keyword, "op")) {
282 -: 255: if (m->n_ops >= DS_MAX_OPS) PERR("too many ops (max %d)", DS_MAX_OPS);
283 -: 256: ds_op *o = &m->ops[m->n_ops];
284 -: 257: memset(o, 0, sizeof *o);
285 -: 258: o->engine = o->bw = o->launcher = -1;
286 -: 259: const char *v;
287 -: 260: if (!(v = get(kvs, n, "id"))) PERR("op needs id=");
288 -: 261: if (ds_find_op(m, v) >= 0) PERR("duplicate op %s", v);
289 -: 262: sset(o->id, sizeof o->id, v);
290 -: 263: if (!(v = get(kvs, n, "kind"))) PERR("op needs kind=");
291 -: 264: if (!strcmp(v, "compute")) o->kind = DS_OP_COMPUTE;
292 -: 265: else if (!strcmp(v, "copy")) o->kind = DS_OP_COPY;
293 -: 266: else if (!strcmp(v, "matvec")) o->kind = DS_OP_MATVEC;
294 -: 267: else if (!strcmp(v, "barrier")) o->kind = DS_OP_BARRIER;
295 -: 268: else if (!strcmp(v, "storage")) o->kind = DS_OP_STORAGE;
296 -: 269: else if (!strcmp(v, "persist")) o->kind = DS_OP_PERSIST;
297 -: 270: else PERR("op kind=%s unknown", v);
298 -: 271: if ((v = get(kvs, n, "engine"))) {
299 -: 272: o->engine = ds_find_res(m, v);
300 -: 273: if (o->engine < 0 || m->res[o->engine].kind != DS_RES_COMPUTE) PERR("engine=%s is not a compute resource defined above", v);
301 -: 274: }
302 -: 275: if ((v = get(kvs, n, "t_ns"))) { if (!parse_real(v, &o->t_ns)) PERR("bad t_ns"); o->has_t = 1; o->lo = o->hi = o->t_ns; }
303 -: 276: if ((v = get(kvs, n, "lo"))) { if (!o->has_t || !parse_real(v, &o->lo) || o->lo > o->t_ns) PERR("lo needs t_ns and lo <= t_ns"); }
304 -: 277: if ((v = get(kvs, n, "hi"))) { if (!o->has_t || !parse_real(v, &o->hi) || o->hi < o->t_ns) PERR("hi needs t_ns and hi >= t_ns"); }
305 -: 278: if ((v = get(kvs, n, "bytes"))) {
306 -: 279: if (!parse_real(v, &o->bytes)) PERR("bad bytes");
307 -: 280: const char *b = get(kvs, n, "bw");
308 -: 281: if (!b || (o->bw = ds_find_res(m, b)) < 0 || m->res[o->bw].kind != DS_RES_BANDWIDTH) PERR("bytes= needs bw=<bandwidth resource defined above>");
309 -: 282: }
310 -: 283: if ((v = get(kvs, n, "launch_ns"))) {
311 -: 284: if (!parse_real(v, &o->launch_ns)) PERR("bad launch_ns");
312 -: 285: const char *l = get(kvs, n, "launcher");
313 -: 286: if (!l || (o->launcher = ds_find_res(m, l)) < 0 || m->res[o->launcher].kind != DS_RES_LAUNCH) PERR("launch_ns= needs launcher=<launch resource defined above>");
314 -: 287: }
315 -: 288: if ((v = get(kvs, n, "M"))) o->M = (uint32_t)strtoul(v, NULL, 10);
316 -: 289: if ((v = get(kvs, n, "N"))) o->N = (uint32_t)strtoul(v, NULL, 10);
317 -: 290: if ((v = get(kvs, n, "core"))) o->core = (uint32_t)strtoul(v, NULL, 10);
318 -: 291: if ((v = get(kvs, n, "arm"))) o->arm = (uint32_t)strtoul(v, NULL, 10);
319 -: 292: if (o->kind == DS_OP_MATVEC && !o->has_t && (o->M == 0 || o->N == 0)) PERR("matvec needs M= and N= (or t_ns=)");
320 -: 293: if (o->kind != DS_OP_BARRIER && o->engine < 0) PERR("op %s needs engine=", o->id);
321 -: 294: int required = o->has_t || o->bytes > 0 || o->launch_ns > 0 || o->kind == DS_OP_MATVEC;
322 -: 295: int rc = parse_prov_src(kvs, n, &o->t_prov, o->src, sizeof o->src, required, err, errcap, lineno); if (rc) return rc;
323 -: 296: if (o->t_prov < 0) o->t_prov = DS_PROV_SPECIFIED; /* a costless barrier: ordering only */
324 -: 297: if (!o->has_t && o->kind != DS_OP_MATVEC && o->t_prov == DS_PROV_UNKNOWN) { /* fine: explicitly unknown */ }
325 -: 298: m->n_ops++;
326 -: 299: } else if (!strcmp(keyword, "dep")) {
327 -: 300: if (npos != 2 || n != 0) PERR("dep <from> <to>");
328 -: 301: if (m->n_deps >= DS_MAX_DEPS) PERR("too many deps");
329 -: 302: int a = ds_find_op(m, pos[0]), b = ds_find_op(m, pos[1]);
330 -: 303: if (a < 0 || b < 0) PERR("dep names an op not defined above: %s %s", pos[0], pos[1]);
331 -: 304: m->deps[m->n_deps].from = a; m->deps[m->n_deps].to = b; m->n_deps++;
332 -: 305: } else if (!strcmp(keyword, "buffer")) {
333 -: 306: if (m->n_buf >= DS_MAX_BUF) PERR("too many buffers");
334 -: 307: ds_buffer *b = &m->buf[m->n_buf];
335 -: 308: memset(b, 0, sizeof *b); b->first = b->last = -1;
336 -: 309: const char *v;
337 -: 310: if (!(v = get(kvs, n, "id"))) PERR("buffer needs id=");
338 -: 311: sset(b->id, sizeof b->id, v);
339 -: 312: if (!parse_real(get(kvs, n, "bytes"), &b->bytes) || !isfinite(b->bytes))
340 -: 313: PERR("buffer bytes must be a finite number >= 0");
341 -: 314: if (!(v = get(kvs, n, "cap")) || (b->cap = ds_find_res(m, v)) < 0 || m->res[b->cap].kind != DS_RES_CAPACITY) PERR("buffer needs cap=<capacity resource>");
342 -: 315: if ((v = get(kvs, n, "first")) && (b->first = ds_find_op(m, v)) < 0) PERR("first=%s not an op", v);
343 -: 316: if ((v = get(kvs, n, "last")) && (b->last = ds_find_op(m, v)) < 0) PERR("last=%s not an op", v);
344 -: 317: m->n_buf++;
345 -: 318: } else if (!strcmp(keyword, "sync")) {
346 -: 319: /* a barrier op that depends on every listed op */
347 -: 320: if (m->n_ops >= DS_MAX_OPS) PERR("too many ops");
348 -: 321: const char *v, *list;
349 -: 322: if (!(v = get(kvs, n, "id"))) PERR("sync needs id=");
350 -: 323: if (ds_find_op(m, v) >= 0) PERR("duplicate op %s", v);
351 -: 324: if (!(list = get(kvs, n, "ops"))) PERR("sync needs ops=a,b,...");
352 -: 325: ds_op *o = &m->ops[m->n_ops];
353 -: 326: memset(o, 0, sizeof *o);
354 -: 327: o->engine = o->bw = o->launcher = -1; o->kind = DS_OP_BARRIER; o->t_prov = DS_PROV_SPECIFIED;
355 -: 328: sset(o->id, sizeof o->id, v);
356 -: 329: int self = m->n_ops++;
357 -: 330: char tmp[DS_SRC]; sset(tmp, sizeof tmp, list);
358 -: 331: char *save = NULL;
359 -: 332: for (char *t = strtok_r(tmp, ",", &save); t; t = strtok_r(NULL, ",", &save)) {
360 -: 333: int a = ds_find_op(m, t);
361 -: 334: if (a < 0 || a == self) PERR("sync lists unknown op %s", t);
362 -: 335: if (m->n_deps >= DS_MAX_DEPS) PERR("too many deps");
363 -: 336: m->deps[m->n_deps].from = a; m->deps[m->n_deps].to = self; m->n_deps++;
364 -: 337: }
365 -: 338: } else if (!strcmp(keyword, "energy")) {
366 -: 339: const char *v;
367 -: 340: if (m->has_energy) PERR("one energy record only");
368 -: 341: if (!(v = get(kvs, n, "instrument"))) PERR("energy needs instrument=");
369 -: 342: sset(m->instrument, sizeof m->instrument, v);
370 -: 343: if ((v = get(kvs, n, "boundary"))) sset(m->boundary, sizeof m->boundary, v);
371 -: 344: const char *j = get(kvs, n, "joules"), *pw = get(kvs, n, "power_w");
372 -: 345: int prov = -1; char src[DS_SRC];
373 -: 346: int rc = parse_prov_src(kvs, n, &prov, src, sizeof src, j || pw ? 1 : 0, err, errcap, lineno); if (rc) return rc;
374 -: 347: m->energy_prov = prov;
375 -: 348: if (j) {
376 -: 349: if (!strcmp(m->instrument, "none") || !m->boundary[0]) PERR("joules= needs a named instrument and boundary=");
377 -: 350: if (prov != DS_PROV_MEASURED) PERR("joules= must be prov=measured with src=");
378 -: 351: if (!parse_real(j, &m->joules)) PERR("bad joules");
379 -: 352: }
380 -: 353: if (pw) {
381 -: 354: if (prov != DS_PROV_SYNTHETIC) PERR("power_w= is allowed only as prov=synthetic (a sensitivity figure); measured power must be integrated into joules= by the instrument");
382 -: 355: if (!parse_real(pw, &m->power_w)) PERR("bad power_w");
383 -: 356: }
384 -: 357: m->has_energy = 1;
385 -: 358: } else if (!strcmp(keyword, "removed")) {
386 -: 359: if (m->n_removed >= DS_MAX_REMOVED) PERR("too many removed records");
387 -: 360: ds_removed *r = &m->removed[m->n_removed];
388 -: 361: memset(r, 0, sizeof *r);
389 -: 362: const char *v;
390 -: 363: if (!(v = get(kvs, n, "op"))) PERR("removed needs op=");
391 -: 364: sset(r->op, sizeof r->op, v);
392 -: 365: if (ds_find_op(m, v) >= 0) PERR("removed op %s is still present in this DAG", v);
393 -: 366: if (!(v = get(kvs, n, "reason"))) PERR("removed needs reason=");
394 -: 367: if (!strcmp(v, "eliminated")) r->reason = DS_RM_ELIMINATED;
395 -: 368: else if (!strcmp(v, "reused")) r->reason = DS_RM_REUSED;
396 -: 369: else if (!strcmp(v, "unchanged_dep")) r->reason = DS_RM_UNCHANGED_DEP;
397 -: 370: else if (!strcmp(v, "deferred")) r->reason = DS_RM_DEFERRED;
398 -: 371: else if (!strcmp(v, "moved")) r->reason = DS_RM_MOVED;
399 -: 372: else if (!strcmp(v, "shared")) r->reason = DS_RM_SHARED;
400 -: 373: else if (!strcmp(v, "lookup")) r->reason = DS_RM_LOOKUP;
401 -: 374: else PERR("removed reason=%s unknown", v);
402 -: 375: if ((v = get(kvs, n, "ref"))) sset(r->ref, sizeof r->ref, v);
403 -: 376: if ((v = get(kvs, n, "proof"))) sset(r->proof, sizeof r->proof, v);
404 -: 377: m->n_removed++;
405 -: 378: } else PERR("unknown record '%s'", keyword);
406 -: 379: char bad[32];
407 -: 380: if (unused_key(kvs, n, bad, sizeof bad)) PERR("unknown field %s= on '%s'", bad, keyword);
408 -: 381: }
409 -: 382: lineno = 0;
410 -: 383: if (!seen_oev) PERR("missing 'oev version=1'");
411 -: 384: if (!seen_machine) PERR("missing machine record");
412 -: 385: if (!seen_build) PERR("missing build record");
413 -: 386: if (!m->has_energy) PERR("missing energy record (use instrument=none for UNMEASURED)");
414 -: 387: return DS_OK;
415 -: 388:}
416 -: 389:#else
417 -: 390:/* Copy only the already-bounded source spans selected by the Omega parser. */
418function dp_copy called 43643 returned 100% blocks executed 100%
419 43643: 391:static void dp_copy(char *dst, const unsigned char *text, const uint64_t *w, size_t i) {
420 43643: 392: memcpy(dst, text + w[i], (size_t)w[i + 1]);
421 43643: 393: dst[w[i + 1]] = 0;
422 43643: 394:}
423 -: 395:static double dp_double(const uint64_t *w, size_t i) {
424 13359: 396: return ds_unbits(w[i]);
425 -: 397:}
426function ds_parse_text called 3445 returned 100% blocks executed 92%
427 3445: 398:int ds_parse_text(const char *text, ds_model *m, char *err, size_t errcap) {
428branch 0 taken 3445 (fallthrough)
429branch 1 taken 0
430 -: 399: memset(m, 0, sizeof *m);
431 3445: 400: if (errcap) err[0] = 0;
432branch 0 taken 3445 (fallthrough)
433branch 1 taken 0
434 3445: 401: size_t n = strnlen(text, 1048576);
435 3445: 402: if (n == 1048576) {
436branch 0 taken 14 (fallthrough)
437branch 1 taken 3431
438 14: 403: if (errcap) snprintf(err, errcap, "file size out of range");
439branch 0 taken 14 (fallthrough)
440branch 1 taken 0
441 14: 404: return DS_PARSE_ERROR;
442 -: 405: }
443 3431: 406: unsigned char *t = malloc(1048576);
444 3431: 407: uint64_t *w = malloc(16384 * sizeof *w);
445 3431: 408: if (!t || !w) {
446branch 0 taken 0 (fallthrough)
447branch 1 taken 3431
448 #####: 409: free(t); free(w);
449 #####: 410: if (errcap) snprintf(err, errcap, "out of memory");
450branch 0 never executed (fallthrough)
451branch 1 never executed
452 #####: 411: return DS_PARSE_ERROR;
453 -: 412: }
454 3431: 413: memcpy(t, text, n + 1);
455call 0 returned 3431
456 3431: 414: unsigned char error[256] = {0};
457 3431: 415: uint64_t rc = 0;
458 3431: 416: uint32_t trap = omega_dag_parse(&rc, t, 1048576, n, w, 16384, error, 256);
459call 0 returned 3431
460 3431: 417: if (trap || rc) {
461branch 0 taken 3431 (fallthrough)
462branch 1 taken 0
463branch 2 taken 2099 (fallthrough)
464branch 3 taken 1332
465 2099: 418: if (errcap) snprintf(err, errcap, "%s", trap ? "Omega parser trap" : (char *)error);
466branch 0 taken 2099 (fallthrough)
467branch 1 taken 0
468branch 2 taken 0 (fallthrough)
469branch 3 taken 2099
470 2099: 419: free(t); free(w); return DS_PARSE_ERROR;
471 -: 420: }
472 1332: 421: m->version = (int32_t)w[0]; m->cores = (int32_t)w[1];
473 1332: 422: m->mem_bytes = dp_double(w, 2); m->has_calibration = (int32_t)w[3];
474 1332: 423: m->cal_taken_day = (int32_t)w[4]; m->cal_valid_days = (int32_t)w[5];
475 1332: 424: m->cal_load1 = dp_double(w, 6); m->has_energy = (int32_t)w[7];
476 1332: 425: m->joules = dp_double(w, 8); m->power_w = dp_double(w, 9);
477 1332: 426: m->energy_prov = (int32_t)w[10];
478 1332: 427: m->n_res = (int32_t)w[11]; m->n_ops = (int32_t)w[12];
479 1332: 428: m->n_buf = (int32_t)w[13]; m->n_deps = (int32_t)w[14]; m->n_removed = (int32_t)w[15];
480 1332: 429: dp_copy(m->machine_id, t, w, 17); dp_copy(m->soc, t, w, 19);
481call 0 returned 1332
482call 1 returned 1332
483 1332: 430: dp_copy(m->repo, t, w, 21); dp_copy(m->build_sha, t, w, 23);
484call 0 returned 1332
485call 1 returned 1332
486 1332: 431: dp_copy(m->physics, t, w, 25); dp_copy(m->cal_id, t, w, 27);
487call 0 returned 1332
488call 1 returned 1332
489 1332: 432: dp_copy(m->cal_src, t, w, 29); dp_copy(m->cal_model, t, w, 31);
490call 0 returned 1332
491call 1 returned 1332
492 1332: 433: dp_copy(m->instrument, t, w, 33); dp_copy(m->boundary, t, w, 35);
493call 0 returned 1332
494call 1 returned 1332
495 5420: 434: for (int i = 0; i < m->n_res; i++) {
496branch 0 taken 4088
497branch 1 taken 1332
498 4088: 435: ds_resource *r = &m->res[i]; const uint64_t *p = w + 64 + i * 12;
499 4088: 436: dp_copy(r->id, t, p, 0); r->kind = (int32_t)p[2]; r->slots = (int32_t)p[3];
500call 0 returned 4088
501 4088: 437: r->cap = dp_double(p, 4); r->lo = dp_double(p, 5); r->hi = dp_double(p, 6);
502 4088: 438: r->prov = (int32_t)p[7]; dp_copy(r->src, t, p, 8);
503call 0 returned 4088
504 -: 439: }
505 6048: 440: for (int i = 0; i < m->n_ops; i++) {
506branch 0 taken 4716
507branch 1 taken 1332
508 4716: 441: ds_op *o = &m->ops[i]; const uint64_t *p = w + 448 + i * 26;
509 4716: 442: dp_copy(o->id, t, p, 0); o->kind = (int32_t)p[2]; o->engine = (int32_t)p[3];
510call 0 returned 4716
511 4716: 443: o->t_ns = dp_double(p, 4); o->lo = dp_double(p, 5); o->hi = dp_double(p, 6);
512 4716: 444: o->t_prov = (int32_t)p[7]; o->has_t = (int32_t)p[8]; o->bytes = dp_double(p, 9);
513 4716: 445: o->bw = (int32_t)p[10]; o->launch_ns = dp_double(p, 11); o->launcher = (int32_t)p[12];
514 4716: 446: o->M = (uint32_t)p[13]; o->N = (uint32_t)p[14]; o->core = (uint32_t)p[15]; o->arm = (uint32_t)p[16];
515 4716: 447: dp_copy(o->src, t, p, 17);
516call 0 returned 4716
517 -: 448: }
518 13678: 449: for (int i = 0; i < m->n_deps; i++) {
519branch 0 taken 12346
520branch 1 taken 1332
521 12346: 450: m->deps[i].from = (int32_t)w[7104 + i * 2];
522 12346: 451: m->deps[i].to = (int32_t)w[7105 + i * 2];
523 -: 452: }
524 4555: 453: for (int i = 0; i < m->n_buf; i++) {
525branch 0 taken 3223
526branch 1 taken 1332
527 3223: 454: ds_buffer *b = &m->buf[i]; const uint64_t *p = w + 9152 + i * 8;
528 3223: 455: dp_copy(b->id, t, p, 0); b->bytes = dp_double(p, 2); b->cap = (int32_t)p[3];
529call 0 returned 3223
530 3223: 456: b->first = (int32_t)p[4]; b->last = (int32_t)p[5];
531 -: 457: }
532 4496: 458: for (int i = 0; i < m->n_removed; i++) {
533branch 0 taken 3164
534branch 1 taken 1332 (fallthrough)
535 3164: 459: ds_removed *r = &m->removed[i]; const uint64_t *p = w + 11200 + i * 8;
536 3164: 460: dp_copy(r->op, t, p, 0); r->reason = (int32_t)p[2];
537call 0 returned 3164
538 3164: 461: dp_copy(r->ref, t, p, 3); dp_copy(r->proof, t, p, 5);
539call 0 returned 3164
540call 1 returned 3164
541 -: 462: }
542 1332: 463: free(t); free(w);
543 1332: 464: return DS_OK;
544 -: 465:}
545 -: 466:#endif
546 -: 467:
547function ds_parse_file called 0 returned 0% blocks executed 0%
548 #####: 468:int ds_parse_file(const char *path, ds_model *m, char *err, size_t errcap) {
549 #####: 469: FILE *fp = fopen(path, "r");
550call 0 never executed
551 #####: 470: if (!fp) { snprintf(err, errcap, "cannot open %s", path); return DS_PARSE_ERROR; }
552branch 0 never executed (fallthrough)
553branch 1 never executed
554 #####: 471: fseek(fp, 0, SEEK_END); long n = ftell(fp); fseek(fp, 0, SEEK_SET);
555call 0 never executed
556call 1 never executed
557call 2 never executed
558 #####: 472: if (n < 0 || n > (1 << 20)) { fclose(fp); snprintf(err, errcap, "file size out of range"); return DS_PARSE_ERROR; }
559branch 0 never executed (fallthrough)
560branch 1 never executed
561call 2 never executed
562 #####: 473: char *buf = malloc((size_t)n + 1);
563 #####: 474: if (!buf) { fclose(fp); snprintf(err, errcap, "out of memory"); return DS_PARSE_ERROR; }
564branch 0 never executed (fallthrough)
565branch 1 never executed
566call 2 never executed
567 #####: 475: size_t got = fread(buf, 1, (size_t)n, fp); buf[got] = 0; fclose(fp);
568call 0 never executed
569 #####: 476: int rc = ds_parse_text(buf, m, err, errcap);
570call 0 never executed
571 #####: 477: free(buf);
572 #####: 478: return rc;
573 -: 479:}
574 -: 480:
575 -: 481:/* ---------------------------------------------------------------- evaluate */
576 -: 482:
577 -: 483:/* resolved per-op numbers for one evaluation mode */
578 -: 484:typedef struct { double t, launch, bytes, cap; int prov; } ds_num; /* cap in B/ns */
579 -: 485:
580 -: 486:static double res_cap(const ds_resource *r, int mode) {
581 #####: 487: if (mode < 0) return r->lo;
582 #####: 488: if (mode > 0) return r->hi;
583branch 0 never executed (fallthrough)
584branch 1 never executed
585 #####: 489: return r->cap;
586 -: 490:}
587 -: 491:
588function refuse called 0 returned 0% blocks executed 0%
589 #####: 492:static int refuse(ds_result *r, int status, const char *fmt, const char *a, const char *b) {
590branch 0 never executed (fallthrough)
591branch 1 never executed
592 -: 493: memset(r, 0, sizeof *r);
593 #####: 494: r->status = status;
594 #####: 495: snprintf(r->reason, sizeof r->reason, fmt, a ? a : "", b ? b : "");
595branch 0 never executed (fallthrough)
596branch 1 never executed
597branch 2 never executed (fallthrough)
598branch 3 never executed
599 #####: 496: return status;
600 -: 497:}
601 -: 498:
602function refuse_msg called 0 returned 0% blocks executed 0%
603 #####: 499:static int refuse_msg(ds_result *r, int status, const char *msg) {
604branch 0 never executed (fallthrough)
605branch 1 never executed
606 -: 500: memset(r, 0, sizeof *r);
607 #####: 501: r->status = status;
608 #####: 502: snprintf(r->reason, sizeof r->reason, "%s", msg ? msg : "");
609branch 0 never executed (fallthrough)
610branch 1 never executed
611 #####: 503: return status;
612 -: 504:}
613 -: 505:
614 -: 506:/* An unsupported operation and a refused prediction are the same as an
615 -: 507: * unknown cell: no certificate. known alone is not enough. */
616 -: 508:static int predict_unusable(int st, const RxCmPrediction *p) {
617 #####: 509: return st == RX_CM_ERR_UNSUPPORTED || p->refused || !p->known || p->n == 0; /* PREDICT_REFUSAL_CHECK */
618branch 0 never executed (fallthrough)
619branch 1 never executed
620branch 2 never executed (fallthrough)
621branch 3 never executed
622branch 4 never executed
623branch 5 never executed (fallthrough)
624branch 6 never executed
625branch 7 never executed (fallthrough)
626 -: 510:}
627 -: 511:
628function resolve called 0 returned 0% blocks executed 0%
629 #####: 512:static int resolve(const ds_model *m, const ds_opts *o, ds_num *num, ds_result *r) {
630 -: 513: int any_cal = 0;
631 #####: 514: for (int i = 0; i < m->n_res; i++) {
632branch 0 never executed
633branch 1 never executed
634 #####: 515: if (m->res[i].prov == DS_PROV_UNKNOWN) return refuse(r, DS_REFUSED_UNKNOWN, "resource %s has prov=unknown; unknown stays unknown%s", m->res[i].id, "");
635branch 0 never executed (fallthrough)
636branch 1 never executed
637call 2 never executed
638 #####: 516: if (m->res[i].prov == DS_PROV_MEASURED || m->res[i].prov == DS_PROV_FITTED) any_cal = 1;
639branch 0 never executed (fallthrough)
640branch 1 never executed
641 -: 517: }
642 #####: 518: for (int i = 0; i < m->n_ops; i++) {
643branch 0 never executed
644branch 1 never executed (fallthrough)
645 -: 519: const ds_op *op = &m->ops[i];
646 #####: 520: ds_num *x = &num[i];
647branch 0 never executed (fallthrough)
648branch 1 never executed
649 -: 521: memset(x, 0, sizeof *x);
650 #####: 522: x->prov = op->t_prov;
651 #####: 523: x->launch = op->launch_ns;
652 #####: 524: x->bytes = op->bytes;
653 #####: 525: x->cap = op->bw >= 0 ? res_cap(&m->res[op->bw], o->mode) * 1e-9 : 0; /* B/s -> B/ns */
654branch 0 never executed (fallthrough)
655branch 1 never executed
656branch 2 never executed (fallthrough)
657branch 3 never executed
658 #####: 526: if (op->kind == DS_OP_MATVEC && !op->has_t) {
659branch 0 never executed (fallthrough)
660branch 1 never executed
661branch 2 never executed (fallthrough)
662branch 3 never executed
663 #####: 527: const RxCostModel *cm = (const RxCostModel *)o->costmodel;
664 #####: 528: if (!cm) return refuse(r, DS_REFUSED_UNKNOWN, "op %s is a matvec with no rx_costmodel blob supplied (calibration model=)%s", op->id, "");
665branch 0 never executed (fallthrough)
666branch 1 never executed
667call 2 never executed
668 -: 529: RxCmFeatures f; memset(&f, 0, sizeof f);
669 #####: 530: f.op = RX_CM_OP_MATVEC; f.M = op->M; f.N = op->N;
670 #####: 531: f.state_bytes = ((uint64_t)op->M * op->N + op->M + op->N) * 8u;
671 #####: 532: f.cache_bytes = 1u << 20; f.core = op->core; f.eligible = 1u << op->arm; f.current_arm = op->arm;
672 -: 533: RxCmPrediction p;
673 #####: 534: int st = rx_cm_predict(cm, &f, op->arm, &p);
674call 0 never executed
675 #####: 535: if (predict_unusable(st, &p)) return refuse(r, DS_REFUSED_UNKNOWN, "op %s: rx_costmodel has no known cell for this (op, core, pressure) and arm; measure it first%s", op->id, "");
676call 0 never executed
677 #####: 536: double q = o->interval_q > 0 && o->interval_q < 1 ? o->interval_q : 0.9;
678branch 0 never executed (fallthrough)
679branch 1 never executed
680branch 2 never executed (fallthrough)
681branch 3 never executed
682 #####: 537: double k = rx_cm_t_quantile(q, p.dof);
683call 0 never executed
684 #####: 538: double l2 = p.mean_log2_ps + (o->mode < 0 ? k * p.sd_log2 : o->mode > 0 ? -k * p.sd_log2 : 0);
685branch 0 never executed (fallthrough)
686branch 1 never executed
687branch 2 never executed (fallthrough)
688branch 3 never executed
689 #####: 539: x->t = pow(2.0, l2) / 1000.0; /* ps -> ns */
690 #####: 540: x->prov = DS_PROV_FITTED;
691 -: 541: any_cal = 1;
692 -: 542: } else {
693 #####: 543: if (op->t_prov == DS_PROV_UNKNOWN) return refuse(r, DS_REFUSED_UNKNOWN, "op %s has prov=unknown (%s); unknown stays unknown", op->id, op->src[0] ? op->src : "no source");
694branch 0 never executed (fallthrough)
695branch 1 never executed
696branch 2 never executed (fallthrough)
697branch 3 never executed
698call 4 never executed
699 #####: 544: x->t = o->mode < 0 ? op->hi : o->mode > 0 ? op->lo : op->t_ns;
700branch 0 never executed (fallthrough)
701branch 1 never executed
702branch 2 never executed (fallthrough)
703branch 3 never executed
704 #####: 545: if (op->t_prov == DS_PROV_MEASURED || op->t_prov == DS_PROV_FITTED) any_cal = 1;
705branch 0 never executed
706branch 1 never executed (fallthrough)
707 -: 546: }
708 #####: 547: if (op->engine < 0 && op->kind != DS_OP_BARRIER) return refuse(r, DS_REFUSED_UNSUPPORTED, "op %s has no engine%s", op->id, "");
709branch 0 never executed (fallthrough)
710branch 1 never executed
711branch 2 never executed (fallthrough)
712branch 3 never executed
713call 4 never executed
714 #####: 548: if (op->launcher >= 0 && op->engine < 0) return refuse(r, DS_REFUSED_UNSUPPORTED, "op %s: launch without an engine%s", op->id, "");
715branch 0 never executed (fallthrough)
716branch 1 never executed
717branch 2 never executed (fallthrough)
718branch 3 never executed
719call 4 never executed
720 -: 549: }
721 #####: 550: if (any_cal) {
722branch 0 never executed (fallthrough)
723branch 1 never executed
724 #####: 551: if (!m->has_calibration) return refuse(r, DS_REFUSED_NO_CALIBRATION, "measured or fitted values need a calibration record naming when and under what load they were taken%s%s", "", "");
725branch 0 never executed (fallthrough)
726branch 1 never executed
727call 2 never executed
728 #####: 552: int asof = o->asof_day;
729 #####: 553: if (asof <= 0) asof = (int)(time(NULL) / 86400);
730branch 0 never executed (fallthrough)
731branch 1 never executed
732call 2 never executed
733 #####: 554: if (asof > m->cal_taken_day + m->cal_valid_days) {
734branch 0 never executed (fallthrough)
735branch 1 never executed
736 #####: 555: char d[64]; snprintf(d, sizeof d, "asof is %d day(s) past the validity envelope", asof - m->cal_taken_day - m->cal_valid_days);
737call 0 never executed
738 #####: 556: return refuse(r, DS_REFUSED_STALE, "calibration %s is stale: %s", m->cal_id, d);
739call 0 never executed
740 -: 557: }
741 -: 558: }
742 -: 559: return DS_OK;
743 -: 560:}
744 -: 561:
745 -: 562:static void pk_d(uint64_t *dst, double x) {
746 -: 563: uint64_t b;
747 -: 564: memcpy(&b, &x, 8);
748 #####: 565: *dst = b;
749 -: 566:}
750 -: 567:
751 -: 568:/* Pack post-resolve numbers for omega_dag_eval. Refusal strings stay in C. */
752function ds_resolved_pack called 0 returned 0% blocks executed 0%
753 #####: 569:int ds_resolved_pack(const ds_model *m, const ds_opts *o, uint64_t *model, ds_result *r) {
754 #####: 570: if (m->n_ops == 0) return refuse(r, DS_REFUSED_UNSUPPORTED, "empty DAG%s%s", "", "");
755branch 0 never executed (fallthrough)
756branch 1 never executed
757call 2 never executed
758 -: 571: ds_num num[DS_MAX_OPS];
759 #####: 572: int rc = resolve(m, o, num, r);
760call 0 never executed
761 #####: 573: if (rc) return rc;
762branch 0 never executed (fallthrough)
763branch 1 never executed
764 -: 574: memset(model, 0, 8192 * sizeof *model);
765 #####: 575: model[0] = (uint64_t)m->n_ops;
766 #####: 576: model[1] = (uint64_t)m->n_res;
767 #####: 577: model[2] = (uint64_t)m->n_deps;
768 #####: 578: model[3] = (uint64_t)m->n_buf;
769 #####: 579: model[4] = m->has_energy ? 1u : 0u;
770branch 0 never executed (fallthrough)
771branch 1 never executed
772 #####: 580: pk_d(&model[5], m->joules);
773branch 0 never executed (fallthrough)
774branch 1 never executed
775 #####: 581: pk_d(&model[6], m->power_w);
776 #####: 582: model[7] = (uint64_t)m->energy_prov;
777 #####: 583: model[8] = strcmp(m->instrument, "none") == 0 ? 1u : 0u;
778branch 0 never executed (fallthrough)
779branch 1 never executed
780 #####: 584: model[9] = 1u;
781 #####: 585: for (int i = 0; i < m->n_ops; i++) {
782branch 0 never executed
783branch 1 never executed
784 #####: 586: uint64_t *p = &model[32 + i * 10];
785 #####: 587: pk_d(&p[0], num[i].t);
786 #####: 588: pk_d(&p[1], num[i].bytes);
787 #####: 589: pk_d(&p[2], num[i].launch);
788 #####: 590: pk_d(&p[3], num[i].cap);
789 #####: 591: p[4] = (uint64_t)(int64_t)m->ops[i].engine;
790 #####: 592: p[5] = (uint64_t)(int64_t)m->ops[i].bw;
791 #####: 593: p[6] = (uint64_t)(int64_t)m->ops[i].launcher;
792 #####: 594: p[7] = (uint64_t)m->ops[i].kind;
793 #####: 595: p[8] = (uint64_t)num[i].prov;
794 -: 596: }
795 #####: 597: for (int i = 0; i < m->n_res; i++) {
796branch 0 never executed
797branch 1 never executed
798 #####: 598: uint64_t *p = &model[2592 + i * 4];
799 #####: 599: p[0] = (uint64_t)m->res[i].kind;
800 #####: 600: p[1] = (uint64_t)m->res[i].slots;
801 #####: 601: pk_d(&p[2], m->res[i].cap);
802 #####: 602: p[3] = (uint64_t)m->res[i].prov;
803 -: 603: }
804 #####: 604: for (int i = 0; i < m->n_deps; i++) {
805branch 0 never executed
806branch 1 never executed
807 #####: 605: uint64_t *p = &model[2720 + i * 2];
808 #####: 606: p[0] = (uint64_t)m->deps[i].from;
809 #####: 607: p[1] = (uint64_t)m->deps[i].to;
810 -: 608: }
811 #####: 609: for (int i = 0; i < m->n_buf; i++) {
812branch 0 never executed
813branch 1 never executed (fallthrough)
814 #####: 610: uint64_t *p = &model[4768 + i * 4];
815 #####: 611: pk_d(&p[0], m->buf[i].bytes);
816 #####: 612: p[1] = (uint64_t)m->buf[i].cap;
817 #####: 613: p[2] = (uint64_t)(int64_t)m->buf[i].first;
818 #####: 614: p[3] = (uint64_t)(int64_t)m->buf[i].last;
819 -: 615: }
820 -: 616: return DS_OK;
821 -: 617:}
822 -: 618:
823 -: 619:/* Kahn topological order; returns 0 on a cycle */
824function topo called 0 returned 0% blocks executed 0%
825 #####: 620:static int topo(const ds_model *m, int *order) {
826 #####: 621: int indeg[DS_MAX_OPS] = {0};
827 #####: 622: for (int i = 0; i < m->n_deps; i++) indeg[m->deps[i].to]++;
828branch 0 never executed
829branch 1 never executed (fallthrough)
830 -: 623: int n = 0, head = 0;
831 #####: 624: for (int i = 0; i < m->n_ops; i++) if (indeg[i] == 0) order[n++] = i;
832branch 0 never executed (fallthrough)
833branch 1 never executed
834branch 2 never executed
835branch 3 never executed (fallthrough)
836 #####: 625: while (head < n) {
837branch 0 never executed
838branch 1 never executed (fallthrough)
839 #####: 626: int u = order[head++];
840 #####: 627: for (int i = 0; i < m->n_deps; i++) if (m->deps[i].from == u && --indeg[m->deps[i].to] == 0) order[n++] = m->deps[i].to;
841branch 0 never executed (fallthrough)
842branch 1 never executed
843branch 2 never executed
844branch 3 never executed (fallthrough)
845branch 4 never executed
846branch 5 never executed (fallthrough)
847 -: 628: }
848 #####: 629: return n == m->n_ops;
849 -: 630:}
850 -: 631:
851 -: 632:enum { ST_WAIT = 0, ST_READY, ST_LAUNCH, ST_RUN, ST_DONE };
852 -: 633:enum { BLK_NONE = 0, BLK_SLOT, BLK_LAUNCHER };
853 -: 634:
854 -: 635:/* Half-open [start, end). Missing first -> 0; missing last -> makespan. */
855 -: 636:static void buffer_window(const ds_model *m, const ds_result *r, int b, double *s, double *e) {
856 #####: 637: *s = m->buf[b].first >= 0 ? r->start_ns[m->buf[b].first] : 0.0;
857branch 0 never executed (fallthrough)
858branch 1 never executed
859branch 2 never executed (fallthrough)
860branch 3 never executed
861branch 4 never executed (fallthrough)
862branch 5 never executed
863 #####: 638: *e = m->buf[b].last >= 0 ? r->end_ns[m->buf[b].last] : r->makespan_ns;
864branch 0 never executed (fallthrough)
865branch 1 never executed
866branch 2 never executed (fallthrough)
867branch 3 never executed
868branch 4 never executed (fallthrough)
869branch 5 never executed
870 -: 639:}
871 -: 640:
872 -: 641:static const char *endpoint_name(const ds_model *m, int op) {
873 #####: 642: return op >= 0 ? m->ops[op].id : "omitted";
874branch 0 never executed (fallthrough)
875branch 1 never executed
876 -: 643:}
877 -: 644:
878 -: 645:/* Resolved end earlier than start is not an interval. Refuse before the ledger. */
879function reject_inverted_lifetimes called 0 returned 0% blocks executed 0%
880 #####: 646:static int reject_inverted_lifetimes(const ds_model *m, ds_result *r) {
881 #####: 647: for (int b = 0; b < m->n_buf; b++) {
882branch 0 never executed
883branch 1 never executed (fallthrough)
884 -: 648: double s, e;
885 -: 649: buffer_window(m, r, b, &s, &e);
886 #####: 650: if (e + 1e-9 < s) {
887branch 0 never executed (fallthrough)
888branch 1 never executed
889 -: 651: char msg[256];
890 -: 652: snprintf(msg, sizeof msg,
891 -: 653: "inverted lifetime for buffer %s: first=%s start_ns=%.9g last=%s end_ns=%.9g",
892 #####: 654: m->buf[b].id, endpoint_name(m, m->buf[b].first), s,
893branch 0 never executed (fallthrough)
894branch 1 never executed
895 -: 655: endpoint_name(m, m->buf[b].last), e);
896 #####: 656: return refuse_msg(r, DS_REFUSED_LIFETIME, msg);
897call 0 never executed
898 -: 657: }
899 -: 658: }
900 -: 659: return DS_OK;
901 -: 660:}
902 -: 661:
903function ds_eval_c called 0 returned 0% blocks executed 0%
904 #####: 662:int ds_eval_c(const ds_model *m, const ds_opts *o, ds_result *r) {
905branch 0 never executed (fallthrough)
906branch 1 never executed
907 -: 663: memset(r, 0, sizeof *r);
908 #####: 664: if (m->n_ops == 0) return refuse(r, DS_REFUSED_UNSUPPORTED, "empty DAG%s%s", "", "");
909branch 0 never executed (fallthrough)
910branch 1 never executed
911call 2 never executed
912 -: 665: ds_num num[DS_MAX_OPS];
913 #####: 666: int rc = resolve(m, o, num, r);
914call 0 never executed
915 #####: 667: if (rc) return rc;
916branch 0 never executed (fallthrough)
917branch 1 never executed
918 -: 668: int order[DS_MAX_OPS];
919 #####: 669: if (!topo(m, order)) return refuse(r, DS_REFUSED_CYCLE, "dependency cycle%s%s", "", "");
920call 0 never executed
921branch 1 never executed (fallthrough)
922branch 2 never executed
923call 3 never executed
924 -: 670: /* a buffer that never fits */
925 #####: 671: for (int i = 0; i < m->n_buf; i++)
926branch 0 never executed
927branch 1 never executed (fallthrough)
928 #####: 672: if (m->buf[i].bytes > m->res[m->buf[i].cap].cap)
929branch 0 never executed (fallthrough)
930branch 1 never executed
931 #####: 673: return refuse(r, DS_REFUSED_CAPACITY, "buffer %s alone exceeds capacity %s", m->buf[i].id, m->res[m->buf[i].cap].id);
932call 0 never executed
933 -: 674:
934 -: 675: /* provenance mask */
935 #####: 676: for (int i = 0; i < m->n_ops; i++) r->prov_mask |= 1u << num[i].prov;
936branch 0 never executed
937branch 1 never executed (fallthrough)
938 #####: 677: for (int i = 0; i < m->n_res; i++) {
939branch 0 never executed
940branch 1 never executed (fallthrough)
941 -: 678: int used = 0;
942 #####: 679: for (int j = 0; j < m->n_ops; j++) if (m->ops[j].engine == i || m->ops[j].bw == i || m->ops[j].launcher == i) used = 1;
943branch 0 never executed (fallthrough)
944branch 1 never executed
945branch 2 never executed (fallthrough)
946branch 3 never executed
947branch 4 never executed (fallthrough)
948branch 5 never executed
949branch 6 never executed
950branch 7 never executed
951 #####: 680: for (int j = 0; j < m->n_buf; j++) if (m->buf[j].cap == i) used = 1;
952branch 0 never executed (fallthrough)
953branch 1 never executed
954branch 2 never executed
955branch 3 never executed (fallthrough)
956 #####: 681: if (used) r->prov_mask |= 1u << m->res[i].prov;
957branch 0 never executed (fallthrough)
958branch 1 never executed
959 -: 682: }
960 -: 683:
961 -: 684: /* ---- fluid simulation ---- */
962 #####: 685: int state[DS_MAX_OPS] = {0}, blocked[DS_MAX_OPS] = {0}, npred[DS_MAX_OPS] = {0}, done_pred[DS_MAX_OPS] = {0};
963 -: 686: double rem_t[DS_MAX_OPS], rem_b[DS_MAX_OPS], rem_l[DS_MAX_OPS], run_start[DS_MAX_OPS], bytes_end[DS_MAX_OPS];
964 #####: 687: int free_slots[DS_MAX_RES], launcher_busy[DS_MAX_RES] = {0};
965 #####: 688: for (int i = 0; i < m->n_res; i++) free_slots[i] = m->res[i].slots;
966branch 0 never executed
967branch 1 never executed
968 #####: 689: for (int i = 0; i < m->n_deps; i++) npred[m->deps[i].to]++;
969branch 0 never executed
970branch 1 never executed (fallthrough)
971 #####: 690: for (int i = 0; i < m->n_ops; i++) {
972branch 0 never executed
973branch 1 never executed
974 #####: 691: rem_t[i] = num[i].t; rem_b[i] = num[i].bytes; rem_l[i] = num[i].launch;
975 #####: 692: run_start[i] = bytes_end[i] = -1;
976 #####: 693: r->n_ops++;
977 #####: 694: r->total_bytes += num[i].bytes; r->total_busy_ns += num[i].t; r->total_launch_ns += num[i].launch;
978 -: 695: }
979 -: 696: double t = 0;
980 -: 697: int remaining = m->n_ops, guard = 0;
981 #####: 698: while (remaining > 0) {
982branch 0 never executed
983branch 1 never executed
984 #####: 699: if (++guard > 8 * DS_MAX_OPS + 16) return refuse(r, DS_REFUSED_UNSUPPORTED, "scheduler did not converge%s%s", "", "");
985branch 0 never executed (fallthrough)
986branch 1 never executed
987call 2 never executed
988 -: 700: /* deps satisfied -> ready */
989 #####: 701: for (int i = 0; i < m->n_ops; i++) if (state[i] == ST_WAIT && done_pred[i] == npred[i]) { state[i] = ST_READY; r->ready_ns[i] = t; }
990branch 0 never executed (fallthrough)
991branch 1 never executed
992branch 2 never executed (fallthrough)
993branch 3 never executed
994branch 4 never executed
995branch 5 never executed
996 -: 702: /* dispatch in file order */
997 #####: 703: for (int i = 0; i < m->n_ops; i++) {
998branch 0 never executed
999branch 1 never executed (fallthrough)
1000 #####: 704: if (state[i] != ST_READY) continue;
1001branch 0 never executed (fallthrough)
1002branch 1 never executed
1003 -: 705: const ds_op *op = &m->ops[i];
1004 #####: 706: if (op->engine >= 0 && free_slots[op->engine] <= 0) { blocked[i] = BLK_SLOT; continue; }
1005branch 0 never executed (fallthrough)
1006branch 1 never executed
1007branch 2 never executed (fallthrough)
1008branch 3 never executed
1009 #####: 707: if (op->launcher >= 0 && rem_l[i] > 0 && launcher_busy[op->launcher]) { blocked[i] = BLK_LAUNCHER; continue; }
1010branch 0 never executed (fallthrough)
1011branch 1 never executed
1012branch 2 never executed (fallthrough)
1013branch 3 never executed
1014branch 4 never executed (fallthrough)
1015branch 5 never executed
1016 #####: 708: if (op->engine >= 0) free_slots[op->engine]--;
1017branch 0 never executed (fallthrough)
1018branch 1 never executed
1019 #####: 709: r->start_ns[i] = t;
1020 #####: 710: if (op->launcher >= 0 && rem_l[i] > 0) { launcher_busy[op->launcher] = 1; state[i] = ST_LAUNCH; }
1021branch 0 never executed (fallthrough)
1022branch 1 never executed
1023branch 2 never executed (fallthrough)
1024branch 3 never executed
1025 #####: 711: else { state[i] = ST_RUN; run_start[i] = t; }
1026 -: 712: }
1027 -: 713: /* next event */
1028 #####: 714: int active[DS_MAX_RES] = {0};
1029 #####: 715: for (int i = 0; i < m->n_ops; i++) if (state[i] == ST_RUN && rem_b[i] > 0) active[m->ops[i].bw]++;
1030branch 0 never executed (fallthrough)
1031branch 1 never executed
1032branch 2 never executed (fallthrough)
1033branch 3 never executed
1034branch 4 never executed
1035branch 5 never executed
1036 -: 716: double dt = -1; int any = 0;
1037 #####: 717: for (int i = 0; i < m->n_ops; i++) {
1038branch 0 never executed
1039branch 1 never executed (fallthrough)
1040 #####: 718: if (state[i] == ST_LAUNCH) { any = 1; if (dt < 0 || rem_l[i] < dt) dt = rem_l[i]; }
1041branch 0 never executed (fallthrough)
1042branch 1 never executed
1043branch 2 never executed (fallthrough)
1044branch 3 never executed
1045branch 4 never executed (fallthrough)
1046branch 5 never executed
1047 #####: 719: else if (state[i] == ST_RUN) {
1048branch 0 never executed (fallthrough)
1049branch 1 never executed
1050 -: 720: any = 1;
1051 -: 721: /* next event for this op: the earlier of its two progress bars */
1052 -: 722: double d = -1;
1053 #####: 723: if (rem_t[i] > 0) d = rem_t[i];
1054branch 0 never executed (fallthrough)
1055branch 1 never executed
1056 #####: 724: if (rem_b[i] > 0) {
1057branch 0 never executed (fallthrough)
1058branch 1 never executed
1059 #####: 725: double share = num[i].cap / active[m->ops[i].bw];
1060 #####: 726: double db = rem_b[i] / share;
1061 #####: 727: if (d < 0 || db < d) d = db;
1062branch 0 never executed (fallthrough)
1063branch 1 never executed
1064branch 2 never executed
1065branch 3 never executed (fallthrough)
1066 -: 728: }
1067 #####: 729: if (d < 0) d = 0;
1068branch 0 never executed (fallthrough)
1069branch 1 never executed
1070 #####: 730: if (dt < 0 || d < dt) dt = d;
1071branch 0 never executed (fallthrough)
1072branch 1 never executed
1073branch 2 never executed (fallthrough)
1074branch 3 never executed
1075 -: 731: }
1076 -: 732: }
1077 #####: 733: if (!any) return refuse(r, DS_REFUSED_UNSUPPORTED, "no op can make progress (slots=0 or all blocked)%s%s", "", "");
1078branch 0 never executed (fallthrough)
1079branch 1 never executed
1080call 2 never executed
1081 #####: 734: if (dt < 0) dt = 0;
1082branch 0 never executed (fallthrough)
1083branch 1 never executed
1084 #####: 735: t += dt;
1085 -: 736: const double eps = 1e-9;
1086 #####: 737: for (int i = 0; i < m->n_ops; i++) {
1087branch 0 never executed
1088branch 1 never executed (fallthrough)
1089 #####: 738: if (state[i] == ST_LAUNCH) {
1090branch 0 never executed (fallthrough)
1091branch 1 never executed
1092 #####: 739: rem_l[i] -= dt;
1093 #####: 740: if (rem_l[i] <= eps) { rem_l[i] = 0; launcher_busy[m->ops[i].launcher] = 0; state[i] = ST_RUN; run_start[i] = t; }
1094branch 0 never executed (fallthrough)
1095branch 1 never executed
1096 #####: 741: } else if (state[i] == ST_RUN) {
1097branch 0 never executed
1098branch 1 never executed (fallthrough)
1099 #####: 742: if (rem_t[i] > 0) { rem_t[i] -= dt; if (rem_t[i] <= eps) rem_t[i] = 0; }
1100branch 0 never executed (fallthrough)
1101branch 1 never executed
1102branch 2 never executed (fallthrough)
1103branch 3 never executed
1104 #####: 743: if (rem_b[i] > 0) {
1105branch 0 never executed (fallthrough)
1106branch 1 never executed
1107 #####: 744: double share = num[i].cap / active[m->ops[i].bw];
1108 #####: 745: rem_b[i] -= share * dt;
1109 #####: 746: if (rem_b[i] <= eps * (num[i].bytes > 1 ? num[i].bytes : 1)) { rem_b[i] = 0; bytes_end[i] = t; }
1110branch 0 never executed (fallthrough)
1111branch 1 never executed
1112branch 2 never executed (fallthrough)
1113branch 3 never executed
1114 -: 747: }
1115 #####: 748: if (rem_t[i] <= 0 && rem_b[i] <= 0) {
1116branch 0 never executed
1117branch 1 never executed (fallthrough)
1118branch 2 never executed
1119branch 3 never executed (fallthrough)
1120 #####: 749: state[i] = ST_DONE; r->end_ns[i] = t; remaining--;
1121 #####: 750: if (m->ops[i].engine >= 0) free_slots[m->ops[i].engine]++;
1122branch 0 never executed (fallthrough)
1123branch 1 never executed
1124 #####: 751: for (int d = 0; d < m->n_deps; d++) if (m->deps[d].from == i) done_pred[m->deps[d].to]++;
1125branch 0 never executed (fallthrough)
1126branch 1 never executed
1127branch 2 never executed
1128branch 3 never executed (fallthrough)
1129 #####: 752: if (num[i].bytes > 0) {
1130branch 0 never executed (fallthrough)
1131branch 1 never executed
1132 #####: 753: double ideal = num[i].bytes / num[i].cap;
1133 #####: 754: double actual = (bytes_end[i] >= 0 ? bytes_end[i] : t) - run_start[i];
1134branch 0 never executed (fallthrough)
1135branch 1 never executed
1136 #####: 755: r->op_contention_ns[i] = actual - ideal > 0 ? actual - ideal : 0;
1137branch 0 never executed (fallthrough)
1138branch 1 never executed
1139 -: 756: }
1140 -: 757: }
1141 -: 758: }
1142 -: 759: }
1143 #####: 760: if (t > r->makespan_ns) r->makespan_ns = t;
1144branch 0 never executed (fallthrough)
1145branch 1 never executed
1146 -: 761: }
1147 -: 762:
1148 -: 763: /* ---- bounds ---- */
1149 -: 764: double cp[DS_MAX_OPS];
1150 #####: 765: for (int k = 0; k < m->n_ops; k++) {
1151branch 0 never executed
1152branch 1 never executed (fallthrough)
1153 #####: 766: int i = order[k];
1154 #####: 767: double floor_ = num[i].t;
1155 #####: 768: if (num[i].bytes > 0 && num[i].bytes / num[i].cap > floor_) floor_ = num[i].bytes / num[i].cap;
1156branch 0 never executed (fallthrough)
1157branch 1 never executed
1158branch 2 never executed
1159branch 3 never executed (fallthrough)
1160 #####: 769: floor_ += num[i].launch;
1161 #####: 770: r->op_floor_ns[i] = floor_;
1162 -: 771: double best = 0;
1163 #####: 772: for (int d = 0; d < m->n_deps; d++) if (m->deps[d].to == i && cp[m->deps[d].from] > best) best = cp[m->deps[d].from];
1164branch 0 never executed (fallthrough)
1165branch 1 never executed
1166branch 2 never executed
1167branch 3 never executed (fallthrough)
1168branch 4 never executed
1169branch 5 never executed (fallthrough)
1170 #####: 773: cp[i] = best + floor_;
1171 #####: 774: if (cp[i] > r->bound_critical_path_ns) r->bound_critical_path_ns = cp[i];
1172branch 0 never executed (fallthrough)
1173branch 1 never executed
1174 -: 775: }
1175 #####: 776: r->bound_ns = r->bound_critical_path_ns;
1176 #####: 777: for (int i = 0; i < m->n_res; i++) {
1177branch 0 never executed
1178branch 1 never executed (fallthrough)
1179 -: 778: double w = 0;
1180 #####: 779: for (int j = 0; j < m->n_ops; j++) {
1181branch 0 never executed
1182branch 1 never executed (fallthrough)
1183 #####: 780: if (m->res[i].kind == DS_RES_BANDWIDTH && m->ops[j].bw == i) w += num[j].bytes / num[j].cap;
1184branch 0 never executed (fallthrough)
1185branch 1 never executed
1186branch 2 never executed (fallthrough)
1187branch 3 never executed
1188 #####: 781: if (m->res[i].kind == DS_RES_COMPUTE && m->ops[j].engine == i) w += (num[j].t + num[j].launch) / m->res[i].slots;
1189branch 0 never executed (fallthrough)
1190branch 1 never executed
1191branch 2 never executed (fallthrough)
1192branch 3 never executed
1193 #####: 782: if (m->res[i].kind == DS_RES_LAUNCH && m->ops[j].launcher == i) w += num[j].launch;
1194branch 0 never executed (fallthrough)
1195branch 1 never executed
1196branch 2 never executed (fallthrough)
1197branch 3 never executed
1198 -: 783: }
1199 #####: 784: r->bound_resource_ns[i] = w;
1200 #####: 785: if (w > r->bound_ns) r->bound_ns = w;
1201branch 0 never executed (fallthrough)
1202branch 1 never executed
1203 -: 786: }
1204 -: 787:
1205 -: 788: /* Inverted lifetimes never enter the ledger (and never rank). */
1206 #####: 789: if ((rc = reject_inverted_lifetimes(m, r)) != DS_OK) return rc; /* LIFETIME_ORDER_CHECK */
1207call 0 never executed
1208branch 1 never executed
1209branch 2 never executed
1210 -: 790:
1211 -: 791: /* ---- capacity ledger: frees before allocations at the same instant ----
1212 -: 792: * Positive intervals only. A zero-duration [s, e) is empty and emits no
1213 -: 793: * event, so a same-time free cannot pull the ledger negative or offset
1214 -: 794: * another buffer. Frees of earlier intervals still precede allocs, which
1215 -: 795: * is the completion/allocation tie. */
1216 #####: 796: for (int c = 0; c < m->n_res; c++) {
1217branch 0 never executed
1218branch 1 never executed
1219 #####: 797: if (m->res[c].kind != DS_RES_CAPACITY) continue;
1220branch 0 never executed (fallthrough)
1221branch 1 never executed
1222 -: 798: double live = 0, peak = 0, peak_at = 0;
1223 -: 799: /* event list */
1224 -: 800: double et[2 * DS_MAX_BUF]; double ev[2 * DS_MAX_BUF]; int en = 0;
1225 #####: 801: for (int b = 0; b < m->n_buf; b++) {
1226branch 0 never executed
1227branch 1 never executed (fallthrough)
1228 #####: 802: if (m->buf[b].cap != c) continue;
1229branch 0 never executed (fallthrough)
1230branch 1 never executed
1231 -: 803: double s, e;
1232 -: 804: buffer_window(m, r, b, &s, &e);
1233 #####: 805: if (!(s + 1e-9 < e)) continue;
1234branch 0 never executed (fallthrough)
1235branch 1 never executed
1236 #####: 806: et[en] = s; ev[en] = m->buf[b].bytes; en++;
1237 #####: 807: et[en] = e; ev[en] = -m->buf[b].bytes; en++;
1238 -: 808: }
1239 -: 809: /* insertion sort by time, frees (negative) first on ties; stable */
1240 #####: 810: for (int i = 1; i < en; i++) {
1241branch 0 never executed
1242branch 1 never executed
1243 #####: 811: double kt = et[i], kv_ = ev[i]; int j = i - 1;
1244 #####: 812: while (j >= 0 && (et[j] > kt || (et[j] == kt && ev[j] > 0 && kv_ < 0))) { et[j + 1] = et[j]; ev[j + 1] = ev[j]; j--; }
1245branch 0 never executed (fallthrough)
1246branch 1 never executed
1247branch 2 never executed
1248branch 3 never executed (fallthrough)
1249branch 4 never executed (fallthrough)
1250branch 5 never executed
1251branch 6 never executed (fallthrough)
1252branch 7 never executed
1253branch 8 never executed
1254branch 9 never executed (fallthrough)
1255 #####: 813: et[j + 1] = kt; ev[j + 1] = kv_;
1256 -: 814: }
1257 #####: 815: for (int i = 0; i < en; i++) {
1258branch 0 never executed
1259branch 1 never executed (fallthrough)
1260 #####: 816: live += ev[i];
1261 -: 817: /* Reachable by rounding: 1e20 + 1 sums to 1e20, so the later
1262 -: 818: * frees overshoot (dagsim_unit rounding_drives_live_negative). */
1263 #####: 819: if (live < -1e-6) {
1264branch 0 never executed (fallthrough)
1265branch 1 never executed
1266 -: 820: char msg[256];
1267 #####: 821: snprintf(msg, sizeof msg,
1268 -: 822: "capacity %s live bytes went negative (%.9g at t=%.9g); refusing the certificate",
1269 #####: 823: m->res[c].id, live, et[i]);
1270call 0 never executed
1271 #####: 824: return refuse_msg(r, DS_REFUSED_LIFETIME, msg);
1272call 0 never executed
1273 -: 825: }
1274 #####: 826: if (live > peak) { peak = live; peak_at = et[i]; }
1275branch 0 never executed (fallthrough)
1276branch 1 never executed
1277 -: 827: }
1278 #####: 828: r->peak_live_bytes[c] = peak; r->peak_live_at_ns[c] = peak_at;
1279 #####: 829: if (peak > m->res[c].cap + 1e-9) {
1280branch 0 never executed (fallthrough)
1281branch 1 never executed
1282 #####: 830: char names[160] = ""; size_t L = 0;
1283 #####: 831: for (int b = 0; b < m->n_buf && L < sizeof names - 8; b++) {
1284branch 0 never executed (fallthrough)
1285branch 1 never executed
1286branch 2 never executed
1287branch 3 never executed (fallthrough)
1288 #####: 832: if (m->buf[b].cap != c) continue;
1289branch 0 never executed (fallthrough)
1290branch 1 never executed
1291 -: 833: double s, e;
1292 -: 834: buffer_window(m, r, b, &s, &e);
1293 #####: 835: if (s <= peak_at && e > peak_at) { snprintf(names + L, sizeof names - L, "%s%s", L ? "," : "", m->buf[b].id); L = strlen(names); }
1294branch 0 never executed (fallthrough)
1295branch 1 never executed
1296branch 2 never executed (fallthrough)
1297branch 3 never executed
1298branch 4 never executed (fallthrough)
1299branch 5 never executed
1300 -: 836: }
1301 -: 837: char what[200]; snprintf(what, sizeof what, "%.0f B live at t=%.0f ns (%s) exceeds", peak, peak_at, names);
1302 #####: 838: int st = refuse(r, DS_REFUSED_CAPACITY, "%s %s", what, m->res[c].id);
1303call 0 never executed
1304 -: 839: return st;
1305 -: 840: }
1306 -: 841: }
1307 -: 842:
1308 -: 843: /* ---- attribution along the schedule's critical chain ---- */
1309 -: 844: int cur = 0;
1310 #####: 845: for (int i = 1; i < m->n_ops; i++) if (r->end_ns[i] > r->end_ns[cur]) cur = i;
1311branch 0 never executed (fallthrough)
1312branch 1 never executed
1313branch 2 never executed
1314branch 3 never executed
1315 -: 846: double accounted = 0;
1316 -: 847: int chain[DS_MAX_OPS]; int nc = 0;
1317 #####: 848: while (cur >= 0 && nc < DS_MAX_OPS) {
1318branch 0 never executed
1319branch 1 never executed (fallthrough)
1320 #####: 849: chain[nc++] = cur;
1321 -: 850: const ds_op *op = &m->ops[cur];
1322 #####: 851: double runtime = r->end_ns[cur] - (run_start[cur] >= 0 ? run_start[cur] : r->start_ns[cur]);
1323branch 0 never executed (fallthrough)
1324branch 1 never executed
1325 #####: 852: r->attr_ns[DS_ATTR_LAUNCH] += num[cur].launch;
1326 #####: 853: accounted += num[cur].launch;
1327 #####: 854: if (op->kind == DS_OP_BARRIER) r->attr_ns[DS_ATTR_SYNC] += runtime;
1328branch 0 never executed (fallthrough)
1329branch 1 never executed
1330 #####: 855: else if (num[cur].bytes > 0) {
1331branch 0 never executed (fallthrough)
1332branch 1 never executed
1333 #####: 856: double ideal = num[cur].bytes / num[cur].cap;
1334 #####: 857: double actual = ideal + r->op_contention_ns[cur];
1335 #####: 858: if (num[cur].t >= actual) r->attr_ns[DS_ATTR_COMPUTE] += runtime;
1336branch 0 never executed (fallthrough)
1337branch 1 never executed
1338 #####: 859: else { r->attr_ns[DS_ATTR_BANDWIDTH] += ideal; r->attr_ns[DS_ATTR_CONTENTION] += r->op_contention_ns[cur]; if (runtime > actual) r->attr_ns[DS_ATTR_RESIDUAL] += runtime - actual; }
1339branch 0 never executed (fallthrough)
1340branch 1 never executed
1341 #####: 860: } else r->attr_ns[DS_ATTR_COMPUTE] += runtime;
1342 #####: 861: accounted += runtime;
1343 -: 862: /* predecessor: the dep that finished last */
1344 -: 863: int pred = -1;
1345 #####: 864: for (int d = 0; d < m->n_deps; d++) if (m->deps[d].to == cur && (pred < 0 || r->end_ns[m->deps[d].from] > r->end_ns[pred])) pred = m->deps[d].from;
1346branch 0 never executed (fallthrough)
1347branch 1 never executed
1348branch 2 never executed (fallthrough)
1349branch 3 never executed
1350branch 4 never executed (fallthrough)
1351branch 5 never executed
1352branch 6 never executed
1353branch 7 never executed (fallthrough)
1354 #####: 865: double gap = r->start_ns[cur] - (pred >= 0 ? r->end_ns[pred] : 0);
1355branch 0 never executed (fallthrough)
1356branch 1 never executed
1357 #####: 866: if (gap > 0) {
1358branch 0 never executed (fallthrough)
1359branch 1 never executed
1360 #####: 867: if (blocked[cur] == BLK_SLOT) r->attr_ns[DS_ATTR_SERIALIZATION] += gap;
1361branch 0 never executed (fallthrough)
1362branch 1 never executed
1363 #####: 868: else if (blocked[cur] == BLK_LAUNCHER) r->attr_ns[DS_ATTR_LAUNCH] += gap;
1364branch 0 never executed (fallthrough)
1365branch 1 never executed
1366 #####: 869: else r->attr_ns[DS_ATTR_RESIDUAL] += gap;
1367 #####: 870: accounted += gap;
1368 -: 871: }
1369 -: 872: cur = pred;
1370 -: 873: }
1371 #####: 874: for (int i = 0; i < nc; i++) r->critical_path[i] = chain[nc - 1 - i];
1372branch 0 never executed
1373branch 1 never executed (fallthrough)
1374 #####: 875: r->n_critical = nc;
1375 #####: 876: double leftover = r->makespan_ns - accounted;
1376 #####: 877: if (fabs(leftover) > 1e-6) r->attr_ns[DS_ATTR_RESIDUAL] += leftover;
1377branch 0 never executed (fallthrough)
1378branch 1 never executed
1379 -: 878:
1380 -: 879: /* ---- energy ---- */
1381 #####: 880: if (m->has_energy && m->joules > 0 && strcmp(m->instrument, "none")) { r->energy_measured = 1; r->energy_j = m->joules; }
1382branch 0 never executed (fallthrough)
1383branch 1 never executed
1384branch 2 never executed (fallthrough)
1385branch 3 never executed
1386branch 4 never executed (fallthrough)
1387branch 5 never executed
1388 #####: 881: else if (m->has_energy && m->power_w > 0 && m->energy_prov == DS_PROV_SYNTHETIC) { r->energy_synthetic = 1; r->energy_j = m->power_w * r->makespan_ns * 1e-9; r->prov_mask |= 1u << DS_PROV_SYNTHETIC; }
1389branch 0 never executed (fallthrough)
1390branch 1 never executed
1391branch 2 never executed (fallthrough)
1392branch 3 never executed
1393branch 4 never executed (fallthrough)
1394branch 5 never executed
1395 #####: 882: r->synthetic = (r->prov_mask & (1u << DS_PROV_SYNTHETIC)) ? 1 : 0;
1396 #####: 883: r->status = DS_OK;
1397 #####: 884: return DS_OK;
1398 -: 885:}
1399 -: 886:
1400 -: 887:#ifndef CUDAPP_MIGRATION_PENDING_C_TOOLS
1401 -: 888:extern uint32_t omega_dag_eval(uint64_t *result, const void *p0, uint64_t p0_n, void *p1, uint64_t p1_n) __attribute__((weak));
1402 -: 889:
1403 -: 890:static double om_f(const uint64_t *s, int i) {
1404 -: 891: double x;
1405 #####: 892: memcpy(&x, &s[i], 8);
1406 -: 893: return x;
1407 -: 894:}
1408 -: 895:
1409function om_names called 0 returned 0% blocks executed 0%
1410 #####: 896:static void om_names(const ds_model *m, const uint64_t *s, char *names, size_t cap) {
1411 #####: 897: names[0] = 0;
1412 -: 898: size_t L = 0;
1413 #####: 899: for (int b = 0; b < m->n_buf && L < cap - 8; b++) {
1414branch 0 never executed (fallthrough)
1415branch 1 never executed
1416branch 2 never executed
1417branch 3 never executed (fallthrough)
1418 #####: 900: if (!(s[6336 + b / 64] & (1ull << (b % 64)))) continue;
1419branch 0 never executed (fallthrough)
1420branch 1 never executed
1421 #####: 901: snprintf(names + L, cap - L, "%s%s", L ? "," : "", m->buf[b].id);
1422branch 0 never executed (fallthrough)
1423branch 1 never executed
1424 #####: 902: L = strlen(names);
1425 -: 903: }
1426 #####: 904:}
1427 -: 905:
1428function om_refuse called 0 returned 0% blocks executed 0%
1429 #####: 906:static int om_refuse(const ds_model *m, const uint64_t *s, ds_result *r) {
1430 #####: 907: int why = (int)s[5], a = (int)s[6], b = (int)s[7];
1431branch 0 never executed (fallthrough)
1432branch 1 never executed
1433 -: 908: double fa = om_f(s, 8), fb = om_f(s, 9);
1434 -: 909: char msg[256];
1435 #####: 910: if (why == 2) return refuse(r, DS_REFUSED_CYCLE, "dependency cycle%s%s", "", "");
1436branch 0 never executed (fallthrough)
1437branch 1 never executed
1438call 2 never executed
1439 #####: 911: if (why == 3 && a >= 0 && a < m->n_buf && b >= 0 && b < m->n_res)
1440branch 0 never executed (fallthrough)
1441branch 1 never executed
1442branch 2 never executed (fallthrough)
1443branch 3 never executed
1444branch 4 never executed (fallthrough)
1445branch 5 never executed
1446branch 6 never executed (fallthrough)
1447branch 7 never executed
1448 #####: 912: return refuse(r, DS_REFUSED_CAPACITY, "buffer %s alone exceeds capacity %s", m->buf[a].id, m->res[b].id);
1449call 0 never executed
1450 #####: 913: if (why == 4) return refuse(r, DS_REFUSED_UNSUPPORTED, "no op can make progress (slots=0 or all blocked)%s%s", "", "");
1451branch 0 never executed (fallthrough)
1452branch 1 never executed
1453call 2 never executed
1454 #####: 914: if (why == 5) return refuse(r, DS_REFUSED_UNSUPPORTED, "scheduler did not converge%s%s", "", "");
1455branch 0 never executed (fallthrough)
1456branch 1 never executed
1457call 2 never executed
1458 #####: 915: if (why == 6 && a >= 0 && a < m->n_buf) {
1459branch 0 never executed (fallthrough)
1460branch 1 never executed
1461branch 2 never executed (fallthrough)
1462branch 3 never executed
1463 -: 916: snprintf(msg, sizeof msg, "inverted lifetime for buffer %s: first=%s start_ns=%.9g last=%s end_ns=%.9g",
1464 #####: 917: m->buf[a].id, endpoint_name(m, m->buf[a].first), fa, endpoint_name(m, m->buf[a].last), fb);
1465branch 0 never executed (fallthrough)
1466branch 1 never executed
1467branch 2 never executed (fallthrough)
1468branch 3 never executed
1469 #####: 918: return refuse_msg(r, DS_REFUSED_LIFETIME, msg);
1470call 0 never executed
1471 -: 919: }
1472 #####: 920: if (why == 7 && a >= 0 && a < m->n_res) {
1473branch 0 never executed (fallthrough)
1474branch 1 never executed
1475branch 2 never executed (fallthrough)
1476branch 3 never executed
1477 -: 921: snprintf(msg, sizeof msg, "capacity %s live bytes went negative (%.9g at t=%.9g); refusing the certificate",
1478 #####: 922: m->res[a].id, fa, fb);
1479call 0 never executed
1480 #####: 923: return refuse_msg(r, DS_REFUSED_LIFETIME, msg);
1481call 0 never executed
1482 -: 924: }
1483 #####: 925: if (why == 8 && a >= 0 && a < m->n_res) {
1484branch 0 never executed (fallthrough)
1485branch 1 never executed
1486branch 2 never executed (fallthrough)
1487branch 3 never executed
1488 -: 926: char names[160], what[200];
1489 #####: 927: om_names(m, s, names, sizeof names);
1490call 0 never executed
1491 -: 928: snprintf(what, sizeof what, "%.0f B live at t=%.0f ns (%s) exceeds", fa, fb, names);
1492 #####: 929: return refuse(r, DS_REFUSED_CAPACITY, "%s %s", what, m->res[a].id);
1493call 0 never executed
1494 -: 930: }
1495 #####: 931: return refuse(r, DS_REFUSED_UNSUPPORTED, "omega refusal %s%s", "", "");
1496call 0 never executed
1497 -: 932:}
1498 -: 933:
1499function om_fill called 0 returned 0% blocks executed 0%
1500 #####: 934:static int om_fill(const ds_model *m, const uint64_t *s, ds_result *r) {
1501 #####: 935: if ((int)s[4] != DS_OK) return om_refuse(m, s, r);
1502branch 0 never executed (fallthrough)
1503branch 1 never executed
1504call 2 never executed
1505 -: 936: memset(r, 0, sizeof *r);
1506 -: 937: r->status = DS_OK;
1507 #####: 938: r->makespan_ns = om_f(s, 3);
1508 #####: 939: r->total_bytes = om_f(s, 15);
1509 #####: 940: r->total_busy_ns = om_f(s, 16);
1510 #####: 941: r->total_launch_ns = om_f(s, 17);
1511 #####: 942: r->bound_ns = om_f(s, 19);
1512 #####: 943: r->bound_critical_path_ns = om_f(s, 20);
1513 #####: 944: r->n_critical = (int)s[21];
1514 #####: 945: r->prov_mask = (uint32_t)s[11];
1515 #####: 946: r->energy_measured = (int)s[22];
1516 #####: 947: r->energy_synthetic = (int)s[23];
1517 #####: 948: r->energy_j = om_f(s, 24);
1518 #####: 949: r->synthetic = (int)s[26];
1519 #####: 950: r->n_ops = m->n_ops;
1520 #####: 951: for (int i = 0; i < m->n_ops; i++) {
1521branch 0 never executed
1522branch 1 never executed
1523 #####: 952: r->start_ns[i] = om_f(s, 4512 + i);
1524branch 0 never executed (fallthrough)
1525branch 1 never executed
1526 #####: 953: r->end_ns[i] = om_f(s, 4768 + i);
1527 #####: 954: r->ready_ns[i] = om_f(s, 5024 + i);
1528 #####: 955: r->op_contention_ns[i] = om_f(s, 5536 + i);
1529 #####: 956: r->op_floor_ns[i] = om_f(s, 5280 + i);
1530 #####: 957: if (i < r->n_critical) r->critical_path[i] = (int)s[6080 + i];
1531branch 0 never executed (fallthrough)
1532branch 1 never executed
1533 -: 958: }
1534 #####: 959: for (int i = 0; i < DS_ATTR_N; i++) r->attr_ns[i] = om_f(s, 5824 + i);
1535branch 0 never executed
1536branch 1 never executed
1537 #####: 960: for (int i = 0; i < m->n_res; i++) {
1538branch 0 never executed
1539branch 1 never executed (fallthrough)
1540 #####: 961: r->bound_resource_ns[i] = om_f(s, 5792 + i);
1541 #####: 962: r->peak_live_bytes[i] = om_f(s, 6344 + i);
1542 #####: 963: r->peak_live_at_ns[i] = om_f(s, 6376 + i);
1543 -: 964: }
1544 -: 965: return DS_OK;
1545 -: 966:}
1546 -: 967:
1547 -: 968:#endif
1548function ds_eval called 0 returned 0% blocks executed 0%
1549 #####: 969:int ds_eval(const ds_model *m, const ds_opts *o, ds_result *r) {
1550 -: 970:#if defined(CUDAPP_MIGRATION_PENDING_C_TOOLS)
1551 -: 971: return ds_eval_c(m, o, r);
1552 -: 972:#else
1553 #####: 973: if (!omega_dag_eval) return ds_eval_c(m, o, r);
1554branch 0 never executed (fallthrough)
1555branch 1 never executed
1556call 2 never executed
1557 -: 974: memset(r, 0, sizeof *r);
1558 #####: 975: uint64_t model[8192], scratch[8192], result = 0;
1559 #####: 976: int rc = ds_resolved_pack(m, o, model, r);
1560call 0 never executed
1561 #####: 977: if (rc) return rc;
1562branch 0 never executed (fallthrough)
1563branch 1 never executed
1564 -: 978: memset(scratch, 0, sizeof scratch);
1565 #####: 979: if (omega_dag_eval(&result, model, 8192, scratch, 8192))
1566call 0 never executed
1567branch 1 never executed (fallthrough)
1568branch 2 never executed
1569 #####: 980: return refuse(r, DS_REFUSED_UNSUPPORTED, "omega trap%s%s", "", "");
1570call 0 never executed
1571 #####: 981: return om_fill(m, scratch, r);
1572call 0 never executed
1573 -: 982:#endif
1574 -: 983:}
1575 -: 984:
1576function ds_eval_interval called 0 returned 0% blocks executed 0%
1577 #####: 985:int ds_eval_interval(const ds_model *m, const ds_opts *o, ds_result *nominal, double *lo_ns, double *hi_ns) {
1578 #####: 986: ds_opts x = *o; x.mode = 0;
1579 #####: 987: int rc = ds_eval(m, &x, nominal);
1580call 0 never executed
1581 #####: 988: *lo_ns = *hi_ns = 0;
1582 #####: 989: if (rc) return rc;
1583branch 0 never executed (fallthrough)
1584branch 1 never executed
1585 -: 990: ds_result tmp;
1586 #####: 991: x.mode = +1; if (ds_eval(m, &x, &tmp) == DS_OK) *lo_ns = tmp.makespan_ns;
1587call 0 never executed
1588branch 1 never executed (fallthrough)
1589branch 2 never executed
1590 #####: 992: x.mode = -1; if (ds_eval(m, &x, &tmp) == DS_OK) *hi_ns = tmp.makespan_ns;
1591call 0 never executed
1592branch 1 never executed (fallthrough)
1593branch 2 never executed
1594 -: 993: return rc;
1595 -: 994:}
1596 -: 995:
1597function ds_counterfactual called 0 returned 0% blocks executed 0%
1598 #####: 996:double ds_counterfactual(const ds_model *m, const ds_opts *o, int res_index) {
1599 #####: 997: if (res_index < 0 || res_index >= m->n_res) return -DS_REFUSED_UNSUPPORTED;
1600branch 0 never executed (fallthrough)
1601branch 1 never executed
1602branch 2 never executed (fallthrough)
1603branch 3 never executed
1604 #####: 998: ds_model *c = malloc(sizeof *c);
1605 #####: 999: if (!c) return -DS_REFUSED_UNSUPPORTED;
1606branch 0 never executed
1607branch 1 never executed (fallthrough)
1608 #####: 1000: *c = *m;
1609 -: 1001: ds_resource *r = &c->res[res_index];
1610 #####: 1002: switch (r->kind) {
1611branch 0 never executed
1612branch 1 never executed
1613branch 2 never executed
1614branch 3 never executed
1615branch 4 never executed
1616 #####: 1003: case DS_RES_BANDWIDTH: r->cap *= 2; r->lo *= 2; r->hi *= 2; break;
1617 #####: 1004: case DS_RES_COMPUTE: r->slots *= 2; break;
1618 #####: 1005: case DS_RES_LAUNCH: for (int i = 0; i < c->n_ops; i++) if (c->ops[i].launcher == res_index) c->ops[i].launch_ns = 0; break;
1619branch 0 never executed (fallthrough)
1620branch 1 never executed
1621branch 2 never executed
1622branch 3 never executed
1623 #####: 1006: case DS_RES_CAPACITY: r->cap *= 2; break;
1624 -: 1007: }
1625 #####: 1008: ds_result res; ds_opts x = *o; x.mode = 0;
1626 #####: 1009: int rc = ds_eval(c, &x, &res);
1627call 0 never executed
1628 #####: 1010: free(c);
1629 #####: 1011: return rc == DS_OK ? res.makespan_ns : -(double)rc;
1630branch 0 never executed (fallthrough)
1631branch 1 never executed
1632 -: 1012:}
1633 -: 1013:
1634 -: 1014:/* ---------------------------------------------------------------- diff */
1635 -: 1015:
1636function in_changed called 0 returned 0% blocks executed 0%
1637 #####: 1016:static int in_changed(const char *list, const char *id) {
1638 #####: 1017: if (!list) return 0;
1639branch 0 never executed (fallthrough)
1640branch 1 never executed
1641 #####: 1018: const char *p = list; size_t L = strlen(id);
1642 #####: 1019: while (*p) {
1643branch 0 never executed
1644branch 1 never executed (fallthrough)
1645 #####: 1020: const char *q = strchr(p, ','); size_t n = q ? (size_t)(q - p) : strlen(p);
1646branch 0 never executed (fallthrough)
1647branch 1 never executed
1648 #####: 1021: if (n == L && !strncmp(p, id, L)) return 1;
1649branch 0 never executed (fallthrough)
1650branch 1 never executed
1651branch 2 never executed (fallthrough)
1652branch 3 never executed
1653 #####: 1022: if (!q) break;
1654branch 0 never executed (fallthrough)
1655branch 1 never executed
1656 #####: 1023: p = q + 1;
1657 -: 1024: }
1658 -: 1025: return 0;
1659 -: 1026:}
1660 -: 1027:
1661function ds_diff_models called 0 returned 0% blocks executed 0%
1662 #####: 1028:int ds_diff_models(const ds_model *b, const ds_model *t, const ds_opts *o, ds_diff *d) {
1663 -: 1029: memset(d, 0, sizeof *d);
1664 #####: 1030: for (int i = 0; i < t->n_ops; i++) if (ds_find_op(b, t->ops[i].id) < 0) d->n_added++;
1665branch 0 never executed (fallthrough)
1666branch 1 never executed
1667branch 2 never executed
1668branch 3 never executed
1669 #####: 1031: for (int i = 0; i < b->n_ops; i++) {
1670branch 0 never executed
1671branch 1 never executed
1672 #####: 1032: int j = ds_find_op(t, b->ops[i].id);
1673 #####: 1033: if (j >= 0) {
1674branch 0 never executed (fallthrough)
1675branch 1 never executed
1676 #####: 1034: d->n_kept++;
1677 #####: 1035: if (b->ops[i].t_ns != t->ops[j].t_ns || b->ops[i].bytes != t->ops[j].bytes)
1678branch 0 never executed (fallthrough)
1679branch 1 never executed
1680branch 2 never executed (fallthrough)
1681branch 3 never executed
1682 #####: 1036: snprintf(d->reason, sizeof d->reason, "op %s kept but its demand changed; trace conservation broken", b->ops[i].id);
1683 #####: 1037: continue;
1684 -: 1038: }
1685 #####: 1039: d->n_removed++;
1686 -: 1040: /* find its removed record(s) */
1687 -: 1041: int found = 0; const ds_removed *rec = NULL;
1688 #####: 1042: for (int k = 0; k < t->n_removed; k++) if (!strcmp(t->removed[k].op, b->ops[i].id)) { found++; rec = &t->removed[k]; }
1689branch 0 never executed (fallthrough)
1690branch 1 never executed
1691branch 2 never executed
1692branch 3 never executed (fallthrough)
1693 #####: 1043: if (found == 0) { d->required_removed = 1; snprintf(d->reason, sizeof d->reason, "op %s vanished without a removed record", b->ops[i].id); return DS_REFUSED_REMOVED_REQUIRED; }
1694branch 0 never executed (fallthrough)
1695branch 1 never executed
1696 #####: 1044: if (found > 1) { d->double_counted = 1; snprintf(d->reason, sizeof d->reason, "op %s removed %d times (double counted)", b->ops[i].id, found); return DS_REFUSED_REMOVED_REQUIRED; }
1697branch 0 never executed (fallthrough)
1698branch 1 never executed
1699 -: 1045: /* consumers of the removed op in the baseline that still exist */
1700 -: 1046: int has_consumer = 0;
1701 #####: 1047: for (int k = 0; k < b->n_deps; k++) if (b->deps[k].from == i && ds_find_op(t, b->ops[b->deps[k].to].id) >= 0) has_consumer = 1;
1702branch 0 never executed (fallthrough)
1703branch 1 never executed
1704branch 2 never executed
1705branch 3 never executed (fallthrough)
1706branch 4 never executed
1707branch 5 never executed (fallthrough)
1708 -: 1048: int ok = 1;
1709 #####: 1049: switch (rec->reason) {
1710branch 0 never executed
1711branch 1 never executed
1712branch 2 never executed
1713branch 3 never executed
1714branch 4 never executed
1715branch 5 never executed
1716 #####: 1050: case DS_RM_ELIMINATED: if (has_consumer && !rec->proof[0]) ok = 0; break;
1717branch 0 never executed (fallthrough)
1718branch 1 never executed
1719branch 2 never executed
1720branch 3 never executed
1721 #####: 1051: case DS_RM_REUSED: case DS_RM_LOOKUP: case DS_RM_MOVED: if (!rec->ref[0] || ds_find_op(t, rec->ref) < 0) ok = 0; break;
1722branch 0 never executed (fallthrough)
1723branch 1 never executed
1724branch 2 never executed
1725branch 3 never executed
1726 #####: 1052: case DS_RM_UNCHANGED_DEP: if (!rec->ref[0] || ds_find_op(b, rec->ref) < 0 || in_changed(o ? o->changed : NULL, rec->ref)) ok = 0; break;
1727branch 0 never executed (fallthrough)
1728branch 1 never executed
1729branch 2 never executed (fallthrough)
1730branch 3 never executed
1731branch 4 never executed (fallthrough)
1732branch 5 never executed
1733call 6 never executed
1734branch 7 never executed
1735branch 8 never executed
1736 #####: 1053: case DS_RM_DEFERRED: if (has_consumer) ok = 0; break;
1737branch 0 never executed
1738branch 1 never executed
1739 #####: 1054: case DS_RM_SHARED:
1740 #####: 1055: if (!rec->ref[0] || ds_find_op(t, rec->ref) < 0) ok = 0;
1741branch 0 never executed (fallthrough)
1742branch 1 never executed
1743branch 2 never executed (fallthrough)
1744branch 3 never executed
1745 #####: 1056: for (int k = 0; k < t->n_removed; k++) if (!strcmp(t->removed[k].op, rec->ref)) { d->double_counted = 1; ok = 0; }
1746branch 0 never executed (fallthrough)
1747branch 1 never executed
1748branch 2 never executed
1749branch 3 never executed (fallthrough)
1750 -: 1057: break;
1751 -: 1058: }
1752 #####: 1059: if (!ok) {
1753branch 0 never executed (fallthrough)
1754branch 1 never executed
1755 #####: 1060: d->required_removed = 1;
1756 #####: 1061: snprintf(d->reason, sizeof d->reason, "op %s: removal reason %d not supported by its evidence (ref=%s proof=%s changed=%s)",
1757 #####: 1062: b->ops[i].id, rec->reason, rec->ref, rec->proof, o && o->changed ? o->changed : "");
1758branch 0 never executed (fallthrough)
1759branch 1 never executed
1760branch 2 never executed (fallthrough)
1761branch 3 never executed
1762 #####: 1063: return DS_REFUSED_REMOVED_REQUIRED;
1763 -: 1064: }
1764 #####: 1065: double w = b->ops[i].t_ns + b->ops[i].launch_ns;
1765 #####: 1066: if (b->ops[i].bytes > 0 && b->ops[i].bw >= 0) { double tb = b->ops[i].bytes / (b->res[b->ops[i].bw].cap * 1e-9); if (tb > b->ops[i].t_ns) w = tb + b->ops[i].launch_ns; }
1766branch 0 never executed (fallthrough)
1767branch 1 never executed
1768branch 2 never executed (fallthrough)
1769branch 3 never executed
1770branch 4 never executed (fallthrough)
1771branch 5 never executed
1772 #####: 1067: d->removed_ns[rec->reason] += w;
1773 -: 1068: }
1774 -: 1069: /* removed records that name ops never in the baseline are fabricated savings */
1775 #####: 1070: for (int k = 0; k < t->n_removed; k++) if (ds_find_op(b, t->removed[k].op) < 0) {
1776branch 0 never executed (fallthrough)
1777branch 1 never executed
1778branch 2 never executed
1779branch 3 never executed (fallthrough)
1780 #####: 1071: d->double_counted = 1;
1781 #####: 1072: snprintf(d->reason, sizeof d->reason, "removed record for %s, which was never in the baseline", t->removed[k].op);
1782 #####: 1073: return DS_REFUSED_REMOVED_REQUIRED;
1783 -: 1074: }
1784 -: 1075: return DS_OK;
1785 -: 1076:}
1786 -: 0:Source:/usr/include/aarch64-linux-gnu/bits/string_fortified.h
1787 -: 0:Graph:build/dagsim-parse/parser.gcno
1788 -: 0:Data:build/dagsim-parse/parser.gcda
1789 -: 0:Runs:9
1790 -: 1:/* Copyright (C) 2004-2024 Free Software Foundation, Inc.
1791 -: 2: This file is part of the GNU C Library.
1792 -: 3:
1793 -: 4: The GNU C Library is free software; you can redistribute it and/or
1794 -: 5: modify it under the terms of the GNU Lesser General Public
1795 -: 6: License as published by the Free Software Foundation; either
1796 -: 7: version 2.1 of the License, or (at your option) any later version.
1797 -: 8:
1798 -: 9: The GNU C Library is distributed in the hope that it will be useful,
1799 -: 10: but WITHOUT ANY WARRANTY; without even the implied warranty of
1800 -: 11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1801 -: 12: Lesser General Public License for more details.
1802 -: 13:
1803 -: 14: You should have received a copy of the GNU Lesser General Public
1804 -: 15: License along with the GNU C Library; if not, see
1805 -: 16: <https://www.gnu.org/licenses/>. */
1806 -: 17:
1807 -: 18:#ifndef _BITS_STRING_FORTIFIED_H
1808 -: 19:#define _BITS_STRING_FORTIFIED_H 1
1809 -: 20:
1810 -: 21:#ifndef _STRING_H
1811 -: 22:# error "Never use <bits/string_fortified.h> directly; include <string.h> instead."
1812 -: 23:#endif
1813 -: 24:
1814 -: 25:__fortify_function void *
1815 -: 26:__NTH (memcpy (void *__restrict __dest, const void *__restrict __src,
1816 -: 27: size_t __len))
1817 -: 28:{
1818 3585*: 29: return __builtin___memcpy_chk (__dest, __src, __len,
1819branch 0 never executed (fallthrough)
1820branch 1 never executed
1821branch 2 never executed (fallthrough)
1822branch 3 never executed
1823branch 4 never executed (fallthrough)
1824branch 5 never executed
1825call 6 returned 3431
1826call 7 returned 154
1827 -: 30: __glibc_objsize0 (__dest));
1828 -: 31:}
1829 -: 32:
1830 -: 33:__fortify_function void *
1831 -: 34:__NTH (memmove (void *__dest, const void *__src, size_t __len))
1832 -: 35:{
1833 -: 36: return __builtin___memmove_chk (__dest, __src, __len,
1834 -: 37: __glibc_objsize0 (__dest));
1835 -: 38:}
1836 -: 39:
1837 -: 40:#ifdef __USE_GNU
1838 -: 41:__fortify_function void *
1839 -: 42:__NTH (mempcpy (void *__restrict __dest, const void *__restrict __src,
1840 -: 43: size_t __len))
1841 -: 44:{
1842 -: 45: return __builtin___mempcpy_chk (__dest, __src, __len,
1843 -: 46: __glibc_objsize0 (__dest));
1844 -: 47:}
1845 -: 48:#endif
1846 -: 49:
1847 -: 50:
1848 -: 51:/* The first two tests here help to catch a somewhat common problem
1849 -: 52: where the second and third parameter are transposed. This is
1850 -: 53: especially problematic if the intended fill value is zero. In this
1851 -: 54: case no work is done at all. We detect these problems by referring
1852 -: 55: non-existing functions. */
1853 -: 56:__fortify_function void *
1854 -: 57:__NTH (memset (void *__dest, int __ch, size_t __len))
1855 -: 58:{
1856 3445*: 59: return __builtin___memset_chk (__dest, __ch, __len,
1857call 0 never executed
1858call 1 never executed
1859branch 2 never executed (fallthrough)
1860branch 3 never executed
1861branch 4 never executed (fallthrough)
1862branch 5 never executed
1863branch 6 never executed (fallthrough)
1864branch 7 never executed
1865call 8 never executed
1866branch 9 never executed (fallthrough)
1867branch 10 never executed
1868branch 11 never executed (fallthrough)
1869branch 12 never executed
1870branch 13 taken 3445 (fallthrough)
1871branch 14 taken 0
1872 -: 60: __glibc_objsize0 (__dest));
1873 -: 61:}
1874 -: 62:
1875 -: 63:#ifdef __USE_MISC
1876 -: 64:# include <bits/strings_fortified.h>
1877 -: 65:
1878 -: 66:void __explicit_bzero_chk (void *__dest, size_t __len, size_t __destlen)
1879 -: 67: __THROW __nonnull ((1)) __fortified_attr_access (__write_only__, 1, 2);
1880 -: 68:
1881 -: 69:__fortify_function void
1882 -: 70:__NTH (explicit_bzero (void *__dest, size_t __len))
1883 -: 71:{
1884 -: 72: __explicit_bzero_chk (__dest, __len, __glibc_objsize0 (__dest));
1885 -: 73:}
1886 -: 74:#endif
1887 -: 75:
1888 -: 76:__fortify_function char *
1889 -: 77:__NTH (strcpy (char *__restrict __dest, const char *__restrict __src))
1890 -: 78:{
1891 -: 79: return __builtin___strcpy_chk (__dest, __src, __glibc_objsize (__dest));
1892 -: 80:}
1893 -: 81:
1894 -: 82:#ifdef __USE_XOPEN2K8
1895 -: 83:__fortify_function char *
1896 -: 84:__NTH (stpcpy (char *__restrict __dest, const char *__restrict __src))
1897 -: 85:{
1898 -: 86: return __builtin___stpcpy_chk (__dest, __src, __glibc_objsize (__dest));
1899 -: 87:}
1900 -: 88:#endif
1901 -: 89:
1902 -: 90:
1903 -: 91:__fortify_function char *
1904 -: 92:__NTH (strncpy (char *__restrict __dest, const char *__restrict __src,
1905 -: 93: size_t __len))
1906 -: 94:{
1907 -: 95: return __builtin___strncpy_chk (__dest, __src, __len,
1908 -: 96: __glibc_objsize (__dest));
1909 -: 97:}
1910 -: 98:
1911 -: 99:#ifdef __USE_XOPEN2K8
1912 -: 100:# if __GNUC_PREREQ (4, 7) || __glibc_clang_prereq (2, 6)
1913 -: 101:__fortify_function char *
1914 -: 102:__NTH (stpncpy (char *__dest, const char *__src, size_t __n))
1915 -: 103:{
1916 -: 104: return __builtin___stpncpy_chk (__dest, __src, __n,
1917 -: 105: __glibc_objsize (__dest));
1918 -: 106:}
1919 -: 107:# else
1920 -: 108:extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n,
1921 -: 109: size_t __destlen) __THROW
1922 -: 110: __fortified_attr_access (__write_only__, 1, 3)
1923 -: 111: __attr_access ((__read_only__, 2));
1924 -: 112:extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, const char *__src,
1925 -: 113: size_t __n), stpncpy);
1926 -: 114:
1927 -: 115:__fortify_function char *
1928 -: 116:__NTH (stpncpy (char *__dest, const char *__src, size_t __n))
1929 -: 117:{
1930 -: 118: if (__bos (__dest) != (size_t) -1
1931 -: 119: && (!__builtin_constant_p (__n) || __n > __bos (__dest)))
1932 -: 120: return __stpncpy_chk (__dest, __src, __n, __bos (__dest));
1933 -: 121: return __stpncpy_alias (__dest, __src, __n);
1934 -: 122:}
1935 -: 123:# endif
1936 -: 124:#endif
1937 -: 125:
1938 -: 126:
1939 -: 127:__fortify_function char *
1940 -: 128:__NTH (strcat (char *__restrict __dest, const char *__restrict __src))
1941 -: 129:{
1942 -: 130: return __builtin___strcat_chk (__dest, __src, __glibc_objsize (__dest));
1943 -: 131:}
1944 -: 132:
1945 -: 133:
1946 -: 134:__fortify_function char *
1947 -: 135:__NTH (strncat (char *__restrict __dest, const char *__restrict __src,
1948 -: 136: size_t __len))
1949 -: 137:{
1950 -: 138: return __builtin___strncat_chk (__dest, __src, __len,
1951 -: 139: __glibc_objsize (__dest));
1952 -: 140:}
1953 -: 141:
1954 -: 142:#ifdef __USE_MISC
1955 -: 143:extern size_t __strlcpy_chk (char *__dest, const char *__src, size_t __n,
1956 -: 144: size_t __destlen) __THROW;
1957 -: 145:extern size_t __REDIRECT_NTH (__strlcpy_alias,
1958 -: 146: (char *__dest, const char *__src, size_t __n),
1959 -: 147: strlcpy);
1960 -: 148:
1961 -: 149:__fortify_function size_t
1962 -: 150:__NTH (strlcpy (char *__restrict __dest, const char *__restrict __src,
1963 -: 151: size_t __n))
1964 -: 152:{
1965 -: 153: if (__glibc_objsize (__dest) != (size_t) -1
1966 -: 154: && (!__builtin_constant_p (__n > __glibc_objsize (__dest))
1967 -: 155: || __n > __glibc_objsize (__dest)))
1968 -: 156: return __strlcpy_chk (__dest, __src, __n, __glibc_objsize (__dest));
1969 -: 157: return __strlcpy_alias (__dest, __src, __n);
1970 -: 158:}
1971 -: 159:
1972 -: 160:extern size_t __strlcat_chk (char *__dest, const char *__src, size_t __n,
1973 -: 161: size_t __destlen) __THROW;
1974 -: 162:extern size_t __REDIRECT_NTH (__strlcat_alias,
1975 -: 163: (char *__dest, const char *__src, size_t __n),
1976 -: 164: strlcat);
1977 -: 165:
1978 -: 166:__fortify_function size_t
1979 -: 167:__NTH (strlcat (char *__restrict __dest, const char *__restrict __src,
1980 -: 168: size_t __n))
1981 -: 169:{
1982 -: 170: if (__glibc_objsize (__dest) != (size_t) -1
1983 -: 171: && (!__builtin_constant_p (__n > __glibc_objsize (__dest))
1984 -: 172: || __n > __glibc_objsize (__dest)))
1985 -: 173: return __strlcat_chk (__dest, __src, __n, __glibc_objsize (__dest));
1986 -: 174: return __strlcat_alias (__dest, __src, __n);
1987 -: 175:}
1988 -: 176:#endif /* __USE_MISC */
1989 -: 177:
1990 -: 178:#endif /* bits/string_fortified.h */
1991 -: 0:Source:/usr/include/aarch64-linux-gnu/bits/stdio2.h
1992 -: 0:Graph:build/dagsim-parse/parser.gcno
1993 -: 0:Data:build/dagsim-parse/parser.gcda
1994 -: 0:Runs:9
1995 -: 1:/* Checking macros for stdio functions.
1996 -: 2: Copyright (C) 2004-2024 Free Software Foundation, Inc.
1997 -: 3: This file is part of the GNU C Library.
1998 -: 4:
1999 -: 5: The GNU C Library is free software; you can redistribute it and/or
2000 -: 6: modify it under the terms of the GNU Lesser General Public
2001 -: 7: License as published by the Free Software Foundation; either
2002 -: 8: version 2.1 of the License, or (at your option) any later version.
2003 -: 9:
2004 -: 10: The GNU C Library is distributed in the hope that it will be useful,
2005 -: 11: but WITHOUT ANY WARRANTY; without even the implied warranty of
2006 -: 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2007 -: 13: Lesser General Public License for more details.
2008 -: 14:
2009 -: 15: You should have received a copy of the GNU Lesser General Public
2010 -: 16: License along with the GNU C Library; if not, see
2011 -: 17: <https://www.gnu.org/licenses/>. */
2012 -: 18:
2013 -: 19:#ifndef _BITS_STDIO2_H
2014 -: 20:#define _BITS_STDIO2_H 1
2015 -: 21:
2016 -: 22:#ifndef _STDIO_H
2017 -: 23:# error "Never include <bits/stdio2.h> directly; use <stdio.h> instead."
2018 -: 24:#endif
2019 -: 25:
2020 -: 26:#ifdef __va_arg_pack
2021 -: 27:__fortify_function int
2022 -: 28:__NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...))
2023 -: 29:{
2024 -: 30: return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
2025 -: 31: __glibc_objsize (__s), __fmt,
2026 -: 32: __va_arg_pack ());
2027 -: 33:}
2028 -: 34:#elif !defined __cplusplus
2029 -: 35:# define sprintf(str, ...) \
2030 -: 36: __builtin___sprintf_chk (str, __USE_FORTIFY_LEVEL - 1, \
2031 -: 37: __glibc_objsize (str), __VA_ARGS__)
2032 -: 38:#endif
2033 -: 39:
2034 -: 40:__fortify_function int
2035 -: 41:__NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt,
2036 -: 42: __gnuc_va_list __ap))
2037 -: 43:{
2038 -: 44: return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
2039 -: 45: __glibc_objsize (__s), __fmt, __ap);
2040 -: 46:}
2041 -: 47:
2042 -: 48:#if defined __USE_ISOC99 || defined __USE_UNIX98
2043 -: 49:# ifdef __va_arg_pack
2044 -: 50:__fortify_function int
2045 -: 51:__NTH (snprintf (char *__restrict __s, size_t __n,
2046 -: 52: const char *__restrict __fmt, ...))
2047 -: 53:{
2048 2113*: 54: return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
2049call 0 never executed
2050call 1 never executed
2051call 2 never executed
2052call 3 never executed
2053call 4 never executed
2054call 5 never executed
2055call 6 never executed
2056 -: 55: __glibc_objsize (__s), __fmt,
2057 -: 56: __va_arg_pack ());
2058 -: 57:}
2059 -: 58:# elif !defined __cplusplus
2060 -: 59:# define snprintf(str, len, ...) \
2061 -: 60: __builtin___snprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, \
2062 -: 61: __glibc_objsize (str), __VA_ARGS__)
2063 -: 62:# endif
2064 -: 63:
2065 -: 64:__fortify_function int
2066 -: 65:__NTH (vsnprintf (char *__restrict __s, size_t __n,
2067 -: 66: const char *__restrict __fmt, __gnuc_va_list __ap))
2068 -: 67:{
2069 -: 68: return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
2070 -: 69: __glibc_objsize (__s), __fmt, __ap);
2071 -: 70:}
2072 -: 71:
2073 -: 72:#endif
2074 -: 73:
2075 -: 74:#if __USE_FORTIFY_LEVEL > 1
2076 -: 75:# ifdef __va_arg_pack
2077 -: 76:__fortify_function __nonnull ((1)) int
2078 -: 77:fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
2079 -: 78:{
2080 -: 79: return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
2081 -: 80: __va_arg_pack ());
2082 -: 81:}
2083 -: 82:
2084 -: 83:__fortify_function int
2085 -: 84:printf (const char *__restrict __fmt, ...)
2086 -: 85:{
2087 -: 86: return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
2088 -: 87:}
2089 -: 88:# elif !defined __cplusplus
2090 -: 89:# define printf(...) \
2091 -: 90: __printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2092 -: 91:# define fprintf(stream, ...) \
2093 -: 92: __fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2094 -: 93:# endif
2095 -: 94:
2096 -: 95:__fortify_function int
2097 -: 96:vprintf (const char *__restrict __fmt, __gnuc_va_list __ap)
2098 -: 97:{
2099 -: 98:#ifdef __USE_EXTERN_INLINES
2100 -: 99: return __vfprintf_chk (stdout, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
2101 -: 100:#else
2102 -: 101: return __vprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap);
2103 -: 102:#endif
2104 -: 103:}
2105 -: 104:
2106 -: 105:__fortify_function __nonnull ((1)) int
2107 -: 106:vfprintf (FILE *__restrict __stream,
2108 -: 107: const char *__restrict __fmt, __gnuc_va_list __ap)
2109 -: 108:{
2110 -: 109: return __vfprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
2111 -: 110:}
2112 -: 111:
2113 -: 112:# ifdef __USE_XOPEN2K8
2114 -: 113:# ifdef __va_arg_pack
2115 -: 114:__fortify_function int
2116 -: 115:dprintf (int __fd, const char *__restrict __fmt, ...)
2117 -: 116:{
2118 -: 117: return __dprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt,
2119 -: 118: __va_arg_pack ());
2120 -: 119:}
2121 -: 120:# elif !defined __cplusplus
2122 -: 121:# define dprintf(fd, ...) \
2123 -: 122: __dprintf_chk (fd, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2124 -: 123:# endif
2125 -: 124:
2126 -: 125:__fortify_function int
2127 -: 126:vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap)
2128 -: 127:{
2129 -: 128: return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
2130 -: 129:}
2131 -: 130:# endif
2132 -: 131:
2133 -: 132:# ifdef __USE_GNU
2134 -: 133:# ifdef __va_arg_pack
2135 -: 134:__fortify_function int
2136 -: 135:__NTH (asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...))
2137 -: 136:{
2138 -: 137: return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt,
2139 -: 138: __va_arg_pack ());
2140 -: 139:}
2141 -: 140:
2142 -: 141:__fortify_function int
2143 -: 142:__NTH (__asprintf (char **__restrict __ptr, const char *__restrict __fmt,
2144 -: 143: ...))
2145 -: 144:{
2146 -: 145: return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt,
2147 -: 146: __va_arg_pack ());
2148 -: 147:}
2149 -: 148:
2150 -: 149:__fortify_function int
2151 -: 150:__NTH (obstack_printf (struct obstack *__restrict __obstack,
2152 -: 151: const char *__restrict __fmt, ...))
2153 -: 152:{
2154 -: 153: return __obstack_printf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt,
2155 -: 154: __va_arg_pack ());
2156 -: 155:}
2157 -: 156:# elif !defined __cplusplus
2158 -: 157:# define asprintf(ptr, ...) \
2159 -: 158: __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2160 -: 159:# define __asprintf(ptr, ...) \
2161 -: 160: __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2162 -: 161:# define obstack_printf(obstack, ...) \
2163 -: 162: __obstack_printf_chk (obstack, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
2164 -: 163:# endif
2165 -: 164:
2166 -: 165:__fortify_function int
2167 -: 166:__NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt,
2168 -: 167: __gnuc_va_list __ap))
2169 -: 168:{
2170 -: 169: return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
2171 -: 170:}
2172 -: 171:
2173 -: 172:__fortify_function int
2174 -: 173:__NTH (obstack_vprintf (struct obstack *__restrict __obstack,
2175 -: 174: const char *__restrict __fmt, __gnuc_va_list __ap))
2176 -: 175:{
2177 -: 176: return __obstack_vprintf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt,
2178 -: 177: __ap);
2179 -: 178:}
2180 -: 179:
2181 -: 180:# endif
2182 -: 181:
2183 -: 182:#endif
2184 -: 183:
2185 -: 184:#if __GLIBC_USE (DEPRECATED_GETS)
2186 -: 185:__fortify_function __wur char *
2187 -: 186:gets (char *__str)
2188 -: 187:{
2189 -: 188: if (__glibc_objsize (__str) != (size_t) -1)
2190 -: 189: return __gets_chk (__str, __glibc_objsize (__str));
2191 -: 190: return __gets_warn (__str);
2192 -: 191:}
2193 -: 192:#endif
2194 -: 193:
2195 -: 194:__fortify_function __wur __fortified_attr_access (__write_only__, 1, 2)
2196 -: 195:__nonnull ((3)) char *
2197 -: 196:fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
2198 -: 197:{
2199 -: 198: size_t sz = __glibc_objsize (__s);
2200 -: 199: if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz))
2201 -: 200: return __fgets_alias (__s, __n, __stream);
2202 -: 201: if (__glibc_unsafe_len (__n, sizeof (char), sz))
2203 -: 202: return __fgets_chk_warn (__s, sz, __n, __stream);
2204 -: 203: return __fgets_chk (__s, sz, __n, __stream);
2205 -: 204:}
2206 -: 205:
2207 -: 206:__fortify_function __wur __nonnull ((4)) size_t
2208 -: 207:fread (void *__restrict __ptr, size_t __size, size_t __n,
2209 -: 208: FILE *__restrict __stream)
2210 -: 209:{
2211 #####: 210: size_t sz = __glibc_objsize0 (__ptr);
2212 #####: 211: if (__glibc_safe_or_unknown_len (__n, __size, sz))
2213branch 0 never executed (fallthrough)
2214branch 1 never executed
2215branch 2 never executed (fallthrough)
2216branch 3 never executed
2217branch 4 never executed (fallthrough)
2218branch 5 never executed
2219branch 6 never executed (fallthrough)
2220branch 7 never executed
2221 #####: 212: return __fread_alias (__ptr, __size, __n, __stream);
2222call 0 never executed
2223 -: 213: if (__glibc_unsafe_len (__n, __size, sz))
2224 #####: 214: return __fread_chk_warn (__ptr, sz, __size, __n, __stream);
2225call 0 never executed
2226 #####: 215: return __fread_chk (__ptr, sz, __size, __n, __stream);
2227call 0 never executed
2228 -: 216:}
2229 -: 217:
2230 -: 218:#ifdef __USE_GNU
2231 -: 219:__fortify_function __wur __fortified_attr_access (__write_only__, 1, 2)
2232 -: 220:__nonnull ((3)) char *
2233 -: 221:fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream)
2234 -: 222:{
2235 -: 223: size_t sz = __glibc_objsize (__s);
2236 -: 224: if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz))
2237 -: 225: return __fgets_unlocked_alias (__s, __n, __stream);
2238 -: 226: if (__glibc_unsafe_len (__n, sizeof (char), sz))
2239 -: 227: return __fgets_unlocked_chk_warn (__s, sz, __n, __stream);
2240 -: 228: return __fgets_unlocked_chk (__s, sz, __n, __stream);
2241 -: 229:}
2242 -: 230:#endif
2243 -: 231:
2244 -: 232:#ifdef __USE_MISC
2245 -: 233:# undef fread_unlocked
2246 -: 234:__fortify_function __wur __nonnull ((4)) size_t
2247 -: 235:fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
2248 -: 236: FILE *__restrict __stream)
2249 -: 237:{
2250 -: 238: size_t sz = __glibc_objsize0 (__ptr);
2251 -: 239: if (__glibc_safe_or_unknown_len (__n, __size, sz))
2252 -: 240: {
2253 -: 241:# ifdef __USE_EXTERN_INLINES
2254 -: 242: if (__builtin_constant_p (__size)
2255 -: 243: && __builtin_constant_p (__n)
2256 -: 244: && (__size | __n) < (((size_t) 1) << (8 * sizeof (size_t) / 2))
2257 -: 245: && __size * __n <= 8)
2258 -: 246: {
2259 -: 247: size_t __cnt = __size * __n;
2260 -: 248: char *__cptr = (char *) __ptr;
2261 -: 249: if (__cnt == 0)
2262 -: 250: return 0;
2263 -: 251:
2264 -: 252: for (; __cnt > 0; --__cnt)
2265 -: 253: {
2266 -: 254: int __c = getc_unlocked (__stream);
2267 -: 255: if (__c == EOF)
2268 -: 256: break;
2269 -: 257: *__cptr++ = __c;
2270 -: 258: }
2271 -: 259: return (__cptr - (char *) __ptr) / __size;
2272 -: 260: }
2273 -: 261:# endif
2274 -: 262: return __fread_unlocked_alias (__ptr, __size, __n, __stream);
2275 -: 263: }
2276 -: 264: if (__glibc_unsafe_len (__n, __size, sz))
2277 -: 265: return __fread_unlocked_chk_warn (__ptr, sz, __size, __n, __stream);
2278 -: 266: return __fread_unlocked_chk (__ptr, sz, __size, __n, __stream);
2279 -: 267:
2280 -: 268:}
2281 -: 269:#endif
2282 -: 270:
2283 -: 271:#endif /* bits/stdio2.h. */
2284 -: 0:Source:tools/dagsim/dagsim_format.h
2285 -: 0:Graph:build/dagsim-parse/parser.gcno
2286 -: 0:Data:build/dagsim-parse/parser.gcda
2287 -: 0:Runs:9
2288 -: 1:/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2289 -: 2: * Fixed-view ABI marshalling only; decisions and arithmetic live in dag_fmt.om. */
2290 -: 3:#ifndef DAGSIM_FORMAT_H
2291 -: 4:#define DAGSIM_FORMAT_H
2292 -: 5:#include "cudapp_native.h"
2293 -: 6:#include <stdint.h>
2294 -: 7:#include <stdlib.h>
2295 -: 8:#include <string.h>
2296function ds_fmt called 173 returned 100% blocks executed 75%
2297 173: 9:static inline uint64_t ds_fmt(unsigned mode, uint64_t a[16], char s[256]) {
2298 173: 10: uint64_t result = 0;
2299 173*: 11: if (omega_dag_fmt(&result, mode, a, 16, s, 256)) abort();
2300call 0 returned 173
2301branch 1 taken 0 (fallthrough)
2302branch 2 taken 173
2303call 3 never executed
2304 173: 12: return result;
2305 -: 13:}
2306 -: 14:static inline uint64_t ds_bits(double d) {
2307 -: 15: uint64_t u; memcpy(&u, &d, sizeof u); return u;
2308 -: 16:}
2309 -: 17:static inline double ds_unbits(uint64_t u) {
2310 -: 18: double d; memcpy(&d, &u, sizeof d); return d;
2311 -: 19:}
2312 -: 20:static inline uint64_t ds_decide(unsigned mode, uint64_t a[16]) {
2313 -: 21: char s[256]; return ds_fmt(mode, a, s);
2314 -: 22:}
2315 -: 23:#endif