diff options
Diffstat (limited to 'core.c')
| -rw-r--r-- | core.c | 94 |
1 files changed, 33 insertions, 61 deletions
@@ -14,6 +14,10 @@ #define MALL_FLAG 0x80 #define UINT64_HALF 0x8000000000000000ul +#if defined(COMPRESS) || defined(DATA_PUSH_PATH) +#include "data/compress.c" +#endif + struct Proc { #define PROC_FIELD(type, name) type name; PROC_FIELDS @@ -46,7 +50,7 @@ struct Core { uint64_t edea; // executions within dead code counter uint64_t aeva[MVEC_SIZE]; // allocation events array - //uint64_t eeva[MVEC_SIZE]; // execution events array + uint64_t eeva[MVEC_SIZE]; // execution events array #define CORE_DATA_FIELD(type, name, suff) type name suff; CORE_DATA_FIELDS @@ -418,7 +422,7 @@ void core_save(FILE *f, const struct Core *core) { fwrite(core->mvec, sizeof(uint8_t), MVEC_SIZE, f); #if defined(DATA_PUSH_PATH) fwrite(core->aeva, sizeof(uint64_t), MVEC_SIZE, f); - //fwrite(core->eeva, sizeof(uint64_t), MVEC_SIZE, f); + fwrite(core->eeva, sizeof(uint64_t), MVEC_SIZE, f); #endif arch_core_save(f, core); @@ -514,7 +518,7 @@ void core_load(FILE *f, struct Core *core) { fread(core->mvec, sizeof(uint8_t), MVEC_SIZE, f); #if defined(DATA_PUSH_PATH) fread(core->aeva, sizeof(uint64_t), MVEC_SIZE, f); - //fread(core->eeva, sizeof(uint64_t), MVEC_SIZE, f); + fread(core->eeva, sizeof(uint64_t), MVEC_SIZE, f); #endif arch_core_load(f, core); @@ -564,17 +568,25 @@ void core_step(struct Core *core) { // Save execution event locations in database assert(mvec_proc_is_live(core, core->pcur)); - struct Proc *proc = proc_fetch(core, core->pcur); + uint64_t pcur_ip = arch_proc_ip_addr(core, core->pcur); - if (mvec_is_in_mb0_of_proc(core, proc->ip, core->pcur)) { + if (mvec_is_in_mb0_of_proc(core, pcur_ip, core->pcur)) { ++core->emb0; - } else if (mvec_is_in_mb1_of_proc(core, proc->ip, core->pcur)) { + } else if (mvec_is_in_mb1_of_proc(core, pcur_ip, core->pcur)) { ++core->emb1; - } else if (mvec_is_alloc(core, proc->ip)) { + } else if (mvec_is_alloc(core, pcur_ip)) { ++core->eliv; } else { ++core->edea; } + +#if defined(MVEC_LOOP) + core->eeva[mvec_loop(pcur_ip)]++; +#else + if (pcur_ip < MVEC_SIZE) { + core->eeva[pcur_ip]++; + } +#endif #endif arch_proc_step(core, core->pcur); @@ -634,18 +646,7 @@ void salis_save(const char *path) { assert(out); z_stream strm = { 0 }; - strm.zalloc = NULL; - strm.zfree = NULL; - strm.opaque = NULL; - - deflateInit(&strm, Z_DEFAULT_COMPRESSION); - - strm.avail_in = size; - strm.avail_out = size; - strm.next_in = (Bytef *)in; - strm.next_out = (Bytef *)out; - - deflate(&strm, Z_FINISH); + salis_deflate(&strm, size, (Bytef *)in, (Bytef *)out); FILE *fx = fopen(path, "wb"); assert(fx); @@ -654,7 +655,7 @@ void salis_save(const char *path) { fwrite(out, sizeof(char), strm.total_out, fx); fclose(fx); - deflateEnd(&strm); + salis_deflate_end(&strm); free(in); free(out); @@ -762,7 +763,7 @@ void salis_push_data_header() { ); // Memory events - char *eprefs[] = { "aev" /*, "eev" */ }; + char *eprefs[] = { "aev", "eev" }; int eprefs_cnt = sizeof(eprefs) / sizeof(eprefs[0]); for (int i = 0; i < CORES; ++i) { @@ -798,10 +799,8 @@ void salis_push_data_line() { struct Core *core = &g_cores[i]; for (uint64_t j = core->pfst; j <= core->plst; ++j) { - const struct Proc *proc = proc_get(core, j); - - amb0[i] += (double)proc->mb0s; - amb1[i] += (double)proc->mb1s; + amb0[i] += (double)arch_proc_mb0_size(core, j); + amb1[i] += (double)arch_proc_mb1_size(core, j); } amb0[i] /= core->pnum; @@ -851,7 +850,7 @@ void salis_push_data_line() { ); // TODO: insert execute memory events - char *eprefs[] = { "aev" /*, "eev" */ }; + char *eprefs[] = { "aev", "eev" }; int eprefs_cnt = sizeof(eprefs) / sizeof(eprefs[0]); for (int i = 0; i < CORES; ++i) { @@ -860,9 +859,9 @@ void salis_push_data_line() { if (!strcmp("aev", eprefs[j])) { in = g_cores[i].aeva; - } // else if (!strcmp("eev", eprefs[j])) { - // in = g_cores[i].eeva; - // } + } else if (!strcmp("eev", eprefs[j])) { + in = g_cores[i].eeva; + } // Compress event data size_t size = sizeof(uint64_t) * MVEC_SIZE; @@ -870,18 +869,7 @@ void salis_push_data_line() { assert(out); z_stream strm = { 0 }; - strm.zalloc = NULL; - strm.zfree = NULL; - strm.opaque = NULL; - - deflateInit(&strm, Z_DEFAULT_COMPRESSION); - - strm.avail_in = size; - strm.avail_out = size; - strm.next_in = (Bytef *)in; - strm.next_out = (Bytef *)out; - - deflate(&strm, Z_FINISH); + salis_deflate(&strm, size, (Bytef *)in, (Bytef *)out); // Insert blob const void *blob = out; @@ -908,7 +896,7 @@ void salis_push_data_line() { blob_size, g_steps ); - deflateEnd(&strm); + salis_deflate_end(&strm); free(out); } } @@ -923,7 +911,7 @@ void salis_push_data_line() { core->edea = 0; memset(core->aeva, 0, sizeof(uint64_t) * MVEC_SIZE); - //memset(core->eeva, 0, sizeof(uint64_t) * MVEC_SIZE); + memset(core->eeva, 0, sizeof(uint64_t) * MVEC_SIZE); } // Push arch-specific data @@ -988,24 +976,8 @@ void salis_load() { assert(out); z_stream strm = { 0 }; - strm.next_in = (Bytef *)in; - strm.avail_in = x_size; - strm.zalloc = NULL; - strm.zfree = NULL; - strm.opaque = NULL; - - inflateInit(&strm); - - strm.avail_out = size; - strm.next_out = (Bytef *)out; - -#if defined(NDEBUG) - inflate(&strm, Z_FINISH); -#else - assert(inflate(&strm, Z_FINISH)); -#endif - - inflateEnd(&strm); + salis_inflate(&strm, x_size, size, (Bytef *)in, (Bytef *)out); + salis_inflate_end(&strm); FILE *f = fmemopen(out, size, "rb"); #else |
