From 4e971bceff2c65d5c6a3152b4d53cf04aee89989 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Tue, 3 Aug 2021 18:42:56 +0200 Subject: [PATCH] Write multiple prv files and add app id view --- cfg/cpu.cfg | 236 +++++++++++++++++++++++++++++++++++++++++++++++++ cfg/thread.cfg | 81 +++++++++++++++++ emu.c | 34 +++++++ emu.h | 4 + emu_nosv.c | 2 + emu_ovni.c | 18 ++-- ovni.c | 16 +++- ovni2prv.c | 2 + prv.c | 23 +++-- prv.h | 13 ++- 10 files changed, 412 insertions(+), 17 deletions(-) create mode 100644 cfg/cpu.cfg create mode 100644 cfg/thread.cfg diff --git a/cfg/cpu.cfg b/cfg/cpu.cfg new file mode 100644 index 0000000..8620160 --- /dev/null +++ b/cfg/cpu.cfg @@ -0,0 +1,236 @@ +#ParaverCFG +ConfigFile.Version: 3.4 +ConfigFile.NumWindows: 6 + + +################################################################################ +< NEW DISPLAYING WINDOW CPU: PID > +################################################################################ +window_name CPU: PID +window_type single +window_id 1 +window_position_x 0 +window_position_y 376 +window_width 954 +window_height 148 +window_comm_lines_enabled true +window_flags_enabled true +window_noncolor_mode true +window_logical_filtered true +window_physical_filtered false +window_comm_fromto true +window_comm_tagsize true +window_comm_typeval true +window_units Microseconds +window_maximum_y 426131.000000000000 +window_minimum_y 1.000000000000 +window_compute_y_max false +window_level thread +window_scale_relative 1.000000000000 +window_end_time_relative 1.000000000000 +window_object appl { 1, { All } } +window_begin_time_relative 0.000000000000 +window_open true +window_drawmode draw_maximum +window_drawmode_rows draw_maximum +window_pixel_size 1 +window_labels_to_draw 1 +window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } +window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } +window_filter_module evt_type 1 10 +window_filter_module evt_type_label 1 "Unknown" +window_synchronize 1 + +################################################################################ +< NEW DISPLAYING WINDOW CPU: Task ID > +################################################################################ +window_name CPU: Task ID +window_type single +window_id 2 +window_position_x 0 +window_position_y 200 +window_width 954 +window_height 149 +window_comm_lines_enabled true +window_flags_enabled true +window_noncolor_mode true +window_logical_filtered true +window_physical_filtered false +window_comm_fromto true +window_comm_tagsize true +window_comm_typeval true +window_units Microseconds +window_maximum_y 21.000000000000 +window_minimum_y 1.000000000000 +window_compute_y_max false +window_level thread +window_scale_relative 1.000000000000 +window_end_time_relative 1.000000000000 +window_object appl { 1, { All } } +window_begin_time_relative 0.000000000000 +window_open true +window_drawmode draw_maximum +window_drawmode_rows draw_maximum +window_pixel_size 1 +window_labels_to_draw 1 +window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } +window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } +window_filter_module evt_type 1 20 +window_filter_module evt_type_label 1 "Unknown" +window_synchronize 1 + +################################################################################ +< NEW DISPLAYING WINDOW CPU: Task Type ID > +################################################################################ +window_name CPU: Task Type ID +window_type single +window_id 3 +window_position_x 0 +window_position_y 901 +window_width 954 +window_height 148 +window_comm_lines_enabled true +window_flags_enabled true +window_noncolor_mode true +window_color_mode window_in_null_gradient_mode +window_logical_filtered true +window_physical_filtered false +window_comm_fromto true +window_comm_tagsize true +window_comm_typeval true +window_units Microseconds +window_maximum_y 2.000000000000 +window_minimum_y 1.000000000000 +window_compute_y_max false +window_level thread +window_scale_relative 1.000000000000 +window_end_time_relative 1.000000000000 +window_object appl { 1, { All } } +window_begin_time_relative 0.000000000000 +window_open true +window_drawmode draw_maximum +window_drawmode_rows draw_maximum +window_pixel_size 1 +window_labels_to_draw 1 +window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } +window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } +window_filter_module evt_type 1 21 +window_filter_module evt_type_label 1 "Unknown" +window_synchronize 1 + +################################################################################ +< NEW DISPLAYING WINDOW CPU: Number of threads running per CPU > +################################################################################ +window_name CPU: Number of threads running per CPU +window_type single +window_id 4 +window_position_x 0 +window_position_y 726 +window_width 954 +window_height 148 +window_comm_lines_enabled true +window_flags_enabled true +window_noncolor_mode true +window_color_mode window_in_null_gradient_mode +window_logical_filtered true +window_physical_filtered false +window_comm_fromto true +window_comm_tagsize true +window_comm_typeval true +window_units Microseconds +window_maximum_y 5.000000000000 +window_minimum_y 1.000000000000 +window_compute_y_max false +window_level thread +window_scale_relative 1.000000000000 +window_end_time_relative 1.000000000000 +window_object appl { 1, { All } } +window_begin_time_relative 0.000000000000 +window_open true +window_drawmode draw_maximum +window_drawmode_rows draw_maximum +window_pixel_size 1 +window_labels_to_draw 1 +window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } +window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } +window_filter_module evt_type 1 12 +window_filter_module evt_type_label 1 "Unknown" +window_synchronize 1 + +################################################################################ +< NEW DISPLAYING WINDOW CPU: Thread TID > +################################################################################ +window_name CPU: Thread TID +window_type single +window_id 5 +window_position_x 0 +window_position_y 551 +window_width 954 +window_height 148 +window_comm_lines_enabled true +window_flags_enabled true +window_noncolor_mode true +window_logical_filtered true +window_physical_filtered false +window_comm_fromto true +window_comm_tagsize true +window_comm_typeval true +window_units Microseconds +window_maximum_y 426239.000000000000 +window_minimum_y 1.000000000000 +window_compute_y_max false +window_level thread +window_scale_relative 1.000000000000 +window_end_time_relative 1.000000000000 +window_object appl { 1, { All } } +window_begin_time_relative 0.000000000000 +window_open true +window_drawmode draw_maximum +window_drawmode_rows draw_maximum +window_pixel_size 1 +window_labels_to_draw 1 +window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } +window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } +window_filter_module evt_type 1 11 +window_filter_module evt_type_label 1 "Unknown" +window_synchronize 1 + +################################################################################ +< NEW DISPLAYING WINDOW CPU: Application ID > +################################################################################ +window_name CPU: Application ID +window_type single +window_id 6 +window_position_x 0 +window_position_y 24 +window_width 954 +window_height 149 +window_comm_lines_enabled true +window_flags_enabled true +window_noncolor_mode true +window_color_mode window_in_null_gradient_mode +window_logical_filtered true +window_physical_filtered false +window_comm_fromto true +window_comm_tagsize true +window_comm_typeval true +window_units Microseconds +window_maximum_y 20.000000000000 +window_minimum_y 1.000000000000 +window_compute_y_max false +window_level thread +window_scale_relative 1.000000000000 +window_end_time_relative 1.000000000000 +window_object appl { 1, { All } } +window_begin_time_relative 0.000000000000 +window_open true +window_drawmode draw_maximum +window_drawmode_rows draw_maximum +window_pixel_size 1 +window_labels_to_draw 1 +window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } +window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } +window_filter_module evt_type 1 30 +window_filter_module evt_type_label 1 "Unknown" +window_synchronize 1 + diff --git a/cfg/thread.cfg b/cfg/thread.cfg new file mode 100644 index 0000000..1b408b0 --- /dev/null +++ b/cfg/thread.cfg @@ -0,0 +1,81 @@ +#ParaverCFG +ConfigFile.Version: 3.4 +ConfigFile.NumWindows: 2 + + +################################################################################ +< NEW DISPLAYING WINDOW Thread: State > +################################################################################ +window_name Thread: State +window_type single +window_id 1 +window_position_x 960 +window_position_y 24 +window_width 954 +window_height 499 +window_comm_lines_enabled true +window_flags_enabled true +window_noncolor_mode true +window_logical_filtered true +window_physical_filtered false +window_comm_fromto true +window_comm_tagsize true +window_comm_typeval true +window_units Microseconds +window_maximum_y 5.000000000000 +window_minimum_y 1.000000000000 +window_compute_y_max false +window_level thread +window_scale_relative 1.000000000000 +window_end_time_relative 1.000000000000 +window_object appl { 1, { All } } +window_begin_time_relative 0.000000000000 +window_open true +window_drawmode draw_maximum +window_drawmode_rows draw_maximum +window_pixel_size 1 +window_labels_to_draw 1 +window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } +window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } +window_filter_module evt_type 1 60 +window_filter_module evt_type_label 1 "Unknown" +window_synchronize 1 + +################################################################################ +< NEW DISPLAYING WINDOW Thread: TID > +################################################################################ +window_name Thread: TID +window_type single +window_id 2 +window_position_x 960 +window_position_y 550 +window_width 954 +window_height 499 +window_comm_lines_enabled true +window_flags_enabled true +window_noncolor_mode true +window_logical_filtered true +window_physical_filtered false +window_comm_fromto true +window_comm_tagsize true +window_comm_typeval true +window_units Microseconds +window_maximum_y 426239.000000000000 +window_minimum_y 426112.000000000000 +window_compute_y_max false +window_level thread +window_scale_relative 1.000000000000 +window_end_time_relative 1.000000000000 +window_object appl { 1, { All } } +window_begin_time_relative 0.000000000000 +window_open true +window_drawmode draw_maximum +window_drawmode_rows draw_maximum +window_pixel_size 1 +window_labels_to_draw 1 +window_selected_functions { 14, { {cpu, Active Thd}, {appl, Adding}, {task, Adding}, {thread, Last Evt Val}, {node, Adding}, {system, Adding}, {workload, Adding}, {from_obj, All}, {to_obj, All}, {tag_msg, All}, {size_msg, All}, {bw_msg, All}, {evt_type, =}, {evt_value, All} } } +window_compose_functions { 9, { {compose_cpu, As Is}, {compose_appl, As Is}, {compose_task, As Is}, {compose_thread, As Is}, {compose_node, As Is}, {compose_system, As Is}, {compose_workload, As Is}, {topcompose1, As Is}, {topcompose2, As Is} } } +window_filter_module evt_type 1 61 +window_filter_module evt_type_label 1 "Unknown" +window_synchronize 1 + diff --git a/emu.c b/emu.c index 9cbc407..8d25efc 100644 --- a/emu.c +++ b/emu.c @@ -12,6 +12,7 @@ #include "ovni.h" #include "ovni_trace.h" #include "emu.h" +#include "prv.h" static void emit_ev(struct ovni_stream *stream, struct ovni_ev *ev) @@ -345,6 +346,36 @@ destroy_metadata(struct ovni_emu *emu) return 0; } +static void +open_prvs(struct ovni_emu *emu, char *tracedir) +{ + char path[PATH_MAX]; + + sprintf(path, "%s/%s", tracedir, "thread.prv"); + + emu->prv_thread = fopen(path, "w"); + + if(emu->prv_thread == NULL) + abort(); + + sprintf(path, "%s/%s", tracedir, "cpu.prv"); + + emu->prv_cpu = fopen(path, "w"); + + if(emu->prv_cpu == NULL) + abort(); + + prv_header(emu->prv_thread, emu->trace.nstreams); + prv_header(emu->prv_cpu, emu->total_cpus + 1); +} + +static void +close_prvs(struct ovni_emu *emu) +{ + fclose(emu->prv_thread); + fclose(emu->prv_cpu); +} + int main(int argc, char *argv[]) @@ -371,11 +402,14 @@ main(int argc, char *argv[]) if(load_metadata(&emu) != 0) abort(); + open_prvs(&emu, tracedir); printf("#Paraver (19/01/38 at 03:14):00000000000000000000_ns:0:1:1(%d:1)\n", emu.total_cpus); emulate(&emu); + close_prvs(&emu); + destroy_metadata(&emu); ovni_free_streams(&emu.trace); diff --git a/emu.h b/emu.h index 0cff8a3..38e8acf 100644 --- a/emu.h +++ b/emu.h @@ -84,6 +84,7 @@ struct ovni_eproc { int pid; int index; int gindex; + int appid; /* Path of the process tracedir */ char dir[PATH_MAX]; @@ -189,6 +190,9 @@ struct ovni_emu { uint64_t lastclock; int64_t delta_time; + FILE *prv_thread; + FILE *prv_cpu; + /* Total counters */ int total_thread; int total_proc; diff --git a/emu_nosv.c b/emu_nosv.c index 63a39ab..8bb6815 100644 --- a/emu_nosv.c +++ b/emu_nosv.c @@ -240,6 +240,7 @@ emit_task_running(struct ovni_emu *emu, struct nosv_task *task) { prv_ev_autocpu(emu, PTC_TASK_ID, task->id + 1); prv_ev_autocpu(emu, PTC_TASK_TYPE_ID, task->type_id + 1); + prv_ev_autocpu(emu, PTC_APP_ID, emu->cur_proc->appid + 1); } static void @@ -247,6 +248,7 @@ emit_task_not_running(struct ovni_emu *emu, struct nosv_task *task) { prv_ev_autocpu(emu, PTC_TASK_ID, 0); prv_ev_autocpu(emu, PTC_TASK_TYPE_ID, 0); + prv_ev_autocpu(emu, PTC_APP_ID, 0); } static void diff --git a/emu_ovni.c b/emu_ovni.c index 2ca8be0..17b82ed 100644 --- a/emu_ovni.c +++ b/emu_ovni.c @@ -271,12 +271,12 @@ emit_thread_state(struct ovni_emu *emu) row = emu->cur_thread->gindex + 1; tid = emu->cur_thread->tid; - prv_ev_row(emu, row, PTT_THREAD_STATE, st); + prv_ev_thread(emu, row, PTT_THREAD_STATE, st); if(st == TH_ST_RUNNING) - prv_ev_row(emu, row, PTT_THREAD_TID, tid); + prv_ev_thread(emu, row, PTT_THREAD_TID, tid); else - prv_ev_row(emu, row, PTT_THREAD_TID, 0); + prv_ev_thread(emu, row, PTT_THREAD_TID, 0); } static void @@ -297,13 +297,13 @@ emit_thread_count(struct ovni_emu *emu) /* Start at 1 */ row = i + 1; n = loom->cpu[i].nthreads; - prv_ev_row(emu, row, PTC_NTHREADS, n); + prv_ev_cpu(emu, row, PTC_NTHREADS, n); pid = n == 1 ? loom->cpu[i].thread[0]->proc->pid : 1; - prv_ev_row(emu, row, PTC_PROC_PID, pid); + prv_ev_cpu(emu, row, PTC_PROC_PID, pid); tid = n == 1 ? loom->cpu[i].thread[0]->tid : 1; - prv_ev_row(emu, row, PTC_THREAD_TID, tid); + prv_ev_cpu(emu, row, PTC_THREAD_TID, tid); } } @@ -313,13 +313,13 @@ emit_thread_count(struct ovni_emu *emu) /* Place the virtual CPU after the physical CPUs */ row = loom->ncpus + 1; n = loom->vcpu.nthreads; - prv_ev_row(emu, row, PTC_NTHREADS, n); + prv_ev_cpu(emu, row, PTC_NTHREADS, n); pid = n == 1 ? loom->vcpu.thread[0]->proc->pid : 1; - prv_ev_row(emu, row, PTC_PROC_PID, pid); + prv_ev_cpu(emu, row, PTC_PROC_PID, pid); tid = n == 1 ? loom->vcpu.thread[0]->tid : 1; - prv_ev_row(emu, row, PTC_THREAD_TID, tid); + prv_ev_cpu(emu, row, PTC_THREAD_TID, tid); } } diff --git a/ovni.c b/ovni.c index 63e720c..0501c72 100644 --- a/ovni.c +++ b/ovni.c @@ -617,6 +617,18 @@ load_thread(struct ovni_ethread *thread, struct ovni_eproc *proc, int index, int return 0; } +static void +load_proc_metadata(struct ovni_eproc *proc) +{ + JSON_Object *meta; + + meta = json_value_get_object(proc->meta); + assert(meta); + + proc->appid = (int) json_object_get_number(meta, "app_id"); +} + + static int load_proc(struct ovni_eproc *proc, int index, int pid, char *procdir) { @@ -634,9 +646,11 @@ load_proc(struct ovni_eproc *proc, int index, int pid, char *procdir) sprintf(path, "%s/%s", procdir, "metadata.json"); proc->meta = json_parse_file_with_comments(path); - assert(proc->meta); + /* The appid is populated from the metadata */ + load_proc_metadata(proc); + if((dir = opendir(procdir)) == NULL) { fprintf(stderr, "opendir %s failed: %s\n", diff --git a/ovni2prv.c b/ovni2prv.c index a35afbd..8d70fe2 100644 --- a/ovni2prv.c +++ b/ovni2prv.c @@ -124,5 +124,7 @@ int main(int argc, char *argv[]) ovni_free_streams(&trace); + fflush(stdout); + return 0; } diff --git a/prv.c b/prv.c index 4ad05e7..9288f9e 100644 --- a/prv.c +++ b/prv.c @@ -5,10 +5,21 @@ #include "emu.h" void -prv_ev_row(struct ovni_emu *emu, int row, int type, int val) +prv_ev(FILE *f, int row, int64_t time, int type, int val) { - printf("2:0:1:1:%d:%ld:%d:%d\n", - row, emu->delta_time, type, val); + fprintf(f, "2:0:1:1:%d:%ld:%d:%d\n", row, time, type, val); +} + +void +prv_ev_thread(struct ovni_emu *emu, int row, int type, int val) +{ + prv_ev(emu->prv_thread, row, emu->delta_time, type, val); +} + +void +prv_ev_cpu(struct ovni_emu *emu, int row, int type, int val) +{ + prv_ev(emu->prv_cpu, row, emu->delta_time, type, val); } void @@ -27,11 +38,11 @@ prv_ev_autocpu(struct ovni_emu *emu, int type, int val) /* Begin at 1 */ row = cpu->i + 1; - prv_ev_row(emu, row, type, val); + prv_ev_cpu(emu, row, type, val); } void -prv_header(struct ovni_emu *emu, int nrows) +prv_header(FILE *f, int nrows) { - printf("#Paraver (19/01/38 at 03:14):00000000000000000000_ns:0:1:1(%d:1)\n", nrows); + fprintf(f, "#Paraver (19/01/38 at 03:14):00000000000000000000_ns:0:1:1(%d:1)\n", nrows); } diff --git a/prv.h b/prv.h index 68deb03..40d8b3a 100644 --- a/prv.h +++ b/prv.h @@ -9,16 +9,27 @@ enum prv_type { PTC_NTHREADS = 12, PTC_TASK_ID = 20, PTC_TASK_TYPE_ID = 21, + PTC_APP_ID = 30, /* Rows are threads */ PTT_THREAD_STATE = 60, PTT_THREAD_TID = 61, }; + +void +prv_ev(FILE *f, int row, int64_t time, int type, int val); + +void +prv_ev_thread(struct ovni_emu *emu, int row, int type, int val); + +void +prv_ev_cpu(struct ovni_emu *emu, int row, int type, int val); + void prv_ev_autocpu(struct ovni_emu *emu, int type, int val); void -prv_ev_row(struct ovni_emu *emu, int row, int type, int val); +prv_header(FILE *f, int nrows); #endif /* OVNI_PRV_H */