From 4604ddad802d0245e7b97daa20a646f81e56aecc Mon Sep 17 00:00:00 2001 From: Takishipp Date: Tue, 18 Jul 2017 14:26:32 +0200 Subject: [PATCH] turn paje_value to a class --- src/instr/instr_interface.cpp | 16 ++++++------- src/instr/instr_paje_values.cpp | 12 +++++----- src/instr/instr_private.h | 13 ++++++---- src/msg/instr_msg_process.cpp | 8 +++---- src/msg/instr_msg_task.cpp | 12 +++++----- src/msg/msg_vm.cpp | 8 +++---- src/smpi/colls/smpi_automatic_selector.cpp | 8 +++---- src/smpi/internals/instr_smpi.cpp | 28 +++++++++++----------- src/surf/instr_routing.cpp | 26 ++++++++++---------- 9 files changed, 67 insertions(+), 64 deletions(-) diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index 43c2b18589..76a78e66a5 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -176,7 +176,7 @@ void TRACE_declare_mark(const char *mark_type) * \see TRACE_mark */ void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mark_value, const char *mark_color) -{ +{ paje_value pj_value; /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with marks */ if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; @@ -196,7 +196,7 @@ void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mar mark_color = white; XBT_DEBUG("MARK,declare_value %s %s %s", mark_type, mark_value, mark_color); - PJ_value_new (mark_value, mark_color, type); + pj_value.PJ_value_new (mark_value, mark_color, type); } /** \ingroup TRACE_mark @@ -231,7 +231,7 @@ void TRACE_declare_mark_value (const char *mark_type, const char *mark_value) * \see TRACE_declare_mark */ void TRACE_mark(const char *mark_type, const char *mark_value) -{ +{ paje_value pj_value; /* safe switches. tracing has to be activated and if platform is not traced, we can't deal with marks */ if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; @@ -247,7 +247,7 @@ void TRACE_mark(const char *mark_type, const char *mark_value) THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type); } - val_t value = PJ_value_get (mark_value, type); + val_t value = pj_value.PJ_value_get (mark_value, type); XBT_DEBUG("MARK %s %s", mark_type, mark_value); new NewEvent (MSG_get_clock(), PJ_container_get_root(), type, value); } @@ -947,10 +947,10 @@ void TRACE_host_state_declare_value (const char *state, const char *value, const * \see TRACE_host_state_declare, TRACE_host_push_state, TRACE_host_pop_state, TRACE_host_reset_state */ void TRACE_host_set_state (const char *host, const char *state, const char *value) -{ +{ paje_value pj_value; container_t container = PJ_container_get(host); type_t type = PJ_type_get (state, container->type); - val_t val = PJ_value_get_or_new (value, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */ + val_t val = pj_value.PJ_value_get_or_new (value, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */ new SetStateEvent(MSG_get_clock(), container, type, val); } @@ -966,10 +966,10 @@ void TRACE_host_set_state (const char *host, const char *state, const char *valu * \see TRACE_host_state_declare, TRACE_host_set_state, TRACE_host_pop_state, TRACE_host_reset_state */ void TRACE_host_push_state (const char *host, const char *state, const char *value) -{ +{ paje_value pj_value; container_t container = PJ_container_get(host); type_t type = PJ_type_get (state, container->type); - val_t val = PJ_value_get_or_new (value, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */ + val_t val = pj_value.PJ_value_get_or_new (value, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */ new PushStateEvent(MSG_get_clock(), container, type, val); } diff --git a/src/instr/instr_paje_values.cpp b/src/instr/instr_paje_values.cpp index 88ad1bbeb3..587a076821 100644 --- a/src/instr/instr_paje_values.cpp +++ b/src/instr/instr_paje_values.cpp @@ -10,7 +10,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)"); -val_t PJ_value_new (const char *name, const char *color, type_t father) +val_t paje_value :: PJ_value_new (const char *name, const char *color, type_t father) { if (name == nullptr || father == nullptr){ THROWF (tracing_error, 0, "can't create a value with a nullptr name (or a nullptr father)"); @@ -31,19 +31,19 @@ val_t PJ_value_new (const char *name, const char *color, type_t father) return ret; } -val_t PJ_value_get_or_new (const char *name, const char *color, type_t father) -{ +val_t paje_value :: PJ_value_get_or_new (const char *name, const char *color, type_t father) +{ paje_value pj_value; val_t ret = 0; try { - ret = PJ_value_get(name, father); + ret = pj_value.PJ_value_get(name, father); } catch(xbt_ex& e) { - ret = PJ_value_new(name, color, father); + ret = pj_value.PJ_value_new(name, color, father); } return ret; } -val_t PJ_value_get (const char *name, type_t father) +val_t paje_value::PJ_value_get (const char *name, type_t father) { if (name == nullptr || father == nullptr){ THROWF (tracing_error, 0, "can't get a value with a nullptr name (or a nullptr father)"); diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index d3d45c26c1..378892617c 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -262,6 +262,14 @@ class NewEvent : public PajeEvent { }; +class paje_value{ + public: + paje_value(){}; + ~paje_value(){}; + val_t PJ_value_new (const char *name, const char *color, type_t father); + val_t PJ_value_get (const char *name, type_t father); + val_t PJ_value_get_or_new (const char *name, const char *color, type_t father); +}; extern XBT_PRIVATE xbt_dict_t created_categories; extern XBT_PRIVATE xbt_dict_t declared_marks; @@ -351,11 +359,6 @@ XBT_PRIVATE XBT_PRIVATE void PJ_type_free (type_t type); /* instr_config.c */ XBT_PRIVATE void recursiveDestroyType (type_t type); -/* instr_paje_values.c */ -XBT_PUBLIC(val_t) PJ_value_new (const char *name, const char *color, type_t father); -XBT_PUBLIC(val_t) PJ_value_get_or_new (const char *name, const char *color, type_t father); -XBT_PUBLIC(val_t) PJ_value_get (const char *name, const type_t father); - XBT_PRIVATE void TRACE_TI_start(); XBT_PRIVATE void TRACE_TI_end(); diff --git a/src/msg/instr_msg_process.cpp b/src/msg/instr_msg_process.cpp index 21a13553d0..856923b245 100644 --- a/src/msg/instr_msg_process.cpp +++ b/src/msg/instr_msg_process.cpp @@ -87,14 +87,14 @@ void TRACE_msg_process_kill(smx_process_exit_status_t status, msg_process_t proc } void TRACE_msg_process_suspend(msg_process_t process) -{ +{ paje_value pj_value; if (TRACE_msg_process_is_enabled()){ int len = INSTR_DEFAULT_STR_SIZE; char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(process, str, len)); type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - val_t value = PJ_value_get ("suspend", type); + val_t value = pj_value.PJ_value_get ("suspend", type); new PushStateEvent (MSG_get_clock(), process_container, type, value); } } @@ -112,14 +112,14 @@ void TRACE_msg_process_resume(msg_process_t process) } void TRACE_msg_process_sleep_in(msg_process_t process) -{ +{ paje_value pj_value; if (TRACE_msg_process_is_enabled()){ int len = INSTR_DEFAULT_STR_SIZE; char str[INSTR_DEFAULT_STR_SIZE]; container_t process_container = PJ_container_get (instr_process_id(process, str, len)); type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - val_t value = PJ_value_get ("sleep", type); + val_t value = pj_value.PJ_value_get ("sleep", type); new PushStateEvent (MSG_get_clock(), process_container, type, value); } } diff --git a/src/msg/instr_msg_task.cpp b/src/msg/instr_msg_task.cpp index fb5862813c..b211d1fdf0 100644 --- a/src/msg/instr_msg_task.cpp +++ b/src/msg/instr_msg_task.cpp @@ -45,7 +45,7 @@ void TRACE_msg_task_create(msg_task_t task) /* MSG_task_execute related functions */ void TRACE_msg_task_execute_start(msg_task_t task) -{ +{ paje_value pj_value; XBT_DEBUG("EXEC,in %p, %lld, %s", task, task->counter, task->category); if (TRACE_msg_process_is_enabled()){ @@ -54,7 +54,7 @@ void TRACE_msg_task_execute_start(msg_task_t task) container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - val_t value = PJ_value_get ("task_execute", type); + val_t value = pj_value.PJ_value_get ("task_execute", type); new PushStateEvent (MSG_get_clock(), process_container, type, value); } } @@ -85,7 +85,7 @@ void TRACE_msg_task_destroy(msg_task_t task) /* MSG_task_get related functions */ void TRACE_msg_task_get_start() -{ +{ paje_value pj_value; XBT_DEBUG("GET,in"); if (TRACE_msg_process_is_enabled()){ @@ -94,7 +94,7 @@ void TRACE_msg_task_get_start() container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - val_t value = PJ_value_get ("receive", type); + val_t value = pj_value.PJ_value_get ("receive", type); new PushStateEvent (MSG_get_clock(), process_container, type, value); } } @@ -120,7 +120,7 @@ void TRACE_msg_task_get_end(double start_time, msg_task_t task) /* MSG_task_put related functions */ int TRACE_msg_task_put_start(msg_task_t task) -{ +{ paje_value pj_value; XBT_DEBUG("PUT,in %p, %lld, %s", task, task->counter, task->category); if (TRACE_msg_process_is_enabled()){ @@ -129,7 +129,7 @@ int TRACE_msg_task_put_start(msg_task_t task) container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len)); type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type); - val_t value = PJ_value_get ("send", type); + val_t value = pj_value.PJ_value_get ("send", type); new PushStateEvent (MSG_get_clock(), process_container, type, value); char key[INSTR_DEFAULT_STR_SIZE]; diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index 2eb403d578..60b752c6b4 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -183,7 +183,7 @@ void MSG_vm_destroy(msg_vm_t vm) * If the VM cannot be started (because of memory over-provisioning), an exception is generated. */ void MSG_vm_start(msg_vm_t vm) -{ +{ paje_value pj_value; simgrid::simix::kernelImmediate([vm]() { simgrid::vm::VmHostExt::ensureVmExtInstalled(); @@ -215,7 +215,7 @@ void MSG_vm_start(msg_vm_t vm) if (TRACE_msg_vm_is_enabled()) { container_t vm_container = PJ_container_get(vm->getCname()); type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type); - val_t value = PJ_value_get_or_new("start", "0 0 1", type); // start is blue + val_t value = pj_value.PJ_value_get_or_new("start", "0 0 1", type); // start is blue new PushStateEvent(MSG_get_clock(), vm_container, type, value); } } @@ -806,7 +806,7 @@ void MSG_vm_migrate(msg_vm_t vm, msg_host_t dst_pm) * No suspension cost occurs. */ void MSG_vm_suspend(msg_vm_t vm) -{ +{ paje_value pj_value; smx_actor_t issuer = SIMIX_process_self(); simgrid::simix::kernelImmediate([vm, issuer]() { vm->pimpl_vm_->suspend(issuer); }); @@ -815,7 +815,7 @@ void MSG_vm_suspend(msg_vm_t vm) if (TRACE_msg_vm_is_enabled()) { container_t vm_container = PJ_container_get(vm->getCname()); type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type); - val_t value = PJ_value_get_or_new("suspend", "1 0 0", type); // suspend is red + val_t value = pj_value.PJ_value_get_or_new("suspend", "1 0 0", type); // suspend is red new PushStateEvent(MSG_get_clock(), vm_container, type, value); } } diff --git a/src/smpi/colls/smpi_automatic_selector.cpp b/src/smpi/colls/smpi_automatic_selector.cpp index b69b56ccba..8ff4452ea7 100644 --- a/src/smpi/colls/smpi_automatic_selector.cpp +++ b/src/smpi/colls/smpi_automatic_selector.cpp @@ -13,16 +13,16 @@ //attempt to do a quick autotuning version of the collective, - -#define TRACE_AUTO_COLL(cat) \ +paje_value pj_value; +#define TRACE_AUTO_COLL(cat) \ if (TRACE_is_enabled()) { \ type_t type = PJ_type_get_or_null(#cat, PJ_type_get_root()); \ if (not type) { \ type = PJ_type_event_new(#cat, PJ_type_get_root()); \ } \ char cont_name[25]; \ - snprintf(cont_name, 25, "rank-%d", smpi_process()->index()); \ - val_t value = PJ_value_get_or_new(Colls::mpi_coll_##cat##_description[i].name, "1.0 1.0 1.0", type); \ + snprintf(cont_name, 25, "rank-%d", smpi_process()->index()); \ + val_t value = pj_value.PJ_value_get_or_new(Colls::mpi_coll_##cat##_description[i].name, "1.0 1.0 1.0", type); \ new NewEvent(SIMIX_get_clock(), PJ_container_get(cont_name), type, value); \ } diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index eb3b1410a0..aca15f009c 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -234,7 +234,7 @@ void TRACE_smpi_finalize(int rank) } void TRACE_smpi_collective_in(int rank, int root, const char *operation, instr_extra_data extra) -{ +{ paje_value pj_value; if (not TRACE_smpi_is_enabled()) { cleanup_extra_data(extra); return; @@ -245,7 +245,7 @@ void TRACE_smpi_collective_in(int rank, int root, const char *operation, instr_e container_t container = PJ_container_get (str); type_t type = PJ_type_get ("MPI_STATE", container->type); const char *color = instr_find_color (operation); - val_t value = PJ_value_get_or_new (operation, color, type); + val_t value = pj_value.PJ_value_get_or_new (operation, color, type); new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast(extra)); } @@ -263,7 +263,7 @@ void TRACE_smpi_collective_out(int rank, int root, const char *operation) } void TRACE_smpi_computing_init(int rank) -{ +{ paje_value pj_value; //first use, initialize the color in the trace if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_computing()) return; @@ -273,12 +273,12 @@ void TRACE_smpi_computing_init(int rank) container_t container = PJ_container_get(str); type_t type = PJ_type_get("MPI_STATE", container->type); const char* color = instr_find_color("computing"); - val_t value = PJ_value_get_or_new("computing", color, type); + val_t value = pj_value.PJ_value_get_or_new("computing", color, type); new PushStateEvent(SIMIX_get_clock(), container, type, value); } void TRACE_smpi_computing_in(int rank, instr_extra_data extra) -{ +{ paje_value pj_value; //do not forget to set the color first, otherwise this will explode if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_computing()) { cleanup_extra_data(extra); @@ -289,7 +289,7 @@ void TRACE_smpi_computing_in(int rank, instr_extra_data extra) smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); type_t type = PJ_type_get ("MPI_STATE", container->type); - val_t value = PJ_value_get_or_new ("computing", nullptr, type); + val_t value = pj_value.PJ_value_get_or_new ("computing", nullptr, type); new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast(extra)); } @@ -305,7 +305,7 @@ void TRACE_smpi_computing_out(int rank) } void TRACE_smpi_sleeping_init(int rank) -{ +{ paje_value pj_value; //first use, initialize the color in the trace if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_sleeping()) return; @@ -315,12 +315,12 @@ void TRACE_smpi_sleeping_init(int rank) container_t container = PJ_container_get (str); type_t type = PJ_type_get ("MPI_STATE", container->type); const char *color = instr_find_color ("sleeping"); - val_t value = PJ_value_get_or_new ("sleeping", color, type); + val_t value = pj_value.PJ_value_get_or_new ("sleeping", color, type); new PushStateEvent (SIMIX_get_clock(), container, type, value); } void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra) -{ +{ paje_value pj_value; //do not forget to set the color first, otherwise this will explode if (not TRACE_smpi_is_enabled() || not TRACE_smpi_is_sleeping()) { cleanup_extra_data(extra); @@ -331,7 +331,7 @@ void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra) smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); type_t type = PJ_type_get ("MPI_STATE", container->type); - val_t value = PJ_value_get_or_new ("sleeping", nullptr, type); + val_t value = pj_value.PJ_value_get_or_new ("sleeping", nullptr, type); new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast(extra)); } @@ -347,7 +347,7 @@ void TRACE_smpi_sleeping_out(int rank) } void TRACE_smpi_testing_in(int rank, instr_extra_data extra) -{ +{ paje_value pj_value; //do not forget to set the color first, otherwise this will explode if (not TRACE_smpi_is_enabled()) { cleanup_extra_data(extra); @@ -358,7 +358,7 @@ void TRACE_smpi_testing_in(int rank, instr_extra_data extra) smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); type_t type = PJ_type_get ("MPI_STATE", container->type); - val_t value = PJ_value_get_or_new ("test", nullptr, type); + val_t value = pj_value.PJ_value_get_or_new ("test", nullptr, type); new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast(extra)); } @@ -374,7 +374,7 @@ void TRACE_smpi_testing_out(int rank) } void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, instr_extra_data extra) -{ +{ paje_value pj_value; if (not TRACE_smpi_is_enabled()) { cleanup_extra_data(extra); return; @@ -385,7 +385,7 @@ void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, instr_ container_t container = PJ_container_get (str); type_t type = PJ_type_get ("MPI_STATE", container->type); const char *color = instr_find_color (operation); - val_t value = PJ_value_get_or_new (operation, color, type); + val_t value = pj_value.PJ_value_get_or_new (operation, color, type); new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast(extra)); } diff --git a/src/surf/instr_routing.cpp b/src/surf/instr_routing.cpp index 420221a19c..039ed4c74d 100644 --- a/src/surf/instr_routing.cpp +++ b/src/surf/instr_routing.cpp @@ -234,7 +234,7 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link) } static void sg_instr_new_host(simgrid::s4u::Host& host) -{ +{ paje_value pj_value; container_t father = currentContainer.back(); container_t container = PJ_container_new(host.getCname(), INSTR_HOST, father); @@ -267,11 +267,11 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) if (msg_process == nullptr){ msg_process = PJ_type_container_new("MSG_PROCESS", container->type); type_t state = PJ_type_state_new ("MSG_PROCESS_STATE", msg_process); - PJ_value_new ("suspend", "1 0 1", state); - PJ_value_new ("sleep", "1 1 0", state); - PJ_value_new ("receive", "1 0 0", state); - PJ_value_new ("send", "0 0 1", state); - PJ_value_new ("task_execute", "0 1 1", state); + pj_value.PJ_value_new ("suspend", "1 0 1", state); + pj_value.PJ_value_new ("sleep", "1 1 0", state); + pj_value.PJ_value_new ("receive", "1 0 0", state); + pj_value.PJ_value_new ("send", "0 0 1", state); + pj_value.PJ_value_new ("task_execute", "0 1 1", state); PJ_type_link_new ("MSG_PROCESS_LINK", PJ_type_get_root(), msg_process, msg_process); PJ_type_link_new ("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process); } @@ -282,11 +282,11 @@ static void sg_instr_new_host(simgrid::s4u::Host& host) if (msg_vm == nullptr){ msg_vm = PJ_type_container_new("MSG_VM", container->type); type_t state = PJ_type_state_new ("MSG_VM_STATE", msg_vm); - PJ_value_new ("suspend", "1 0 1", state); - PJ_value_new ("sleep", "1 1 0", state); - PJ_value_new ("receive", "1 0 0", state); - PJ_value_new ("send", "0 0 1", state); - PJ_value_new ("task_execute", "0 1 1", state); + pj_value.PJ_value_new ("suspend", "1 0 1", state); + pj_value.PJ_value_new ("sleep", "1 1 0", state); + pj_value.PJ_value_new ("receive", "1 0 0", state); + pj_value.PJ_value_new ("send", "0 0 1", state); + pj_value.PJ_value_new ("task_execute", "0 1 1", state); PJ_type_link_new ("MSG_VM_LINK", PJ_type_get_root(), msg_vm, msg_vm); PJ_type_link_new ("MSG_VM_PROCESS_LINK", PJ_type_get_root(), msg_vm, msg_vm); } @@ -401,9 +401,9 @@ void instr_new_user_state_type (const char *father_type, const char *new_typenam } static void recursiveNewValueForUserStateType (const char *type_name, const char *value, const char *color, type_t root) -{ +{ paje_value pj_value; if (not strcmp(root->name, type_name)) { - PJ_value_new (value, color, root); + pj_value.PJ_value_new (value, color, root); } xbt_dict_cursor_t cursor = nullptr; type_t child_type; -- 2.20.1