CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / evidence / dagsim-resolve-om / scheduler-resolve.gcov
| 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 <ctype.h> |
| 20 | -: 16:#include <math.h> |
| 21 | -: 17:#include <stdio.h> |
| 22 | -: 18:#include <stdlib.h> |
| 23 | -: 19:#include <string.h> |
| 24 | -: 20:#include <time.h> |
| 25 | -: 21:#if !CUDAPP_MIGRATION_PENDING_C_DAGSIM_PARSE |
| 26 | -: 22:#include "dagsim_format.h" |
| 27 | -: 23:#endif |
| 28 | -: 24: |
| 29 | -: 25:/* ---------------------------------------------------------------- names */ |
| 30 | -: 26: |
| 31 | -: 27:#if CUDAPP_MIGRATION_PENDING_C_DAGSIM_PARSE |
| 32 | -: 28:const char *ds_status_name(int s) { |
| 33 | -: 29: switch (s) { |
| 34 | -: 30: case DS_OK: return "OK"; |
| 35 | -: 31: case DS_REFUSED_UNKNOWN: return "REFUSED_UNKNOWN"; |
| 36 | -: 32: case DS_REFUSED_STALE: return "REFUSED_STALE"; |
| 37 | -: 33: case DS_REFUSED_NO_CALIBRATION: return "REFUSED_NO_CALIBRATION"; |
| 38 | -: 34: case DS_REFUSED_CAPACITY: return "REFUSED_CAPACITY"; |
| 39 | -: 35: case DS_REFUSED_CYCLE: return "REFUSED_CYCLE"; |
| 40 | -: 36: case DS_REFUSED_UNSUPPORTED: return "REFUSED_UNSUPPORTED"; |
| 41 | -: 37: case DS_REFUSED_REMOVED_REQUIRED: return "REFUSED_REMOVED_REQUIRED"; |
| 42 | -: 38: case DS_REFUSED_LIFETIME: return "REFUSED_LIFETIME"; |
| 43 | -: 39: case DS_PARSE_ERROR: return "PARSE_ERROR"; |
| 44 | -: 40: default: return "?"; |
| 45 | -: 41: } |
| 46 | -: 42:} |
| 47 | -: 43: |
| 48 | -: 44:const char *ds_prov_name(int p) { |
| 49 | -: 45: switch (p) { |
| 50 | -: 46: case DS_PROV_UNKNOWN: return "unknown"; |
| 51 | -: 47: case DS_PROV_SYNTHETIC: return "synthetic"; |
| 52 | -: 48: case DS_PROV_FITTED: return "fitted"; |
| 53 | -: 49: case DS_PROV_MEASURED: return "measured"; |
| 54 | -: 50: case DS_PROV_SPECIFIED: return "specified"; |
| 55 | -: 51: default: return "?"; |
| 56 | -: 52: } |
| 57 | -: 53:} |
| 58 | -: 54: |
| 59 | -: 55:static int prov_from_name(const char *s) { |
| 60 | -: 56: if (!strcmp(s, "unknown")) return DS_PROV_UNKNOWN; |
| 61 | -: 57: if (!strcmp(s, "synthetic")) return DS_PROV_SYNTHETIC; |
| 62 | -: 58: if (!strcmp(s, "fitted")) return DS_PROV_FITTED; |
| 63 | -: 59: if (!strcmp(s, "measured")) return DS_PROV_MEASURED; |
| 64 | -: 60: if (!strcmp(s, "specified")) return DS_PROV_SPECIFIED; |
| 65 | -: 61: return -1; |
| 66 | -: 62:} |
| 67 | -: 63: |
| 68 | -: 64:/* days since 1970-01-01 for a civil date (Howard Hinnant's days_from_civil) */ |
| 69 | -: 65:int ds_day_from_date(const char *s) { |
| 70 | -: 66: int y, m, d; |
| 71 | -: 67: if (!s || sscanf(s, "%d-%d-%d", &y, &m, &d) != 3) return -1; |
| 72 | -: 68: y -= m <= 2; |
| 73 | -: 69: int era = (y >= 0 ? y : y - 399) / 400; |
| 74 | -: 70: unsigned yoe = (unsigned)(y - era * 400); |
| 75 | -: 71: unsigned doy = (153u * (unsigned)(m + (m > 2 ? -3 : 9)) + 2u) / 5u + (unsigned)d - 1u; |
| 76 | -: 72: unsigned doe = yoe * 365u + yoe / 4u - yoe / 100u + doy; |
| 77 | -: 73: return era * 146097 + (int)doe - 719468; |
| 78 | -: 74:} |
| 79 | -: 75:#else |
| 80 | function ds_status_name called 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=<bandwidth resource defined above>"); |
| 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=<launch resource defined above>"); |
| 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 <from> <to>"); |
| 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=<capacity resource>"); |
| 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:static const char *endpoint_name(const ds_model *m, int op) { |
| 749 | #####: 641: return op >= 0 ? m->ops[op].id : "omitted"; |
| 750 | -: 642:} |
| 751 | -: 643: |
| 752 | -: 644:#ifdef CUDAPP_MIGRATION_PENDING_C_TOOLS |
| 753 | -: 645:/* Kahn topological order; returns 0 on a cycle */ |
| 754 | -: 646:static int topo(const ds_model *m, int *order) { |
| 755 | -: 647: int indeg[DS_MAX_OPS] = {0}; |
| 756 | -: 648: for (int i = 0; i < m->n_deps; i++) indeg[m->deps[i].to]++; |
| 757 | -: 649: int n = 0, head = 0; |
| 758 | -: 650: for (int i = 0; i < m->n_ops; i++) if (indeg[i] == 0) order[n++] = i; |
| 759 | -: 651: while (head < n) { |
| 760 | -: 652: int u = order[head++]; |
| 761 | -: 653: 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; |
| 762 | -: 654: } |
| 763 | -: 655: return n == m->n_ops; |
| 764 | -: 656:} |
| 765 | -: 657: |
| 766 | -: 658:enum { ST_WAIT = 0, ST_READY, ST_LAUNCH, ST_RUN, ST_DONE }; |
| 767 | -: 659:enum { BLK_NONE = 0, BLK_SLOT, BLK_LAUNCHER }; |
| 768 | -: 660: |
| 769 | -: 661:/* Half-open [start, end). Missing first -> 0; missing last -> makespan. */ |
| 770 | -: 662:static void buffer_window(const ds_model *m, const ds_result *r, int b, double *s, double *e) { |
| 771 | -: 663: *s = m->buf[b].first >= 0 ? r->start_ns[m->buf[b].first] : 0.0; |
| 772 | -: 664: *e = m->buf[b].last >= 0 ? r->end_ns[m->buf[b].last] : r->makespan_ns; |
| 773 | -: 665:} |
| 774 | -: 666: |
| 775 | -: 667:/* Resolved end earlier than start is not an interval. Refuse before the ledger. */ |
| 776 | -: 668:static int reject_inverted_lifetimes(const ds_model *m, ds_result *r) { |
| 777 | -: 669: for (int b = 0; b < m->n_buf; b++) { |
| 778 | -: 670: double s, e; |
| 779 | -: 671: buffer_window(m, r, b, &s, &e); |
| 780 | -: 672: if (e + 1e-9 < s) { |
| 781 | -: 673: char msg[256]; |
| 782 | -: 674: snprintf(msg, sizeof msg, |
| 783 | -: 675: "inverted lifetime for buffer %s: first=%s start_ns=%.9g last=%s end_ns=%.9g", |
| 784 | -: 676: m->buf[b].id, endpoint_name(m, m->buf[b].first), s, |
| 785 | -: 677: endpoint_name(m, m->buf[b].last), e); |
| 786 | -: 678: return refuse_msg(r, DS_REFUSED_LIFETIME, msg); |
| 787 | -: 679: } |
| 788 | -: 680: } |
| 789 | -: 681: return DS_OK; |
| 790 | -: 682:} |
| 791 | -: 683: |
| 792 | -: 684:int ds_eval_c(const ds_model *m, const ds_opts *o, ds_result *r) { |
| 793 | -: 685: memset(r, 0, sizeof *r); |
| 794 | -: 686: if (m->n_ops == 0) return refuse(r, DS_REFUSED_UNSUPPORTED, "empty DAG%s%s", "", ""); |
| 795 | -: 687: ds_num num[DS_MAX_OPS]; |
| 796 | -: 688: int rc = resolve(m, o, num, r); |
| 797 | -: 689: if (rc) return rc; |
| 798 | -: 690: int order[DS_MAX_OPS]; |
| 799 | -: 691: if (!topo(m, order)) return refuse(r, DS_REFUSED_CYCLE, "dependency cycle%s%s", "", ""); |
| 800 | -: 692: /* a buffer that never fits */ |
| 801 | -: 693: for (int i = 0; i < m->n_buf; i++) |
| 802 | -: 694: if (m->buf[i].bytes > m->res[m->buf[i].cap].cap) |
| 803 | -: 695: return refuse(r, DS_REFUSED_CAPACITY, "buffer %s alone exceeds capacity %s", m->buf[i].id, m->res[m->buf[i].cap].id); |
| 804 | -: 696: |
| 805 | -: 697: /* provenance mask */ |
| 806 | -: 698: for (int i = 0; i < m->n_ops; i++) r->prov_mask |= 1u << num[i].prov; |
| 807 | -: 699: for (int i = 0; i < m->n_res; i++) { |
| 808 | -: 700: int used = 0; |
| 809 | -: 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; |
| 810 | -: 702: for (int j = 0; j < m->n_buf; j++) if (m->buf[j].cap == i) used = 1; |
| 811 | -: 703: if (used) r->prov_mask |= 1u << m->res[i].prov; |
| 812 | -: 704: } |
| 813 | -: 705: |
| 814 | -: 706: /* ---- fluid simulation ---- */ |
| 815 | -: 707: int state[DS_MAX_OPS] = {0}, blocked[DS_MAX_OPS] = {0}, npred[DS_MAX_OPS] = {0}, done_pred[DS_MAX_OPS] = {0}; |
| 816 | -: 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]; |
| 817 | -: 709: int free_slots[DS_MAX_RES], launcher_busy[DS_MAX_RES] = {0}; |
| 818 | -: 710: for (int i = 0; i < m->n_res; i++) free_slots[i] = m->res[i].slots; |
| 819 | -: 711: for (int i = 0; i < m->n_deps; i++) npred[m->deps[i].to]++; |
| 820 | -: 712: for (int i = 0; i < m->n_ops; i++) { |
| 821 | -: 713: rem_t[i] = num[i].t; rem_b[i] = num[i].bytes; rem_l[i] = num[i].launch; |
| 822 | -: 714: run_start[i] = bytes_end[i] = -1; |
| 823 | -: 715: r->n_ops++; |
| 824 | -: 716: r->total_bytes += num[i].bytes; r->total_busy_ns += num[i].t; r->total_launch_ns += num[i].launch; |
| 825 | -: 717: } |
| 826 | -: 718: double t = 0; |
| 827 | -: 719: int remaining = m->n_ops, guard = 0; |
| 828 | -: 720: while (remaining > 0) { |
| 829 | -: 721: if (++guard > 8 * DS_MAX_OPS + 16) return refuse(r, DS_REFUSED_UNSUPPORTED, "scheduler did not converge%s%s", "", ""); |
| 830 | -: 722: /* deps satisfied -> ready */ |
| 831 | -: 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; } |
| 832 | -: 724: /* dispatch in file order */ |
| 833 | -: 725: for (int i = 0; i < m->n_ops; i++) { |
| 834 | -: 726: if (state[i] != ST_READY) continue; |
| 835 | -: 727: const ds_op *op = &m->ops[i]; |
| 836 | -: 728: if (op->engine >= 0 && free_slots[op->engine] <= 0) { blocked[i] = BLK_SLOT; continue; } |
| 837 | -: 729: if (op->launcher >= 0 && rem_l[i] > 0 && launcher_busy[op->launcher]) { blocked[i] = BLK_LAUNCHER; continue; } |
| 838 | -: 730: if (op->engine >= 0) free_slots[op->engine]--; |
| 839 | -: 731: r->start_ns[i] = t; |
| 840 | -: 732: if (op->launcher >= 0 && rem_l[i] > 0) { launcher_busy[op->launcher] = 1; state[i] = ST_LAUNCH; } |
| 841 | -: 733: else { state[i] = ST_RUN; run_start[i] = t; } |
| 842 | -: 734: } |
| 843 | -: 735: /* next event */ |
| 844 | -: 736: int active[DS_MAX_RES] = {0}; |
| 845 | -: 737: for (int i = 0; i < m->n_ops; i++) if (state[i] == ST_RUN && rem_b[i] > 0) active[m->ops[i].bw]++; |
| 846 | -: 738: double dt = -1; int any = 0; |
| 847 | -: 739: for (int i = 0; i < m->n_ops; i++) { |
| 848 | -: 740: if (state[i] == ST_LAUNCH) { any = 1; if (dt < 0 || rem_l[i] < dt) dt = rem_l[i]; } |
| 849 | -: 741: else if (state[i] == ST_RUN) { |
| 850 | -: 742: any = 1; |
| 851 | -: 743: /* next event for this op: the earlier of its two progress bars */ |
| 852 | -: 744: double d = -1; |
| 853 | -: 745: if (rem_t[i] > 0) d = rem_t[i]; |
| 854 | -: 746: if (rem_b[i] > 0) { |
| 855 | -: 747: double share = num[i].cap / active[m->ops[i].bw]; |
| 856 | -: 748: double db = rem_b[i] / share; |
| 857 | -: 749: if (d < 0 || db < d) d = db; |
| 858 | -: 750: } |
| 859 | -: 751: if (d < 0) d = 0; |
| 860 | -: 752: if (dt < 0 || d < dt) dt = d; |
| 861 | -: 753: } |
| 862 | -: 754: } |
| 863 | -: 755: if (!any) return refuse(r, DS_REFUSED_UNSUPPORTED, "no op can make progress (slots=0 or all blocked)%s%s", "", ""); |
| 864 | -: 756: if (dt < 0) dt = 0; |
| 865 | -: 757: t += dt; |
| 866 | -: 758: const double eps = 1e-9; |
| 867 | -: 759: for (int i = 0; i < m->n_ops; i++) { |
| 868 | -: 760: if (state[i] == ST_LAUNCH) { |
| 869 | -: 761: rem_l[i] -= dt; |
| 870 | -: 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; } |
| 871 | -: 763: } else if (state[i] == ST_RUN) { |
| 872 | -: 764: if (rem_t[i] > 0) { rem_t[i] -= dt; if (rem_t[i] <= eps) rem_t[i] = 0; } |
| 873 | -: 765: if (rem_b[i] > 0) { |
| 874 | -: 766: double share = num[i].cap / active[m->ops[i].bw]; |
| 875 | -: 767: rem_b[i] -= share * dt; |
| 876 | -: 768: if (rem_b[i] <= eps * (num[i].bytes > 1 ? num[i].bytes : 1)) { rem_b[i] = 0; bytes_end[i] = t; } |
| 877 | -: 769: } |
| 878 | -: 770: if (rem_t[i] <= 0 && rem_b[i] <= 0) { |
| 879 | -: 771: state[i] = ST_DONE; r->end_ns[i] = t; remaining--; |
| 880 | -: 772: if (m->ops[i].engine >= 0) free_slots[m->ops[i].engine]++; |
| 881 | -: 773: for (int d = 0; d < m->n_deps; d++) if (m->deps[d].from == i) done_pred[m->deps[d].to]++; |
| 882 | -: 774: if (num[i].bytes > 0) { |
| 883 | -: 775: double ideal = num[i].bytes / num[i].cap; |
| 884 | -: 776: double actual = (bytes_end[i] >= 0 ? bytes_end[i] : t) - run_start[i]; |
| 885 | -: 777: r->op_contention_ns[i] = actual - ideal > 0 ? actual - ideal : 0; |
| 886 | -: 778: } |
| 887 | -: 779: } |
| 888 | -: 780: } |
| 889 | -: 781: } |
| 890 | -: 782: if (t > r->makespan_ns) r->makespan_ns = t; |
| 891 | -: 783: } |
| 892 | -: 784: |
| 893 | -: 785: /* ---- bounds ---- */ |
| 894 | -: 786: double cp[DS_MAX_OPS]; |
| 895 | -: 787: for (int k = 0; k < m->n_ops; k++) { |
| 896 | -: 788: int i = order[k]; |
| 897 | -: 789: double floor_ = num[i].t; |
| 898 | -: 790: if (num[i].bytes > 0 && num[i].bytes / num[i].cap > floor_) floor_ = num[i].bytes / num[i].cap; |
| 899 | -: 791: floor_ += num[i].launch; |
| 900 | -: 792: r->op_floor_ns[i] = floor_; |
| 901 | -: 793: double best = 0; |
| 902 | -: 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]; |
| 903 | -: 795: cp[i] = best + floor_; |
| 904 | -: 796: if (cp[i] > r->bound_critical_path_ns) r->bound_critical_path_ns = cp[i]; |
| 905 | -: 797: } |
| 906 | -: 798: r->bound_ns = r->bound_critical_path_ns; |
| 907 | -: 799: for (int i = 0; i < m->n_res; i++) { |
| 908 | -: 800: double w = 0; |
| 909 | -: 801: for (int j = 0; j < m->n_ops; j++) { |
| 910 | -: 802: if (m->res[i].kind == DS_RES_BANDWIDTH && m->ops[j].bw == i) w += num[j].bytes / num[j].cap; |
| 911 | -: 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; |
| 912 | -: 804: if (m->res[i].kind == DS_RES_LAUNCH && m->ops[j].launcher == i) w += num[j].launch; |
| 913 | -: 805: } |
| 914 | -: 806: r->bound_resource_ns[i] = w; |
| 915 | -: 807: if (w > r->bound_ns) r->bound_ns = w; |
| 916 | -: 808: } |
| 917 | -: 809: |
| 918 | -: 810: /* Inverted lifetimes never enter the ledger (and never rank). */ |
| 919 | -: 811: if ((rc = reject_inverted_lifetimes(m, r)) != DS_OK) return rc; /* LIFETIME_ORDER_CHECK */ |
| 920 | -: 812: |
| 921 | -: 813: /* ---- capacity ledger: frees before allocations at the same instant ---- |
| 922 | -: 814: * Positive intervals only. A zero-duration [s, e) is empty and emits no |
| 923 | -: 815: * event, so a same-time free cannot pull the ledger negative or offset |
| 924 | -: 816: * another buffer. Frees of earlier intervals still precede allocs, which |
| 925 | -: 817: * is the completion/allocation tie. */ |
| 926 | -: 818: for (int c = 0; c < m->n_res; c++) { |
| 927 | -: 819: if (m->res[c].kind != DS_RES_CAPACITY) continue; |
| 928 | -: 820: double live = 0, peak = 0, peak_at = 0; |
| 929 | -: 821: /* event list */ |
| 930 | -: 822: double et[2 * DS_MAX_BUF]; double ev[2 * DS_MAX_BUF]; int en = 0; |
| 931 | -: 823: for (int b = 0; b < m->n_buf; b++) { |
| 932 | -: 824: if (m->buf[b].cap != c) continue; |
| 933 | -: 825: double s, e; |
| 934 | -: 826: buffer_window(m, r, b, &s, &e); |
| 935 | -: 827: if (!(s + 1e-9 < e)) continue; |
| 936 | -: 828: et[en] = s; ev[en] = m->buf[b].bytes; en++; |
| 937 | -: 829: et[en] = e; ev[en] = -m->buf[b].bytes; en++; |
| 938 | -: 830: } |
| 939 | -: 831: /* insertion sort by time, frees (negative) first on ties; stable */ |
| 940 | -: 832: for (int i = 1; i < en; i++) { |
| 941 | -: 833: double kt = et[i], kv_ = ev[i]; int j = i - 1; |
| 942 | -: 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--; } |
| 943 | -: 835: et[j + 1] = kt; ev[j + 1] = kv_; |
| 944 | -: 836: } |
| 945 | -: 837: for (int i = 0; i < en; i++) { |
| 946 | -: 838: live += ev[i]; |
| 947 | -: 839: /* Reachable by rounding: 1e20 + 1 sums to 1e20, so the later |
| 948 | -: 840: * frees overshoot (dagsim_unit rounding_drives_live_negative). */ |
| 949 | -: 841: if (live < -1e-6) { |
| 950 | -: 842: char msg[256]; |
| 951 | -: 843: snprintf(msg, sizeof msg, |
| 952 | -: 844: "capacity %s live bytes went negative (%.9g at t=%.9g); refusing the certificate", |
| 953 | -: 845: m->res[c].id, live, et[i]); |
| 954 | -: 846: return refuse_msg(r, DS_REFUSED_LIFETIME, msg); |
| 955 | -: 847: } |
| 956 | -: 848: if (live > peak) { peak = live; peak_at = et[i]; } |
| 957 | -: 849: } |
| 958 | -: 850: r->peak_live_bytes[c] = peak; r->peak_live_at_ns[c] = peak_at; |
| 959 | -: 851: if (peak > m->res[c].cap + 1e-9) { |
| 960 | -: 852: char names[160] = ""; size_t L = 0; |
| 961 | -: 853: for (int b = 0; b < m->n_buf && L < sizeof names - 8; b++) { |
| 962 | -: 854: if (m->buf[b].cap != c) continue; |
| 963 | -: 855: double s, e; |
| 964 | -: 856: buffer_window(m, r, b, &s, &e); |
| 965 | -: 857: if (s <= peak_at && e > peak_at) { snprintf(names + L, sizeof names - L, "%s%s", L ? "," : "", m->buf[b].id); L = strlen(names); } |
| 966 | -: 858: } |
| 967 | -: 859: char what[200]; snprintf(what, sizeof what, "%.0f B live at t=%.0f ns (%s) exceeds", peak, peak_at, names); |
| 968 | -: 860: int st = refuse(r, DS_REFUSED_CAPACITY, "%s %s", what, m->res[c].id); |
| 969 | -: 861: return st; |
| 970 | -: 862: } |
| 971 | -: 863: } |
| 972 | -: 864: |
| 973 | -: 865: /* ---- attribution along the schedule's critical chain ---- */ |
| 974 | -: 866: int cur = 0; |
| 975 | -: 867: for (int i = 1; i < m->n_ops; i++) if (r->end_ns[i] > r->end_ns[cur]) cur = i; |
| 976 | -: 868: double accounted = 0; |
| 977 | -: 869: int chain[DS_MAX_OPS]; int nc = 0; |
| 978 | -: 870: while (cur >= 0 && nc < DS_MAX_OPS) { |
| 979 | -: 871: chain[nc++] = cur; |
| 980 | -: 872: const ds_op *op = &m->ops[cur]; |
| 981 | -: 873: double runtime = r->end_ns[cur] - (run_start[cur] >= 0 ? run_start[cur] : r->start_ns[cur]); |
| 982 | -: 874: r->attr_ns[DS_ATTR_LAUNCH] += num[cur].launch; |
| 983 | -: 875: accounted += num[cur].launch; |
| 984 | -: 876: if (op->kind == DS_OP_BARRIER) r->attr_ns[DS_ATTR_SYNC] += runtime; |
| 985 | -: 877: else if (num[cur].bytes > 0) { |
| 986 | -: 878: double ideal = num[cur].bytes / num[cur].cap; |
| 987 | -: 879: double actual = ideal + r->op_contention_ns[cur]; |
| 988 | -: 880: if (num[cur].t >= actual) r->attr_ns[DS_ATTR_COMPUTE] += runtime; |
| 989 | -: 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; } |
| 990 | -: 882: } else r->attr_ns[DS_ATTR_COMPUTE] += runtime; |
| 991 | -: 883: accounted += runtime; |
| 992 | -: 884: /* predecessor: the dep that finished last */ |
| 993 | -: 885: int pred = -1; |
| 994 | -: 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; |
| 995 | -: 887: double gap = r->start_ns[cur] - (pred >= 0 ? r->end_ns[pred] : 0); |
| 996 | -: 888: if (gap > 0) { |
| 997 | -: 889: if (blocked[cur] == BLK_SLOT) r->attr_ns[DS_ATTR_SERIALIZATION] += gap; |
| 998 | -: 890: else if (blocked[cur] == BLK_LAUNCHER) r->attr_ns[DS_ATTR_LAUNCH] += gap; |
| 999 | -: 891: else r->attr_ns[DS_ATTR_RESIDUAL] += gap; |
| 1000 | -: 892: accounted += gap; |
| 1001 | -: 893: } |
| 1002 | -: 894: cur = pred; |
| 1003 | -: 895: } |
| 1004 | -: 896: for (int i = 0; i < nc; i++) r->critical_path[i] = chain[nc - 1 - i]; |
| 1005 | -: 897: r->n_critical = nc; |
| 1006 | -: 898: double leftover = r->makespan_ns - accounted; |
| 1007 | -: 899: if (fabs(leftover) > 1e-6) r->attr_ns[DS_ATTR_RESIDUAL] += leftover; |
| 1008 | -: 900: |
| 1009 | -: 901: /* ---- energy ---- */ |
| 1010 | -: 902: if (m->has_energy && m->joules > 0 && strcmp(m->instrument, "none")) { r->energy_measured = 1; r->energy_j = m->joules; } |
| 1011 | -: 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; } |
| 1012 | -: 904: r->synthetic = (r->prov_mask & (1u << DS_PROV_SYNTHETIC)) ? 1 : 0; |
| 1013 | -: 905: r->status = DS_OK; |
| 1014 | -: 906: return DS_OK; |
| 1015 | -: 907:} |
| 1016 | -: 908:#endif |
| 1017 | -: 909: |
| 1018 | -: 910:#ifndef CUDAPP_MIGRATION_PENDING_C_TOOLS |
| 1019 | -: 911:extern uint32_t omega_dag_eval(uint64_t *result, const void *p0, uint64_t p0_n, void *p1, uint64_t p1_n); |
| 1020 | -: 912: |
| 1021 | -: 913:static double om_f(const uint64_t *s, int i) { |
| 1022 | -: 914: double x; |
| 1023 | 234: 915: memcpy(&x, &s[i], 8); |
| 1024 | -: 916: return x; |
| 1025 | -: 917:} |
| 1026 | -: 918: |
| 1027 | function om_names called 0 returned 0% blocks executed 0% |
| 1028 | #####: 919:static void om_names(const ds_model *m, const uint64_t *s, char *names, size_t cap) { |
| 1029 | #####: 920: names[0] = 0; |
| 1030 | -: 921: size_t L = 0; |
| 1031 | #####: 922: for (int b = 0; b < m->n_buf && L < cap - 8; b++) { |
| 1032 | branch 0 never executed (fallthrough) |
| 1033 | branch 1 never executed |
| 1034 | branch 2 never executed |
| 1035 | branch 3 never executed (fallthrough) |
| 1036 | #####: 923: if (!(s[6336 + b / 64] & (1ull << (b % 64)))) continue; |
| 1037 | branch 0 never executed (fallthrough) |
| 1038 | branch 1 never executed |
| 1039 | #####: 924: snprintf(names + L, cap - L, "%s%s", L ? "," : "", m->buf[b].id); |
| 1040 | branch 0 never executed (fallthrough) |
| 1041 | branch 1 never executed |
| 1042 | #####: 925: L = strlen(names); |
| 1043 | -: 926: } |
| 1044 | #####: 927:} |
| 1045 | -: 928: |
| 1046 | function om_refuse called 0 returned 0% blocks executed 0% |
| 1047 | #####: 929:static int om_refuse(const ds_model *m, const uint64_t *s, ds_result *r) { |
| 1048 | #####: 930: int why = (int)s[5], a = (int)s[6], b = (int)s[7]; |
| 1049 | branch 0 never executed (fallthrough) |
| 1050 | branch 1 never executed |
| 1051 | -: 931: double fa = om_f(s, 8), fb = om_f(s, 9); |
| 1052 | -: 932: char msg[256]; |
| 1053 | #####: 933: if (why == 2) return refuse(r, DS_REFUSED_CYCLE, "dependency cycle%s%s", "", ""); |
| 1054 | branch 0 never executed (fallthrough) |
| 1055 | branch 1 never executed |
| 1056 | call 2 never executed |
| 1057 | #####: 934: if (why == 3 && a >= 0 && a < m->n_buf && b >= 0 && b < m->n_res) |
| 1058 | branch 0 never executed (fallthrough) |
| 1059 | branch 1 never executed |
| 1060 | branch 2 never executed (fallthrough) |
| 1061 | branch 3 never executed |
| 1062 | branch 4 never executed (fallthrough) |
| 1063 | branch 5 never executed |
| 1064 | branch 6 never executed (fallthrough) |
| 1065 | branch 7 never executed |
| 1066 | #####: 935: return refuse(r, DS_REFUSED_CAPACITY, "buffer %s alone exceeds capacity %s", m->buf[a].id, m->res[b].id); |
| 1067 | call 0 never executed |
| 1068 | #####: 936: if (why == 4) return refuse(r, DS_REFUSED_UNSUPPORTED, "no op can make progress (slots=0 or all blocked)%s%s", "", ""); |
| 1069 | branch 0 never executed (fallthrough) |
| 1070 | branch 1 never executed |
| 1071 | call 2 never executed |
| 1072 | #####: 937: if (why == 5) return refuse(r, DS_REFUSED_UNSUPPORTED, "scheduler did not converge%s%s", "", ""); |
| 1073 | branch 0 never executed (fallthrough) |
| 1074 | branch 1 never executed |
| 1075 | call 2 never executed |
| 1076 | #####: 938: if (why == 6 && a >= 0 && a < m->n_buf) { |
| 1077 | branch 0 never executed (fallthrough) |
| 1078 | branch 1 never executed |
| 1079 | branch 2 never executed (fallthrough) |
| 1080 | branch 3 never executed |
| 1081 | -: 939: snprintf(msg, sizeof msg, "inverted lifetime for buffer %s: first=%s start_ns=%.9g last=%s end_ns=%.9g", |
| 1082 | #####: 940: m->buf[a].id, endpoint_name(m, m->buf[a].first), fa, endpoint_name(m, m->buf[a].last), fb); |
| 1083 | branch 0 never executed (fallthrough) |
| 1084 | branch 1 never executed |
| 1085 | branch 2 never executed (fallthrough) |
| 1086 | branch 3 never executed |
| 1087 | #####: 941: return refuse_msg(r, DS_REFUSED_LIFETIME, msg); |
| 1088 | call 0 never executed |
| 1089 | -: 942: } |
| 1090 | #####: 943: if (why == 7 && a >= 0 && a < m->n_res) { |
| 1091 | branch 0 never executed (fallthrough) |
| 1092 | branch 1 never executed |
| 1093 | branch 2 never executed (fallthrough) |
| 1094 | branch 3 never executed |
| 1095 | -: 944: snprintf(msg, sizeof msg, "capacity %s live bytes went negative (%.9g at t=%.9g); refusing the certificate", |
| 1096 | #####: 945: m->res[a].id, fa, fb); |
| 1097 | call 0 never executed |
| 1098 | #####: 946: return refuse_msg(r, DS_REFUSED_LIFETIME, msg); |
| 1099 | call 0 never executed |
| 1100 | -: 947: } |
| 1101 | #####: 948: if (why == 8 && a >= 0 && a < m->n_res) { |
| 1102 | branch 0 never executed (fallthrough) |
| 1103 | branch 1 never executed |
| 1104 | branch 2 never executed (fallthrough) |
| 1105 | branch 3 never executed |
| 1106 | -: 949: char names[160], what[200]; |
| 1107 | #####: 950: om_names(m, s, names, sizeof names); |
| 1108 | call 0 never executed |
| 1109 | -: 951: snprintf(what, sizeof what, "%.0f B live at t=%.0f ns (%s) exceeds", fa, fb, names); |
| 1110 | #####: 952: return refuse(r, DS_REFUSED_CAPACITY, "%s %s", what, m->res[a].id); |
| 1111 | call 0 never executed |
| 1112 | -: 953: } |
| 1113 | #####: 954: return refuse(r, DS_REFUSED_UNSUPPORTED, "omega refusal %s%s", "", ""); |
| 1114 | call 0 never executed |
| 1115 | -: 955:} |
| 1116 | -: 956: |
| 1117 | function om_fill called 18 returned 100% blocks executed 92% |
| 1118 | 18: 957:static int om_fill(const ds_model *m, const uint64_t *s, ds_result *r) { |
| 1119 | 18*: 958: if ((int)s[4] != DS_OK) return om_refuse(m, s, r); |
| 1120 | branch 0 taken 0 (fallthrough) |
| 1121 | branch 1 taken 18 |
| 1122 | call 2 never executed |
| 1123 | -: 959: memset(r, 0, sizeof *r); |
| 1124 | -: 960: r->status = DS_OK; |
| 1125 | 18: 961: r->makespan_ns = om_f(s, 3); |
| 1126 | 18: 962: r->total_bytes = om_f(s, 15); |
| 1127 | 18: 963: r->total_busy_ns = om_f(s, 16); |
| 1128 | 18: 964: r->total_launch_ns = om_f(s, 17); |
| 1129 | 18: 965: r->bound_ns = om_f(s, 19); |
| 1130 | 18: 966: r->bound_critical_path_ns = om_f(s, 20); |
| 1131 | 18: 967: r->n_critical = (int)s[21]; |
| 1132 | 18: 968: r->prov_mask = (uint32_t)s[11]; |
| 1133 | 18: 969: r->energy_measured = (int)s[22]; |
| 1134 | 18: 970: r->energy_synthetic = (int)s[23]; |
| 1135 | 18: 971: r->energy_j = om_f(s, 24); |
| 1136 | 18: 972: r->synthetic = (int)s[26]; |
| 1137 | 18: 973: r->n_ops = m->n_ops; |
| 1138 | 54: 974: for (int i = 0; i < m->n_ops; i++) { |
| 1139 | branch 0 taken 36 |
| 1140 | branch 1 taken 18 |
| 1141 | 36: 975: r->start_ns[i] = om_f(s, 4512 + i); |
| 1142 | branch 0 taken 18 (fallthrough) |
| 1143 | branch 1 taken 18 |
| 1144 | 36: 976: r->end_ns[i] = om_f(s, 4768 + i); |
| 1145 | 36: 977: r->ready_ns[i] = om_f(s, 5024 + i); |
| 1146 | 36: 978: r->op_contention_ns[i] = om_f(s, 5536 + i); |
| 1147 | 36: 979: r->op_floor_ns[i] = om_f(s, 5280 + i); |
| 1148 | 36: 980: if (i < r->n_critical) r->critical_path[i] = (int)s[6080 + i]; |
| 1149 | branch 0 taken 18 (fallthrough) |
| 1150 | branch 1 taken 18 |
| 1151 | -: 981: } |
| 1152 | 144: 982: for (int i = 0; i < DS_ATTR_N; i++) r->attr_ns[i] = om_f(s, 5824 + i); |
| 1153 | branch 0 taken 126 |
| 1154 | branch 1 taken 18 |
| 1155 | 90: 983: for (int i = 0; i < m->n_res; i++) { |
| 1156 | branch 0 taken 72 |
| 1157 | branch 1 taken 18 (fallthrough) |
| 1158 | 72: 984: r->bound_resource_ns[i] = om_f(s, 5792 + i); |
| 1159 | 72: 985: r->peak_live_bytes[i] = om_f(s, 6344 + i); |
| 1160 | 72: 986: r->peak_live_at_ns[i] = om_f(s, 6376 + i); |
| 1161 | -: 987: } |
| 1162 | -: 988: return DS_OK; |
| 1163 | -: 989:} |
| 1164 | -: 990: |
| 1165 | -: 991:#endif |
| 1166 | function ds_eval called 19 returned 100% blocks executed 86% |
| 1167 | 19: 992:int ds_eval(const ds_model *m, const ds_opts *o, ds_result *r) { |
| 1168 | call 0 returned 19 |
| 1169 | -: 993:#if defined(CUDAPP_MIGRATION_PENDING_C_TOOLS) |
| 1170 | -: 994: return ds_eval_c(m, o, r); |
| 1171 | -: 995:#else |
| 1172 | -: 996: memset(r, 0, sizeof *r); |
| 1173 | 19: 997: uint64_t model[8192], scratch[8192], result = 0; |
| 1174 | 19: 998: int rc = ds_resolved_pack(m, o, model, r); |
| 1175 | call 0 returned 19 |
| 1176 | 19: 999: if (rc) return rc; |
| 1177 | branch 0 taken 18 (fallthrough) |
| 1178 | branch 1 taken 1 |
| 1179 | -: 1000: memset(scratch, 0, sizeof scratch); |
| 1180 | 18: 1001: if (omega_dag_eval(&result, model, 8192, scratch, 8192)) |
| 1181 | call 0 returned 18 |
| 1182 | branch 1 taken 0 (fallthrough) |
| 1183 | branch 2 taken 18 |
| 1184 | #####: 1002: return refuse(r, DS_REFUSED_UNSUPPORTED, "omega trap%s%s", "", ""); |
| 1185 | call 0 never executed |
| 1186 | 18: 1003: return om_fill(m, scratch, r); |
| 1187 | call 0 returned 18 |
| 1188 | -: 1004:#endif |
| 1189 | -: 1005:} |
| 1190 | -: 1006: |
| 1191 | function ds_eval_interval called 0 returned 0% blocks executed 0% |
| 1192 | #####: 1007:int ds_eval_interval(const ds_model *m, const ds_opts *o, ds_result *nominal, double *lo_ns, double *hi_ns) { |
| 1193 | #####: 1008: ds_opts x = *o; x.mode = 0; |
| 1194 | #####: 1009: int rc = ds_eval(m, &x, nominal); |
| 1195 | call 0 never executed |
| 1196 | #####: 1010: *lo_ns = *hi_ns = 0; |
| 1197 | #####: 1011: if (rc) return rc; |
| 1198 | branch 0 never executed (fallthrough) |
| 1199 | branch 1 never executed |
| 1200 | -: 1012: ds_result tmp; |
| 1201 | #####: 1013: x.mode = +1; if (ds_eval(m, &x, &tmp) == DS_OK) *lo_ns = tmp.makespan_ns; |
| 1202 | call 0 never executed |
| 1203 | branch 1 never executed (fallthrough) |
| 1204 | branch 2 never executed |
| 1205 | #####: 1014: x.mode = -1; if (ds_eval(m, &x, &tmp) == DS_OK) *hi_ns = tmp.makespan_ns; |
| 1206 | call 0 never executed |
| 1207 | branch 1 never executed (fallthrough) |
| 1208 | branch 2 never executed |
| 1209 | -: 1015: return rc; |
| 1210 | -: 1016:} |
| 1211 | -: 1017: |
| 1212 | function ds_counterfactual called 26 returned 100% blocks executed 100% |
| 1213 | 26: 1018:double ds_counterfactual(const ds_model *m, const ds_opts *o, int res_index) { |
| 1214 | -: 1019:#if CUDAPP_MIGRATION_PENDING_C_DAGSIM_RESOLVE |
| 1215 | -: 1020: if (res_index < 0 || res_index >= m->n_res) return -DS_REFUSED_UNSUPPORTED; |
| 1216 | -: 1021: ds_model *c = malloc(sizeof *c); |
| 1217 | -: 1022: if (!c) return -DS_REFUSED_UNSUPPORTED; |
| 1218 | -: 1023: *c = *m; |
| 1219 | -: 1024: ds_resource *r = &c->res[res_index]; |
| 1220 | -: 1025: switch (r->kind) { |
| 1221 | -: 1026: case DS_RES_BANDWIDTH: r->cap *= 2; r->lo *= 2; r->hi *= 2; break; |
| 1222 | -: 1027: case DS_RES_COMPUTE: r->slots *= 2; break; |
| 1223 | -: 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; |
| 1224 | -: 1029: case DS_RES_CAPACITY: r->cap *= 2; break; |
| 1225 | -: 1030: } |
| 1226 | -: 1031: ds_result res; ds_opts x = *o; x.mode = 0; |
| 1227 | -: 1032: int rc = ds_eval(c, &x, &res); |
| 1228 | -: 1033: free(c); |
| 1229 | -: 1034: return rc == DS_OK ? res.makespan_ns : -(double)rc; |
| 1230 | -: 1035:#else |
| 1231 | 26: 1036: return dr_counter(m,o,res_index); |
| 1232 | call 0 returned 26 |
| 1233 | -: 1037:#endif |
| 1234 | -: 1038:} |
| 1235 | -: 1039: |
| 1236 | -: 1040:/* ---------------------------------------------------------------- diff */ |
| 1237 | -: 1041: |
| 1238 | -: 1042:#if CUDAPP_MIGRATION_PENDING_C_DAGSIM_RESOLVE |
| 1239 | -: 1043:static int in_changed(const char *list, const char *id) { |
| 1240 | -: 1044: if (!list) return 0; |
| 1241 | -: 1045: const char *p = list; size_t L = strlen(id); |
| 1242 | -: 1046: while (*p) { |
| 1243 | -: 1047: const char *q = strchr(p, ','); size_t n = q ? (size_t)(q - p) : strlen(p); |
| 1244 | -: 1048: if (n == L && !strncmp(p, id, L)) return 1; |
| 1245 | -: 1049: if (!q) break; |
| 1246 | -: 1050: p = q + 1; |
| 1247 | -: 1051: } |
| 1248 | -: 1052: return 0; |
| 1249 | -: 1053:} |
| 1250 | -: 1054:#endif |
| 1251 | -: 1055: |
| 1252 | function ds_diff_models called 1820 returned 100% blocks executed 100% |
| 1253 | 1820: 1056:int ds_diff_models(const ds_model *b, const ds_model *t, const ds_opts *o, ds_diff *d) { |
| 1254 | -: 1057:#if CUDAPP_MIGRATION_PENDING_C_DAGSIM_RESOLVE |
| 1255 | -: 1058: memset(d, 0, sizeof *d); |
| 1256 | -: 1059: for (int i = 0; i < t->n_ops; i++) if (ds_find_op(b, t->ops[i].id) < 0) d->n_added++; |
| 1257 | -: 1060: for (int i = 0; i < b->n_ops; i++) { |
| 1258 | -: 1061: int j = ds_find_op(t, b->ops[i].id); |
| 1259 | -: 1062: if (j >= 0) { |
| 1260 | -: 1063: d->n_kept++; |
| 1261 | -: 1064: if (b->ops[i].t_ns != t->ops[j].t_ns || b->ops[i].bytes != t->ops[j].bytes) |
| 1262 | -: 1065: snprintf(d->reason, sizeof d->reason, "op %s kept but its demand changed; trace conservation broken", b->ops[i].id); |
| 1263 | -: 1066: continue; |
| 1264 | -: 1067: } |
| 1265 | -: 1068: d->n_removed++; |
| 1266 | -: 1069: /* find its removed record(s) */ |
| 1267 | -: 1070: int found = 0; const ds_removed *rec = NULL; |
| 1268 | -: 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]; } |
| 1269 | -: 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; } |
| 1270 | -: 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; } |
| 1271 | -: 1074: /* consumers of the removed op in the baseline that still exist */ |
| 1272 | -: 1075: int has_consumer = 0; |
| 1273 | -: 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; |
| 1274 | -: 1077: int ok = 1; |
| 1275 | -: 1078: switch (rec->reason) { |
| 1276 | -: 1079: case DS_RM_ELIMINATED: if (has_consumer && !rec->proof[0]) ok = 0; break; |
| 1277 | -: 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; |
| 1278 | -: 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; |
| 1279 | -: 1082: case DS_RM_DEFERRED: if (has_consumer) ok = 0; break; |
| 1280 | -: 1083: case DS_RM_SHARED: |
| 1281 | -: 1084: if (!rec->ref[0] || ds_find_op(t, rec->ref) < 0) ok = 0; |
| 1282 | -: 1085: for (int k = 0; k < t->n_removed; k++) if (!strcmp(t->removed[k].op, rec->ref)) { d->double_counted = 1; ok = 0; } |
| 1283 | -: 1086: break; |
| 1284 | -: 1087: } |
| 1285 | -: 1088: if (!ok) { |
| 1286 | -: 1089: d->required_removed = 1; |
| 1287 | -: 1090: snprintf(d->reason, sizeof d->reason, "op %s: removal reason %d not supported by its evidence (ref=%s proof=%s changed=%s)", |
| 1288 | -: 1091: b->ops[i].id, rec->reason, rec->ref, rec->proof, o && o->changed ? o->changed : ""); |
| 1289 | -: 1092: return DS_REFUSED_REMOVED_REQUIRED; |
| 1290 | -: 1093: } |
| 1291 | -: 1094: double w = b->ops[i].t_ns + b->ops[i].launch_ns; |
| 1292 | -: 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; } |
| 1293 | -: 1096: d->removed_ns[rec->reason] += w; |
| 1294 | -: 1097: } |
| 1295 | -: 1098: /* removed records that name ops never in the baseline are fabricated savings */ |
| 1296 | -: 1099: for (int k = 0; k < t->n_removed; k++) if (ds_find_op(b, t->removed[k].op) < 0) { |
| 1297 | -: 1100: d->double_counted = 1; |
| 1298 | -: 1101: snprintf(d->reason, sizeof d->reason, "removed record for %s, which was never in the baseline", t->removed[k].op); |
| 1299 | -: 1102: return DS_REFUSED_REMOVED_REQUIRED; |
| 1300 | -: 1103: } |
| 1301 | -: 1104: return DS_OK; |
| 1302 | -: 1105:#else |
| 1303 | 1820: 1106: return dr_diff(b,t,o,d); |
| 1304 | call 0 returned 1820 |
| 1305 | -: 1107:#endif |
| 1306 | -: 1108:} |
| 1307 | -: 0:Source:/usr/include/aarch64-linux-gnu/bits/string_fortified.h |
| 1308 | -: 0:Graph:build/dagsim-resolve/resolve.gcno |
| 1309 | -: 0:Data:build/dagsim-resolve/resolve.gcda |
| 1310 | -: 0:Runs:1 |
| 1311 | -: 1:/* Copyright (C) 2004-2024 Free Software Foundation, Inc. |
| 1312 | -: 2: This file is part of the GNU C Library. |
| 1313 | -: 3: |
| 1314 | -: 4: The GNU C Library is free software; you can redistribute it and/or |
| 1315 | -: 5: modify it under the terms of the GNU Lesser General Public |
| 1316 | -: 6: License as published by the Free Software Foundation; either |
| 1317 | -: 7: version 2.1 of the License, or (at your option) any later version. |
| 1318 | -: 8: |
| 1319 | -: 9: The GNU C Library is distributed in the hope that it will be useful, |
| 1320 | -: 10: but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1321 | -: 11: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 1322 | -: 12: Lesser General Public License for more details. |
| 1323 | -: 13: |
| 1324 | -: 14: You should have received a copy of the GNU Lesser General Public |
| 1325 | -: 15: License along with the GNU C Library; if not, see |
| 1326 | -: 16: <https://www.gnu.org/licenses/>. */ |
| 1327 | -: 17: |
| 1328 | -: 18:#ifndef _BITS_STRING_FORTIFIED_H |
| 1329 | -: 19:#define _BITS_STRING_FORTIFIED_H 1 |
| 1330 | -: 20: |
| 1331 | -: 21:#ifndef _STRING_H |
| 1332 | -: 22:# error "Never use <bits/string_fortified.h> directly; include <string.h> instead." |
| 1333 | -: 23:#endif |
| 1334 | -: 24: |
| 1335 | -: 25:__fortify_function void * |
| 1336 | -: 26:__NTH (memcpy (void *__restrict __dest, const void *__restrict __src, |
| 1337 | -: 27: size_t __len)) |
| 1338 | -: 28:{ |
| 1339 | 42698*: 29: return __builtin___memcpy_chk (__dest, __src, __len, |
| 1340 | branch 0 taken 18 (fallthrough) |
| 1341 | branch 1 taken 18 |
| 1342 | branch 2 never executed (fallthrough) |
| 1343 | branch 3 never executed |
| 1344 | call 4 returned 3110 |
| 1345 | call 5 returned 243 |
| 1346 | branch 6 taken 50 (fallthrough) |
| 1347 | branch 7 taken 2 |
| 1348 | call 8 never executed |
| 1349 | call 9 never executed |
| 1350 | -: 30: __glibc_objsize0 (__dest)); |
| 1351 | -: 31:} |
| 1352 | -: 32: |
| 1353 | -: 33:__fortify_function void * |
| 1354 | -: 34:__NTH (memmove (void *__dest, const void *__src, size_t __len)) |
| 1355 | -: 35:{ |
| 1356 | -: 36: return __builtin___memmove_chk (__dest, __src, __len, |
| 1357 | -: 37: __glibc_objsize0 (__dest)); |
| 1358 | -: 38:} |
| 1359 | -: 39: |
| 1360 | -: 40:#ifdef __USE_GNU |
| 1361 | -: 41:__fortify_function void * |
| 1362 | -: 42:__NTH (mempcpy (void *__restrict __dest, const void *__restrict __src, |
| 1363 | -: 43: size_t __len)) |
| 1364 | -: 44:{ |
| 1365 | -: 45: return __builtin___mempcpy_chk (__dest, __src, __len, |
| 1366 | -: 46: __glibc_objsize0 (__dest)); |
| 1367 | -: 47:} |
| 1368 | -: 48:#endif |
| 1369 | -: 49: |
| 1370 | -: 50: |
| 1371 | -: 51:/* The first two tests here help to catch a somewhat common problem |
| 1372 | -: 52: where the second and third parameter are transposed. This is |
| 1373 | -: 53: especially problematic if the intended fill value is zero. In this |
| 1374 | -: 54: case no work is done at all. We detect these problems by referring |
| 1375 | -: 55: non-existing functions. */ |
| 1376 | -: 56:__fortify_function void * |
| 1377 | -: 57:__NTH (memset (void *__dest, int __ch, size_t __len)) |
| 1378 | -: 58:{ |
| 1379 | 6015*: 59: return __builtin___memset_chk (__dest, __ch, __len, |
| 1380 | call 0 returned 19 |
| 1381 | call 1 returned 18 |
| 1382 | branch 2 taken 1818 (fallthrough) |
| 1383 | branch 3 taken 2 |
| 1384 | call 4 returned 1820 |
| 1385 | call 5 returned 243 |
| 1386 | call 6 returned 142 |
| 1387 | branch 7 never executed (fallthrough) |
| 1388 | branch 8 never executed |
| 1389 | branch 9 taken 0 (fallthrough) |
| 1390 | branch 10 taken 117 |
| 1391 | branch 11 never executed (fallthrough) |
| 1392 | branch 12 never executed |
| 1393 | -: 60: __glibc_objsize0 (__dest)); |
| 1394 | -: 61:} |
| 1395 | -: 62: |
| 1396 | -: 63:#ifdef __USE_MISC |
| 1397 | -: 64:# include <bits/strings_fortified.h> |
| 1398 | -: 65: |
| 1399 | -: 66:void __explicit_bzero_chk (void *__dest, size_t __len, size_t __destlen) |
| 1400 | -: 67: __THROW __nonnull ((1)) __fortified_attr_access (__write_only__, 1, 2); |
| 1401 | -: 68: |
| 1402 | -: 69:__fortify_function void |
| 1403 | -: 70:__NTH (explicit_bzero (void *__dest, size_t __len)) |
| 1404 | -: 71:{ |
| 1405 | -: 72: __explicit_bzero_chk (__dest, __len, __glibc_objsize0 (__dest)); |
| 1406 | -: 73:} |
| 1407 | -: 74:#endif |
| 1408 | -: 75: |
| 1409 | -: 76:__fortify_function char * |
| 1410 | -: 77:__NTH (strcpy (char *__restrict __dest, const char *__restrict __src)) |
| 1411 | -: 78:{ |
| 1412 | -: 79: return __builtin___strcpy_chk (__dest, __src, __glibc_objsize (__dest)); |
| 1413 | -: 80:} |
| 1414 | -: 81: |
| 1415 | -: 82:#ifdef __USE_XOPEN2K8 |
| 1416 | -: 83:__fortify_function char * |
| 1417 | -: 84:__NTH (stpcpy (char *__restrict __dest, const char *__restrict __src)) |
| 1418 | -: 85:{ |
| 1419 | -: 86: return __builtin___stpcpy_chk (__dest, __src, __glibc_objsize (__dest)); |
| 1420 | -: 87:} |
| 1421 | -: 88:#endif |
| 1422 | -: 89: |
| 1423 | -: 90: |
| 1424 | -: 91:__fortify_function char * |
| 1425 | -: 92:__NTH (strncpy (char *__restrict __dest, const char *__restrict __src, |
| 1426 | -: 93: size_t __len)) |
| 1427 | -: 94:{ |
| 1428 | -: 95: return __builtin___strncpy_chk (__dest, __src, __len, |
| 1429 | -: 96: __glibc_objsize (__dest)); |
| 1430 | -: 97:} |
| 1431 | -: 98: |
| 1432 | -: 99:#ifdef __USE_XOPEN2K8 |
| 1433 | -: 100:# if __GNUC_PREREQ (4, 7) || __glibc_clang_prereq (2, 6) |
| 1434 | -: 101:__fortify_function char * |
| 1435 | -: 102:__NTH (stpncpy (char *__dest, const char *__src, size_t __n)) |
| 1436 | -: 103:{ |
| 1437 | -: 104: return __builtin___stpncpy_chk (__dest, __src, __n, |
| 1438 | -: 105: __glibc_objsize (__dest)); |
| 1439 | -: 106:} |
| 1440 | -: 107:# else |
| 1441 | -: 108:extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n, |
| 1442 | -: 109: size_t __destlen) __THROW |
| 1443 | -: 110: __fortified_attr_access (__write_only__, 1, 3) |
| 1444 | -: 111: __attr_access ((__read_only__, 2)); |
| 1445 | -: 112:extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, const char *__src, |
| 1446 | -: 113: size_t __n), stpncpy); |
| 1447 | -: 114: |
| 1448 | -: 115:__fortify_function char * |
| 1449 | -: 116:__NTH (stpncpy (char *__dest, const char *__src, size_t __n)) |
| 1450 | -: 117:{ |
| 1451 | -: 118: if (__bos (__dest) != (size_t) -1 |
| 1452 | -: 119: && (!__builtin_constant_p (__n) || __n > __bos (__dest))) |
| 1453 | -: 120: return __stpncpy_chk (__dest, __src, __n, __bos (__dest)); |
| 1454 | -: 121: return __stpncpy_alias (__dest, __src, __n); |
| 1455 | -: 122:} |
| 1456 | -: 123:# endif |
| 1457 | -: 124:#endif |
| 1458 | -: 125: |
| 1459 | -: 126: |
| 1460 | -: 127:__fortify_function char * |
| 1461 | -: 128:__NTH (strcat (char *__restrict __dest, const char *__restrict __src)) |
| 1462 | -: 129:{ |
| 1463 | -: 130: return __builtin___strcat_chk (__dest, __src, __glibc_objsize (__dest)); |
| 1464 | -: 131:} |
| 1465 | -: 132: |
| 1466 | -: 133: |
| 1467 | -: 134:__fortify_function char * |
| 1468 | -: 135:__NTH (strncat (char *__restrict __dest, const char *__restrict __src, |
| 1469 | -: 136: size_t __len)) |
| 1470 | -: 137:{ |
| 1471 | -: 138: return __builtin___strncat_chk (__dest, __src, __len, |
| 1472 | -: 139: __glibc_objsize (__dest)); |
| 1473 | -: 140:} |
| 1474 | -: 141: |
| 1475 | -: 142:#ifdef __USE_MISC |
| 1476 | -: 143:extern size_t __strlcpy_chk (char *__dest, const char *__src, size_t __n, |
| 1477 | -: 144: size_t __destlen) __THROW; |
| 1478 | -: 145:extern size_t __REDIRECT_NTH (__strlcpy_alias, |
| 1479 | -: 146: (char *__dest, const char *__src, size_t __n), |
| 1480 | -: 147: strlcpy); |
| 1481 | -: 148: |
| 1482 | -: 149:__fortify_function size_t |
| 1483 | -: 150:__NTH (strlcpy (char *__restrict __dest, const char *__restrict __src, |
| 1484 | -: 151: size_t __n)) |
| 1485 | -: 152:{ |
| 1486 | -: 153: if (__glibc_objsize (__dest) != (size_t) -1 |
| 1487 | -: 154: && (!__builtin_constant_p (__n > __glibc_objsize (__dest)) |
| 1488 | -: 155: || __n > __glibc_objsize (__dest))) |
| 1489 | -: 156: return __strlcpy_chk (__dest, __src, __n, __glibc_objsize (__dest)); |
| 1490 | -: 157: return __strlcpy_alias (__dest, __src, __n); |
| 1491 | -: 158:} |
| 1492 | -: 159: |
| 1493 | -: 160:extern size_t __strlcat_chk (char *__dest, const char *__src, size_t __n, |
| 1494 | -: 161: size_t __destlen) __THROW; |
| 1495 | -: 162:extern size_t __REDIRECT_NTH (__strlcat_alias, |
| 1496 | -: 163: (char *__dest, const char *__src, size_t __n), |
| 1497 | -: 164: strlcat); |
| 1498 | -: 165: |
| 1499 | -: 166:__fortify_function size_t |
| 1500 | -: 167:__NTH (strlcat (char *__restrict __dest, const char *__restrict __src, |
| 1501 | -: 168: size_t __n)) |
| 1502 | -: 169:{ |
| 1503 | -: 170: if (__glibc_objsize (__dest) != (size_t) -1 |
| 1504 | -: 171: && (!__builtin_constant_p (__n > __glibc_objsize (__dest)) |
| 1505 | -: 172: || __n > __glibc_objsize (__dest))) |
| 1506 | -: 173: return __strlcat_chk (__dest, __src, __n, __glibc_objsize (__dest)); |
| 1507 | -: 174: return __strlcat_alias (__dest, __src, __n); |
| 1508 | -: 175:} |
| 1509 | -: 176:#endif /* __USE_MISC */ |
| 1510 | -: 177: |
| 1511 | -: 178:#endif /* bits/string_fortified.h */ |
| 1512 | -: 0:Source:/usr/include/aarch64-linux-gnu/bits/stdio2.h |
| 1513 | -: 0:Graph:build/dagsim-resolve/resolve.gcno |
| 1514 | -: 0:Data:build/dagsim-resolve/resolve.gcda |
| 1515 | -: 0:Runs:1 |
| 1516 | -: 1:/* Checking macros for stdio functions. |
| 1517 | -: 2: Copyright (C) 2004-2024 Free Software Foundation, Inc. |
| 1518 | -: 3: This file is part of the GNU C Library. |
| 1519 | -: 4: |
| 1520 | -: 5: The GNU C Library is free software; you can redistribute it and/or |
| 1521 | -: 6: modify it under the terms of the GNU Lesser General Public |
| 1522 | -: 7: License as published by the Free Software Foundation; either |
| 1523 | -: 8: version 2.1 of the License, or (at your option) any later version. |
| 1524 | -: 9: |
| 1525 | -: 10: The GNU C Library is distributed in the hope that it will be useful, |
| 1526 | -: 11: but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1527 | -: 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 1528 | -: 13: Lesser General Public License for more details. |
| 1529 | -: 14: |
| 1530 | -: 15: You should have received a copy of the GNU Lesser General Public |
| 1531 | -: 16: License along with the GNU C Library; if not, see |
| 1532 | -: 17: <https://www.gnu.org/licenses/>. */ |
| 1533 | -: 18: |
| 1534 | -: 19:#ifndef _BITS_STDIO2_H |
| 1535 | -: 20:#define _BITS_STDIO2_H 1 |
| 1536 | -: 21: |
| 1537 | -: 22:#ifndef _STDIO_H |
| 1538 | -: 23:# error "Never include <bits/stdio2.h> directly; use <stdio.h> instead." |
| 1539 | -: 24:#endif |
| 1540 | -: 25: |
| 1541 | -: 26:#ifdef __va_arg_pack |
| 1542 | -: 27:__fortify_function int |
| 1543 | -: 28:__NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...)) |
| 1544 | -: 29:{ |
| 1545 | -: 30: return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, |
| 1546 | -: 31: __glibc_objsize (__s), __fmt, |
| 1547 | -: 32: __va_arg_pack ()); |
| 1548 | -: 33:} |
| 1549 | -: 34:#elif !defined __cplusplus |
| 1550 | -: 35:# define sprintf(str, ...) \ |
| 1551 | -: 36: __builtin___sprintf_chk (str, __USE_FORTIFY_LEVEL - 1, \ |
| 1552 | -: 37: __glibc_objsize (str), __VA_ARGS__) |
| 1553 | -: 38:#endif |
| 1554 | -: 39: |
| 1555 | -: 40:__fortify_function int |
| 1556 | -: 41:__NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt, |
| 1557 | -: 42: __gnuc_va_list __ap)) |
| 1558 | -: 43:{ |
| 1559 | -: 44: return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, |
| 1560 | -: 45: __glibc_objsize (__s), __fmt, __ap); |
| 1561 | -: 46:} |
| 1562 | -: 47: |
| 1563 | -: 48:#if defined __USE_ISOC99 || defined __USE_UNIX98 |
| 1564 | -: 49:# ifdef __va_arg_pack |
| 1565 | -: 50:__fortify_function int |
| 1566 | -: 51:__NTH (snprintf (char *__restrict __s, size_t __n, |
| 1567 | -: 52: const char *__restrict __fmt, ...)) |
| 1568 | -: 53:{ |
| 1569 | 1424*: 54: return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, |
| 1570 | call 0 never executed |
| 1571 | call 1 never executed |
| 1572 | call 2 never executed |
| 1573 | call 3 returned 4 |
| 1574 | -: 55: __glibc_objsize (__s), __fmt, |
| 1575 | -: 56: __va_arg_pack ()); |
| 1576 | -: 57:} |
| 1577 | -: 58:# elif !defined __cplusplus |
| 1578 | -: 59:# define snprintf(str, len, ...) \ |
| 1579 | -: 60: __builtin___snprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, \ |
| 1580 | -: 61: __glibc_objsize (str), __VA_ARGS__) |
| 1581 | -: 62:# endif |
| 1582 | -: 63: |
| 1583 | -: 64:__fortify_function int |
| 1584 | -: 65:__NTH (vsnprintf (char *__restrict __s, size_t __n, |
| 1585 | -: 66: const char *__restrict __fmt, __gnuc_va_list __ap)) |
| 1586 | -: 67:{ |
| 1587 | -: 68: return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, |
| 1588 | -: 69: __glibc_objsize (__s), __fmt, __ap); |
| 1589 | -: 70:} |
| 1590 | -: 71: |
| 1591 | -: 72:#endif |
| 1592 | -: 73: |
| 1593 | -: 74:#if __USE_FORTIFY_LEVEL > 1 |
| 1594 | -: 75:# ifdef __va_arg_pack |
| 1595 | -: 76:__fortify_function __nonnull ((1)) int |
| 1596 | -: 77:fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...) |
| 1597 | -: 78:{ |
| 1598 | -: 79: return __fprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, |
| 1599 | -: 80: __va_arg_pack ()); |
| 1600 | -: 81:} |
| 1601 | -: 82: |
| 1602 | -: 83:__fortify_function int |
| 1603 | -: 84:printf (const char *__restrict __fmt, ...) |
| 1604 | -: 85:{ |
| 1605 | -: 86: return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); |
| 1606 | -: 87:} |
| 1607 | -: 88:# elif !defined __cplusplus |
| 1608 | -: 89:# define printf(...) \ |
| 1609 | -: 90: __printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
| 1610 | -: 91:# define fprintf(stream, ...) \ |
| 1611 | -: 92: __fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
| 1612 | -: 93:# endif |
| 1613 | -: 94: |
| 1614 | -: 95:__fortify_function int |
| 1615 | -: 96:vprintf (const char *__restrict __fmt, __gnuc_va_list __ap) |
| 1616 | -: 97:{ |
| 1617 | -: 98:#ifdef __USE_EXTERN_INLINES |
| 1618 | -: 99: return __vfprintf_chk (stdout, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); |
| 1619 | -: 100:#else |
| 1620 | -: 101: return __vprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap); |
| 1621 | -: 102:#endif |
| 1622 | -: 103:} |
| 1623 | -: 104: |
| 1624 | -: 105:__fortify_function __nonnull ((1)) int |
| 1625 | -: 106:vfprintf (FILE *__restrict __stream, |
| 1626 | -: 107: const char *__restrict __fmt, __gnuc_va_list __ap) |
| 1627 | -: 108:{ |
| 1628 | -: 109: return __vfprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); |
| 1629 | -: 110:} |
| 1630 | -: 111: |
| 1631 | -: 112:# ifdef __USE_XOPEN2K8 |
| 1632 | -: 113:# ifdef __va_arg_pack |
| 1633 | -: 114:__fortify_function int |
| 1634 | -: 115:dprintf (int __fd, const char *__restrict __fmt, ...) |
| 1635 | -: 116:{ |
| 1636 | -: 117: return __dprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, |
| 1637 | -: 118: __va_arg_pack ()); |
| 1638 | -: 119:} |
| 1639 | -: 120:# elif !defined __cplusplus |
| 1640 | -: 121:# define dprintf(fd, ...) \ |
| 1641 | -: 122: __dprintf_chk (fd, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
| 1642 | -: 123:# endif |
| 1643 | -: 124: |
| 1644 | -: 125:__fortify_function int |
| 1645 | -: 126:vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap) |
| 1646 | -: 127:{ |
| 1647 | -: 128: return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); |
| 1648 | -: 129:} |
| 1649 | -: 130:# endif |
| 1650 | -: 131: |
| 1651 | -: 132:# ifdef __USE_GNU |
| 1652 | -: 133:# ifdef __va_arg_pack |
| 1653 | -: 134:__fortify_function int |
| 1654 | -: 135:__NTH (asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...)) |
| 1655 | -: 136:{ |
| 1656 | -: 137: return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, |
| 1657 | -: 138: __va_arg_pack ()); |
| 1658 | -: 139:} |
| 1659 | -: 140: |
| 1660 | -: 141:__fortify_function int |
| 1661 | -: 142:__NTH (__asprintf (char **__restrict __ptr, const char *__restrict __fmt, |
| 1662 | -: 143: ...)) |
| 1663 | -: 144:{ |
| 1664 | -: 145: return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, |
| 1665 | -: 146: __va_arg_pack ()); |
| 1666 | -: 147:} |
| 1667 | -: 148: |
| 1668 | -: 149:__fortify_function int |
| 1669 | -: 150:__NTH (obstack_printf (struct obstack *__restrict __obstack, |
| 1670 | -: 151: const char *__restrict __fmt, ...)) |
| 1671 | -: 152:{ |
| 1672 | -: 153: return __obstack_printf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt, |
| 1673 | -: 154: __va_arg_pack ()); |
| 1674 | -: 155:} |
| 1675 | -: 156:# elif !defined __cplusplus |
| 1676 | -: 157:# define asprintf(ptr, ...) \ |
| 1677 | -: 158: __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
| 1678 | -: 159:# define __asprintf(ptr, ...) \ |
| 1679 | -: 160: __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
| 1680 | -: 161:# define obstack_printf(obstack, ...) \ |
| 1681 | -: 162: __obstack_printf_chk (obstack, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
| 1682 | -: 163:# endif |
| 1683 | -: 164: |
| 1684 | -: 165:__fortify_function int |
| 1685 | -: 166:__NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt, |
| 1686 | -: 167: __gnuc_va_list __ap)) |
| 1687 | -: 168:{ |
| 1688 | -: 169: return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); |
| 1689 | -: 170:} |
| 1690 | -: 171: |
| 1691 | -: 172:__fortify_function int |
| 1692 | -: 173:__NTH (obstack_vprintf (struct obstack *__restrict __obstack, |
| 1693 | -: 174: const char *__restrict __fmt, __gnuc_va_list __ap)) |
| 1694 | -: 175:{ |
| 1695 | -: 176: return __obstack_vprintf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt, |
| 1696 | -: 177: __ap); |
| 1697 | -: 178:} |
| 1698 | -: 179: |
| 1699 | -: 180:# endif |
| 1700 | -: 181: |
| 1701 | -: 182:#endif |
| 1702 | -: 183: |
| 1703 | -: 184:#if __GLIBC_USE (DEPRECATED_GETS) |
| 1704 | -: 185:__fortify_function __wur char * |
| 1705 | -: 186:gets (char *__str) |
| 1706 | -: 187:{ |
| 1707 | -: 188: if (__glibc_objsize (__str) != (size_t) -1) |
| 1708 | -: 189: return __gets_chk (__str, __glibc_objsize (__str)); |
| 1709 | -: 190: return __gets_warn (__str); |
| 1710 | -: 191:} |
| 1711 | -: 192:#endif |
| 1712 | -: 193: |
| 1713 | -: 194:__fortify_function __wur __fortified_attr_access (__write_only__, 1, 2) |
| 1714 | -: 195:__nonnull ((3)) char * |
| 1715 | -: 196:fgets (char *__restrict __s, int __n, FILE *__restrict __stream) |
| 1716 | -: 197:{ |
| 1717 | -: 198: size_t sz = __glibc_objsize (__s); |
| 1718 | -: 199: if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz)) |
| 1719 | -: 200: return __fgets_alias (__s, __n, __stream); |
| 1720 | -: 201: if (__glibc_unsafe_len (__n, sizeof (char), sz)) |
| 1721 | -: 202: return __fgets_chk_warn (__s, sz, __n, __stream); |
| 1722 | -: 203: return __fgets_chk (__s, sz, __n, __stream); |
| 1723 | -: 204:} |
| 1724 | -: 205: |
| 1725 | -: 206:__fortify_function __wur __nonnull ((4)) size_t |
| 1726 | -: 207:fread (void *__restrict __ptr, size_t __size, size_t __n, |
| 1727 | -: 208: FILE *__restrict __stream) |
| 1728 | -: 209:{ |
| 1729 | #####: 210: size_t sz = __glibc_objsize0 (__ptr); |
| 1730 | #####: 211: if (__glibc_safe_or_unknown_len (__n, __size, sz)) |
| 1731 | branch 0 never executed (fallthrough) |
| 1732 | branch 1 never executed |
| 1733 | branch 2 never executed (fallthrough) |
| 1734 | branch 3 never executed |
| 1735 | branch 4 never executed (fallthrough) |
| 1736 | branch 5 never executed |
| 1737 | branch 6 never executed (fallthrough) |
| 1738 | branch 7 never executed |
| 1739 | #####: 212: return __fread_alias (__ptr, __size, __n, __stream); |
| 1740 | call 0 never executed |
| 1741 | -: 213: if (__glibc_unsafe_len (__n, __size, sz)) |
| 1742 | #####: 214: return __fread_chk_warn (__ptr, sz, __size, __n, __stream); |
| 1743 | call 0 never executed |
| 1744 | #####: 215: return __fread_chk (__ptr, sz, __size, __n, __stream); |
| 1745 | call 0 never executed |
| 1746 | -: 216:} |
| 1747 | -: 217: |
| 1748 | -: 218:#ifdef __USE_GNU |
| 1749 | -: 219:__fortify_function __wur __fortified_attr_access (__write_only__, 1, 2) |
| 1750 | -: 220:__nonnull ((3)) char * |
| 1751 | -: 221:fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) |
| 1752 | -: 222:{ |
| 1753 | -: 223: size_t sz = __glibc_objsize (__s); |
| 1754 | -: 224: if (__glibc_safe_or_unknown_len (__n, sizeof (char), sz)) |
| 1755 | -: 225: return __fgets_unlocked_alias (__s, __n, __stream); |
| 1756 | -: 226: if (__glibc_unsafe_len (__n, sizeof (char), sz)) |
| 1757 | -: 227: return __fgets_unlocked_chk_warn (__s, sz, __n, __stream); |
| 1758 | -: 228: return __fgets_unlocked_chk (__s, sz, __n, __stream); |
| 1759 | -: 229:} |
| 1760 | -: 230:#endif |
| 1761 | -: 231: |
| 1762 | -: 232:#ifdef __USE_MISC |
| 1763 | -: 233:# undef fread_unlocked |
| 1764 | -: 234:__fortify_function __wur __nonnull ((4)) size_t |
| 1765 | -: 235:fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n, |
| 1766 | -: 236: FILE *__restrict __stream) |
| 1767 | -: 237:{ |
| 1768 | -: 238: size_t sz = __glibc_objsize0 (__ptr); |
| 1769 | -: 239: if (__glibc_safe_or_unknown_len (__n, __size, sz)) |
| 1770 | -: 240: { |
| 1771 | -: 241:# ifdef __USE_EXTERN_INLINES |
| 1772 | -: 242: if (__builtin_constant_p (__size) |
| 1773 | -: 243: && __builtin_constant_p (__n) |
| 1774 | -: 244: && (__size | __n) < (((size_t) 1) << (8 * sizeof (size_t) / 2)) |
| 1775 | -: 245: && __size * __n <= 8) |
| 1776 | -: 246: { |
| 1777 | -: 247: size_t __cnt = __size * __n; |
| 1778 | -: 248: char *__cptr = (char *) __ptr; |
| 1779 | -: 249: if (__cnt == 0) |
| 1780 | -: 250: return 0; |
| 1781 | -: 251: |
| 1782 | -: 252: for (; __cnt > 0; --__cnt) |
| 1783 | -: 253: { |
| 1784 | -: 254: int __c = getc_unlocked (__stream); |
| 1785 | -: 255: if (__c == EOF) |
| 1786 | -: 256: break; |
| 1787 | -: 257: *__cptr++ = __c; |
| 1788 | -: 258: } |
| 1789 | -: 259: return (__cptr - (char *) __ptr) / __size; |
| 1790 | -: 260: } |
| 1791 | -: 261:# endif |
| 1792 | -: 262: return __fread_unlocked_alias (__ptr, __size, __n, __stream); |
| 1793 | -: 263: } |
| 1794 | -: 264: if (__glibc_unsafe_len (__n, __size, sz)) |
| 1795 | -: 265: return __fread_unlocked_chk_warn (__ptr, sz, __size, __n, __stream); |
| 1796 | -: 266: return __fread_unlocked_chk (__ptr, sz, __size, __n, __stream); |
| 1797 | -: 267: |
| 1798 | -: 268:} |
| 1799 | -: 269:#endif |
| 1800 | -: 270: |
| 1801 | -: 271:#endif /* bits/stdio2.h. */ |
| 1802 | -: 0:Source:tools/dagsim/dagsim_resolve.h |
| 1803 | -: 0:Graph:build/dagsim-resolve/resolve.gcno |
| 1804 | -: 0:Data:build/dagsim-resolve/resolve.gcda |
| 1805 | -: 0:Runs:1 |
| 1806 | -: 1:/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 1807 | -: 2:/* Internal fixed-view ABI shell. All selection, evidence, lookup and arithmetic |
| 1808 | -: 3: * decisions live in dag_res.om / dag_diff.om. The host owns bytes and messages. */ |
| 1809 | -: 4:#include "cudapp_native.h" |
| 1810 | function dr_call called 3689 returned 100% blocks executed 75% |
| 1811 | 3689: 5:static uint64_t dr_call(uint64_t mode,uint64_t *w,uint64_t *s,unsigned char *t,uint64_t *a) { |
| 1812 | -: 6: uint64_t result; |
| 1813 | 3689*: 7: if(omega_dag_res(&result,mode,w,16384,s,8192,t,131072,a,64))abort(); |
| 1814 | call 0 returned 3689 |
| 1815 | branch 1 taken 0 (fallthrough) |
| 1816 | branch 2 taken 3689 |
| 1817 | call 3 never executed |
| 1818 | 3689: 8: return result; |
| 1819 | -: 9:} |
| 1820 | -: 10:static double dr_double_bits(uint64_t x) { double d; memcpy(&d,&x,sizeof d); return d; } |
| 1821 | -: 11:static uint64_t dr_bits(double d) { uint64_t x; memcpy(&x,&d,sizeof x); return x; } |
| 1822 | function dr_model called 3909 returned 100% blocks executed 100% |
| 1823 | 3909: 12:static void dr_model(const ds_model *m, uint64_t *w, int side) { |
| 1824 | 3909: 13: uint64_t *h=w+side*8192; |
| 1825 | 3909: 14: h[0]=m->n_ops; h[1]=m->n_res; h[2]=m->n_deps; h[3]=m->n_removed; |
| 1826 | 3909: 15: h[4]=(uint64_t)(int64_t)m->has_calibration; h[5]=(uint64_t)(int64_t)m->cal_taken_day; |
| 1827 | 3909: 16: h[6]=(uint64_t)(int64_t)m->cal_valid_days; h[7]=(uint64_t)(int64_t)m->has_energy; |
| 1828 | 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; |
| 1829 | 23454: 18: for(int i=0;i<5;i++)h[13+i]=(unsigned char)m->instrument[i]; |
| 1830 | branch 0 taken 19545 |
| 1831 | branch 1 taken 3909 (fallthrough) |
| 1832 | 19569: 19: for(int i=0;i<m->n_res;i++) { |
| 1833 | branch 0 taken 15660 |
| 1834 | branch 1 taken 3909 (fallthrough) |
| 1835 | 15660: 20: const ds_resource *r=&m->res[i]; uint64_t *p=h+32+i*8; |
| 1836 | 15660: 21: p[0]=r->kind;p[1]=(uint64_t)(int64_t)r->slots;p[2]=dr_bits(r->cap); |
| 1837 | 15660: 22: p[3]=dr_bits(r->lo);p[4]=dr_bits(r->hi);p[5]=r->prov; |
| 1838 | -: 23: } |
| 1839 | 12118: 24: for(int i=0;i<m->n_ops;i++) { |
| 1840 | branch 0 taken 8209 |
| 1841 | branch 1 taken 3909 (fallthrough) |
| 1842 | 8209: 25: const ds_op *r=&m->ops[i];uint64_t *p=h+288+i*16; |
| 1843 | 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); |
| 1844 | 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; |
| 1845 | 8209: 28: p[9]=dr_bits(r->launch_ns);p[10]=(uint64_t)(int64_t)r->launcher; |
| 1846 | 8209: 29: p[11]=r->M;p[12]=r->N;p[13]=r->core;p[14]=r->arm; |
| 1847 | -: 30: } |
| 1848 | 5509: 31: for(int i=0;i<m->n_deps;i++){h[4384+i*2]=m->deps[i].from;h[4385+i*2]=m->deps[i].to;} |
| 1849 | branch 0 taken 1600 |
| 1850 | branch 1 taken 3909 (fallthrough) |
| 1851 | 6425: 32: for(int i=0;i<m->n_removed;i++) { |
| 1852 | branch 0 taken 2516 |
| 1853 | branch 1 taken 3909 (fallthrough) |
| 1854 | 2516: 33: h[6432+i*4]=m->removed[i].reason; |
| 1855 | -: 34: } |
| 1856 | 3909: 35:} |
| 1857 | function dr_names called 3640 returned 100% blocks executed 100% |
| 1858 | 3640: 36:static void dr_names(const ds_model *m,unsigned char *t,int side) { |
| 1859 | 3640: 37: unsigned char *names=t+side*65536; |
| 1860 | 10807: 38: for(int i=0;i<m->n_ops;i++)memcpy(names+i*40,m->ops[i].id,DS_ID); |
| 1861 | branch 0 taken 7167 |
| 1862 | branch 1 taken 3640 |
| 1863 | 6156: 39: for(int i=0;i<m->n_removed;i++) { |
| 1864 | branch 0 taken 2516 |
| 1865 | branch 1 taken 3640 (fallthrough) |
| 1866 | 2516: 40: memcpy(names+11520+i*208,m->removed[i].op,DS_ID); |
| 1867 | 2516: 41: memcpy(names+11560+i*208,m->removed[i].ref,DS_ID); |
| 1868 | 2516: 42: memcpy(names+11600+i*208,m->removed[i].proof,DS_SRC); |
| 1869 | -: 43: } |
| 1870 | 3640: 44:} |
| 1871 | function dr_lookup called 52 returned 100% blocks executed 100% |
| 1872 | 52: 45:static int dr_lookup(const ds_model *m, const char *id, int kind) { |
| 1873 | 52: 46: uint64_t w[16384],s[8192],a[64]={0};unsigned char t[131072]; |
| 1874 | 52: 47: w[0]=m->n_ops;w[1]=m->n_res;a[1]=kind; |
| 1875 | 52: 48: if(kind==0) { |
| 1876 | branch 0 taken 10 |
| 1877 | branch 1 taken 42 |
| 1878 | 30: 49: for(int i=0;i<m->n_ops;i++)memcpy(t+i*40,m->ops[i].id,DS_ID); |
| 1879 | branch 0 taken 20 |
| 1880 | branch 1 taken 10 |
| 1881 | -: 50: } else { |
| 1882 | 1106: 51: for(int i=0;i<m->n_res;i++)memcpy(t+10240+i*40,m->res[i].id,DS_ID); |
| 1883 | branch 0 taken 1064 |
| 1884 | branch 1 taken 42 (fallthrough) |
| 1885 | -: 52: } |
| 1886 | -: 53: /* Copy at most DS_ID bytes: a longer query cannot equal a valid model id. */ |
| 1887 | 52: 54: size_t n=strnlen(id,DS_ID);memcpy(t+130816,id,n);if(n<DS_ID)t[130816+n]=0; |
| 1888 | branch 0 taken 50 (fallthrough) |
| 1889 | branch 1 taken 2 |
| 1890 | 52: 55: return (int)(int32_t)dr_call(2,w,s,t,a); |
| 1891 | call 0 returned 52 |
| 1892 | -: 56:} |
| 1893 | function dr_refusal called 117 returned 100% blocks executed 93% |
| 1894 | 117: 57:static int dr_refusal(const ds_model *m, const uint64_t *a, ds_result *r) { |
| 1895 | 117: 58: int i=(int)a[1],status=(int)a[2];const ds_op *op=&m->ops[i]; |
| 1896 | 117: 59: switch(a[0]) { |
| 1897 | branch 0 taken 4 |
| 1898 | branch 1 taken 1 |
| 1899 | branch 2 taken 84 |
| 1900 | branch 3 taken 6 |
| 1901 | branch 4 taken 10 |
| 1902 | branch 5 taken 1 |
| 1903 | branch 6 taken 6 |
| 1904 | branch 7 taken 4 |
| 1905 | branch 8 taken 1 |
| 1906 | branch 9 taken 0 |
| 1907 | 4: 60: case 1:return refuse(r,status,"resource %s has prov=unknown; unknown stays unknown%s",m->res[i].id,""); |
| 1908 | call 0 returned 4 |
| 1909 | 1: 61: case 2:return refuse(r,status,"op %s is a matvec with no rx_costmodel blob supplied (calibration model=)%s",op->id,""); |
| 1910 | call 0 returned 1 |
| 1911 | 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,""); |
| 1912 | call 0 returned 84 |
| 1913 | 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"); |
| 1914 | branch 0 taken 3 (fallthrough) |
| 1915 | branch 1 taken 3 |
| 1916 | call 2 returned 6 |
| 1917 | 10: 64: case 5:return refuse(r,status,"op %s has no engine%s",op->id,""); |
| 1918 | call 0 returned 10 |
| 1919 | 1: 65: case 6:return refuse(r,status,"op %s: launch without an engine%s",op->id,""); |
| 1920 | call 0 returned 1 |
| 1921 | 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","",""); |
| 1922 | call 0 returned 6 |
| 1923 | 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);} |
| 1924 | call 0 returned 4 |
| 1925 | 1: 68: case 10:return refuse(r,status,"empty DAG%s%s","",""); |
| 1926 | call 0 returned 1 |
| 1927 | -: 69: } |
| 1928 | #####: 70: return refuse_msg(r,status,"invalid Omega resolver refusal"); |
| 1929 | call 0 never executed |
| 1930 | -: 71:} |
| 1931 | function dr_resolved called 243 returned 100% blocks executed 100% |
| 1932 | 243: 72:static int dr_resolved(const ds_model *m,const ds_opts *o,uint64_t *s,ds_result *r) { |
| 1933 | 243: 73: uint64_t w[16384],a[64]={0};unsigned char t[131072]; |
| 1934 | 243: 74: dr_model(m,w,0);memset(s,0,8192*sizeof *s); |
| 1935 | call 0 returned 243 |
| 1936 | 243: 75: a[5]=(uint64_t)(int64_t)o->mode;a[6]=(uint64_t)(int64_t)o->asof_day; |
| 1937 | 243: 76: a[7]=(uintptr_t)o->costmodel;a[9]=dr_bits(o->interval_q);a[35]=(uint64_t)time(NULL); |
| 1938 | call 0 returned 243 |
| 1939 | -: 77: for(;;) { |
| 1940 | 501: 78: uint64_t rc=dr_call(0,w,s,t,a); |
| 1941 | call 0 returned 501 |
| 1942 | 501: 79: switch(rc) { |
| 1943 | branch 0 taken 142 |
| 1944 | branch 1 taken 58 |
| 1945 | branch 2 taken 58 |
| 1946 | branch 3 taken 117 |
| 1947 | branch 4 taken 126 |
| 1948 | -: 80: case 0:return DS_OK; |
| 1949 | -: 81: case 1:{ |
| 1950 | -: 82: RxCmFeatures f;memset(&f,0,sizeof f); |
| 1951 | 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]; |
| 1952 | 142: 84: f.core=a[20];f.eligible=a[21];f.current_arm=a[22];RxCmPrediction p; |
| 1953 | 142: 85: int st=rx_cm_predict((const RxCostModel *)o->costmodel,&f,(uint32_t)a[22],&p); |
| 1954 | call 0 returned 142 |
| 1955 | 142: 86: a[24]=(uint64_t)(int64_t)st;a[25]=p.refused;a[26]=p.known;a[27]=p.n; |
| 1956 | 142: 87: a[28]=dr_bits(p.mean_log2_ps);a[29]=dr_bits(p.sd_log2);a[30]=dr_bits(p.dof);break;} |
| 1957 | 58: 88: case 2:a[31]=dr_bits(rx_cm_t_quantile(dr_double_bits(a[9]),dr_double_bits(a[30])));break; |
| 1958 | call 0 returned 58 |
| 1959 | 58: 89: case 3:a[33]=dr_bits(pow(2.0,dr_double_bits(a[32])));break; |
| 1960 | 117: 90: default:return dr_refusal(m,a,r); |
| 1961 | call 0 returned 117 |
| 1962 | -: 91: } |
| 1963 | -: 92: } |
| 1964 | -: 93:} |
| 1965 | -: 94:#ifdef CUDAPP_MIGRATION_PENDING_C_TOOLS |
| 1966 | -: 95:static int resolve(const ds_model *m,const ds_opts *o,ds_num *num,ds_result *r) { |
| 1967 | -: 96: uint64_t s[8192];int rc=dr_resolved(m,o,s,r);if(rc)return rc; |
| 1968 | -: 97: for(int i=0;i<m->n_ops;i++) { |
| 1969 | -: 98: const uint64_t *p=s+32+i*10;num[i].t=dr_double_bits(p[0]);num[i].bytes=dr_double_bits(p[1]); |
| 1970 | -: 99: num[i].launch=dr_double_bits(p[2]);num[i].cap=dr_double_bits(p[3]);num[i].prov=(int)p[8]; |
| 1971 | -: 100: } |
| 1972 | -: 101: return DS_OK; |
| 1973 | -: 102:} |
| 1974 | -: 103:#endif |
| 1975 | function dr_counter called 26 returned 100% blocks executed 100% |
| 1976 | 26: 104:static double dr_counter(const ds_model *m,const ds_opts *o,int idx) { |
| 1977 | 26: 105: uint64_t w[16384],s[8192],a[64]={0};unsigned char t[131072];dr_model(m,w,0); |
| 1978 | call 0 returned 26 |
| 1979 | 26: 106: a[1]=(uint64_t)(int64_t)idx; |
| 1980 | 26: 107: if(dr_call(1,w,s,t,a))return -DS_REFUSED_UNSUPPORTED; |
| 1981 | call 0 returned 26 |
| 1982 | branch 1 taken 6 (fallthrough) |
| 1983 | branch 2 taken 20 |
| 1984 | 20: 108: ds_model *c=malloc(sizeof *c);if(!c)return -DS_REFUSED_UNSUPPORTED;*c=*m; |
| 1985 | branch 0 taken 1 |
| 1986 | branch 1 taken 19 (fallthrough) |
| 1987 | 95: 109: for(int i=0;i<m->n_res;i++) { |
| 1988 | branch 0 taken 76 |
| 1989 | branch 1 taken 19 |
| 1990 | 76: 110: 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]); |
| 1991 | 76: 111: c->res[i].lo=dr_double_bits(p[3]);c->res[i].hi=dr_double_bits(p[4]); |
| 1992 | -: 112: } |
| 1993 | 57: 113: for(int i=0;i<m->n_ops;i++)c->ops[i].launch_ns=dr_double_bits(w[288+i*16+9]); |
| 1994 | branch 0 taken 38 |
| 1995 | branch 1 taken 19 (fallthrough) |
| 1996 | 19: 114: ds_result r;ds_opts x=*o;x.mode=0;int rc=ds_eval(c,&x,&r);free(c); |
| 1997 | call 0 returned 19 |
| 1998 | 19: 115: return rc==DS_OK?r.makespan_ns:-(double)rc; |
| 1999 | branch 0 taken 18 (fallthrough) |
| 2000 | branch 1 taken 1 |
| 2001 | -: 116:} |
| 2002 | function dr_diff called 1820 returned 100% blocks executed 96% |
| 2003 | 1820: 117:static int dr_diff(const ds_model *b,const ds_model *t,const ds_opts *o,ds_diff *d) { |
| 2004 | 1820: 118: uint64_t w[16384],s[8192],a[64]={0};unsigned char names[131072]; |
| 2005 | 1820: 119: dr_model(b,w,0);dr_model(t,w,1);dr_names(b,names,0);dr_names(t,names,1); |
| 2006 | call 0 returned 1820 |
| 2007 | call 1 returned 1820 |
| 2008 | call 2 returned 1820 |
| 2009 | call 3 returned 1820 |
| 2010 | -: 120: memset(w+7600,0,DS_MAX_OPS*sizeof *w); |
| 2011 | 1820: 121: const char *list=o?o->changed:NULL; |
| 2012 | branch 0 taken 1818 (fallthrough) |
| 2013 | branch 1 taken 2 |
| 2014 | 1818: 122: if(list) { |
| 2015 | branch 0 taken 1554 (fallthrough) |
| 2016 | branch 1 taken 264 |
| 2017 | 1554: 123: size_t left=strlen(list); |
| 2018 | -: 124: do { |
| 2019 | 3110: 125: size_t n=left>256?256:left;memcpy(names+130816,list,n);a[41]=n;a[42]=(n==left); |
| 2020 | call 0 returned 3110 |
| 2021 | 3110: 126: dr_call(3,w,s,names,a);list+=n;left-=n; |
| 2022 | call 0 returned 3110 |
| 2023 | 3110: 127: }while(left); |
| 2024 | branch 0 taken 1556 |
| 2025 | branch 1 taken 1554 (fallthrough) |
| 2026 | -: 128: } |
| 2027 | -: 129: memset(a,0,sizeof a);uint64_t result; |
| 2028 | 1820*: 130: if(omega_dag_diff(&result,w,16384,names,131072,a,64))abort(); |
| 2029 | call 0 returned 1820 |
| 2030 | branch 1 taken 0 (fallthrough) |
| 2031 | branch 2 taken 1820 |
| 2032 | call 3 never executed |
| 2033 | 1820: 131: int rc=(int)result;memset(d,0,sizeof *d); |
| 2034 | 1820: 132: 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]; |
| 2035 | 16380: 133: for(int i=0;i<8;i++)d->removed_ns[i]=dr_double_bits(a[32+i]); |
| 2036 | branch 0 taken 14560 |
| 2037 | branch 1 taken 1820 (fallthrough) |
| 2038 | 1820: 134: int i=(int)a[1];const ds_removed *rec=&t->removed[a[3]]; |
| 2039 | 1820: 135: switch(a[0]) { |
| 2040 | branch 0 taken 2 |
| 2041 | branch 1 taken 1 |
| 2042 | branch 2 taken 1 |
| 2043 | branch 3 taken 1415 |
| 2044 | branch 4 taken 1 |
| 2045 | branch 5 taken 400 |
| 2046 | 2: 136: case 1:snprintf(d->reason,sizeof d->reason,"op %s kept but its demand changed; trace conservation broken",b->ops[i].id);break; |
| 2047 | 1: 137: case 2:snprintf(d->reason,sizeof d->reason,"op %s vanished without a removed record",b->ops[i].id);break; |
| 2048 | 1: 138: case 3:snprintf(d->reason,sizeof d->reason,"op %s removed %d times (double counted)",b->ops[i].id,(int)a[4]);break; |
| 2049 | 1415: 139: 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; |
| 2050 | branch 0 taken 1414 (fallthrough) |
| 2051 | branch 1 taken 1 |
| 2052 | branch 2 taken 124 (fallthrough) |
| 2053 | branch 3 taken 1290 |
| 2054 | 1: 140: case 5:snprintf(d->reason,sizeof d->reason,"removed record for %s, which was never in the baseline",rec->op);break; |
| 2055 | -: 141: } |
| 2056 | 1820: 142: return rc; |
| 2057 | -: 143:} |
| 2058 | -: 0:Source:tools/dagsim/dagsim_format.h |
| 2059 | -: 0:Graph:build/dagsim-resolve/resolve.gcno |
| 2060 | -: 0:Data:build/dagsim-resolve/resolve.gcda |
| 2061 | -: 0:Runs:1 |
| 2062 | -: 1:/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2063 | -: 2: * Fixed-view ABI marshalling only; decisions and arithmetic live in dag_fmt.om. */ |
| 2064 | -: 3:#ifndef DAGSIM_FORMAT_H |
| 2065 | -: 4:#define DAGSIM_FORMAT_H |
| 2066 | -: 5:#include "cudapp_native.h" |
| 2067 | -: 6:#include <stdint.h> |
| 2068 | -: 7:#include <stdlib.h> |
| 2069 | -: 8:#include <string.h> |
| 2070 | function ds_fmt called 0 returned 0% blocks executed 0% |
| 2071 | #####: 9:static inline uint64_t ds_fmt(unsigned mode, uint64_t a[16], char s[256]) { |
| 2072 | #####: 10: uint64_t result = 0; |
| 2073 | #####: 11: if (omega_dag_fmt(&result, mode, a, 16, s, 256)) abort(); |
| 2074 | call 0 never executed |
| 2075 | branch 1 never executed (fallthrough) |
| 2076 | branch 2 never executed |
| 2077 | call 3 never executed |
| 2078 | #####: 12: return result; |
| 2079 | -: 13:} |
| 2080 | -: 14:static inline uint64_t ds_bits(double d) { |
| 2081 | -: 15: uint64_t u; memcpy(&u, &d, sizeof u); return u; |
| 2082 | -: 16:} |
| 2083 | -: 17:static inline double ds_unbits(uint64_t u) { |
| 2084 | -: 18: double d; memcpy(&d, &u, sizeof d); return d; |
| 2085 | -: 19:} |
| 2086 | -: 20:static inline uint64_t ds_decide(unsigned mode, uint64_t a[16]) { |
| 2087 | -: 21: char s[256]; return ds_fmt(mode, a, s); |
| 2088 | -: 22:} |
| 2089 | -: 23:#endif |