X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7d002fc71f86ae6e429f611deffc33dceb18b31c..c5418e2f161ecfa4af596fb3d25e8ac696935af3:/src/instr/instr_paje_trace.cpp diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index cab9eefca8..84c6059dea 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -6,7 +6,7 @@ #include "src/instr/instr_private.h" #include "src/instr/instr_smpi.h" -#include "src/smpi/private.hpp" +#include "src/smpi/include/private.hpp" #include "typeinfo" #include "xbt/virtu.h" /* sg_cmdline */ #include "simgrid/sg_config.h" @@ -27,12 +27,6 @@ FILE *tracing_file = nullptr; static xbt_dict_t tracing_files = nullptr; // TI specific static double prefix=0.0; // TI specific - -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 */ - std::vector buffer; void buffer_debug(std::vector *buf); @@ -74,14 +68,14 @@ void TRACE_paje_dump_buffer (int force) return; XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump); if (force){ - for (auto event : buffer){ + for (auto const& event : buffer) { event->print(); delete event; } buffer.clear(); }else{ std::vector::iterator i = buffer.begin(); - for (auto event :buffer){ + for (auto const& event : buffer) { double head_timestamp = event->timestamp; if (head_timestamp > TRACE_last_timestamp_to_dump) break; @@ -98,7 +92,7 @@ void buffer_debug(std::vector *buf); void buffer_debug(std::vector *buf) { return; XBT_DEBUG(">>>>>> Dump the state of the buffer. %zu events", buf->size()); - for (auto event :*buf){ + for (auto const& event : *buf) { event->print(); XBT_DEBUG("%p %s", event, stream.str().c_str()); stream.str(""); @@ -120,9 +114,9 @@ static void print_timestamp(PajeEvent* event) { /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */ if (event->timestamp < 1e-12) stream << 0; - else + else stream << event->timestamp; -} +} /* internal do the instrumentation module */ static void insert_into_buffer (PajeEvent* tbi) @@ -160,20 +154,6 @@ PajeEvent:: ~PajeEvent() { XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__, this, (int)event_type, timestamp); -// xbt_backtrace_display_current(); - - /* switch (event->event_type){ - case PAJE_StartLink: - xbt_free (((startLink_t)(event->data))->value); - xbt_free (((startLink_t)(event->data))->key); - break; - case PAJE_EndLink: - xbt_free (((endLink_t)(event->data))->value); - xbt_free (((endLink_t)(event->data))->key); - break; - default: - break; - }*/ } void TRACE_paje_start() { @@ -212,42 +192,34 @@ void TRACE_paje_end() { XBT_DEBUG("Filename %s is closed", filename); } -void DefineContainerEvent(type_t type) +void DefineContainerEvent(Type* type) { - e_event_type event_type = PAJE_DefineContainerType; - double timestamp = 0; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineContainerType); //print it 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; - } + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineContainerType, TRACE_precision(), 0.); + stream << std::fixed << std::setprecision(TRACE_precision()); + stream << PAJE_DefineContainerType; + 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 DefineVariableTypeEvent(type_t type) +void LogVariableTypeDefinition(Type* type) { - e_event_type event_type = PAJE_DefineVariableType; - double timestamp = 0; - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); + XBT_DEBUG("%s: event_type=%d", __FUNCTION__, PAJE_DefineVariableType); //print it if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineVariableType, TRACE_precision(), 0.); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)event_type; + stream << PAJE_DefineVariableType; stream << " " << type->id << " " << type->father->id << " " << type->name; if (type->color) stream << " \"" << type->color << "\""; @@ -259,39 +231,13 @@ if (instr_fmt_type == instr_fmt_paje) { } } - -DefineStateTypeEvent::DefineStateTypeEvent(type_t type) +void LogStateTypeDefinition(Type* type) { - this->event_type = PAJE_DefineStateType; - this->timestamp = 0; - this->type = type; - - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); - //print it - print(); - delete this; -} - - -DefineEventTypeEvent::DefineEventTypeEvent(type_t type) -{ - this->event_type = PAJE_DefineEventType; - this->timestamp = 0; - this->type = type; - - XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type); - - //print it - print(); -} - - -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); +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 << (int)this->event_type; + stream << PAJE_DefineStateType; stream << " " << type->id << " " << type->father->id << " " << type->name; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { @@ -301,11 +247,13 @@ void DefineStateTypeEvent::print() { } } -void DefineEventTypeEvent::print() { +void LogDefineEventType(Type* type) +{ + //print it if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp); + XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, PAJE_DefineEventType, TRACE_precision(), 0.); stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; + stream << PAJE_DefineEventType; stream << " " << type->id << " " << type->father->id << " " << type->name; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { @@ -315,26 +263,14 @@ void DefineEventTypeEvent::print() { } } -DefineLinkTypeEvent::DefineLinkTypeEvent(type_t type, type_t source, type_t dest) +void LogLinkTypeDefinition(Type* type, Type* source, Type* 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) { @@ -344,28 +280,16 @@ void DefineLinkTypeEvent::print() { } } -DefineEntityValueEvent::DefineEntityValueEvent (val_t value) +void LogEntityValue(Value* val) { - 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) { stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - stream << " " << value->id << " " << value->father->id << " " << value->name; - if (value->color) - stream << " \"" << value->color << "\""; + stream << PAJE_DefineEntityValue; + stream << " " << val->id << " " << val->father->id << " " << val->name; + if (val->color) + stream << " \"" << val->color << "\""; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */ @@ -374,24 +298,22 @@ void DefineEntityValueEvent::print() { } } -CreateContainerEvent::CreateContainerEvent (container_t container) + +void LogContainerCreation (container_t container) { - this->event_type = PAJE_CreateContainer; - 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_CreateContainer,timestamp); - print(); - delete this; -} - -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) { stream << std::fixed << std::setprecision(TRACE_precision()); - stream << (int)this->event_type; - print_timestamp(this); + 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 << "\""; @@ -428,26 +350,22 @@ 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) { 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) { @@ -460,7 +378,8 @@ void DestroyContainerEvent::print() { } } -SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value) + +SetVariableEvent::SetVariableEvent (double timestamp, container_t container, Type* type, double value) { this->event_type = PAJE_SetVariable; this->timestamp = timestamp; @@ -488,7 +407,7 @@ void SetVariableEvent::print() { } } -AddVariableEvent::AddVariableEvent (double timestamp, container_t container, type_t type, double value) +AddVariableEvent::AddVariableEvent (double timestamp, container_t container, Type* type, double value) { this->event_type = PAJE_AddVariable; this->timestamp = timestamp; @@ -516,7 +435,7 @@ void AddVariableEvent::print() { } } -SubVariableEvent::SubVariableEvent (double timestamp, container_t container, type_t type, double value) +SubVariableEvent::SubVariableEvent (double timestamp, container_t container, Type* type, double value) { this->event_type = PAJE_SubVariable; this->timestamp = timestamp; @@ -544,13 +463,13 @@ void SubVariableEvent::print() { } } -SetStateEvent::SetStateEvent (double timestamp, container_t container, type_t type, val_t value) +SetStateEvent::SetStateEvent(double timestamp, container_t container, Type* type, Value* val) { this->event_type = PAJE_SetState; this->timestamp = timestamp; this->type = type; this->container = container; - this->value = value; + this->val = val; #if HAVE_SMPI if (xbt_cfg_get_boolean("smpi/trace-call-location")) { @@ -572,7 +491,7 @@ void SetStateEvent::print() { stream << (int)this->event_type; print_timestamp(this); stream << " " << type->id << " " << container->id; - stream << " " << value->id; + stream << " " << val->id; #if HAVE_SMPI if (xbt_cfg_get_boolean("smpi/trace-call-location")) { stream << " \"" << filename << "\" " << linenumber; @@ -586,13 +505,13 @@ void SetStateEvent::print() { } } -PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value, void* extra) +PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val, void* extra) { this->event_type = PAJE_PushState; this->timestamp = timestamp; this->type = type; this->container = container; - this->value = value; + this->val = val; this->extra_ = extra; #if HAVE_SMPI @@ -608,8 +527,8 @@ PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t insert_into_buffer (this); } -PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value) - : PushStateEvent(timestamp, container, type, value, nullptr) +PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, Value* val) + : PushStateEvent(timestamp, container, type, val, nullptr) {} void PushStateEvent::print() { if (instr_fmt_type == instr_fmt_paje) { @@ -618,7 +537,7 @@ void PushStateEvent::print() { stream << (int)this->event_type; print_timestamp(this); stream << " " << type->id << " " << container->id; - stream << " " << value->id; + stream << " " << val->id; if (TRACE_display_sizes()) { stream << " "; @@ -744,11 +663,13 @@ void PushStateEvent::print() { fprintf(trace_file, "%d ", extra->recvcounts[i]); fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2); break; + case TRACING_ALLGATHER: // rank allgather sendcount recvcounts (sendtype) (recvtype) + fprintf(trace_file, "%s allGather %d %d %s %s", process_id, extra->send_size, extra->recv_size, extra->datatype1, extra->datatype2); + break; case TRACING_WAITANY: case TRACING_SENDRECV: case TRACING_SCATTER: case TRACING_SCATTERV: - case TRACING_ALLGATHER: case TRACING_SCAN: case TRACING_EXSCAN: case TRACING_COMM_SIZE: @@ -757,7 +678,7 @@ void PushStateEvent::print() { case TRACING_SSEND: case TRACING_ISSEND: default: - XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->name); + XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", val->name); break; } @@ -774,7 +695,7 @@ void PushStateEvent::print() { } -PopStateEvent::PopStateEvent (double timestamp, container_t container, type_t type) +PopStateEvent::PopStateEvent (double timestamp, container_t container, Type* type) { this->event_type = PAJE_PopState; this->timestamp = timestamp; @@ -801,7 +722,7 @@ void PopStateEvent::print() { } } -ResetStateEvent::ResetStateEvent (double timestamp, container_t container, type_t type) +ResetStateEvent::ResetStateEvent (double timestamp, container_t container, Type* type) { this->event_type = PAJE_ResetState; this->timestamp = timestamp; @@ -811,7 +732,7 @@ ResetStateEvent::ResetStateEvent (double timestamp, container_t container, type_ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); insert_into_buffer (this); - delete [] this; + delete[] this; } void ResetStateEvent::print() { @@ -835,11 +756,11 @@ StartLinkEvent::~StartLinkEvent() free(key); } StartLinkEvent::StartLinkEvent (double timestamp, container_t container, - type_t type, container_t sourceContainer, const char *value, const char *key) + Type* type, container_t sourceContainer, const char *value, const char *key) : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1) {} -StartLinkEvent::StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer, +StartLinkEvent::StartLinkEvent (double timestamp, container_t container, Type* type, container_t sourceContainer, const char *value, const char *key, int size) { event_type = PAJE_StartLink; @@ -877,7 +798,7 @@ void StartLinkEvent::print() { } } -EndLinkEvent::EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer, +EndLinkEvent::EndLinkEvent (double timestamp, container_t container, Type* type, container_t destContainer, const char *value, const char *key) { this->event_type = PAJE_EndLink; @@ -914,13 +835,13 @@ void EndLinkEvent::print() { } } -NewEvent::NewEvent (double timestamp, container_t container, type_t type, val_t value) +NewEvent::NewEvent(double timestamp, container_t container, Type* type, Value* val) { this->event_type = PAJE_NewEvent; this->timestamp = timestamp; this->type = type; this->container = container; - this->value = value; + this->val = val; XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp); @@ -933,7 +854,7 @@ void NewEvent::print () { stream << std::fixed << std::setprecision(TRACE_precision()); stream << (int)this->event_type; print_timestamp(this); - stream << " " << type->id << " " << container->id << " " << value->id; + stream << " " << type->id << " " << container->id << " " << val->id; print_row(); } else if (instr_fmt_type == instr_fmt_TI) { /* Nothing to do */