diff options
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/v1/arch.c | 140 | ||||
| -rw-r--r-- | arch/v1/arch_vars.py | 3 |
2 files changed, 94 insertions, 49 deletions
diff --git a/arch/v1/arch.c b/arch/v1/arch.c index 38de920..b4dabcf 100644 --- a/arch/v1/arch.c +++ b/arch/v1/arch.c @@ -7,6 +7,22 @@ enum { #undef INST }; +#if defined(DATA_PUSH_PATH) +#define ARCH_EVENT_ARRAYS \ + ARCH_EVENT_ARRAY(0, wev) /* write events array*/ \ + ARCH_EVENT_ARRAY(1, xev) /* memory block swap events array */ +#define ARCH_EVENT_ARRAYS_COUNT 2 + +#define INST_EVENT_ARRAYS \ + INST_EVENT_ARRAY(0, pop) /* instruction population */ \ + INST_EVENT_ARRAY(1, exe) /* instruction executions */ \ + INST_EVENT_ARRAY(2, wrt) /* instruction writes */ +#define INST_EVENT_ARRAYS_COUNT 3 + +thrd_t g_arch_eva_thrds[CORES][ARCH_EVENT_ARRAYS_COUNT]; +struct DeflateParams g_arch_eva_deflate_params[CORES][ARCH_EVENT_ARRAYS_COUNT]; +#endif + #if (defined(COMMAND_BENCH) || defined(COMMAND_NEW)) && defined(ANC_BYTES) void arch_core_init(struct Core *core) { assert(core); @@ -46,8 +62,10 @@ void arch_core_save(FILE *f, const struct Core *core) { fwrite(&core->wmb0, sizeof(uint64_t), 1, f); fwrite(&core->wmb1, sizeof(uint64_t), 1, f); fwrite(&core->wdea, sizeof(uint64_t), 1, f); - fwrite(core->weva, sizeof(uint64_t), MVEC_SIZE, f); - fwrite(core->xeva, sizeof(uint64_t), MVEC_SIZE, f); +#define ARCH_EVENT_ARRAY(_, ev) \ + fwrite(core->ev##a, sizeof(uint64_t), MVEC_SIZE, f); + ARCH_EVENT_ARRAYS +#undef ARCH_EVENT_ARRAY #else (void)f; (void)core; @@ -66,8 +84,10 @@ void arch_core_load(FILE *f, struct Core *core) { fread(&core->wmb0, sizeof(uint64_t), 1, f); fread(&core->wmb1, sizeof(uint64_t), 1, f); fread(&core->wdea, sizeof(uint64_t), 1, f); - fread(core->weva, sizeof(uint64_t), MVEC_SIZE, f); - fread(core->xeva, sizeof(uint64_t), MVEC_SIZE, f); +#define ARCH_EVENT_ARRAY(_, ev) \ + fread(core->ev##a, sizeof(uint64_t), MVEC_SIZE, f); + ARCH_EVENT_ARRAYS +#undef ARCH_EVENT_ARRAY #else (void)f; (void)core; @@ -858,10 +878,10 @@ const char *arch_mnemonic(uint8_t inst) { void arch_push_data_header(void) { assert(g_sim_data); - g_info("Creating 'arch_general' table in SQLite database"); + g_info("Creating 'arch' table in SQLite database"); salis_exec_sql( 0, NULL, NULL, - "create table arch_general (" + "create table arch (" #define FOR_CORE(i) \ "cycl_" #i " int not null, " \ "wmb0_" #i " int not null, " \ @@ -897,12 +917,19 @@ void arch_push_data_header(void) { } // Memory events - char *eprefs[] = { "wev", "xev" }; - int eprefs_cnt = sizeof(eprefs) / sizeof(eprefs[0]); - for (int i = 0; i < CORES; ++i) { - for (int j = 0; j < eprefs_cnt; ++j) { - g_info("Creating '%s_%d' table in SQLite database", eprefs[j], i); + for (int j = 0; j < ARCH_EVENT_ARRAYS_COUNT; ++j) { + char *pref = NULL; + + switch (j) { +#define ARCH_EVENT_ARRAY(idx, ev) \ + case idx: pref = #ev; break; + ARCH_EVENT_ARRAYS +#undef ARCH_EVENT_ARRAY + default: assert(false); + } + + g_info("Creating '%s_%d' table in SQLite database", pref, i); salis_exec_sql( 0, NULL, NULL, "create table %s_%d (" @@ -913,7 +940,7 @@ void arch_push_data_header(void) { "evts blob not null ," "step int not null" ");", - eprefs[j], i + pref, i ); } } @@ -924,30 +951,28 @@ void arch_push_data_line(void) { assert(g_sim_data); // Measure instruction population - uint64_t ipop[CORES][INST_COUNT] = { 0 }; - for (int i = 0; i < CORES; ++i) { struct Core *core = &g_cores[i]; for (uint64_t j = 0; j < MVEC_SIZE; ++j) { - ++ipop[i][_get_inst(core, j)]; + ++core->ipop[_get_inst(core, j)]; } #if !defined(NDEBUG) uint64_t pop_tot = 0; for (int j = 0; j < INST_COUNT; ++j) { - pop_tot += ipop[i][j]; + pop_tot += core->ipop[j]; } assert(pop_tot == MVEC_SIZE); #endif } - g_info("Pushing row to 'arch_general' table in SQLite database"); + g_info("Pushing row to 'arch' table in SQLite database"); salis_exec_sql( 0, NULL, NULL, - "insert into arch_general (" + "insert into arch (" #define FOR_CORE(i) \ "cycl_" #i ", " \ "wmb0_" #i ", " \ @@ -978,16 +1003,17 @@ void arch_push_data_line(void) { for (int i = 0; i < CORES; ++i) { for (int j = 0; j < iprefs_cnt; ++j) { uint64_t *ia = NULL; + char *pref = NULL; - if (!strcmp("pop", iprefs[j])) { - ia = ipop[i]; - } else if (!strcmp("exe", iprefs[j])) { - ia = g_cores[i].iexe; - } else if (!strcmp("wrt", iprefs[j])) { - ia = g_cores[i].iwrt; + switch (j) { +#define INST_EVENT_ARRAY(idx, iv) \ + case idx: ia = g_cores[i].i##iv; pref = #iv; break; + INST_EVENT_ARRAYS +#undef INST_EVENT_ARRAY + default: assert(false); } - g_info("Pushing row to '%s_%d' table in SQLite database", iprefs[j], i); + g_info("Pushing row to '%s_%d' table in SQLite database", pref, i); salis_exec_sql( 0, NULL, NULL, "insert into %s_%d (" @@ -1007,8 +1033,7 @@ void arch_push_data_line(void) { #undef INST "%ld" ");", - iprefs[j], - i, + pref, i, #define FOR_CORE(i) g_cores[i].cycl, FOR_CORES #undef FOR_CORE @@ -1021,32 +1046,48 @@ void arch_push_data_line(void) { } // Insert arch-specific memory events - char *eprefs[] = { "wev", "xev" }; - int eprefs_cnt = sizeof(eprefs) / sizeof(eprefs[0]); - + // Compression (deflation) is CPU intensive so it is done in parallel for (int i = 0; i < CORES; ++i) { - for (int j = 0; j < eprefs_cnt; ++j) { + for (int j = 0; j < ARCH_EVENT_ARRAYS_COUNT; ++j) { uint64_t *in = NULL; - if (!strcmp("wev", eprefs[j])) { - in = g_cores[i].weva; - } else if (!strcmp("xev", eprefs[j])) { - in = g_cores[i].xeva; + switch (j) { +#define ARCH_EVENT_ARRAY(idx, ev) \ + case idx: in = g_cores[i].ev##a; break; + ARCH_EVENT_ARRAYS +#undef ARCH_EVENT_ARRAY + default: assert(false); } // Compress event data - size_t size = sizeof(uint64_t) * MVEC_SIZE; - char *out = malloc(size); - assert(out); + struct DeflateParams *params = &g_arch_eva_deflate_params[i][j]; + params->size = EVA_SIZE; + params->in = (Bytef *)in; + params->out = (Bytef *)malloc(EVA_SIZE); + thrd_create(&g_arch_eva_thrds[i][j], (thrd_start_t)salis_deflate, params); + } + } + + for (int i = 0; i < CORES; ++i) { + for (int j = 0; j < ARCH_EVENT_ARRAYS_COUNT; ++j) { + char *pref = NULL; + + switch (j) { +#define ARCH_EVENT_ARRAY(idx, ev) \ + case idx: pref = #ev; break; + ARCH_EVENT_ARRAYS +#undef ARCH_EVENT_ARRAY + default: assert(false); + } - z_stream strm = { 0 }; - salis_deflate(&strm, size, (Bytef *)in, (Bytef *)out); + thrd_join(g_arch_eva_thrds[i][j], NULL); // Insert blob - const void *blob = out; - int blob_size = strm.total_out; + struct DeflateParams *params = &g_arch_eva_deflate_params[i][j]; + const void *blob = params->out; + int blob_size = params->strm.total_out; - g_info("Pushing row to '%s_%d' table in SQLite database", eprefs[j], i); + g_info("Pushing row to '%s_%d' table in SQLite database", pref, i); salis_exec_sql( 1, &blob, &blob_size, "insert into %s_%d (" @@ -1060,15 +1101,15 @@ void arch_push_data_line(void) { #undef FOR_CORE "%ld, ?, %ld" ");", - eprefs[j], i, + pref, i, #define FOR_CORE(i) g_cores[i].cycl, FOR_CORES #undef FOR_CORE blob_size, g_steps ); - salis_deflate_end(&strm); - free(out); + salis_deflate_end(params); + free(params->out); } } @@ -1076,6 +1117,7 @@ void arch_push_data_line(void) { for (int i = 0; i < CORES; ++i) { struct Core *core = &g_cores[i]; + memset(core->ipop, 0, sizeof(uint64_t) * INST_COUNT); memset(core->iexe, 0, sizeof(uint64_t) * INST_COUNT); memset(core->iwrt, 0, sizeof(uint64_t) * INST_COUNT); @@ -1083,8 +1125,10 @@ void arch_push_data_line(void) { core->wmb1 = 0; core->wdea = 0; - memset(core->weva, 0, sizeof(uint64_t) * MVEC_SIZE); - memset(core->xeva, 0, sizeof(uint64_t) * MVEC_SIZE); +#define ARCH_EVENT_ARRAY(_, ev) \ + memset(core->ev##a, 0, EVA_SIZE); + ARCH_EVENT_ARRAYS +#undef ARCH_EVENT_ARRAY } } #endif diff --git a/arch/v1/arch_vars.py b/arch/v1/arch_vars.py index 4fb6bb2..9605f85 100644 --- a/arch/v1/arch_vars.py +++ b/arch/v1/arch_vars.py @@ -76,6 +76,7 @@ class ArchVars: self.core_fields = [] self.core_data_fields = [ + ("uint64_t", "ipop", f"[{len(self.inst_set)}]"), # instruction population counter ("uint64_t", "iexe", f"[{len(self.inst_set)}]"), # instruction execution counter ("uint64_t", "iwrt", f"[{len(self.inst_set)}]"), # instruction write counter @@ -113,7 +114,7 @@ class ArchVars: self.plots = { "General": { "wevs": { - "table": "arch_general", + "table": "arch", "type": "lines", "cols": [f"{pref}_{i}" for pref in ["wmb0", "wmb1", "wdea"] for i in range(args.cores)], }, |
