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