From: Frederic Suter Date: Fri, 27 Oct 2017 16:10:20 +0000 (+0200) Subject: rework State related events X-Git-Tag: v3.18~378 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7adf7d3cc45bf13462b257c7e3bc8a2eae2bf981?hp=a556249b944206d2eed1e775c537caf5d3397206 rework State related events --- diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index 7bcae37cb1..0182dd2122 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -944,7 +944,7 @@ void TRACE_host_set_state(const char* host, const char* state_name, const char* container_t container = simgrid::instr::Container::byName(host); simgrid::instr::StateType* state = static_cast(container->type_->byName(state_name)); state->addEntityValue(value_name); - new simgrid::instr::SetStateEvent(MSG_get_clock(), container, state, state->getEntityValue(value_name)); + state->setEvent(MSG_get_clock(), container, value_name); } /** \ingroup TRACE_user_variables @@ -963,7 +963,7 @@ void TRACE_host_push_state(const char* host, const char* state_name, const char* container_t container = simgrid::instr::Container::byName(host); simgrid::instr::StateType* state = static_cast(container->type_->byName(state_name)); state->addEntityValue(value_name); - new simgrid::instr::PushStateEvent(MSG_get_clock(), container, state, state->getEntityValue(value_name)); + state->pushEvent(MSG_get_clock(), container, value_name); } /** \ingroup TRACE_user_variables @@ -976,11 +976,11 @@ void TRACE_host_push_state(const char* host, const char* state_name, const char* * * \see TRACE_host_state_declare, TRACE_host_set_state, TRACE_host_push_state, TRACE_host_reset_state */ -void TRACE_host_pop_state (const char *host, const char *state) +void TRACE_host_pop_state(const char* host, const char* state_name) { container_t container = simgrid::instr::Container::byName(host); - simgrid::instr::Type* type = container->type_->byName(state); - new simgrid::instr::PopStateEvent(MSG_get_clock(), container, type); + simgrid::instr::StateType* state = static_cast(container->type_->byName(state_name)); + state->popEvent(MSG_get_clock(), container); } /** \ingroup TRACE_API diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index 26b51e8001..2b16c72199 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -188,7 +188,6 @@ void Container::logCreation() xbt_free(folder_name); xbt_free(filename); } - tracing_files.insert({this, ti_unique_file}); } else { THROW_IMPOSSIBLE; diff --git a/src/instr/instr_paje_events.cpp b/src/instr/instr_paje_events.cpp new file mode 100644 index 0000000000..7997d0f643 --- /dev/null +++ b/src/instr/instr_paje_events.cpp @@ -0,0 +1,210 @@ +/* Copyright (c) 2012-2017. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#include "src/instr/instr_private.hpp" +#include "src/instr/instr_smpi.hpp" +#include "src/smpi/include/private.hpp" + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_events, instr, "Paje tracing event system (events)"); +extern FILE* tracing_file; +std::map tracing_files; // TI specific + +namespace simgrid { +namespace instr { + +StateEvent::StateEvent(double timestamp, Container* container, Type* type, e_event_type event_type, EntityValue* value) + : StateEvent(timestamp, container, type, event_type, value, nullptr) +{ +} + +StateEvent::StateEvent(double timestamp, Container* container, Type* type, e_event_type event_type, EntityValue* value, + void* extra) + : PajeEvent::PajeEvent(container, type, timestamp, event_type), value(value), extra_(extra) +{ +#if HAVE_SMPI + if (xbt_cfg_get_boolean("smpi/trace-call-location")) { + smpi_trace_call_location_t* loc = smpi_trace_get_call_location(); + filename = loc->filename; + linenumber = loc->linenumber; + } +#endif + + XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, timestamp_); + insertIntoBuffer(); +}; + +void StateEvent::print() +{ + std::stringstream stream; + stream << std::fixed << std::setprecision(TRACE_precision()); + XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_); + if (instr_fmt_type == instr_fmt_paje) { + if (timestamp_ < 1e-12) + stream << eventType_ << " " << 0 << " " << type->getId() << " " << container->getId(); + else + stream << eventType_ << " " << timestamp_ << " " << type->getId() << " " << container->getId(); + + if (value != nullptr) // PAJE_PopState Event does not need to have a value + stream << " " << value->getId(); + + if (TRACE_display_sizes()) { + stream << " "; + if (extra_ != nullptr) { + stream << static_cast(extra_)->send_size; + } else { + stream << 0; + } + } +#if HAVE_SMPI + if (xbt_cfg_get_boolean("smpi/trace-call-location")) { + stream << " \"" << filename << "\" " << linenumber; + } +#endif + XBT_DEBUG("Dump %s", stream.str().c_str()); + fprintf(tracing_file, "%s\n", stream.str().c_str()); + + if (extra_ != nullptr) { + if (static_cast(extra_)->sendcounts != nullptr) + xbt_free(static_cast(extra_)->sendcounts); + if (static_cast(extra_)->recvcounts != nullptr) + xbt_free(static_cast(extra_)->recvcounts); + xbt_free(extra_); + } + } else if (instr_fmt_type == instr_fmt_TI) { + if (extra_ == nullptr) + return; + instr_extra_data extra = (instr_extra_data)extra_; + + char* process_id = nullptr; + // FIXME: dirty extract "rank-" from the name, as we want the bare process id here + if (container->getName().find("rank-") != 0) + process_id = xbt_strdup(container->getCname()); + else + process_id = xbt_strdup(container->getCname() + 5); + + FILE* trace_file = tracing_files.at(container); + + switch (extra->type) { + case TRACING_INIT: + fprintf(trace_file, "%s init\n", process_id); + break; + case TRACING_FINALIZE: + fprintf(trace_file, "%s finalize\n", process_id); + break; + case TRACING_SEND: + fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1); + break; + case TRACING_ISEND: + fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1); + break; + case TRACING_RECV: + fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1); + break; + case TRACING_IRECV: + fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1); + break; + case TRACING_TEST: + fprintf(trace_file, "%s test\n", process_id); + break; + case TRACING_WAIT: + fprintf(trace_file, "%s wait\n", process_id); + break; + case TRACING_WAITALL: + fprintf(trace_file, "%s waitAll\n", process_id); + break; + case TRACING_BARRIER: + fprintf(trace_file, "%s barrier\n", process_id); + break; + case TRACING_BCAST: // rank bcast size (root) (datatype) + fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size); + if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, ""))) + fprintf(trace_file, "%d %s", extra->root, extra->datatype1); + fprintf(trace_file, "\n"); + break; + case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype) + fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size); + if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, ""))) + fprintf(trace_file, "%d %s", extra->root, extra->datatype1); + fprintf(trace_file, "\n"); + break; + case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype) + fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size, + extra->datatype1); + break; + case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype) + fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, + extra->datatype1, extra->datatype2); + break; + case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype) + fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size); + for (int i = 0; i < extra->num_processes; i++) + fprintf(trace_file, "%d ", extra->sendcounts[i]); + fprintf(trace_file, "%d ", extra->recv_size); + for (int i = 0; i < extra->num_processes; i++) + fprintf(trace_file, "%d ", extra->recvcounts[i]); + fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2); + break; + case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype) + fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root, + extra->datatype1, extra->datatype2); + break; + case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype) + fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size); + for (int i = 0; i < extra->num_processes; i++) + fprintf(trace_file, "%d ", extra->recvcounts[i]); + fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2); + break; + case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype) + fprintf(trace_file, "%s reduceScatter ", process_id); + for (int i = 0; i < extra->num_processes; i++) + fprintf(trace_file, "%d ", extra->recvcounts[i]); + fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1); + break; + case TRACING_COMPUTING: + fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size); + break; + case TRACING_SLEEPING: + fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration); + break; + case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype) + fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size); + for (int i = 0; i < extra->num_processes; i++) + 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_SCAN: + case TRACING_EXSCAN: + case TRACING_COMM_SIZE: + case TRACING_COMM_SPLIT: + case TRACING_COMM_DUP: + case TRACING_SSEND: + case TRACING_ISSEND: + default: + XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->getCname()); + break; + } + + if (extra->recvcounts != nullptr) + xbt_free(extra->recvcounts); + if (extra->sendcounts != nullptr) + xbt_free(extra->sendcounts); + xbt_free(process_id); + xbt_free(extra); + + } else { + THROW_IMPOSSIBLE; + } +} +} +} diff --git a/src/instr/instr_paje_trace.cpp b/src/instr/instr_paje_trace.cpp index e4dfaa390c..255c28e299 100644 --- a/src/instr/instr_paje_trace.cpp +++ b/src/instr/instr_paje_trace.cpp @@ -17,8 +17,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "tracing event system") static std::stringstream stream; FILE *tracing_file = nullptr; -std::map tracing_files; // TI specific - std::vector buffer; void buffer_debug(std::vector* buf); @@ -247,277 +245,6 @@ void simgrid::instr::SubVariableEvent::print() } } -simgrid::instr::SetStateEvent::SetStateEvent(double timestamp, container_t container, Type* type, EntityValue* value) - : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_SetState), value(value) -{ -#if HAVE_SMPI - if (xbt_cfg_get_boolean("smpi/trace-call-location")) { - smpi_trace_call_location_t* loc = smpi_trace_get_call_location(); - filename = loc->filename; - linenumber = loc->linenumber; - } -#endif - - XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_); - insertIntoBuffer(); -} - -void simgrid::instr::SetStateEvent::print() -{ - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << eventType_; - print_timestamp(this); - stream << " " << type->getId() << " " << container->getId(); - stream << " " << value->getId(); -#if HAVE_SMPI - if (xbt_cfg_get_boolean("smpi/trace-call-location")) { - stream << " \"" << filename << "\" " << linenumber; - } -#endif - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } -} - -simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, EntityValue* value, - void* extra) - : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PushState), value(value), extra_(extra) -{ -#if HAVE_SMPI - if (xbt_cfg_get_boolean("smpi/trace-call-location")) { - smpi_trace_call_location_t* loc = smpi_trace_get_call_location(); - filename = loc->filename; - linenumber = loc->linenumber; - } -#endif - - XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_); - - insertIntoBuffer(); -} - -simgrid::instr::PushStateEvent::PushStateEvent(double timestamp, container_t container, Type* type, EntityValue* val) - : PushStateEvent(timestamp, container, type, val, nullptr) -{} - -void simgrid::instr::PushStateEvent::print() -{ - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << eventType_; - print_timestamp(this); - stream << " " << type->getId() << " " << container->getId(); - stream << " " << value->getId(); - - if (TRACE_display_sizes()) { - stream << " "; - if (extra_ != nullptr) { - stream << static_cast(extra_)->send_size; - } else { - stream << 0; - } - } -#if HAVE_SMPI - if (xbt_cfg_get_boolean("smpi/trace-call-location")) { - stream << " \"" << filename << "\" " << linenumber; - } -#endif - print_row(); - - if (extra_ != nullptr) { - if (static_cast(extra_)->sendcounts != nullptr) - xbt_free(static_cast(extra_)->sendcounts); - if (static_cast(extra_)->recvcounts != nullptr) - xbt_free(static_cast(extra_)->recvcounts); - xbt_free(extra_); - } - } else if (instr_fmt_type == instr_fmt_TI) { - if (extra_ == nullptr) - return; - instr_extra_data extra = (instr_extra_data)extra_; - - char* process_id = nullptr; - // FIXME: dirty extract "rank-" from the name, as we want the bare process id here - if (container->getName().find("rank-") != 0) - process_id = xbt_strdup(container->getCname()); - else - process_id = xbt_strdup(container->getCname() + 5); - - FILE* trace_file = tracing_files.at(container); - - switch (extra->type) { - case TRACING_INIT: - fprintf(trace_file, "%s init\n", process_id); - break; - case TRACING_FINALIZE: - fprintf(trace_file, "%s finalize\n", process_id); - break; - case TRACING_SEND: - fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1); - break; - case TRACING_ISEND: - fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1); - break; - case TRACING_RECV: - fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1); - break; - case TRACING_IRECV: - fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1); - break; - case TRACING_TEST: - fprintf(trace_file, "%s test\n", process_id); - break; - case TRACING_WAIT: - fprintf(trace_file, "%s wait\n", process_id); - break; - case TRACING_WAITALL: - fprintf(trace_file, "%s waitAll\n", process_id); - break; - case TRACING_BARRIER: - fprintf(trace_file, "%s barrier\n", process_id); - break; - case TRACING_BCAST: // rank bcast size (root) (datatype) - fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size); - if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, ""))) - fprintf(trace_file, "%d %s", extra->root, extra->datatype1); - fprintf(trace_file, "\n"); - break; - case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype) - fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size); - if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, ""))) - fprintf(trace_file, "%d %s", extra->root, extra->datatype1); - fprintf(trace_file, "\n"); - break; - case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype) - fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size, - extra->datatype1); - break; - case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype) - fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, - extra->datatype1, extra->datatype2); - break; - case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype) - fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size); - for (int i = 0; i < extra->num_processes; i++) - fprintf(trace_file, "%d ", extra->sendcounts[i]); - fprintf(trace_file, "%d ", extra->recv_size); - for (int i = 0; i < extra->num_processes; i++) - fprintf(trace_file, "%d ", extra->recvcounts[i]); - fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2); - break; - case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype) - fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root, - extra->datatype1, extra->datatype2); - break; - case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype) - fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size); - for (int i = 0; i < extra->num_processes; i++) - fprintf(trace_file, "%d ", extra->recvcounts[i]); - fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2); - break; - case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype) - fprintf(trace_file, "%s reduceScatter ", process_id); - for (int i = 0; i < extra->num_processes; i++) - fprintf(trace_file, "%d ", extra->recvcounts[i]); - fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1); - break; - case TRACING_COMPUTING: - fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size); - break; - case TRACING_SLEEPING: - fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration); - break; - case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype) - fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size); - for (int i = 0; i < extra->num_processes; i++) - 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_SCAN: - case TRACING_EXSCAN: - case TRACING_COMM_SIZE: - case TRACING_COMM_SPLIT: - case TRACING_COMM_DUP: - case TRACING_SSEND: - case TRACING_ISSEND: - default: - XBT_WARN("Call from %s impossible to translate into replay command : Not implemented (yet)", value->getCname()); - break; - } - - if (extra->recvcounts != nullptr) - xbt_free(extra->recvcounts); - if (extra->sendcounts != nullptr) - xbt_free(extra->sendcounts); - xbt_free(process_id); - xbt_free(extra); - - } else { - THROW_IMPOSSIBLE; - } -} - -simgrid::instr::PopStateEvent::PopStateEvent(double timestamp, container_t container, Type* type) - : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_PopState) -{ - XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_); - insertIntoBuffer(); -} - -void simgrid::instr::PopStateEvent::print() -{ - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << eventType_; - print_timestamp(this); - stream << " " << type->getId() << " " << container->getId(); - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } -} - -simgrid::instr::ResetStateEvent::ResetStateEvent(double timestamp, container_t container, Type* type) - : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_ResetState) -{ - XBT_DEBUG("%s: event_type=%u, timestamp=%f", __FUNCTION__, eventType_, this->timestamp_); - insertIntoBuffer(); - delete[] this; -} - -void simgrid::instr::ResetStateEvent::print() -{ - if (instr_fmt_type == instr_fmt_paje) { - XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __FUNCTION__, eventType_, TRACE_precision(), timestamp_); - stream << std::fixed << std::setprecision(TRACE_precision()); - stream << eventType_; - print_timestamp(this); - stream << " " << type->getId() << " " << container->getId(); - print_row(); - } else if (instr_fmt_type == instr_fmt_TI) { - /* Nothing to do */ - } else { - THROW_IMPOSSIBLE; - } -} - simgrid::instr::StartLinkEvent::StartLinkEvent(double timestamp, container_t container, Type* type, container_t sourceContainer, std::string value, std::string key) : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1) diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index 91ab9374ce..f86eb05c94 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -56,6 +56,31 @@ StateType::StateType(std::string name, Type* father) : ValueType(name, father) logDefinition(PAJE_DefineStateType); } +StateType::~StateType() +{ + events_.clear(); +} + +void StateType::setEvent(double timestamp, Container* container, std::string value_name) +{ + events_.push_back(new StateEvent(timestamp, container, this, PAJE_SetState, getEntityValue(value_name))); +} + +void StateType::pushEvent(double timestamp, Container* container, std::string value_name, void* extra) +{ + events_.push_back(new StateEvent(timestamp, container, this, PAJE_PushState, getEntityValue(value_name), extra)); +} + +void StateType::pushEvent(double timestamp, Container* container, std::string value_name) +{ + events_.push_back(new StateEvent(timestamp, container, this, PAJE_PushState, getEntityValue(value_name))); +} + +void StateType::popEvent(double timestamp, Container* container) +{ + events_.push_back(new StateEvent(timestamp, container, this, PAJE_PopState, nullptr)); +} + VariableType::VariableType(std::string name, std::string color, Type* father) : Type(name, name, color, father) { XBT_DEBUG("VariableType %s(%lld), child of %s(%lld)", getCname(), getId(), father->getCname(), father->getId()); diff --git a/src/instr/instr_paje_types.hpp b/src/instr/instr_paje_types.hpp index dca29b3835..c487ed0e29 100644 --- a/src/instr/instr_paje_types.hpp +++ b/src/instr/instr_paje_types.hpp @@ -8,6 +8,7 @@ #include "src/instr/instr_private.hpp" #include +#include namespace simgrid { namespace instr { @@ -18,6 +19,7 @@ class EventType; class LinkType; class StateType; class VariableType; +class StateEvent; class Type { long long int id_; @@ -83,8 +85,15 @@ public: }; class StateType : public ValueType { + std::vector events_; + public: StateType(std::string name, Type* father); + ~StateType(); + void setEvent(double timestamp, Container* container, std::string value_name); + void pushEvent(double timestamp, Container* container, std::string value_name); + void pushEvent(double timestamp, Container* container, std::string value_name, void* extra); + void popEvent(double timestamp, Container* container); }; } } diff --git a/src/instr/instr_private.hpp b/src/instr/instr_private.hpp index 94494fb63e..4a9433bab0 100644 --- a/src/instr/instr_private.hpp +++ b/src/instr/instr_private.hpp @@ -114,37 +114,16 @@ public: void print() override; }; -class SetStateEvent : public PajeEvent { +class StateEvent : public PajeEvent { EntityValue* value; std::string filename; int linenumber; + void* extra_ = nullptr; public: - SetStateEvent(double timestamp, Container* container, Type* type, EntityValue* val); - void print() override; -}; - -class PushStateEvent : public PajeEvent { - EntityValue* value; - std::string filename; - int linenumber; - void* extra_; - -public: - PushStateEvent(double timestamp, Container* container, Type* type, EntityValue* val); - PushStateEvent(double timestamp, Container* container, Type* type, EntityValue* val, void* extra); - void print() override; -}; - -class PopStateEvent : public PajeEvent { -public: - PopStateEvent(double timestamp, Container* container, Type* type); - void print() override; -}; - -class ResetStateEvent : public PajeEvent { -public: - ResetStateEvent(double timestamp, Container* container, Type* type); + StateEvent(double timestamp, Container* container, Type* type, e_event_type event_type, EntityValue* value); + StateEvent(double timestamp, Container* container, Type* type, e_event_type event_type, EntityValue* value, + void* extra); void print() override; }; diff --git a/src/msg/instr_msg_process.cpp b/src/msg/instr_msg_process.cpp index 5e621ae13a..4a6eedc576 100644 --- a/src/msg/instr_msg_process.cpp +++ b/src/msg/instr_msg_process.cpp @@ -77,8 +77,7 @@ void TRACE_msg_process_suspend(msg_process_t process) container_t process_container = simgrid::instr::Container::byName(instr_process_id(process)); simgrid::instr::StateType* state = static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); - simgrid::instr::EntityValue* val = state->getEntityValue("suspend"); - new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val); + state->pushEvent(MSG_get_clock(), process_container, "suspend"); } } @@ -86,8 +85,9 @@ void TRACE_msg_process_resume(msg_process_t process) { if (TRACE_msg_process_is_enabled()){ container_t process_container = simgrid::instr::Container::byName(instr_process_id(process)); - simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE"); - new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type); + simgrid::instr::StateType* state = + static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); + state->popEvent(MSG_get_clock(), process_container); } } @@ -97,8 +97,7 @@ void TRACE_msg_process_sleep_in(msg_process_t process) container_t process_container = simgrid::instr::Container::byName(instr_process_id(process)); simgrid::instr::StateType* state = static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); - simgrid::instr::EntityValue* val = state->getEntityValue("sleep"); - new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val); + state->pushEvent(MSG_get_clock(), process_container, "sleep"); } } @@ -106,7 +105,8 @@ void TRACE_msg_process_sleep_out(msg_process_t process) { if (TRACE_msg_process_is_enabled()){ container_t process_container = simgrid::instr::Container::byName(instr_process_id(process)); - simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE"); - new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type); + simgrid::instr::StateType* state = + static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); + state->popEvent(MSG_get_clock(), process_container); } } diff --git a/src/msg/instr_msg_task.cpp b/src/msg/instr_msg_task.cpp index 10214709c8..166e199d61 100644 --- a/src/msg/instr_msg_task.cpp +++ b/src/msg/instr_msg_task.cpp @@ -52,8 +52,7 @@ void TRACE_msg_task_execute_start(msg_task_t task) container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self())); simgrid::instr::StateType* state = static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); - simgrid::instr::EntityValue* val = state->getEntityValue("task_execute"); - new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val); + state->pushEvent(MSG_get_clock(), process_container, "task_execute"); } } @@ -63,8 +62,9 @@ void TRACE_msg_task_execute_end(msg_task_t task) if (TRACE_msg_process_is_enabled()){ container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self())); - simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE"); - new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type); + simgrid::instr::StateType* state = + static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); + state->popEvent(MSG_get_clock(), process_container); } } @@ -87,8 +87,7 @@ void TRACE_msg_task_get_start() container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self())); simgrid::instr::StateType* state = static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); - simgrid::instr::EntityValue* val = state->getEntityValue("receive"); - new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val); + state->pushEvent(MSG_get_clock(), process_container, "receive"); } } @@ -98,11 +97,12 @@ void TRACE_msg_task_get_end(double start_time, msg_task_t task) if (TRACE_msg_process_is_enabled()){ container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self())); - simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE"); - new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type); + simgrid::instr::StateType* state = + static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); + state->popEvent(MSG_get_clock(), process_container); std::string key = std::string("p") + std::to_string(task->counter); - type = simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_TASK_LINK"); + simgrid::instr::Type* type = simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_TASK_LINK"); new simgrid::instr::EndLinkEvent(MSG_get_clock(), simgrid::instr::Container::getRootContainer(), type, process_container, "SR", key); } @@ -117,8 +117,7 @@ int TRACE_msg_task_put_start(msg_task_t task) container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self())); simgrid::instr::StateType* state = static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); - simgrid::instr::EntityValue* val = state->getEntityValue("send"); - new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, state, val); + state->pushEvent(MSG_get_clock(), process_container, "send"); std::string key = std::string("p") + std::to_string(task->counter); simgrid::instr::LinkType* type = @@ -136,7 +135,8 @@ void TRACE_msg_task_put_end() if (TRACE_msg_process_is_enabled()){ container_t process_container = simgrid::instr::Container::byName(instr_process_id(MSG_process_self())); - simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE"); - new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type); + simgrid::instr::StateType* state = + static_cast(process_container->type_->byName("MSG_PROCESS_STATE")); + state->popEvent(MSG_get_clock(), process_container); } } diff --git a/src/msg/msg_vm.cpp b/src/msg/msg_vm.cpp index bbbfb1a5a4..ce7c0a4e5d 100644 --- a/src/msg/msg_vm.cpp +++ b/src/msg/msg_vm.cpp @@ -189,7 +189,7 @@ void MSG_vm_start(msg_vm_t vm) simgrid::instr::StateType* state = static_cast(vm_container->type_->byName("MSG_VM_STATE")); state->addEntityValue("start", "0 0 1"); // start is blue - new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, state, state->getEntityValue("start")); + state->pushEvent(MSG_get_clock(), vm_container, "start"); } } @@ -773,7 +773,7 @@ void MSG_vm_suspend(msg_vm_t vm) simgrid::instr::StateType* state = static_cast(vm_container->type_->byName("MSG_VM_STATE")); state->addEntityValue("suspend", "1 0 0"); // suspend is red - new simgrid::instr::PushStateEvent(MSG_get_clock(), vm_container, state, state->getEntityValue("suspend")); + state->pushEvent(MSG_get_clock(), vm_container, "suspend"); } } @@ -788,8 +788,9 @@ void MSG_vm_resume(msg_vm_t vm) if (TRACE_msg_vm_is_enabled()) { container_t vm_container = simgrid::instr::Container::byName(vm->getName()); - simgrid::instr::Type* type = vm_container->type_->byName("MSG_VM_STATE"); - new simgrid::instr::PopStateEvent(MSG_get_clock(), vm_container, type); + simgrid::instr::StateType* state = + static_cast(vm_container->type_->byName("MSG_VM_STATE")); + state->popEvent(MSG_get_clock(), vm_container); } } diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index 5985693348..5c9cf7daa2 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -201,8 +201,7 @@ void TRACE_smpi_collective_in(int rank, const char *operation, instr_extra_data simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); const char *color = instr_find_color (operation); state->addEntityValue(operation, color); - new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue(operation), - static_cast(extra)); + state->pushEvent(SIMIX_get_clock(), container, operation, static_cast(extra)); } void TRACE_smpi_collective_out(int rank, const char *operation) @@ -211,9 +210,8 @@ void TRACE_smpi_collective_out(int rank, const char *operation) return; container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* type = container->type_->byName("MPI_STATE"); - - new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); + state->popEvent(SIMIX_get_clock(), container); } void TRACE_smpi_computing_init(int rank) @@ -225,7 +223,7 @@ void TRACE_smpi_computing_init(int rank) container_t container = simgrid::instr::Container::byName(smpi_container(rank)); simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); state->addEntityValue("computing", instr_find_color("computing")); - new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("computing")); + state->pushEvent(SIMIX_get_clock(), container, "computing"); } void TRACE_smpi_computing_in(int rank, instr_extra_data extra) @@ -239,8 +237,7 @@ void TRACE_smpi_computing_in(int rank, instr_extra_data extra) container_t container = simgrid::instr::Container::byName(smpi_container(rank)); simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); state->addEntityValue("computing"); - new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("computing"), - static_cast(extra)); + state->pushEvent(SIMIX_get_clock(), container, "computing", static_cast(extra)); } void TRACE_smpi_computing_out(int rank) @@ -249,8 +246,8 @@ void TRACE_smpi_computing_out(int rank) return; container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* type = container->type_->byName("MPI_STATE"); - new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); + state->popEvent(SIMIX_get_clock(), container); } void TRACE_smpi_sleeping_init(int rank) @@ -262,7 +259,7 @@ void TRACE_smpi_sleeping_init(int rank) container_t container = simgrid::instr::Container::byName(smpi_container(rank)); simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); state->addEntityValue("sleeping", instr_find_color("sleeping")); - new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("sleeping")); + state->pushEvent(SIMIX_get_clock(), container, "sleeping"); } void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra) @@ -276,8 +273,7 @@ void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra) container_t container = simgrid::instr::Container::byName(smpi_container(rank)); simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); state->addEntityValue("sleeping"); - new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("sleeping"), - static_cast(extra)); + state->pushEvent(SIMIX_get_clock(), container, "sleeping", static_cast(extra)); } void TRACE_smpi_sleeping_out(int rank) @@ -286,8 +282,8 @@ void TRACE_smpi_sleeping_out(int rank) return; container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* type = container->type_->byName("MPI_STATE"); - new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); + state->popEvent(SIMIX_get_clock(), container); } void TRACE_smpi_testing_in(int rank, instr_extra_data extra) @@ -301,8 +297,7 @@ void TRACE_smpi_testing_in(int rank, instr_extra_data extra) container_t container = simgrid::instr::Container::byName(smpi_container(rank)); simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); state->addEntityValue("test"); - new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue("test"), - static_cast(extra)); + state->pushEvent(SIMIX_get_clock(), container, "test", static_cast(extra)); } void TRACE_smpi_testing_out(int rank) @@ -311,8 +306,8 @@ void TRACE_smpi_testing_out(int rank) return; container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* type = container->type_->byName("MPI_STATE"); - new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); + state->popEvent(SIMIX_get_clock(), container); } void TRACE_smpi_ptp_in(int rank, const char *operation, instr_extra_data extra) @@ -325,8 +320,7 @@ void TRACE_smpi_ptp_in(int rank, const char *operation, instr_extra_data extra) container_t container = simgrid::instr::Container::byName(smpi_container(rank)); simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); state->addEntityValue(operation, instr_find_color(operation)); - new simgrid::instr::PushStateEvent(SIMIX_get_clock(), container, state, state->getEntityValue(operation), - static_cast(extra)); + state->pushEvent(SIMIX_get_clock(), container, operation, static_cast(extra)); } void TRACE_smpi_ptp_out(int rank, int dst, const char *operation) @@ -335,9 +329,8 @@ void TRACE_smpi_ptp_out(int rank, int dst, const char *operation) return; container_t container = simgrid::instr::Container::byName(smpi_container(rank)); - simgrid::instr::Type* type = container->type_->byName("MPI_STATE"); - - new simgrid::instr::PopStateEvent(SIMIX_get_clock(), container, type); + simgrid::instr::StateType* state = static_cast(container->type_->byName("MPI_STATE")); + state->popEvent(SIMIX_get_clock(), container); } void TRACE_smpi_send(int rank, int src, int dst, int tag, int size) diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 8a4b47f532..e4b0078176 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -548,12 +548,13 @@ set(LUA_SRC set(TRACING_SRC src/instr/instr_config.cpp src/instr/instr_interface.cpp - src/instr/instr_paje_containers.hpp src/instr/instr_paje_containers.cpp + src/instr/instr_paje_containers.hpp + src/instr/instr_paje_events.cpp src/instr/instr_paje_header.cpp src/instr/instr_paje_trace.cpp - src/instr/instr_paje_types.hpp src/instr/instr_paje_types.cpp + src/instr/instr_paje_types.hpp src/instr/instr_paje_values.cpp src/instr/instr_private.hpp src/instr/instr_smpi.hpp