From b54b9ceb2952ba84b58e75aba014558b17d08e77 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 2 Jul 2026 23:51:22 +0200 Subject: Evas are now saved to files --- arch/v1/arch.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'arch/v1/arch.c') diff --git a/arch/v1/arch.c b/arch/v1/arch.c index cb52bf7..1501b42 100644 --- a/arch/v1/arch.c +++ b/arch/v1/arch.c @@ -874,15 +874,15 @@ void arch_push_data_header(void) { log_info("Creating arch table in SQLite database"); sql_exec( - 0, NULL, NULL, NULL, NULL, + 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, " + #ev EVENT_ARRAYS_SIZE_COL_MARKER #core " int not null, " \ + #ev "_" #core " blob, " #define FOR_CORE(i) \ "wmb0_" #i " int not null, " \ "wmb1_" #i " int not null, " \ @@ -900,8 +900,9 @@ void arch_push_data_header(void) { } #endif -void arch_push_data_line(void) { +void arch_push_data_line(FILE *eva_file) { assert(g_sim_db); + assert(eva_file); // Measure instruction population for (int i = 0; i < CORES; ++i) { @@ -925,8 +926,7 @@ void arch_push_data_line(void) { // 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]; + uint64_t blob_sizes[CORES][ARCH_EVENT_ARRAYS_COUNT]; for (int i = 0; i < CORES; ++i) { for (int j = 0; j < ARCH_EVENT_ARRAYS_COUNT; ++j) { @@ -942,9 +942,9 @@ void arch_push_data_line(void) { // Compress event data struct DeflateParams *params = &g_arch_eva_deflate_params[i][j]; - params->size = EVA_SIZE; + params->size = EVENT_ARRAYS_SIZE; params->in = (Bytef *)in; - params->out = (Bytef *)malloc(EVA_SIZE); + params->out = (Bytef *)malloc(EVENT_ARRAYS_SIZE); thrd_create(&g_arch_eva_thrds[i][j], (thrd_start_t)comp_deflate, params); } } @@ -952,24 +952,24 @@ void arch_push_data_line(void) { for (int i = 0; i < CORES; ++i) { for (int j = 0; j < ARCH_EVENT_ARRAYS_COUNT; ++j) { thrd_join(g_arch_eva_thrds[i][j], NULL); - struct DeflateParams *params = &g_arch_eva_deflate_params[i][j]; - blobs[i][j] = params->out; blob_sizes[i][j] = params->strm.total_out; + fwrite(params->out, sizeof(char), blob_sizes[i][j], eva_file); + comp_deflate_end(params); + free(params->out); } } log_info("Pushing row to arch table in SQLite database"); sql_exec( - CORES * ARCH_EVENT_ARRAYS_COUNT, (const void **)blobs, (int *)blob_sizes, NULL, NULL, + NULL, NULL, "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 ", " + #ev EVENT_ARRAYS_SIZE_COL_MARKER #core ", " #define FOR_CORE(i) \ "wmb0_" #i ", " \ "wmb1_" #i ", " \ @@ -988,9 +988,11 @@ void arch_push_data_line(void) { #define INST_EVENT_ARRAY(core, index, iv) \ INST_SET(core, iv) #define ARCH_EVENT_ARRAY(core, index, ev) \ - "%ld, ?, " + "%ld, " #define FOR_CORE(i) \ - "%ld, %ld, %ld, " \ + "%ld, " \ + "%ld, " \ + "%ld, " \ INST_EVENT_ARRAYS(i) \ ARCH_EVENT_ARRAYS(i) FOR_CORES @@ -1020,14 +1022,6 @@ void arch_push_data_line(void) { 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]; - comp_deflate_end(params); - free(params->out); - } - } - // Reset arch-specific data aggregation fields for (int i = 0; i < CORES; ++i) { struct Core *core = &g_cores[i]; @@ -1041,7 +1035,7 @@ void arch_push_data_line(void) { core->wdea = 0; #define ARCH_EVENT_ARRAY(core, index, ev) \ - memset(core->ev##a, 0, EVA_SIZE); + memset(core->ev##a, 0, EVENT_ARRAYS_SIZE); ARCH_EVENT_ARRAYS(core) #undef ARCH_EVENT_ARRAY } -- cgit v1.2.1