From ad21f51f4f14da9b9283fa72f1574cdb7286c4d9 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Mon, 25 May 2026 04:39:17 +0200 Subject: Reorganizes SQLite database into two (core and arch) tables --- arch/dummy/arch.c | 8 +- arch/v1/arch.c | 294 ++++++++++++++++++++---------------------------------- core/salis.c | 193 +++++++++++++++-------------------- salis.py | 4 +- 4 files changed, 196 insertions(+), 303 deletions(-) diff --git a/arch/dummy/arch.c b/arch/dummy/arch.c index 20fc49d..278754f 100644 --- a/arch/dummy/arch.c +++ b/arch/dummy/arch.c @@ -124,8 +124,8 @@ void arch_validate_proc(const struct Core *core, uint64_t pix) { wchar_t arch_symbol(uint8_t inst) { switch (inst) { -#define INST(index, label, mnemonic, symbol) case index: return symbol; - INST_SET +#define INST(core, pref, index, label, mnemonic, symbol) case index: return symbol; + INST_SET(core, pref) #undef INST } @@ -135,8 +135,8 @@ wchar_t arch_symbol(uint8_t inst) { const char *arch_mnemonic(uint8_t inst) { switch (inst) { -#define INST(index, label, mnemonic, symbol) case index: return mnemonic; - INST_SET +#define INST(core, pref, index, label, mnemonic, symbol) case index: return mnemonic; + INST_SET(core, pref) #undef INST } diff --git a/arch/v1/arch.c b/arch/v1/arch.c index ec5d778..9e6f3e6 100644 --- a/arch/v1/arch.c +++ b/arch/v1/arch.c @@ -2,23 +2,23 @@ // https://git.pauloliver.dev/salis-v1/about/ enum { -#define INST(index, label, mnemonic, symbol) label, - INST_SET +#define INST(core, pref, index, label, mnemonic, symbol) label, + INST_SET(core, pref) #undef INST }; #if defined(DATA_PUSH) -#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(core) \ + INST_EVENT_ARRAY(core, 0, pop) /* instruction population */ \ + INST_EVENT_ARRAY(core, 1, exe) /* instruction executions */ \ + INST_EVENT_ARRAY(core, 2, wrt) /* instruction writes */ #define INST_EVENT_ARRAYS_COUNT 3 +#define ARCH_EVENT_ARRAYS(core) \ + ARCH_EVENT_ARRAY(core, 0, wev) /* write events array*/ \ + ARCH_EVENT_ARRAY(core, 1, xev) /* memory block swap events array */ +#define ARCH_EVENT_ARRAYS_COUNT 2 + thrd_t g_arch_eva_thrds[CORES][ARCH_EVENT_ARRAYS_COUNT]; struct DeflateParams g_arch_eva_deflate_params[CORES][ARCH_EVENT_ARRAYS_COUNT]; #endif @@ -62,9 +62,9 @@ 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); -#define ARCH_EVENT_ARRAY(_, ev) \ +#define ARCH_EVENT_ARRAY(core, index, ev) \ fwrite(core->ev##a, sizeof(uint64_t), MVEC_SIZE, f); - ARCH_EVENT_ARRAYS + ARCH_EVENT_ARRAYS(core) #undef ARCH_EVENT_ARRAY #else (void)f; @@ -84,9 +84,9 @@ 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); -#define ARCH_EVENT_ARRAY(_, ev) \ +#define ARCH_EVENT_ARRAY(core, index, ev) \ fread(core->ev##a, sizeof(uint64_t), MVEC_SIZE, f); - ARCH_EVENT_ARRAYS + ARCH_EVENT_ARRAYS(core) #undef ARCH_EVENT_ARRAY #else (void)f; @@ -850,8 +850,8 @@ void arch_validate_proc(const struct Core *core, uint64_t pix) { wchar_t arch_symbol(uint8_t inst) { switch (inst % INST_COUNT) { -#define INST(index, label, mnemonic, symbol) case index: return symbol; - INST_SET +#define INST(core, pref, index, label, mnemonic, symbol) case index: return symbol; + INST_SET(core, pref) #undef INST } @@ -861,8 +861,8 @@ wchar_t arch_symbol(uint8_t inst) { const char *arch_mnemonic(uint8_t inst) { switch (inst % INST_COUNT) { -#define INST(index, label, mnemonic, symbol) case index: return mnemonic; - INST_SET +#define INST(core, pref, index, label, mnemonic, symbol) case index: return mnemonic; + INST_SET(core, pref) #undef INST } @@ -882,68 +882,28 @@ void arch_push_data_header(void) { salis_exec_sql( 0, NULL, NULL, "create table arch (" +#define INST(core, pref, index, label, mnemonic, symbol) \ + #label "_" #pref "_" #core " int not null, " +#define INST_EVENT_ARRAY(core, index, iv) \ + INST_SET(core, iv) +#define ARCH_EVENT_ARRAY(core, index, ev) \ + #ev "_size_" #core " int not null, " \ + #ev "_" #core " blob not null, " #define FOR_CORE(i) \ "cycl_" #i " int not null, " \ "wmb0_" #i " int not null, " \ "wmb1_" #i " int not null, " \ - "wdea_" #i " int not null, " + "wdea_" #i " int not null, " \ + INST_EVENT_ARRAYS(i) \ + ARCH_EVENT_ARRAYS(i) FOR_CORES #undef FOR_CORE +#undef ARCH_EVENT_ARRAY +#undef INST_EVENT_ARRAY +#undef INST "step int not null" ");" ); - - // Instruction events - char *iprefs[] = { "pop", "exe", "wrt" }; - int iprefs_cnt = sizeof(iprefs) / sizeof(iprefs[0]); - - for (int i = 0; i < CORES; ++i) { - for (int j = 0; j < iprefs_cnt; ++j) { - g_info("Creating %s_%d table in SQLite database", iprefs[j], i); - salis_exec_sql( - 0, NULL, NULL, - "create table %s_%d (" -#define FOR_CORE(i) "cycl_" #i " int not null, " - FOR_CORES -#undef FOR_CORE -#define INST(index, label, mnemonic, symbol) #label " int not null, " - INST_SET -#undef INST - "step int not null" - ");", - iprefs[j], i - ); - } - } - - // Memory events - 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); - } - - g_info("Creating %s_%d table in SQLite database", pref, i); - salis_exec_sql( - 0, NULL, NULL, - "create table %s_%d (" -#define FOR_CORE(i) "cycl_" #i " int not null, " - FOR_CORES -#undef FOR_CORE - "size int not null, " - "evts blob not null ," - "step int not null" - ");", - pref, i - ); - } - } } #endif @@ -969,92 +929,20 @@ void arch_push_data_line(void) { #endif } - g_info("Pushing row to arch table in SQLite database"); - salis_exec_sql( - 0, NULL, NULL, - "insert into arch (" -#define FOR_CORE(i) \ - "cycl_" #i ", " \ - "wmb0_" #i ", " \ - "wmb1_" #i ", " \ - "wdea_" #i ", " - FOR_CORES -#undef FOR_CORE - "step" - ") values (" -#define FOR_CORE(i) "%ld, %ld, %ld, %ld, " - FOR_CORES -#undef FOR_CORE - "%ld" - ");", -#define FOR_CORE(i) \ - g_cores[i].cycl, \ - g_cores[i].wmb0, \ - g_cores[i].wmb1, \ - g_cores[i].wdea, - FOR_CORES -#undef FOR_CORE - g_steps - ); - - char *iprefs[] = { "pop", "exe", "wrt" }; - int iprefs_cnt = sizeof(iprefs) / sizeof(iprefs[0]); - - for (int i = 0; i < CORES; ++i) { - for (int j = 0; j < iprefs_cnt; ++j) { - uint64_t *ia = NULL; - char *pref = NULL; - - 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", pref, i); - salis_exec_sql( - 0, NULL, NULL, - "insert into %s_%d (" -#define FOR_CORE(i) "cycl_" #i ", " - FOR_CORES -#undef FOR_CORE -#define INST(index, label, mnemonic, symbol) #label ", " - INST_SET -#undef INST - "step" - ") values (" -#define FOR_CORE(i) "%ld, " - FOR_CORES -#undef FOR_CORE -#define INST(index, label, mnemonic, symbol) "%ld, " - INST_SET -#undef INST - "%ld" - ");", - pref, i, -#define FOR_CORE(i) g_cores[i].cycl, - FOR_CORES -#undef FOR_CORE -#define INST(index, label, mnemonic, symbol) ia[index], - INST_SET -#undef INST - g_steps - ); - } - } - - // Insert arch-specific memory events + // Compress event arrays // Compression (deflation) is CPU intensive so it is done in parallel + memset(&g_arch_eva_deflate_params, 0, sizeof(struct DeflateParams) * CORES * ARCH_EVENT_ARRAYS_COUNT); + const void *blobs[CORES][ARCH_EVENT_ARRAYS_COUNT]; + int blob_sizes[CORES][ARCH_EVENT_ARRAYS_COUNT]; + for (int i = 0; i < CORES; ++i) { for (int j = 0; j < ARCH_EVENT_ARRAYS_COUNT; ++j) { uint64_t *in = NULL; switch (j) { -#define ARCH_EVENT_ARRAY(idx, ev) \ - case idx: in = g_cores[i].ev##a; break; - ARCH_EVENT_ARRAYS +#define ARCH_EVENT_ARRAY(core, index, ev) \ + case index: in = g_cores[i].ev##a; break; + ARCH_EVENT_ARRAYS(core) #undef ARCH_EVENT_ARRAY default: assert(false); } @@ -1070,44 +958,80 @@ void arch_push_data_line(void) { 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); - } - thrd_join(g_arch_eva_thrds[i][j], NULL); - // Insert blob 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", pref, i); - salis_exec_sql( - 1, &blob, &blob_size, - "insert into %s_%d (" -#define FOR_CORE(i) "cycl_" #i ", " - FOR_CORES + blobs[i][j] = params->out; + blob_sizes[i][j] = params->strm.total_out; + } + } + + g_info("Pushing row to arch table in SQLite database"); + salis_exec_sql( + CORES * ARCH_EVENT_ARRAYS_COUNT, (const void **)blobs, (int *)blob_sizes, + "insert into arch (" +#define INST(core, pref, index, label, mnemonic, symbol) \ + #label "_" #pref "_" #core ", " +#define INST_EVENT_ARRAY(core, index, iv) \ + INST_SET(core, iv) +#define ARCH_EVENT_ARRAY(core, index, ev) \ + #ev "_size_" #core ", " \ + #ev "_" #core ", " +#define FOR_CORE(i) \ + "cycl_" #i ", " \ + "wmb0_" #i ", " \ + "wmb1_" #i ", " \ + "wdea_" #i ", " \ + INST_EVENT_ARRAYS(i) \ + ARCH_EVENT_ARRAYS(i) + FOR_CORES #undef FOR_CORE - "size, evts, step" - ") values (" -#define FOR_CORE(i) "%ld, " - FOR_CORES +#undef ARCH_EVENT_ARRAY +#undef INST_EVENT_ARRAY +#undef INST + "step" + ") values (" +#define INST(core, pref, index, label, mnemonic, symbol) \ + "%ld, " +#define INST_EVENT_ARRAY(core, index, iv) \ + INST_SET(core, iv) +#define ARCH_EVENT_ARRAY(core, index, ev) \ + "%ld, ?, " +#define FOR_CORE(i) \ + "%ld, %ld, %ld, %ld, " \ + INST_EVENT_ARRAYS(i) \ + ARCH_EVENT_ARRAYS(i) + FOR_CORES #undef FOR_CORE - "%ld, ?, %ld" - ");", - pref, i, -#define FOR_CORE(i) g_cores[i].cycl, - FOR_CORES +#undef ARCH_EVENT_ARRAY +#undef INST_EVENT_ARRAY +#undef INST + "%ld" + ");", +#define INST(core, pref, index, label, mnemonic, symbol) \ + g_cores[core].i##pref, +#define INST_EVENT_ARRAY(core, index, iv) \ + INST_SET(core, iv) +#define ARCH_EVENT_ARRAY(core, index, ev) \ + blob_sizes[core][index], +#define FOR_CORE(i) \ + g_cores[i].cycl, \ + g_cores[i].wmb0, \ + g_cores[i].wmb1, \ + g_cores[i].wdea, \ + INST_EVENT_ARRAYS(i) \ + ARCH_EVENT_ARRAYS(i) + FOR_CORES #undef FOR_CORE - blob_size, g_steps - ); +#undef ARCH_EVENT_ARRAY +#undef INST_EVENT_ARRAY +#undef INST + g_steps + ); + for (int i = 0; i < CORES; ++i) { + for (int j = 0; j < ARCH_EVENT_ARRAYS_COUNT; ++j) { + struct DeflateParams *params = &g_arch_eva_deflate_params[i][j]; salis_deflate_end(params); free(params->out); } @@ -1125,9 +1049,9 @@ void arch_push_data_line(void) { core->wmb1 = 0; core->wdea = 0; -#define ARCH_EVENT_ARRAY(_, ev) \ +#define ARCH_EVENT_ARRAY(core, index, ev) \ memset(core->ev##a, 0, EVA_SIZE); - ARCH_EVENT_ARRAYS + ARCH_EVENT_ARRAYS(core) #undef ARCH_EVENT_ARRAY } } diff --git a/core/salis.c b/core/salis.c index 135fa4a..ed96944 100644 --- a/core/salis.c +++ b/core/salis.c @@ -27,10 +27,10 @@ #if defined(DATA_PUSH) #define DATA_PUSH_BUSY_TIMEOUT 600000 -#define EVENT_ARRAYS \ - EVENT_ARRAY(0, aev) /* allocation events array */ \ - EVENT_ARRAY(1, eev) /* executions events array */ \ - EVENT_ARRAY(2, bev) /* birth events array */ +#define EVENT_ARRAYS(core) \ + EVENT_ARRAY(core, 0, aev) /* allocation events array */ \ + EVENT_ARRAY(core, 1, eev) /* executions events array */ \ + EVENT_ARRAY(core, 2, bev) /* birth events array */ #define EVENT_ARRAYS_COUNT 3 #endif @@ -65,8 +65,8 @@ struct Core { uint64_t eliv; // executions within not-owned live code counter (parasites) uint64_t edea; // executions within dead code counter -#define EVENT_ARRAY(_, ev) uint64_t ev##a[MVEC_SIZE]; - EVENT_ARRAYS +#define EVENT_ARRAY(core, index, ev) uint64_t ev##a[MVEC_SIZE]; + EVENT_ARRAYS(core) #undef EVENT_ARRAY #define CORE_DATA_FIELD(type, name) type name; @@ -459,9 +459,9 @@ void core_save(FILE *f, const struct Core *core) { fwrite(core->pvec, sizeof(struct Proc), core->pcap, f); fwrite(core->mvec, sizeof(uint8_t), MVEC_SIZE, f); #if defined(DATA_PUSH) -#define EVENT_ARRAY(_, ev) \ +#define EVENT_ARRAY(core, index, ev) \ fwrite(core->ev##a, sizeof(uint64_t), MVEC_SIZE, f); - EVENT_ARRAYS + EVENT_ARRAYS(core) #undef EVENT_ARRAY #endif @@ -557,9 +557,9 @@ void core_load(FILE *f, struct Core *core) { fread(core->pvec, sizeof(struct Proc), core->pcap, f); fread(core->mvec, sizeof(uint8_t), MVEC_SIZE, f); #if defined(DATA_PUSH) -#define EVENT_ARRAY(_, ev) \ +#define EVENT_ARRAY(core, index, ev) \ fread(core->ev##a, sizeof(uint64_t), MVEC_SIZE, f); - EVENT_ARRAYS + EVENT_ARRAYS(core) #undef EVENT_ARRAY #endif @@ -744,6 +744,10 @@ void salis_exec_sql(int blob_cnt, const void **blobs, const int *blob_sizes, con vsprintf(sql_str, sql_format, args); va_end(args); + FILE *temp = fopen("/tmp/salis.temp", "a"); + fprintf(temp, "EXECUTING SQL: %s\n", sql_str); + fclose(temp); + int sql_res; sqlite3_stmt *sql_stmt; @@ -784,10 +788,13 @@ void salis_exec_sql(int blob_cnt, const void **blobs, const int *blob_sizes, con void salis_push_data_header(void) { assert(g_sim_data); - g_info("Creating general table in SQLite database"); + g_info("Creating core table in SQLite database"); salis_exec_sql( 0, NULL, NULL, - "create table general (" + "create table core (" +#define EVENT_ARRAY(core, index, ev) \ + #ev "_size_" #core " int not null, " \ + #ev "_" #core " blob not null, " #define FOR_CORE(i) \ "cycl_" #i " int not null, " \ "mall_" #i " int not null, " \ @@ -799,42 +806,15 @@ void salis_push_data_header(void) { "emb0_" #i " int not null, " \ "emb1_" #i " int not null, " \ "eliv_" #i " int not null, " \ - "edea_" #i " int not null, " + "edea_" #i " int not null, " \ + EVENT_ARRAYS(i) FOR_CORES #undef FOR_CORE +#undef EVENT_ARRAY "step int not null" ");" ); - // Memory events - for (int i = 0; i < CORES; ++i) { - for (int j = 0; j < EVENT_ARRAYS_COUNT; ++j) { - char *pref = NULL; - - switch (j) { -#define EVENT_ARRAY(idx, ev) \ - case idx: pref = #ev; break; - EVENT_ARRAYS -#undef 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 (" -#define FOR_CORE(i) "cycl_" #i " int not null, " - FOR_CORES -#undef FOR_CORE - "size int not null, " - "evts blob not null ," - "step int not null" - ");", - pref, i - ); - } - } - arch_push_data_header(); } #endif @@ -858,10 +838,50 @@ void salis_push_data_line(void) { amb1[i] /= core->pnum; } - g_info("Pushing row to general table in SQLite database"); + // Compress event arrays + // Compression (deflation) is CPU intensive so it's done in parallel + memset(&g_eva_deflate_params, 0, sizeof(struct DeflateParams) * CORES * EVENT_ARRAYS_COUNT); + const void *blobs[CORES][EVENT_ARRAYS_COUNT]; + int blob_sizes[CORES][EVENT_ARRAYS_COUNT]; + + for (int i = 0; i < CORES; ++i) { + for (int j = 0; j < EVENT_ARRAYS_COUNT; ++j) { + uint64_t *in = NULL; + + switch (j) { +#define EVENT_ARRAY(core, idx, ev) \ + case idx: in = g_cores[i].ev##a; break; + EVENT_ARRAYS(core) +#undef EVENT_ARRAY + default: assert(false); + } + + // Compress event data + struct DeflateParams *params = &g_eva_deflate_params[i][j]; + params->size = EVA_SIZE, + params->in = (Bytef *)in, + params->out = (Bytef *)malloc(EVA_SIZE), + thrd_create(&g_eva_thrds[i][j], (thrd_start_t)salis_deflate, params); + } + } + + for (int i = 0; i < CORES; ++i) { + for (int j = 0; j < EVENT_ARRAYS_COUNT; ++j) { + thrd_join(g_eva_thrds[i][j], NULL); + + struct DeflateParams *params = &g_eva_deflate_params[i][j]; + blobs[i][j] = params->out; + blob_sizes[i][j] = params->strm.total_out; + } + } + + g_info("Pushing row to core table in SQLite database"); salis_exec_sql( - 0, NULL, NULL, - "insert into general (" + CORES * EVENT_ARRAYS_COUNT, (const void **)blobs, (int *)blob_sizes, + "insert into core (" +#define EVENT_ARRAY(core, index, ev) \ + #ev "_size_" #core ", " \ + #ev "_" #core ", " #define FOR_CORE(i) \ "cycl_" #i ", " \ "mall_" #i ", " \ @@ -873,16 +893,25 @@ void salis_push_data_line(void) { "emb0_" #i ", " \ "emb1_" #i ", " \ "eliv_" #i ", " \ - "edea_" #i ", " + "edea_" #i ", " \ + EVENT_ARRAYS(i) FOR_CORES #undef FOR_CORE +#undef EVENT_ARRAY "step" ") values (" -#define FOR_CORE(i) "%ld, %ld, %ld, %ld, %ld, %f, %f, %ld, %ld, %ld, %ld, " +#define EVENT_ARRAY(core, index, ev) \ + "%ld, ?," +#define FOR_CORE(i) \ + "%ld, %ld, %ld, %ld, %ld, %f, %f, %ld, %ld, %ld, %ld, " \ + EVENT_ARRAYS(i) FOR_CORES #undef FOR_CORE +#undef EVENT_ARRAY "%ld" ");", +#define EVENT_ARRAY(core, index, ev) \ + blob_sizes[core][index], #define FOR_CORE(i) \ g_cores[i].cycl, \ g_cores[i].mall, \ @@ -894,77 +923,17 @@ void salis_push_data_line(void) { g_cores[i].emb0, \ g_cores[i].emb1, \ g_cores[i].eliv, \ - g_cores[i].edea, + g_cores[i].edea, \ + EVENT_ARRAYS(i) FOR_CORES #undef FOR_CORE +#undef EVENT_ARRAY g_steps ); - // Insert generic memory events - // Compression (deflation) is CPU intensive so it is done in parallel - memset(&g_eva_deflate_params, 0, sizeof(struct DeflateParams) * CORES * EVENT_ARRAYS_COUNT); - - for (int i = 0; i < CORES; ++i) { - for (int j = 0; j < EVENT_ARRAYS_COUNT; ++j) { - uint64_t *in = NULL; - - switch (j) { -#define EVENT_ARRAY(idx, ev) \ - case idx: in = g_cores[i].ev##a; break; - EVENT_ARRAYS -#undef EVENT_ARRAY - default: assert(false); - } - - // Compress event data - struct DeflateParams *params = &g_eva_deflate_params[i][j]; - params->size = EVA_SIZE, - params->in = (Bytef *)in, - params->out = (Bytef *)malloc(EVA_SIZE), - thrd_create(&g_eva_thrds[i][j], (thrd_start_t)salis_deflate, params); - } - } - for (int i = 0; i < CORES; ++i) { for (int j = 0; j < EVENT_ARRAYS_COUNT; ++j) { - char *pref = NULL; - - switch (j) { -#define EVENT_ARRAY(idx, ev) \ - case idx: pref = #ev; break; - EVENT_ARRAYS -#undef EVENT_ARRAY - default: assert(false); - } - - thrd_join(g_eva_thrds[i][j], NULL); - - // Insert blob struct DeflateParams *params = &g_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", pref, i); - salis_exec_sql( - 1, &blob, &blob_size, - "insert into %s_%d (" -#define FOR_CORE(i) "cycl_" #i ", " - FOR_CORES -#undef FOR_CORE - "size, evts, step" - ") values (" -#define FOR_CORE(i) "%ld, " - FOR_CORES -#undef FOR_CORE - "%ld, ?, %ld" - ");", - pref, i, -#define FOR_CORE(i) g_cores[i].cycl, - FOR_CORES -#undef FOR_CORE - blob_size, g_steps - ); - salis_deflate_end(params); free(params->out); } @@ -979,9 +948,9 @@ void salis_push_data_line(void) { core->eliv = 0; core->edea = 0; -#define EVENT_ARRAY(_, ev) \ +#define EVENT_ARRAY(core, index, ev) \ memset(core->ev##a, 0, EVA_SIZE); - EVENT_ARRAYS + EVENT_ARRAYS(core) #undef EVENT_ARRAY } diff --git a/salis.py b/salis.py index 7569430..3e286e2 100755 --- a/salis.py +++ b/salis.py @@ -65,7 +65,7 @@ options = { (("f", "force"), (new,), fmt_id): {"action": "store_true", "help": "overwrite existing simulation of given name", "required": False}, (("F", "muta-flip"), (new,), fmt_id): {"action": "store_true", "help": "cosmic rays flip bits instead of randomizing whole bytes", "required": False}, (("g", "c-compiler"), (new, load, server, client), fmt_id): {"metavar": "CC", "help": "C compiler to use", "default": "gcc", "required": False, "type": str}, - (("G", "c-compiler-flags"), (new, load, server, client), fmt_id): {"metavar": "FLAGS", "help": "base set of flags to pass to C compiler", "default": "-Wall -Wextra -Werror -pedantic", "required": False, "type": str}, + (("G", "c-compiler-flags"), (new, load, server, client), fmt_id): {"metavar": "FLAGS", "help": "base set of flags to pass to C compiler", "default": "-Wall -Wextra -Werror -Wno-overlength-strings -pedantic", "required": False, "type": str}, (("g++", "cpp-compiler"), (client,), fmt_id): {"metavar": "CXX", "help": "C++ compiler to use", "default": "g++", "required": False, "type": str}, (("G++", "cpp-compiler-flags"), (client,), fmt_id): {"metavar": "FLAGS", "help": "base set of flags to pass to C++ compiler", "default": "-Wall -Wextra -Werror -pedantic", "required": False, "type": str}, (("H", "home"), (new, load, server), fmt_id): {"metavar": "PATH", "help": "salis home directory", "default": os.path.join(os.environ["HOME"], ".salis"), "required": False, "type": str}, @@ -393,7 +393,7 @@ def pop_general(): ns.b.defines.add(f"-DCORES={args.cores}") ns.b.defines.add(f"-DFOR_CORES={" ".join(f"FOR_CORE({i})" for i in range(args.cores))}") ns.b.defines.add(f"-DINST_COUNT={len(arch_vars["inst_set"])}") - ns.b.defines.add(f"-DINST_SET={" ".join(f"INST({index}, {"_".join(inst[0])}, \"{" ".join(inst[0])}\", L'{inst[1]}')" for index, inst in enumerate(arch_vars["inst_set"]))}") + ns.b.defines.add(f"-DINST_SET(core, pref)={" ".join(f"INST(core, pref, {index}, {"_".join(inst[0])}, \"{" ".join(inst[0])}\", L'{inst[1]}')" for index, inst in enumerate(arch_vars["inst_set"]))}") ns.b.defines.add(f"-DMUTA_RANGE={2 ** args.muta_pow}ul") ns.b.defines.add(f"-DMVEC_SIZE={2 ** args.mvec_pow}ul") ns.b.defines.add(f"-DNAME=\"{args.name}\"") -- cgit v1.3