From: Toufik Boubehziz Date: Wed, 14 Jun 2017 07:17:16 +0000 (+0200) Subject: Merge branch 'master' into clean_events X-Git-Tag: v3.16~63^2^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/61427a88a76a2c2ef25d0d5b8132995c6f550e5c?hp=863aeead864a309c494893a1b06ec33ed2b7daf1 Merge branch 'master' into clean_events --- diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index f024629ae9..c2b651568a 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); + LogContainerCreation(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); + LogContainerDestruction(container); } //remove it from allContainers data structure diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index 6afb85878f..825183e3ea 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -21,8 +21,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "tracing event system"); -extern s_instr_trace_writer_t active_writer; - static std::stringstream stream; FILE *tracing_file = nullptr; @@ -35,10 +33,6 @@ void print_NULL(PajeEvent* event){} /* The active set of functions for the selected trace format * By default, they all do nothing, hence the print_NULL to avoid segfaults */ -s_instr_trace_writer_t active_writer = {&print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, - &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, - &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL}; - std::vector buffer; void buffer_debug(std::vector *buf); @@ -218,23 +212,14 @@ void TRACE_paje_end() { XBT_DEBUG("Filename %s is closed", filename); } -DefineContainerEvent::DefineContainerEvent(type_t type) +void DefineContainerEvent(type_t type) { - - event_type = PAJE_DefineContainerType; - timestamp = 0; - this->type = type; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineContainerType); //print it - print (); - delete this; -} - -void DefineContainerEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineContainerType, TRACE_precision(), 0.); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << PAJE_DefineContainerType; stream << " " << type->id << " " << type->father->id << " " << type->name; @@ -244,27 +229,21 @@ void DefineContainerEvent::print() { } else { THROW_IMPOSSIBLE; } + //-- } -DefineVariableTypeEvent::DefineVariableTypeEvent(type_t type) + +void LogVariableTypeDefinition(type_t type) { - this->event_type = PAJE_DefineVariableType; - this->timestamp = 0; - this->type = type; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineVariableType); //print it - print (); - delete this; -} - -void DefineVariableTypeEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); +if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineVariableType, TRACE_precision(), 0.); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << PAJE_DefineVariableType; stream << " " << type->id << " " << type->father->id << " " << type->name; if (type->color) stream << " \"" << type->color << "\""; @@ -276,17 +255,24 @@ void DefineVariableTypeEvent::print() { } } -DefineStateTypeEvent::DefineStateTypeEvent(type_t type) + +void LogStateTypeDefinition(type_t type) { - this->event_type = PAJE_DefineStateType; - this->timestamp = 0; - this->type = type; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineStateType); //print it - print(); - delete this; +if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineStateType, TRACE_precision(), 0.); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << PAJE_DefineStateType; + stream << " " << type->id << " " << type->father->id << " " << type->name; + print_row(); + } else if (instr_fmt_type == instr_fmt_TI) { + /* Nothing to do */ + } else { + THROW_IMPOSSIBLE; + } } @@ -303,20 +289,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); @@ -331,26 +303,14 @@ void DefineEventTypeEvent::print() { } } -DefineLinkTypeEvent::DefineLinkTypeEvent(type_t type, type_t source, type_t dest) +void LogLinkTypeDefinition(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; - - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); - + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineLinkType); //print it - print(); - delete this; -} - -void DefineLinkTypeEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); +if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineLinkType, TRACE_precision(), 0.); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << PAJE_DefineLinkType; stream << " " << type->id << " " << type->father->id << " " << source->id << " " << dest->id << " " << type->name; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { @@ -360,25 +320,14 @@ void DefineLinkTypeEvent::print() { } } -DefineEntityValueEvent::DefineEntityValueEvent (val_t value) +void LogEntityValue (val_t value) { - this->event_type = PAJE_DefineEntityValue; - this->timestamp = 0; - this->value = value; - - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); - + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineEntityValue); //print it - print(); - delete this; -} - - -void DefineEntityValueEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); +if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineEntityValue, TRACE_precision(),0.); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << PAJE_DefineEntityValue; stream << " " << value->id << " " << value->father->id << " " << value->name; if (value->color) stream << " \"" << value->color << "\""; @@ -390,26 +339,25 @@ 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 LogContainerCreation (container_t container) +{ + double timestamp = SIMIX_get_clock(); - print(); - delete this; -} + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, PAJE_CreateContainer,timestamp); -void CreateContainerEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); +if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_CreateContainer, 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 << PAJE_CreateContainer; + 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) { @@ -444,26 +392,23 @@ void CreateContainerEvent::print() { } } -DestroyContainerEvent::DestroyContainerEvent (container_t container) +void LogContainerDestruction(container_t container) { - this->event_type = PAJE_DestroyContainer; - this->timestamp = SIMIX_get_clock(); - this->container = container; + 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__, PAJE_DestroyContainer, timestamp); - print(); - delete this; -} - -void DestroyContainerEvent::print() { - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); +if (instr_fmt_type == instr_fmt_paje) { + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DestroyContainer, TRACE_precision(), timestamp); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); + stream << PAJE_DestroyContainer; + 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) { @@ -476,6 +421,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 2eb903041b..02c935cf5d 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -130,7 +130,7 @@ type_t PJ_type_container_new (const char *name, type_t father) if(father){ XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); - new DefineContainerEvent(ret); + DefineContainerEvent(ret); } return ret; } @@ -162,7 +162,7 @@ type_t PJ_type_variable_new (const char *name, const char *color, type_t father) ret = newType (name, name, color, TYPE_VARIABLE, father); } XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id); - new DefineVariableTypeEvent (ret); + LogVariableTypeDefinition (ret); return ret; } @@ -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); + LogLinkTypeDefinition(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); + LogStateTypeDefinition(ret); return ret; } diff --git a/src/instr/instr_paje_values.cpp b/src/instr/instr_paje_values.cpp index d07eb6f12d..7c0505ff23 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); + LogEntityValue(ret); return ret; } diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 9d10c4b1a3..64e6080b00 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -123,17 +123,6 @@ class PajeEvent { virtual ~PajeEvent(); }; -class DefineContainerEvent : public PajeEvent -{ - public: - type_t type; - void print() override; - DefineContainerEvent(type_t); -}; - -//-------------------------------------------------- - - //-------------------------------------------------- class DefineVariableTypeEvent : public PajeEvent @@ -159,36 +148,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; @@ -404,25 +363,6 @@ XBT_PUBLIC(val_t) PJ_value_get_or_new (const char *name, const char *color, typ XBT_PUBLIC(val_t) PJ_value_get (const char *name, const type_t father); XBT_PRIVATE void PJ_value_free (val_t value); -XBT_PRIVATE void print_pajeDefineContainerType(PajeEvent* event); -XBT_PRIVATE void print_pajeDefineVariableType(PajeEvent* event); -XBT_PRIVATE void print_pajeDefineStateType(PajeEvent* event); -XBT_PRIVATE void print_pajeDefineEventType(PajeEvent* event); -XBT_PRIVATE void print_pajeDefineLinkType(PajeEvent* event); -XBT_PRIVATE void print_pajeDefineEntityValue (PajeEvent* event); -XBT_PRIVATE void print_pajeCreateContainer(PajeEvent* event); -XBT_PRIVATE void print_pajeDestroyContainer(PajeEvent* event); -XBT_PRIVATE void print_pajeSetVariable(PajeEvent* event); -XBT_PRIVATE void print_pajeAddVariable(PajeEvent* event); -XBT_PRIVATE void print_pajeSubVariable(PajeEvent* event); -XBT_PRIVATE void print_pajeSetState(PajeEvent* event); -XBT_PRIVATE void print_pajePushState(PajeEvent* event); -XBT_PRIVATE void print_pajePopState(PajeEvent* event); -XBT_PRIVATE void print_pajeResetState(PajeEvent* event); -XBT_PRIVATE void print_pajeStartLink(PajeEvent* event); -XBT_PRIVATE void print_pajeEndLink(PajeEvent* event); -XBT_PRIVATE void print_pajeNewEvent (PajeEvent* event); - XBT_PRIVATE void TRACE_TI_start(); XBT_PRIVATE void TRACE_TI_end(); @@ -431,27 +371,6 @@ XBT_PRIVATE void TRACE_paje_dump_buffer (int force); XBT_PRIVATE void dump_comment_file (const char *filename); XBT_PRIVATE void dump_comment (const char *comment); -typedef struct instr_trace_writer { - void (*print_DefineContainerType) (PajeEvent* event); - void (*print_DefineVariableType)(PajeEvent* event); - void (*print_DefineStateType)(PajeEvent* event); - void (*print_DefineEventType)(PajeEvent* event); - void (*print_DefineLinkType)(PajeEvent* event); - void (*print_DefineEntityValue)(PajeEvent* event); - void (*print_CreateContainer)(PajeEvent* event); - void (*print_DestroyContainer)(PajeEvent* event); - void (*print_SetVariable)(PajeEvent* event); - void (*print_AddVariable)(PajeEvent* event); - void (*print_SubVariable)(PajeEvent* event); - void (*print_SetState)(PajeEvent* event); - void (*print_PushState)(PajeEvent* event); - void (*print_PopState)(PajeEvent* event); - void (*print_ResetState)(PajeEvent* event); - void (*print_StartLink)(PajeEvent* event); - void (*print_EndLink)(PajeEvent* event); - void (*print_NewEvent) (PajeEvent* event); -} s_instr_trace_writer_t; - struct s_instr_extra_data; typedef struct s_instr_extra_data *instr_extra_data; @@ -517,4 +436,12 @@ extern instr_fmt_type_t instr_fmt_type; SG_END_DECL() +void DefineContainerEvent(type_t type); +void LogVariableTypeDefinition(type_t type); +void LogStateTypeDefinition(type_t type); +void LogLinkTypeDefinition(type_t type, type_t source, type_t dest); +void LogEntityValue (val_t value); +void LogContainerCreation (container_t container); +void LogContainerDestruction (container_t container); + #endif