diff --git a/cfg/active-pid-and-tasks.cfg b/cfg/active-pid-and-tasks.cfg index a4bca2e..a1bc076 100644 --- a/cfg/active-pid-and-tasks.cfg +++ b/cfg/active-pid-and-tasks.cfg @@ -38,7 +38,7 @@ 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 400 +window_filter_module evt_type 1 10 window_filter_module evt_type_label 1 "Unknown" window_synchronize 1 @@ -77,7 +77,7 @@ 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 200 +window_filter_module evt_type 1 20 window_filter_module evt_type_label 1 "Unknown" window_synchronize 1 @@ -116,7 +116,7 @@ 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 300 +window_filter_module evt_type 1 21 window_filter_module evt_type_label 1 "Unknown" window_synchronize 1 diff --git a/cfg/all.cfg b/cfg/all.cfg new file mode 100644 index 0000000..5961ab7 --- /dev/null +++ b/cfg/all.cfg @@ -0,0 +1,283 @@ +#ParaverCFG +ConfigFile.Version: 3.4 +ConfigFile.NumWindows: 7 + + +################################################################################ +< NEW DISPLAYING WINDOW Active PID > +################################################################################ +window_name Active PID +window_type single +window_id 1 +window_position_x 0 +window_position_y 231 +window_width 956 +window_height 189 +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 7088.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_object task { 0, 1, { All } } +window_object thread { 0, 0, 19, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } +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 Active Task ID > +################################################################################ +window_name Active Task ID +window_type single +window_id 2 +window_position_x 0 +window_position_y 442 +window_width 956 +window_height 190 +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 2.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_object task { 0, 1, { All } } +window_object thread { 0, 0, 19, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } +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 Active Task Type ID > +################################################################################ +window_name Active Task Type ID +window_type single +window_id 3 +window_position_x 0 +window_position_y 654 +window_width 956 +window_height 190 +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 21.000000000000 +window_minimum_y 2.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_object task { 0, 1, { All } } +window_object thread { 0, 0, 19, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } +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 Number of threads running per CPU > +################################################################################ +window_name Number of threads running per CPU +window_type single +window_id 4 +window_position_x 0 +window_position_y 866 +window_width 956 +window_height 190 +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_object task { 0, 1, { All } } +window_object thread { 0, 0, 19, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } +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 T:Thread State > +################################################################################ +window_name T:Thread State +window_type single +window_id 5 +window_position_x 960 +window_position_y 559 +window_width 956 +window_height 497 +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 T:Active TID > +################################################################################ +window_name T:Active TID +window_type single +window_id 6 +window_position_x 960 +window_position_y 40 +window_width 956 +window_height 497 +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 7103.000000000000 +window_minimum_y 7086.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 + +################################################################################ +< NEW DISPLAYING WINDOW C:Thread TID > +################################################################################ +window_name C:Thread TID +window_type single +window_id 7 +window_position_x 0 +window_position_y 20 +window_width 956 +window_height 189 +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 7102.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_object task { 0, 1, { All } } +window_object thread { 0, 0, 19, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } +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 + diff --git a/emu.c b/emu.c index 2e46f78..4b950bf 100644 --- a/emu.c +++ b/emu.c @@ -237,14 +237,6 @@ emu_get_thread(struct ovni_emu *emu, int tid) return thread; } -void -emu_emit_prv(struct ovni_emu *emu, int type, int val) -{ - printf("2:0:1:1:%d:%ld:%d:%d\n", - emu->cur_thread->cpu->cpu_id + 2, - emu->delta_time, - type, val); -} int diff --git a/emu.h b/emu.h index a6f402c..55c59e1 100644 --- a/emu.h +++ b/emu.h @@ -33,6 +33,7 @@ enum nosv_task_state { }; struct ovni_ethread; +struct ovni_eproc; struct nosv_task { int id; @@ -53,6 +54,12 @@ struct ovni_ethread { /* Emulated thread tid */ pid_t tid; + int index; + int gindex; + + /* The process associated with this thread */ + struct ovni_eproc *proc; + /* Stream fd */ int stream_fd; @@ -74,6 +81,8 @@ struct ovni_ethread { /* State of each emulated process */ struct ovni_eproc { int pid; + int index; + int gindex; /* Path of the process tracedir */ char dir[PATH_MAX]; @@ -140,7 +149,7 @@ struct ovni_cpu { int index; enum ovni_cpu_state state; - enum ovni_cpu_type type; + //enum ovni_cpu_type type; size_t last_nthreads; @@ -171,6 +180,10 @@ struct ovni_emu { uint64_t lastclock; int64_t delta_time; + /* Total counters */ + int total_thread; + int total_proc; + struct nosv_task *cur_task; }; diff --git a/emu_nosv.c b/emu_nosv.c index 96230c9..7c89d09 100644 --- a/emu_nosv.c +++ b/emu_nosv.c @@ -1,8 +1,10 @@ +#include +#include "uthash.h" + #include "ovni.h" #include "ovni_trace.h" #include "emu.h" -#include "uthash.h" -#include +#include "prv.h" enum nosv_prv_type { PRV_TYPE_PROCID @@ -235,50 +237,37 @@ hook_pre_nosv(struct ovni_emu *emu) /* --------------------------- emit ------------------------------- */ static void -emit_task_create(struct ovni_emu *emu) +emit_task_running(struct ovni_emu *emu, struct nosv_task *task) { - //emu_emit_prv(emu, 200, emu->cur_task->id); + prv_ev_autocpu(emu, PTC_TASK_ID, task->id + 1); + prv_ev_autocpu(emu, PTC_TASK_TYPE_ID, task->type_id + 1); } static void -emit_task_execute(struct ovni_emu *emu) +emit_task_not_running(struct ovni_emu *emu, struct nosv_task *task) { - emu_emit_prv(emu, 200, emu->cur_task->id + 1); - emu_emit_prv(emu, 300, emu->cur_task->type_id + 1); - emu_emit_prv(emu, 300, emu->cur_task->type_id + 1); -} - -static void -emit_task_pause(struct ovni_emu *emu) -{ - emu_emit_prv(emu, 200, 0); - emu_emit_prv(emu, 300, 0); -} - -static void -emit_task_resume(struct ovni_emu *emu) -{ - emu_emit_prv(emu, 200, emu->cur_task->id + 1); - emu_emit_prv(emu, 300, emu->cur_task->type_id + 1); -} - -static void -emit_task_end(struct ovni_emu *emu) -{ - emu_emit_prv(emu, 200, 0); - emu_emit_prv(emu, 300, 0); + prv_ev_autocpu(emu, PTC_TASK_ID, 0); + prv_ev_autocpu(emu, PTC_TASK_TYPE_ID, 0); } static void emit_task(struct ovni_emu *emu) { + struct nosv_task *task; + + task = emu->cur_task; + switch(emu->cur_ev->header.value) { - case 'c': emit_task_create(emu); break; - case 'x': emit_task_execute(emu); break; - case 'p': emit_task_pause(emu); break; - case 'r': emit_task_resume(emu); break; - case 'e': emit_task_end(emu); break; + case 'x': + case 'r': + emit_task_running(emu, task); + break; + case 'p': + case 'e': + emit_task_not_running(emu, task); + break; + case 'c': default: break; } diff --git a/emu_ovni.c b/emu_ovni.c index d0cce55..0db3aeb 100644 --- a/emu_ovni.c +++ b/emu_ovni.c @@ -1,5 +1,6 @@ #include "ovni.h" #include "emu.h" +#include "prv.h" #include @@ -325,43 +326,60 @@ hook_pre_ovni(struct ovni_emu *emu) //print_threads_state(emu); } +static void +emit_thread_state(struct ovni_emu *emu) +{ + int row, st, tid; + + st = emu->cur_thread->state; + row = emu->cur_thread->gindex + 1; + tid = emu->cur_thread->tid; + + prv_ev_row(emu, row, PTT_THREAD_STATE, st); + + if(st == TH_ST_RUNNING) + prv_ev_row(emu, row, PTT_THREAD_TID, tid); + else + prv_ev_row(emu, row, PTT_THREAD_TID, 0); +} + static void emit_thread_count(struct ovni_emu *emu) { - int i, n, cpu = -1; - int64_t delta_time; - static int64_t t0 = -1; - - if(t0 < 0) - t0 = ovni_ev_get_clock(emu->cur_ev); - - delta_time = ovni_ev_get_clock(emu->cur_ev) - t0; + int i, n, row, pid, tid; /* Check every CPU looking for a change in nthreads */ for(i=0; incpus; i++) { if(emu->cpu[i].last_nthreads != emu->cpu[i].nthreads) { - cpu = i + 1; + /* Start at 1 */ + row = i + 1; n = emu->cpu[i].nthreads; - goto emit; + prv_ev_row(emu, row, PTC_NTHREADS, n); + + pid = n == 1 ? emu->cpu[i].thread[0]->proc->pid : 1; + prv_ev_row(emu, row, PTC_PROC_PID, pid); + + tid = n == 1 ? emu->cpu[i].thread[0]->tid : 1; + prv_ev_row(emu, row, PTC_THREAD_TID, tid); } } /* Same with the virtual CPU */ if(emu->vcpu.last_nthreads != emu->vcpu.nthreads) { - cpu = 0; + /* Place the virtual CPU after the physical CPUs */ + row = emu->ncpus + 1; n = emu->vcpu.nthreads; - goto emit; + prv_ev_row(emu, row, PTC_NTHREADS, n); + + pid = n == 1 ? emu->vcpu.thread[0]->proc->pid : 1; + prv_ev_row(emu, row, PTC_PROC_PID, pid); + + tid = n == 1 ? emu->vcpu.thread[0]->tid : 1; + prv_ev_row(emu, row, PTC_THREAD_TID, tid); } - - return; - -emit: - - printf("2:0:1:1:%d:%ld:100:%d\n", - cpu+1, delta_time, n); } static void @@ -370,7 +388,7 @@ emit_current_pid(struct ovni_emu *emu) if(emu->cur_thread->cpu == NULL) return; - emu_emit_prv(emu, 400, emu->cur_proc->pid); + prv_ev_autocpu(emu, PTC_PROC_PID, emu->cur_proc->pid); } void @@ -379,10 +397,12 @@ hook_emit_ovni(struct ovni_emu *emu) switch(emu->cur_ev->header.class) { case 'H': + emit_thread_state(emu); + /* falltrough */ case 'A': case 'C': emit_thread_count(emu); - emit_current_pid(emu); + //emit_current_pid(emu); break; default: break; diff --git a/ovni.c b/ovni.c index 65a7adf..9db022d 100644 --- a/ovni.c +++ b/ovni.c @@ -470,9 +470,15 @@ find_dir_prefix(struct dirent *dirent, const char *prefix, int *num) } static int -load_thread(struct ovni_ethread *thread, int tid, char *filepath) +load_thread(struct ovni_ethread *thread, struct ovni_eproc *proc, int index, int tid, char *filepath) { + static int total_threads = 0; + thread->tid = tid; + thread->index = index; + thread->gindex = total_threads++; + thread->state = TH_ST_UNKNOWN; + thread->proc = proc; thread->stream_fd = open(filepath, O_RDONLY); if(thread->stream_fd == -1) @@ -480,14 +486,14 @@ load_thread(struct ovni_ethread *thread, int tid, char *filepath) perror("open"); return -1; } - - thread->state = TH_ST_UNKNOWN; return 0; } static int -load_proc(struct ovni_eproc *proc, int pid, char *procdir) +load_proc(struct ovni_eproc *proc, int index, int pid, char *procdir) { + static int total_procs = 0; + struct dirent *dirent; DIR *dir; char path[PATH_MAX]; @@ -495,6 +501,8 @@ load_proc(struct ovni_eproc *proc, int pid, char *procdir) int tid; proc->pid = pid; + proc->index = index; + proc->gindex = total_procs++; if((dir = opendir(procdir)) == NULL) { @@ -520,10 +528,12 @@ load_proc(struct ovni_eproc *proc, int pid, char *procdir) abort(); } - thread = &proc->thread[proc->nthreads++]; + thread = &proc->thread[proc->nthreads]; - if(load_thread(thread, tid, path) != 0) + if(load_thread(thread, proc, proc->nthreads, tid, path) != 0) return -1; + + proc->nthreads++; } closedir(dir); @@ -566,10 +576,12 @@ load_loom(struct ovni_loom *loom, int loomid, char *loomdir) abort(); } - proc = &loom->proc[loom->nprocs++]; + proc = &loom->proc[loom->nprocs]; - if(load_proc(proc, pid, path) != 0) + if(load_proc(proc, loom->nprocs, pid, path) != 0) return -1; + + loom->nprocs++; } closedir(dir); diff --git a/ovni.h b/ovni.h index 71452fc..33e5f96 100644 --- a/ovni.h +++ b/ovni.h @@ -13,8 +13,8 @@ #define OVNI_MAX_LOOM 4 #define OVNI_TRACEDIR "ovni" -/* Reserved buffer for event allocation */ -#define OVNI_MAX_EV_BUF (16 * 1024LL * 1024LL * 1024LL) +/* Reserved buffer for event allocation per thread */ +#define OVNI_MAX_EV_BUF (2 * 1024LL * 1024LL) /* 2 MiB */ /* ----------------------- common ------------------------ */ diff --git a/prv.c b/prv.c new file mode 100644 index 0000000..8232eae --- /dev/null +++ b/prv.c @@ -0,0 +1,32 @@ +#include +#include + +#include "ovni.h" +#include "emu.h" + +void +prv_ev_row(struct ovni_emu *emu, int row, int type, int val) +{ + printf("2:0:1:1:%d:%ld:%d:%d\n", + row, emu->delta_time, type, val); +} + +void +prv_ev_autocpu(struct ovni_emu *emu, int type, int val) +{ + int row; + struct ovni_cpu *cpu; + + assert(emu->cur_thread); + + cpu = emu->cur_thread->cpu; + + assert(cpu); + assert(cpu->index >= 0); + assert(cpu->cpu_id >= 0); + + /* Begin at 1 */ + row = cpu->index + 1; + + prv_ev_row(emu, row, type, val); +} diff --git a/prv.h b/prv.h new file mode 100644 index 0000000..68deb03 --- /dev/null +++ b/prv.h @@ -0,0 +1,24 @@ +#ifndef OVNI_PRV_H +#define OVNI_PRV_H + +/* All PRV event types */ +enum prv_type { + /* Rows are CPUs */ + PTC_PROC_PID = 10, + PTC_THREAD_TID = 11, + PTC_NTHREADS = 12, + PTC_TASK_ID = 20, + PTC_TASK_TYPE_ID = 21, + + /* Rows are threads */ + PTT_THREAD_STATE = 60, + PTT_THREAD_TID = 61, +}; + +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); + +#endif /* OVNI_PRV_H */