CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / evidence / dagsim-parse-om / unpacker.gcov
| 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 |
| 80 | function 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; |
| 84 | call 0 returned 12 |
| 85 | -: 79:} |
| 86 | function 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; |
| 90 | call 0 returned 7 |
| 91 | -: 83:} |
| 92 | function 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; |
| 95 | branch 0 taken 73 (fallthrough) |
| 96 | branch 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); |
| 101 | call 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); |
| 105 | call 0 returned 154 |
| 106 | 154: 93: if (rc == 1) return (int32_t)a[12]; |
| 107 | branch 0 taken 65 (fallthrough) |
| 108 | branch 1 taken 89 |
| 109 | 89: 94: if (rc == 2) return -1; |
| 110 | branch 0 taken 81 (fallthrough) |
| 111 | branch 1 taken 8 |
| 112 | 81: 95: s += n; |
| 113 | -: 96: } |
| 114 | -: 97:} |
| 115 | -: 98:#endif |
| 116 | -: 99: |
| 117 | function 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; |
| 120 | branch 0 never executed (fallthrough) |
| 121 | branch 1 never executed |
| 122 | branch 2 never executed |
| 123 | branch 3 never executed (fallthrough) |
| 124 | -: 102: return -1; |
| 125 | -: 103:} |
| 126 | function 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; |
| 129 | branch 0 never executed (fallthrough) |
| 130 | branch 1 never executed |
| 131 | branch 2 never executed |
| 132 | branch 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. */ |
| 418 | function 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:} |
| 426 | function 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) { |
| 428 | branch 0 taken 3445 (fallthrough) |
| 429 | branch 1 taken 0 |
| 430 | -: 399: memset(m, 0, sizeof *m); |
| 431 | 3445: 400: if (errcap) err[0] = 0; |
| 432 | branch 0 taken 3445 (fallthrough) |
| 433 | branch 1 taken 0 |
| 434 | 3445: 401: size_t n = strnlen(text, 1048576); |
| 435 | 3445: 402: if (n == 1048576) { |
| 436 | branch 0 taken 14 (fallthrough) |
| 437 | branch 1 taken 3431 |
| 438 | 14: 403: if (errcap) snprintf(err, errcap, "file size out of range"); |
| 439 | branch 0 taken 14 (fallthrough) |
| 440 | branch 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) { |
| 446 | branch 0 taken 0 (fallthrough) |
| 447 | branch 1 taken 3431 |
| 448 | #####: 409: free(t); free(w); |
| 449 | #####: 410: if (errcap) snprintf(err, errcap, "out of memory"); |
| 450 | branch 0 never executed (fallthrough) |
| 451 | branch 1 never executed |
| 452 | #####: 411: return DS_PARSE_ERROR; |
| 453 | -: 412: } |
| 454 | 3431: 413: memcpy(t, text, n + 1); |
| 455 | call 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); |
| 459 | call 0 returned 3431 |
| 460 | 3431: 417: if (trap || rc) { |
| 461 | branch 0 taken 3431 (fallthrough) |
| 462 | branch 1 taken 0 |
| 463 | branch 2 taken 2099 (fallthrough) |
| 464 | branch 3 taken 1332 |
| 465 | 2099: 418: if (errcap) snprintf(err, errcap, "%s", trap ? "Omega parser trap" : (char *)error); |
| 466 | branch 0 taken 2099 (fallthrough) |
| 467 | branch 1 taken 0 |
| 468 | branch 2 taken 0 (fallthrough) |
| 469 | branch 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); |
| 481 | call 0 returned 1332 |
| 482 | call 1 returned 1332 |
| 483 | 1332: 430: dp_copy(m->repo, t, w, 21); dp_copy(m->build_sha, t, w, 23); |
| 484 | call 0 returned 1332 |
| 485 | call 1 returned 1332 |
| 486 | 1332: 431: dp_copy(m->physics, t, w, 25); dp_copy(m->cal_id, t, w, 27); |
| 487 | call 0 returned 1332 |
| 488 | call 1 returned 1332 |
| 489 | 1332: 432: dp_copy(m->cal_src, t, w, 29); dp_copy(m->cal_model, t, w, 31); |
| 490 | call 0 returned 1332 |
| 491 | call 1 returned 1332 |
| 492 | 1332: 433: dp_copy(m->instrument, t, w, 33); dp_copy(m->boundary, t, w, 35); |
| 493 | call 0 returned 1332 |
| 494 | call 1 returned 1332 |
| 495 | 5420: 434: for (int i = 0; i < m->n_res; i++) { |
| 496 | branch 0 taken 4088 |
| 497 | branch 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]; |
| 500 | call 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); |
| 503 | call 0 returned 4088 |
| 504 | -: 439: } |
| 505 | 6048: 440: for (int i = 0; i < m->n_ops; i++) { |
| 506 | branch 0 taken 4716 |
| 507 | branch 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]; |
| 510 | call 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); |
| 516 | call 0 returned 4716 |
| 517 | -: 448: } |
| 518 | 13678: 449: for (int i = 0; i < m->n_deps; i++) { |
| 519 | branch 0 taken 12346 |
| 520 | branch 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++) { |
| 525 | branch 0 taken 3223 |
| 526 | branch 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]; |
| 529 | call 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++) { |
| 533 | branch 0 taken 3164 |
| 534 | branch 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]; |
| 537 | call 0 returned 3164 |
| 538 | 3164: 461: dp_copy(r->ref, t, p, 3); dp_copy(r->proof, t, p, 5); |
| 539 | call 0 returned 3164 |
| 540 | call 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: |
| 547 | function 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"); |
| 550 | call 0 never executed |
| 551 | #####: 470: if (!fp) { snprintf(err, errcap, "cannot open %s", path); return DS_PARSE_ERROR; } |
| 552 | branch 0 never executed (fallthrough) |
| 553 | branch 1 never executed |
| 554 | #####: 471: fseek(fp, 0, SEEK_END); long n = ftell(fp); fseek(fp, 0, SEEK_SET); |
| 555 | call 0 never executed |
| 556 | call 1 never executed |
| 557 | call 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; } |
| 559 | branch 0 never executed (fallthrough) |
| 560 | branch 1 never executed |
| 561 | call 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; } |
| 564 | branch 0 never executed (fallthrough) |
| 565 | branch 1 never executed |
| 566 | call 2 never executed |
| 567 | #####: 475: size_t got = fread(buf, 1, (size_t)n, fp); buf[got] = 0; fclose(fp); |
| 568 | call 0 never executed |
| 569 | #####: 476: int rc = ds_parse_text(buf, m, err, errcap); |
| 570 | call 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; |
| 583 | branch 0 never executed (fallthrough) |
| 584 | branch 1 never executed |
| 585 | #####: 489: return r->cap; |
| 586 | -: 490:} |
| 587 | -: 491: |
| 588 | function 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) { |
| 590 | branch 0 never executed (fallthrough) |
| 591 | branch 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 : ""); |
| 595 | branch 0 never executed (fallthrough) |
| 596 | branch 1 never executed |
| 597 | branch 2 never executed (fallthrough) |
| 598 | branch 3 never executed |
| 599 | #####: 496: return status; |
| 600 | -: 497:} |
| 601 | -: 498: |
| 602 | function refuse_msg called 0 returned 0% blocks executed 0% |
| 603 | #####: 499:static int refuse_msg(ds_result *r, int status, const char *msg) { |
| 604 | branch 0 never executed (fallthrough) |
| 605 | branch 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 : ""); |
| 609 | branch 0 never executed (fallthrough) |
| 610 | branch 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 */ |
| 618 | branch 0 never executed (fallthrough) |
| 619 | branch 1 never executed |
| 620 | branch 2 never executed (fallthrough) |
| 621 | branch 3 never executed |
| 622 | branch 4 never executed |
| 623 | branch 5 never executed (fallthrough) |
| 624 | branch 6 never executed |
| 625 | branch 7 never executed (fallthrough) |
| 626 | -: 510:} |
| 627 | -: 511: |
| 628 | function 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++) { |
| 632 | branch 0 never executed |
| 633 | branch 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, ""); |
| 635 | branch 0 never executed (fallthrough) |
| 636 | branch 1 never executed |
| 637 | call 2 never executed |
| 638 | #####: 516: if (m->res[i].prov == DS_PROV_MEASURED || m->res[i].prov == DS_PROV_FITTED) any_cal = 1; |
| 639 | branch 0 never executed (fallthrough) |
| 640 | branch 1 never executed |
| 641 | -: 517: } |
| 642 | #####: 518: for (int i = 0; i < m->n_ops; i++) { |
| 643 | branch 0 never executed |
| 644 | branch 1 never executed (fallthrough) |
| 645 | -: 519: const ds_op *op = &m->ops[i]; |
| 646 | #####: 520: ds_num *x = &num[i]; |
| 647 | branch 0 never executed (fallthrough) |
| 648 | branch 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 */ |
| 654 | branch 0 never executed (fallthrough) |
| 655 | branch 1 never executed |
| 656 | branch 2 never executed (fallthrough) |
| 657 | branch 3 never executed |
| 658 | #####: 526: if (op->kind == DS_OP_MATVEC && !op->has_t) { |
| 659 | branch 0 never executed (fallthrough) |
| 660 | branch 1 never executed |
| 661 | branch 2 never executed (fallthrough) |
| 662 | branch 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, ""); |
| 665 | branch 0 never executed (fallthrough) |
| 666 | branch 1 never executed |
| 667 | call 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); |
| 674 | call 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, ""); |
| 676 | call 0 never executed |
| 677 | #####: 536: double q = o->interval_q > 0 && o->interval_q < 1 ? o->interval_q : 0.9; |
| 678 | branch 0 never executed (fallthrough) |
| 679 | branch 1 never executed |
| 680 | branch 2 never executed (fallthrough) |
| 681 | branch 3 never executed |
| 682 | #####: 537: double k = rx_cm_t_quantile(q, p.dof); |
| 683 | call 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); |
| 685 | branch 0 never executed (fallthrough) |
| 686 | branch 1 never executed |
| 687 | branch 2 never executed (fallthrough) |
| 688 | branch 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"); |
| 694 | branch 0 never executed (fallthrough) |
| 695 | branch 1 never executed |
| 696 | branch 2 never executed (fallthrough) |
| 697 | branch 3 never executed |
| 698 | call 4 never executed |
| 699 | #####: 544: x->t = o->mode < 0 ? op->hi : o->mode > 0 ? op->lo : op->t_ns; |
| 700 | branch 0 never executed (fallthrough) |
| 701 | branch 1 never executed |
| 702 | branch 2 never executed (fallthrough) |
| 703 | branch 3 never executed |
| 704 | #####: 545: if (op->t_prov == DS_PROV_MEASURED || op->t_prov == DS_PROV_FITTED) any_cal = 1; |
| 705 | branch 0 never executed |
| 706 | branch 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, ""); |
| 709 | branch 0 never executed (fallthrough) |
| 710 | branch 1 never executed |
| 711 | branch 2 never executed (fallthrough) |
| 712 | branch 3 never executed |
| 713 | call 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, ""); |
| 715 | branch 0 never executed (fallthrough) |
| 716 | branch 1 never executed |
| 717 | branch 2 never executed (fallthrough) |
| 718 | branch 3 never executed |
| 719 | call 4 never executed |
| 720 | -: 549: } |
| 721 | #####: 550: if (any_cal) { |
| 722 | branch 0 never executed (fallthrough) |
| 723 | branch 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", "", ""); |
| 725 | branch 0 never executed (fallthrough) |
| 726 | branch 1 never executed |
| 727 | call 2 never executed |
| 728 | #####: 552: int asof = o->asof_day; |
| 729 | #####: 553: if (asof <= 0) asof = (int)(time(NULL) / 86400); |
| 730 | branch 0 never executed (fallthrough) |
| 731 | branch 1 never executed |
| 732 | call 2 never executed |
| 733 | #####: 554: if (asof > m->cal_taken_day + m->cal_valid_days) { |
| 734 | branch 0 never executed (fallthrough) |
| 735 | branch 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); |
| 737 | call 0 never executed |
| 738 | #####: 556: return refuse(r, DS_REFUSED_STALE, "calibration %s is stale: %s", m->cal_id, d); |
| 739 | call 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. */ |
| 752 | function 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", "", ""); |
| 755 | branch 0 never executed (fallthrough) |
| 756 | branch 1 never executed |
| 757 | call 2 never executed |
| 758 | -: 571: ds_num num[DS_MAX_OPS]; |
| 759 | #####: 572: int rc = resolve(m, o, num, r); |
| 760 | call 0 never executed |
| 761 | #####: 573: if (rc) return rc; |
| 762 | branch 0 never executed (fallthrough) |
| 763 | branch 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; |
| 770 | branch 0 never executed (fallthrough) |
| 771 | branch 1 never executed |
| 772 | #####: 580: pk_d(&model[5], m->joules); |
| 773 | branch 0 never executed (fallthrough) |
| 774 | branch 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; |
| 778 | branch 0 never executed (fallthrough) |
| 779 | branch 1 never executed |
| 780 | #####: 584: model[9] = 1u; |
| 781 | #####: 585: for (int i = 0; i < m->n_ops; i++) { |
| 782 | branch 0 never executed |
| 783 | branch 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++) { |
| 796 | branch 0 never executed |
| 797 | branch 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++) { |
| 805 | branch 0 never executed |
| 806 | branch 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++) { |
| 812 | branch 0 never executed |
| 813 | branch 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 */ |
| 824 | function 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]++; |
| 828 | branch 0 never executed |
| 829 | branch 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; |
| 832 | branch 0 never executed (fallthrough) |
| 833 | branch 1 never executed |
| 834 | branch 2 never executed |
| 835 | branch 3 never executed (fallthrough) |
| 836 | #####: 625: while (head < n) { |
| 837 | branch 0 never executed |
| 838 | branch 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; |
| 841 | branch 0 never executed (fallthrough) |
| 842 | branch 1 never executed |
| 843 | branch 2 never executed |
| 844 | branch 3 never executed (fallthrough) |
| 845 | branch 4 never executed |
| 846 | branch 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; |
| 857 | branch 0 never executed (fallthrough) |
| 858 | branch 1 never executed |
| 859 | branch 2 never executed (fallthrough) |
| 860 | branch 3 never executed |
| 861 | branch 4 never executed (fallthrough) |
| 862 | branch 5 never executed |
| 863 | #####: 638: *e = m->buf[b].last >= 0 ? r->end_ns[m->buf[b].last] : r->makespan_ns; |
| 864 | branch 0 never executed (fallthrough) |
| 865 | branch 1 never executed |
| 866 | branch 2 never executed (fallthrough) |
| 867 | branch 3 never executed |
| 868 | branch 4 never executed (fallthrough) |
| 869 | branch 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"; |
| 874 | branch 0 never executed (fallthrough) |
| 875 | branch 1 never executed |
| 876 | -: 643:} |
| 877 | -: 644: |
| 878 | -: 645:/* Resolved end earlier than start is not an interval. Refuse before the ledger. */ |
| 879 | function 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++) { |
| 882 | branch 0 never executed |
| 883 | branch 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) { |
| 887 | branch 0 never executed (fallthrough) |
| 888 | branch 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, |
| 893 | branch 0 never executed (fallthrough) |
| 894 | branch 1 never executed |
| 895 | -: 655: endpoint_name(m, m->buf[b].last), e); |
| 896 | #####: 656: return refuse_msg(r, DS_REFUSED_LIFETIME, msg); |
| 897 | call 0 never executed |
| 898 | -: 657: } |
| 899 | -: 658: } |
| 900 | -: 659: return DS_OK; |
| 901 | -: 660:} |
| 902 | -: 661: |
| 903 | function 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) { |
| 905 | branch 0 never executed (fallthrough) |
| 906 | branch 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", "", ""); |
| 909 | branch 0 never executed (fallthrough) |
| 910 | branch 1 never executed |
| 911 | call 2 never executed |
| 912 | -: 665: ds_num num[DS_MAX_OPS]; |
| 913 | #####: 666: int rc = resolve(m, o, num, r); |
| 914 | call 0 never executed |
| 915 | #####: 667: if (rc) return rc; |
| 916 | branch 0 never executed (fallthrough) |
| 917 | branch 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", "", ""); |
| 920 | call 0 never executed |
| 921 | branch 1 never executed (fallthrough) |
| 922 | branch 2 never executed |
| 923 | call 3 never executed |
| 924 | -: 670: /* a buffer that never fits */ |
| 925 | #####: 671: for (int i = 0; i < m->n_buf; i++) |
| 926 | branch 0 never executed |
| 927 | branch 1 never executed (fallthrough) |
| 928 | #####: 672: if (m->buf[i].bytes > m->res[m->buf[i].cap].cap) |
| 929 | branch 0 never executed (fallthrough) |
| 930 | branch 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); |
| 932 | call 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; |
| 936 | branch 0 never executed |
| 937 | branch 1 never executed (fallthrough) |
| 938 | #####: 677: for (int i = 0; i < m->n_res; i++) { |
| 939 | branch 0 never executed |
| 940 | branch 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; |
| 943 | branch 0 never executed (fallthrough) |
| 944 | branch 1 never executed |
| 945 | branch 2 never executed (fallthrough) |
| 946 | branch 3 never executed |
| 947 | branch 4 never executed (fallthrough) |
| 948 | branch 5 never executed |
| 949 | branch 6 never executed |
| 950 | branch 7 never executed |
| 951 | #####: 680: for (int j = 0; j < m->n_buf; j++) if (m->buf[j].cap == i) used = 1; |
| 952 | branch 0 never executed (fallthrough) |
| 953 | branch 1 never executed |
| 954 | branch 2 never executed |
| 955 | branch 3 never executed (fallthrough) |
| 956 | #####: 681: if (used) r->prov_mask |= 1u << m->res[i].prov; |
| 957 | branch 0 never executed (fallthrough) |
| 958 | branch 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; |
| 966 | branch 0 never executed |
| 967 | branch 1 never executed |
| 968 | #####: 689: for (int i = 0; i < m->n_deps; i++) npred[m->deps[i].to]++; |
| 969 | branch 0 never executed |
| 970 | branch 1 never executed (fallthrough) |
| 971 | #####: 690: for (int i = 0; i < m->n_ops; i++) { |
| 972 | branch 0 never executed |
| 973 | branch 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) { |
| 982 | branch 0 never executed |
| 983 | branch 1 never executed |
| 984 | #####: 699: if (++guard > 8 * DS_MAX_OPS + 16) return refuse(r, DS_REFUSED_UNSUPPORTED, "scheduler did not converge%s%s", "", ""); |
| 985 | branch 0 never executed (fallthrough) |
| 986 | branch 1 never executed |
| 987 | call 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; } |
| 990 | branch 0 never executed (fallthrough) |
| 991 | branch 1 never executed |
| 992 | branch 2 never executed (fallthrough) |
| 993 | branch 3 never executed |
| 994 | branch 4 never executed |
| 995 | branch 5 never executed |
| 996 | -: 702: /* dispatch in file order */ |
| 997 | #####: 703: for (int i = 0; i < m->n_ops; i++) { |
| 998 | branch 0 never executed |
| 999 | branch 1 never executed (fallthrough) |
| 1000 | #####: 704: if (state[i] != ST_READY) continue; |
| 1001 | branch 0 never executed (fallthrough) |
| 1002 | branch 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; } |
| 1005 | branch 0 never executed (fallthrough) |
| 1006 | branch 1 never executed |
| 1007 | branch 2 never executed (fallthrough) |
| 1008 | branch 3 never executed |
| 1009 | #####: 707: if (op->launcher >= 0 && rem_l[i] > 0 && launcher_busy[op->launcher]) { blocked[i] = BLK_LAUNCHER; continue; } |
| 1010 | branch 0 never executed (fallthrough) |
| 1011 | branch 1 never executed |
| 1012 | branch 2 never executed (fallthrough) |
| 1013 | branch 3 never executed |
| 1014 | branch 4 never executed (fallthrough) |
| 1015 | branch 5 never executed |
| 1016 | #####: 708: if (op->engine >= 0) free_slots[op->engine]--; |
| 1017 | branch 0 never executed (fallthrough) |
| 1018 | branch 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; } |
| 1021 | branch 0 never executed (fallthrough) |
| 1022 | branch 1 never executed |
| 1023 | branch 2 never executed (fallthrough) |
| 1024 | branch 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]++; |
| 1030 | branch 0 never executed (fallthrough) |
| 1031 | branch 1 never executed |
| 1032 | branch 2 never executed (fallthrough) |
| 1033 | branch 3 never executed |
| 1034 | branch 4 never executed |
| 1035 | branch 5 never executed |
| 1036 | -: 716: double dt = -1; int any = 0; |
| 1037 | #####: 717: for (int i = 0; i < m->n_ops; i++) { |
| 1038 | branch 0 never executed |
| 1039 | branch 1 never executed (fallthrough) |
| 1040 | #####: 718: if (state[i] == ST_LAUNCH) { any = 1; if (dt < 0 || rem_l[i] < dt) dt = rem_l[i]; } |
| 1041 | branch 0 never executed (fallthrough) |
| 1042 | branch 1 never executed |
| 1043 | branch 2 never executed (fallthrough) |
| 1044 | branch 3 never executed |
| 1045 | branch 4 never executed (fallthrough) |
| 1046 | branch 5 never executed |
| 1047 | #####: 719: else if (state[i] == ST_RUN) { |
| 1048 | branch 0 never executed (fallthrough) |
| 1049 | branch 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]; |
| 1054 | branch 0 never executed (fallthrough) |
| 1055 | branch 1 never executed |
| 1056 | #####: 724: if (rem_b[i] > 0) { |
| 1057 | branch 0 never executed (fallthrough) |
| 1058 | branch 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; |
| 1062 | branch 0 never executed (fallthrough) |
| 1063 | branch 1 never executed |
| 1064 | branch 2 never executed |
| 1065 | branch 3 never executed (fallthrough) |
| 1066 | -: 728: } |
| 1067 | #####: 729: if (d < 0) d = 0; |
| 1068 | branch 0 never executed (fallthrough) |
| 1069 | branch 1 never executed |
| 1070 | #####: 730: if (dt < 0 || d < dt) dt = d; |
| 1071 | branch 0 never executed (fallthrough) |
| 1072 | branch 1 never executed |
| 1073 | branch 2 never executed (fallthrough) |
| 1074 | branch 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", "", ""); |
| 1078 | branch 0 never executed (fallthrough) |
| 1079 | branch 1 never executed |
| 1080 | call 2 never executed |
| 1081 | #####: 734: if (dt < 0) dt = 0; |
| 1082 | branch 0 never executed (fallthrough) |
| 1083 | branch 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++) { |
| 1087 | branch 0 never executed |
| 1088 | branch 1 never executed (fallthrough) |
| 1089 | #####: 738: if (state[i] == ST_LAUNCH) { |
| 1090 | branch 0 never executed (fallthrough) |
| 1091 | branch 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; } |
| 1094 | branch 0 never executed (fallthrough) |
| 1095 | branch 1 never executed |
| 1096 | #####: 741: } else if (state[i] == ST_RUN) { |
| 1097 | branch 0 never executed |
| 1098 | branch 1 never executed (fallthrough) |
| 1099 | #####: 742: if (rem_t[i] > 0) { rem_t[i] -= dt; if (rem_t[i] <= eps) rem_t[i] = 0; } |
| 1100 | branch 0 never executed (fallthrough) |
| 1101 | branch 1 never executed |
| 1102 | branch 2 never executed (fallthrough) |
| 1103 | branch 3 never executed |
| 1104 | #####: 743: if (rem_b[i] > 0) { |
| 1105 | branch 0 never executed (fallthrough) |
| 1106 | branch 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; } |
| 1110 | branch 0 never executed (fallthrough) |
| 1111 | branch 1 never executed |
| 1112 | branch 2 never executed (fallthrough) |
| 1113 | branch 3 never executed |
| 1114 | -: 747: } |
| 1115 | #####: 748: if (rem_t[i] <= 0 && rem_b[i] <= 0) { |
| 1116 | branch 0 never executed |
| 1117 | branch 1 never executed (fallthrough) |
| 1118 | branch 2 never executed |
| 1119 | branch 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]++; |
| 1122 | branch 0 never executed (fallthrough) |
| 1123 | branch 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]++; |
| 1125 | branch 0 never executed (fallthrough) |
| 1126 | branch 1 never executed |
| 1127 | branch 2 never executed |
| 1128 | branch 3 never executed (fallthrough) |
| 1129 | #####: 752: if (num[i].bytes > 0) { |
| 1130 | branch 0 never executed (fallthrough) |
| 1131 | branch 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]; |
| 1134 | branch 0 never executed (fallthrough) |
| 1135 | branch 1 never executed |
| 1136 | #####: 755: r->op_contention_ns[i] = actual - ideal > 0 ? actual - ideal : 0; |
| 1137 | branch 0 never executed (fallthrough) |
| 1138 | branch 1 never executed |
| 1139 | -: 756: } |
| 1140 | -: 757: } |
| 1141 | -: 758: } |
| 1142 | -: 759: } |
| 1143 | #####: 760: if (t > r->makespan_ns) r->makespan_ns = t; |
| 1144 | branch 0 never executed (fallthrough) |
| 1145 | branch 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++) { |
| 1151 | branch 0 never executed |
| 1152 | branch 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; |
| 1156 | branch 0 never executed (fallthrough) |
| 1157 | branch 1 never executed |
| 1158 | branch 2 never executed |
| 1159 | branch 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]; |
| 1164 | branch 0 never executed (fallthrough) |
| 1165 | branch 1 never executed |
| 1166 | branch 2 never executed |
| 1167 | branch 3 never executed (fallthrough) |
| 1168 | branch 4 never executed |
| 1169 | branch 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]; |
| 1172 | branch 0 never executed (fallthrough) |
| 1173 | branch 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++) { |
| 1177 | branch 0 never executed |
| 1178 | branch 1 never executed (fallthrough) |
| 1179 | -: 778: double w = 0; |
| 1180 | #####: 779: for (int j = 0; j < m->n_ops; j++) { |
| 1181 | branch 0 never executed |
| 1182 | branch 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; |
| 1184 | branch 0 never executed (fallthrough) |
| 1185 | branch 1 never executed |
| 1186 | branch 2 never executed (fallthrough) |
| 1187 | branch 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; |
| 1189 | branch 0 never executed (fallthrough) |
| 1190 | branch 1 never executed |
| 1191 | branch 2 never executed (fallthrough) |
| 1192 | branch 3 never executed |
| 1193 | #####: 782: if (m->res[i].kind == DS_RES_LAUNCH && m->ops[j].launcher == i) w += num[j].launch; |
| 1194 | branch 0 never executed (fallthrough) |
| 1195 | branch 1 never executed |
| 1196 | branch 2 never executed (fallthrough) |
| 1197 | branch 3 never executed |
| 1198 | -: 783: } |
| 1199 | #####: 784: r->bound_resource_ns[i] = w; |
| 1200 | #####: 785: if (w > r->bound_ns) r->bound_ns = w; |
| 1201 | branch 0 never executed (fallthrough) |
| 1202 | branch 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 */ |
| 1207 | call 0 never executed |
| 1208 | branch 1 never executed |
| 1209 | branch 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++) { |
| 1217 | branch 0 never executed |
| 1218 | branch 1 never executed |
| 1219 | #####: 797: if (m->res[c].kind != DS_RES_CAPACITY) continue; |
| 1220 | branch 0 never executed (fallthrough) |
| 1221 | branch 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++) { |
| 1226 | branch 0 never executed |
| 1227 | branch 1 never executed (fallthrough) |
| 1228 | #####: 802: if (m->buf[b].cap != c) continue; |
| 1229 | branch 0 never executed (fallthrough) |
| 1230 | branch 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; |
| 1234 | branch 0 never executed (fallthrough) |
| 1235 | branch 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++) { |
| 1241 | branch 0 never executed |
| 1242 | branch 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--; } |
| 1245 | branch 0 never executed (fallthrough) |
| 1246 | branch 1 never executed |
| 1247 | branch 2 never executed |
| 1248 | branch 3 never executed (fallthrough) |
| 1249 | branch 4 never executed (fallthrough) |
| 1250 | branch 5 never executed |
| 1251 | branch 6 never executed (fallthrough) |
| 1252 | branch 7 never executed |
| 1253 | branch 8 never executed |
| 1254 | branch 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++) { |
| 1258 | branch 0 never executed |
| 1259 | branch 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) { |
| 1264 | branch 0 never executed (fallthrough) |
| 1265 | branch 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]); |
| 1270 | call 0 never executed |
| 1271 | #####: 824: return refuse_msg(r, DS_REFUSED_LIFETIME, msg); |
| 1272 | call 0 never executed |
| 1273 | -: 825: } |
| 1274 | #####: 826: if (live > peak) { peak = live; peak_at = et[i]; } |
| 1275 | branch 0 never executed (fallthrough) |
| 1276 | branch 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) { |
| 1280 | branch 0 never executed (fallthrough) |
| 1281 | branch 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++) { |
| 1284 | branch 0 never executed (fallthrough) |
| 1285 | branch 1 never executed |
| 1286 | branch 2 never executed |
| 1287 | branch 3 never executed (fallthrough) |
| 1288 | #####: 832: if (m->buf[b].cap != c) continue; |
| 1289 | branch 0 never executed (fallthrough) |
| 1290 | branch 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); } |
| 1294 | branch 0 never executed (fallthrough) |
| 1295 | branch 1 never executed |
| 1296 | branch 2 never executed (fallthrough) |
| 1297 | branch 3 never executed |
| 1298 | branch 4 never executed (fallthrough) |
| 1299 | branch 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); |
| 1303 | call 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; |
| 1311 | branch 0 never executed (fallthrough) |
| 1312 | branch 1 never executed |
| 1313 | branch 2 never executed |
| 1314 | branch 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) { |
| 1318 | branch 0 never executed |
| 1319 | branch 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]); |
| 1323 | branch 0 never executed (fallthrough) |
| 1324 | branch 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; |
| 1328 | branch 0 never executed (fallthrough) |
| 1329 | branch 1 never executed |
| 1330 | #####: 855: else if (num[cur].bytes > 0) { |
| 1331 | branch 0 never executed (fallthrough) |
| 1332 | branch 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; |
| 1336 | branch 0 never executed (fallthrough) |
| 1337 | branch 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; } |
| 1339 | branch 0 never executed (fallthrough) |
| 1340 | branch 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; |
| 1346 | branch 0 never executed (fallthrough) |
| 1347 | branch 1 never executed |
| 1348 | branch 2 never executed (fallthrough) |
| 1349 | branch 3 never executed |
| 1350 | branch 4 never executed (fallthrough) |
| 1351 | branch 5 never executed |
| 1352 | branch 6 never executed |
| 1353 | branch 7 never executed (fallthrough) |
| 1354 | #####: 865: double gap = r->start_ns[cur] - (pred >= 0 ? r->end_ns[pred] : 0); |
| 1355 | branch 0 never executed (fallthrough) |
| 1356 | branch 1 never executed |
| 1357 | #####: 866: if (gap > 0) { |
| 1358 | branch 0 never executed (fallthrough) |
| 1359 | branch 1 never executed |
| 1360 | #####: 867: if (blocked[cur] == BLK_SLOT) r->attr_ns[DS_ATTR_SERIALIZATION] += gap; |
| 1361 | branch 0 never executed (fallthrough) |
| 1362 | branch 1 never executed |
| 1363 | #####: 868: else if (blocked[cur] == BLK_LAUNCHER) r->attr_ns[DS_ATTR_LAUNCH] += gap; |
| 1364 | branch 0 never executed (fallthrough) |
| 1365 | branch 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]; |
| 1372 | branch 0 never executed |
| 1373 | branch 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; |
| 1377 | branch 0 never executed (fallthrough) |
| 1378 | branch 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; } |
| 1382 | branch 0 never executed (fallthrough) |
| 1383 | branch 1 never executed |
| 1384 | branch 2 never executed (fallthrough) |
| 1385 | branch 3 never executed |
| 1386 | branch 4 never executed (fallthrough) |
| 1387 | branch 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; } |
| 1389 | branch 0 never executed (fallthrough) |
| 1390 | branch 1 never executed |
| 1391 | branch 2 never executed (fallthrough) |
| 1392 | branch 3 never executed |
| 1393 | branch 4 never executed (fallthrough) |
| 1394 | branch 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: |
| 1409 | function 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++) { |
| 1414 | branch 0 never executed (fallthrough) |
| 1415 | branch 1 never executed |
| 1416 | branch 2 never executed |
| 1417 | branch 3 never executed (fallthrough) |
| 1418 | #####: 900: if (!(s[6336 + b / 64] & (1ull << (b % 64)))) continue; |
| 1419 | branch 0 never executed (fallthrough) |
| 1420 | branch 1 never executed |
| 1421 | #####: 901: snprintf(names + L, cap - L, "%s%s", L ? "," : "", m->buf[b].id); |
| 1422 | branch 0 never executed (fallthrough) |
| 1423 | branch 1 never executed |
| 1424 | #####: 902: L = strlen(names); |
| 1425 | -: 903: } |
| 1426 | #####: 904:} |
| 1427 | -: 905: |
| 1428 | function 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]; |
| 1431 | branch 0 never executed (fallthrough) |
| 1432 | branch 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", "", ""); |
| 1436 | branch 0 never executed (fallthrough) |
| 1437 | branch 1 never executed |
| 1438 | call 2 never executed |
| 1439 | #####: 911: if (why == 3 && a >= 0 && a < m->n_buf && b >= 0 && b < m->n_res) |
| 1440 | branch 0 never executed (fallthrough) |
| 1441 | branch 1 never executed |
| 1442 | branch 2 never executed (fallthrough) |
| 1443 | branch 3 never executed |
| 1444 | branch 4 never executed (fallthrough) |
| 1445 | branch 5 never executed |
| 1446 | branch 6 never executed (fallthrough) |
| 1447 | branch 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); |
| 1449 | call 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", "", ""); |
| 1451 | branch 0 never executed (fallthrough) |
| 1452 | branch 1 never executed |
| 1453 | call 2 never executed |
| 1454 | #####: 914: if (why == 5) return refuse(r, DS_REFUSED_UNSUPPORTED, "scheduler did not converge%s%s", "", ""); |
| 1455 | branch 0 never executed (fallthrough) |
| 1456 | branch 1 never executed |
| 1457 | call 2 never executed |
| 1458 | #####: 915: if (why == 6 && a >= 0 && a < m->n_buf) { |
| 1459 | branch 0 never executed (fallthrough) |
| 1460 | branch 1 never executed |
| 1461 | branch 2 never executed (fallthrough) |
| 1462 | branch 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); |
| 1465 | branch 0 never executed (fallthrough) |
| 1466 | branch 1 never executed |
| 1467 | branch 2 never executed (fallthrough) |
| 1468 | branch 3 never executed |
| 1469 | #####: 918: return refuse_msg(r, DS_REFUSED_LIFETIME, msg); |
| 1470 | call 0 never executed |
| 1471 | -: 919: } |
| 1472 | #####: 920: if (why == 7 && a >= 0 && a < m->n_res) { |
| 1473 | branch 0 never executed (fallthrough) |
| 1474 | branch 1 never executed |
| 1475 | branch 2 never executed (fallthrough) |
| 1476 | branch 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); |
| 1479 | call 0 never executed |
| 1480 | #####: 923: return refuse_msg(r, DS_REFUSED_LIFETIME, msg); |
| 1481 | call 0 never executed |
| 1482 | -: 924: } |
| 1483 | #####: 925: if (why == 8 && a >= 0 && a < m->n_res) { |
| 1484 | branch 0 never executed (fallthrough) |
| 1485 | branch 1 never executed |
| 1486 | branch 2 never executed (fallthrough) |
| 1487 | branch 3 never executed |
| 1488 | -: 926: char names[160], what[200]; |
| 1489 | #####: 927: om_names(m, s, names, sizeof names); |
| 1490 | call 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); |
| 1493 | call 0 never executed |
| 1494 | -: 930: } |
| 1495 | #####: 931: return refuse(r, DS_REFUSED_UNSUPPORTED, "omega refusal %s%s", "", ""); |
| 1496 | call 0 never executed |
| 1497 | -: 932:} |
| 1498 | -: 933: |
| 1499 | function 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); |
| 1502 | branch 0 never executed (fallthrough) |
| 1503 | branch 1 never executed |
| 1504 | call 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++) { |
| 1521 | branch 0 never executed |
| 1522 | branch 1 never executed |
| 1523 | #####: 952: r->start_ns[i] = om_f(s, 4512 + i); |
| 1524 | branch 0 never executed (fallthrough) |
| 1525 | branch 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]; |
| 1531 | branch 0 never executed (fallthrough) |
| 1532 | branch 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); |
| 1535 | branch 0 never executed |
| 1536 | branch 1 never executed |
| 1537 | #####: 960: for (int i = 0; i < m->n_res; i++) { |
| 1538 | branch 0 never executed |
| 1539 | branch 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 |
| 1548 | function 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); |
| 1554 | branch 0 never executed (fallthrough) |
| 1555 | branch 1 never executed |
| 1556 | call 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); |
| 1560 | call 0 never executed |
| 1561 | #####: 977: if (rc) return rc; |
| 1562 | branch 0 never executed (fallthrough) |
| 1563 | branch 1 never executed |
| 1564 | -: 978: memset(scratch, 0, sizeof scratch); |
| 1565 | #####: 979: if (omega_dag_eval(&result, model, 8192, scratch, 8192)) |
| 1566 | call 0 never executed |
| 1567 | branch 1 never executed (fallthrough) |
| 1568 | branch 2 never executed |
| 1569 | #####: 980: return refuse(r, DS_REFUSED_UNSUPPORTED, "omega trap%s%s", "", ""); |
| 1570 | call 0 never executed |
| 1571 | #####: 981: return om_fill(m, scratch, r); |
| 1572 | call 0 never executed |
| 1573 | -: 982:#endif |
| 1574 | -: 983:} |
| 1575 | -: 984: |
| 1576 | function 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); |
| 1580 | call 0 never executed |
| 1581 | #####: 988: *lo_ns = *hi_ns = 0; |
| 1582 | #####: 989: if (rc) return rc; |
| 1583 | branch 0 never executed (fallthrough) |
| 1584 | branch 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; |
| 1587 | call 0 never executed |
| 1588 | branch 1 never executed (fallthrough) |
| 1589 | branch 2 never executed |
| 1590 | #####: 992: x.mode = -1; if (ds_eval(m, &x, &tmp) == DS_OK) *hi_ns = tmp.makespan_ns; |
| 1591 | call 0 never executed |
| 1592 | branch 1 never executed (fallthrough) |
| 1593 | branch 2 never executed |
| 1594 | -: 993: return rc; |
| 1595 | -: 994:} |
| 1596 | -: 995: |
| 1597 | function 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; |
| 1600 | branch 0 never executed (fallthrough) |
| 1601 | branch 1 never executed |
| 1602 | branch 2 never executed (fallthrough) |
| 1603 | branch 3 never executed |
| 1604 | #####: 998: ds_model *c = malloc(sizeof *c); |
| 1605 | #####: 999: if (!c) return -DS_REFUSED_UNSUPPORTED; |
| 1606 | branch 0 never executed |
| 1607 | branch 1 never executed (fallthrough) |
| 1608 | #####: 1000: *c = *m; |
| 1609 | -: 1001: ds_resource *r = &c->res[res_index]; |
| 1610 | #####: 1002: switch (r->kind) { |
| 1611 | branch 0 never executed |
| 1612 | branch 1 never executed |
| 1613 | branch 2 never executed |
| 1614 | branch 3 never executed |
| 1615 | branch 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; |
| 1619 | branch 0 never executed (fallthrough) |
| 1620 | branch 1 never executed |
| 1621 | branch 2 never executed |
| 1622 | branch 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); |
| 1627 | call 0 never executed |
| 1628 | #####: 1010: free(c); |
| 1629 | #####: 1011: return rc == DS_OK ? res.makespan_ns : -(double)rc; |
| 1630 | branch 0 never executed (fallthrough) |
| 1631 | branch 1 never executed |
| 1632 | -: 1012:} |
| 1633 | -: 1013: |
| 1634 | -: 1014:/* ---------------------------------------------------------------- diff */ |
| 1635 | -: 1015: |
| 1636 | function 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; |
| 1639 | branch 0 never executed (fallthrough) |
| 1640 | branch 1 never executed |
| 1641 | #####: 1018: const char *p = list; size_t L = strlen(id); |
| 1642 | #####: 1019: while (*p) { |
| 1643 | branch 0 never executed |
| 1644 | branch 1 never executed (fallthrough) |
| 1645 | #####: 1020: const char *q = strchr(p, ','); size_t n = q ? (size_t)(q - p) : strlen(p); |
| 1646 | branch 0 never executed (fallthrough) |
| 1647 | branch 1 never executed |
| 1648 | #####: 1021: if (n == L && !strncmp(p, id, L)) return 1; |
| 1649 | branch 0 never executed (fallthrough) |
| 1650 | branch 1 never executed |
| 1651 | branch 2 never executed (fallthrough) |
| 1652 | branch 3 never executed |
| 1653 | #####: 1022: if (!q) break; |
| 1654 | branch 0 never executed (fallthrough) |
| 1655 | branch 1 never executed |
| 1656 | #####: 1023: p = q + 1; |
| 1657 | -: 1024: } |
| 1658 | -: 1025: return 0; |
| 1659 | -: 1026:} |
| 1660 | -: 1027: |
| 1661 | function 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++; |
| 1665 | branch 0 never executed (fallthrough) |
| 1666 | branch 1 never executed |
| 1667 | branch 2 never executed |
| 1668 | branch 3 never executed |
| 1669 | #####: 1031: for (int i = 0; i < b->n_ops; i++) { |
| 1670 | branch 0 never executed |
| 1671 | branch 1 never executed |
| 1672 | #####: 1032: int j = ds_find_op(t, b->ops[i].id); |
| 1673 | #####: 1033: if (j >= 0) { |
| 1674 | branch 0 never executed (fallthrough) |
| 1675 | branch 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) |
| 1678 | branch 0 never executed (fallthrough) |
| 1679 | branch 1 never executed |
| 1680 | branch 2 never executed (fallthrough) |
| 1681 | branch 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]; } |
| 1689 | branch 0 never executed (fallthrough) |
| 1690 | branch 1 never executed |
| 1691 | branch 2 never executed |
| 1692 | branch 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; } |
| 1694 | branch 0 never executed (fallthrough) |
| 1695 | branch 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; } |
| 1697 | branch 0 never executed (fallthrough) |
| 1698 | branch 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; |
| 1702 | branch 0 never executed (fallthrough) |
| 1703 | branch 1 never executed |
| 1704 | branch 2 never executed |
| 1705 | branch 3 never executed (fallthrough) |
| 1706 | branch 4 never executed |
| 1707 | branch 5 never executed (fallthrough) |
| 1708 | -: 1048: int ok = 1; |
| 1709 | #####: 1049: switch (rec->reason) { |
| 1710 | branch 0 never executed |
| 1711 | branch 1 never executed |
| 1712 | branch 2 never executed |
| 1713 | branch 3 never executed |
| 1714 | branch 4 never executed |
| 1715 | branch 5 never executed |
| 1716 | #####: 1050: case DS_RM_ELIMINATED: if (has_consumer && !rec->proof[0]) ok = 0; break; |
| 1717 | branch 0 never executed (fallthrough) |
| 1718 | branch 1 never executed |
| 1719 | branch 2 never executed |
| 1720 | branch 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; |
| 1722 | branch 0 never executed (fallthrough) |
| 1723 | branch 1 never executed |
| 1724 | branch 2 never executed |
| 1725 | branch 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; |
| 1727 | branch 0 never executed (fallthrough) |
| 1728 | branch 1 never executed |
| 1729 | branch 2 never executed (fallthrough) |
| 1730 | branch 3 never executed |
| 1731 | branch 4 never executed (fallthrough) |
| 1732 | branch 5 never executed |
| 1733 | call 6 never executed |
| 1734 | branch 7 never executed |
| 1735 | branch 8 never executed |
| 1736 | #####: 1053: case DS_RM_DEFERRED: if (has_consumer) ok = 0; break; |
| 1737 | branch 0 never executed |
| 1738 | branch 1 never executed |
| 1739 | #####: 1054: case DS_RM_SHARED: |
| 1740 | #####: 1055: if (!rec->ref[0] || ds_find_op(t, rec->ref) < 0) ok = 0; |
| 1741 | branch 0 never executed (fallthrough) |
| 1742 | branch 1 never executed |
| 1743 | branch 2 never executed (fallthrough) |
| 1744 | branch 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; } |
| 1746 | branch 0 never executed (fallthrough) |
| 1747 | branch 1 never executed |
| 1748 | branch 2 never executed |
| 1749 | branch 3 never executed (fallthrough) |
| 1750 | -: 1057: break; |
| 1751 | -: 1058: } |
| 1752 | #####: 1059: if (!ok) { |
| 1753 | branch 0 never executed (fallthrough) |
| 1754 | branch 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 : ""); |
| 1758 | branch 0 never executed (fallthrough) |
| 1759 | branch 1 never executed |
| 1760 | branch 2 never executed (fallthrough) |
| 1761 | branch 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; } |
| 1766 | branch 0 never executed (fallthrough) |
| 1767 | branch 1 never executed |
| 1768 | branch 2 never executed (fallthrough) |
| 1769 | branch 3 never executed |
| 1770 | branch 4 never executed (fallthrough) |
| 1771 | branch 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) { |
| 1776 | branch 0 never executed (fallthrough) |
| 1777 | branch 1 never executed |
| 1778 | branch 2 never executed |
| 1779 | branch 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, |
| 1819 | branch 0 never executed (fallthrough) |
| 1820 | branch 1 never executed |
| 1821 | branch 2 never executed (fallthrough) |
| 1822 | branch 3 never executed |
| 1823 | branch 4 never executed (fallthrough) |
| 1824 | branch 5 never executed |
| 1825 | call 6 returned 3431 |
| 1826 | call 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, |
| 1857 | call 0 never executed |
| 1858 | call 1 never executed |
| 1859 | branch 2 never executed (fallthrough) |
| 1860 | branch 3 never executed |
| 1861 | branch 4 never executed (fallthrough) |
| 1862 | branch 5 never executed |
| 1863 | branch 6 never executed (fallthrough) |
| 1864 | branch 7 never executed |
| 1865 | call 8 never executed |
| 1866 | branch 9 never executed (fallthrough) |
| 1867 | branch 10 never executed |
| 1868 | branch 11 never executed (fallthrough) |
| 1869 | branch 12 never executed |
| 1870 | branch 13 taken 3445 (fallthrough) |
| 1871 | branch 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, |
| 2049 | call 0 never executed |
| 2050 | call 1 never executed |
| 2051 | call 2 never executed |
| 2052 | call 3 never executed |
| 2053 | call 4 never executed |
| 2054 | call 5 never executed |
| 2055 | call 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)) |
| 2213 | branch 0 never executed (fallthrough) |
| 2214 | branch 1 never executed |
| 2215 | branch 2 never executed (fallthrough) |
| 2216 | branch 3 never executed |
| 2217 | branch 4 never executed (fallthrough) |
| 2218 | branch 5 never executed |
| 2219 | branch 6 never executed (fallthrough) |
| 2220 | branch 7 never executed |
| 2221 | #####: 212: return __fread_alias (__ptr, __size, __n, __stream); |
| 2222 | call 0 never executed |
| 2223 | -: 213: if (__glibc_unsafe_len (__n, __size, sz)) |
| 2224 | #####: 214: return __fread_chk_warn (__ptr, sz, __size, __n, __stream); |
| 2225 | call 0 never executed |
| 2226 | #####: 215: return __fread_chk (__ptr, sz, __size, __n, __stream); |
| 2227 | call 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> |
| 2296 | function 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(); |
| 2300 | call 0 returned 173 |
| 2301 | branch 1 taken 0 (fallthrough) |
| 2302 | branch 2 taken 173 |
| 2303 | call 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 |