From da6a8948438ab0798f492ed7bf5dad2a515ca04e Mon Sep 17 00:00:00 2001 From: Takishipp Date: Tue, 13 Jun 2017 12:51:00 +0200 Subject: [PATCH 1/1] remove all the events that are called and destroyed one time --- src/instr/instr_paje_containers.cpp | 4 +- src/instr/instr_paje_trace.cpp | 126 ++++++++++++---------------- src/instr/instr_paje_types.cpp | 4 +- src/instr/instr_paje_values.cpp | 2 +- src/instr/instr_private.h | 44 ++-------- 5 files changed, 62 insertions(+), 118 deletions(-) diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index f024629ae9..16bbd9ba02 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -138,7 +138,7 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe newContainer->children = xbt_dict_new_homogeneous(nullptr); if (newContainer->father){ xbt_dict_set(newContainer->father->children, newContainer->name, newContainer, nullptr); - new CreateContainerEvent(newContainer); + CreateContainerEvent(newContainer); } //register all kinds by name @@ -206,7 +206,7 @@ void PJ_container_free (container_t container) if (not TRACE_disable_destroy() && container != PJ_container_get_root()) { //do not trace the container destruction if user requests //or if the container is root - new DestroyContainerEvent(container); + DestroyContainerEvent(container); } //remove it from allContainers data structure diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index cab9eefca8..5cabc10819 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -260,17 +260,25 @@ if (instr_fmt_type == instr_fmt_paje) { } -DefineStateTypeEvent::DefineStateTypeEvent(type_t type) +void DefineStateTypeEvent(type_t type) { - this->event_type = PAJE_DefineStateType; - this->timestamp = 0; - this->type = type; + e_event_type event_type = PAJE_DefineStateType; + double timestamp = 0; XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); //print it - print(); - delete this; +if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << (int)event_type; + stream << " " << type->id << " " << type->father->id << " " << type->name; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } @@ -287,20 +295,6 @@ DefineEventTypeEvent::DefineEventTypeEvent(type_t type) } -void DefineStateTypeEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - stream << " " << type->id << " " << type->father->id << " " << type->name; - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } -} - void DefineEventTypeEvent::print() { if (instr_fmt_type == instr_fmt_paje) { XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); @@ -315,26 +309,18 @@ void DefineEventTypeEvent::print() { } } -DefineLinkTypeEvent::DefineLinkTypeEvent(type_t type, type_t source, type_t dest) +void DefineLinkTypeEvent(type_t type, type_t source, type_t dest) { - this->event_type = PAJE_DefineLinkType; - this->timestamp = 0; - this->type = type; - this->source = source; - this->dest = dest; + e_event_type event_type = PAJE_DefineLinkType; + double timestamp = 0; XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); //print it - print(); - delete this; -} - -void DefineLinkTypeEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { +if (instr_fmt_type == instr_fmt_paje) { XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)event_type; stream << " " << type->id << " " << type->father->id << " " << source->id << " " << dest->id << " " << type->name; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { @@ -344,25 +330,18 @@ void DefineLinkTypeEvent::print() { } } -DefineEntityValueEvent::DefineEntityValueEvent (val_t value) +void DefineEntityValueEvent (val_t value) { - this->event_type = PAJE_DefineEntityValue; - this->timestamp = 0; - this->value = value; + e_event_type event_type = PAJE_DefineEntityValue; + double timestamp = 0; XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); //print it - print(); - delete this; -} - - -void DefineEntityValueEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { +if (instr_fmt_type == instr_fmt_paje) { XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << (int)event_type; stream << " " << value->id << " " << value->father->id << " " << value->name; if (value->color) stream << " \"" << value->color << "\""; @@ -374,26 +353,26 @@ void DefineEntityValueEvent::print() { } } -CreateContainerEvent::CreateContainerEvent (container_t container) -{ - this->event_type = PAJE_CreateContainer; - this->timestamp = SIMIX_get_clock(); - this->container = container; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); +void CreateContainerEvent (container_t container) +{ + e_event_type event_type = PAJE_CreateContainer; + double timestamp = SIMIX_get_clock(); - print(); - delete this; -} + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type,timestamp); -void CreateContainerEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { +if (instr_fmt_type == instr_fmt_paje) { XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); - stream << " " << container->id << " " << container->type->id << " " << container->father->id << " \"" - << container->name << "\""; + stream << (int)event_type; + stream << " "; + /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */ + if (timestamp < 1e-12) + stream << 0; + else + stream << timestamp; + stream << " " << container->id << " " << container->type->id << " " << container->father->id << " \"" + << container->name << "\""; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { @@ -428,26 +407,24 @@ void CreateContainerEvent::print() { } } -DestroyContainerEvent::DestroyContainerEvent (container_t container) +void DestroyContainerEvent (container_t container) { - this->event_type = PAJE_DestroyContainer; - this->timestamp = SIMIX_get_clock(); - this->container = container; + e_event_type event_type = PAJE_DestroyContainer; + double timestamp = SIMIX_get_clock(); - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, timestamp); - print(); - delete this; -} - -void DestroyContainerEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { +if (instr_fmt_type == instr_fmt_paje) { XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); + stream << (int)event_type; + stream << " "; + /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */ + if (timestamp < 1e-12) + stream << 0; + else + stream << timestamp; stream << " " << container->type->id << " " << container->id; - print_row(); } else if (instr_fmt_type == instr_fmt_TI) { if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || xbt_dict_length(tracing_files) == 1) { @@ -460,6 +437,7 @@ void DestroyContainerEvent::print() { } } + SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value) { this->event_type = PAJE_SetVariable; diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index af481486fb..461f96b9d5 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -179,7 +179,7 @@ type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t ret = newType (name, key, nullptr, TYPE_LINK, father); XBT_DEBUG("LinkType %s(%s), child of %s(%s) %s(%s)->%s(%s)", ret->name, ret->id, father->name, father->id, source->name, source->id, dest->name, dest->id); - new DefineLinkTypeEvent(ret, source, dest); + DefineLinkTypeEvent(ret, source, dest); return ret; } @@ -193,6 +193,6 @@ type_t PJ_type_state_new (const char *name, type_t father) ret = newType (name, name, nullptr, TYPE_STATE, father); XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); - new DefineStateTypeEvent(ret); + DefineStateTypeEvent(ret); return ret; } diff --git a/src/instr/instr_paje_values.cpp b/src/instr/instr_paje_values.cpp index d07eb6f12d..f07a6409e2 100644 --- a/src/instr/instr_paje_values.cpp +++ b/src/instr/instr_paje_values.cpp @@ -27,7 +27,7 @@ val_t PJ_value_new (const char *name, const char *color, type_t father) xbt_dict_set (father->values, name, ret, nullptr); XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name); - new DefineEntityValueEvent(ret); + DefineEntityValueEvent(ret); return ret; } diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index ac6366acb9..9b3d7a8c9d 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -125,15 +125,6 @@ class PajeEvent { //-------------------------------------------------- -//-------------------------------------------------- - -class DefineStateTypeEvent : public PajeEvent { - type_t type; - public: - DefineStateTypeEvent(type_t type); - void print() override; -}; - class DefineEventTypeEvent : public PajeEvent { type_t type; public: @@ -141,36 +132,6 @@ class DefineEventTypeEvent : public PajeEvent { void print() override; }; -class DefineLinkTypeEvent : public PajeEvent { - type_t type; - type_t source; - type_t dest; - public: - DefineLinkTypeEvent(type_t type, type_t source, type_t dest); - void print() override; -}; - -class DefineEntityValueEvent : public PajeEvent { - val_t value; - public: - DefineEntityValueEvent (val_t type); - void print() override; -}; - -class CreateContainerEvent : public PajeEvent { - public: - container_t container; - explicit CreateContainerEvent (container_t container); - void print() override; -}; - -class DestroyContainerEvent : public PajeEvent { - public: - container_t container; - DestroyContainerEvent (container_t container); - void print() override; -}; - class SetVariableEvent : public PajeEvent { container_t container; @@ -461,5 +422,10 @@ SG_END_DECL() void DefineContainerEvent(type_t type); void DefineVariableTypeEvent(type_t type); +void DefineStateTypeEvent(type_t type); +void DefineLinkTypeEvent(type_t type, type_t source, type_t dest); +void DefineEntityValueEvent (val_t value); +void CreateContainerEvent (container_t container); +void DestroyContainerEvent (container_t container); #endif -- 2.20.1