include src/instr/instr_paje_trace.cpp
include src/instr/instr_paje_types.cpp
include src/instr/instr_paje_types.hpp
-include src/instr/instr_paje_values.cpp
include src/instr/instr_paje_values.hpp
include src/instr/instr_platform.cpp
include src/instr/instr_private.hpp
#include "simgrid/version.h"
#include "src/instr/instr_private.hpp"
#include "surf/surf.hpp"
-#include "xbt/virtu.h" /* xbt::cmdline */
#include <sys/stat.h>
#ifdef WIN32
"Do not trace link bandwidth and latency.", false};
static simgrid::config::Flag<bool> trace_disable_power{"tracing/disable_power", "Do not trace host power.", false};
-simgrid::instr::TraceFormat simgrid::instr::trace_format = simgrid::instr::TraceFormat::Paje;
-
bool TRACE_needs_platform ()
{
return TRACE_actor_is_enabled() || TRACE_vm_is_enabled() || TRACE_categorized() || TRACE_uncategorized() ||
return trace_disable_power && trace_enabled;
}
-bool TRACE_basic ()
-{
- return trace_basic && trace_enabled;
-}
-
bool TRACE_display_sizes ()
{
return trace_display_sizes && trace_smpi_enabled && trace_enabled;
}
-int TRACE_precision ()
-{
- return simgrid::config::get_value<int>("tracing/precision");
-}
-
-std::string TRACE_get_filename()
-{
- return simgrid::config::get_value<std::string>("tracing/filename");
-}
-
static void print_line(const char* option, const char* desc, const char* longdesc)
{
std::string str = std::string("--cfg=") + option + " ";
namespace simgrid {
namespace instr {
-
static bool trace_active = false;
+TraceFormat trace_format = TraceFormat::Paje;
+int trace_precision;
+
/*************
* Callbacks *
*************/
XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_CreateContainer, timestamp);
- stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_CreateContainer << " ";
+ stream << std::fixed << std::setprecision(trace_precision) << PAJE_CreateContainer << " ";
stream << timestamp << " " << c.get_id() << " " << c.type_->get_id() << " " << c.father_->get_id() << " \"";
if (c.get_name().find("rank-") != 0)
stream << c.get_name() << "\"";
static void on_container_destruction_paje(Container& c)
{
// obligation to dump previous events because they might reference the container that is about to be destroyed
- TRACE_last_timestamp_to_dump = SIMIX_get_clock();
- TRACE_paje_dump_buffer(true);
+ last_timestamp_to_dump = SIMIX_get_clock();
+ dump_buffer(true);
// trace my destruction, but not if user requests so or if the container is root
if (not trace_disable_destroy && &c != Container::get_root()) {
XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_DestroyContainer, timestamp);
- stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_DestroyContainer << " ";
+ stream << std::fixed << std::setprecision(trace_precision) << PAJE_DestroyContainer << " ";
stream << timestamp << " " << c.type_->get_id() << " " << c.get_id();
XBT_DEBUG("Dump %s", stream.str().c_str());
tracing_file << stream.str() << std::endl;
static void on_container_destruction_ti(Container& c)
{
// obligation to dump previous events because they might reference the container that is about to be destroyed
- TRACE_last_timestamp_to_dump = SIMIX_get_clock();
- TRACE_paje_dump_buffer(true);
+ last_timestamp_to_dump = SIMIX_get_clock();
+ dump_buffer(true);
if (not trace_disable_destroy && &c != Container::get_root()) {
XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_DestroyContainer, SIMIX_get_clock());
{
std::stringstream stream;
XBT_DEBUG("%s: event_type=%u", __func__, PAJE_DefineEntityValue);
- stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_DefineEntityValue;
+ stream << std::fixed << std::setprecision(trace_precision) << PAJE_DefineEntityValue;
stream << " " << value.get_id() << " " << value.get_father()->get_id() << " " << value.get_name();
if (not value.get_color().empty())
stream << " \"" << value.get_color() << "\"";
return; // this kind of type has to be handled differently
std::stringstream stream;
- stream << std::fixed << std::setprecision(TRACE_precision());
- XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, event_type, TRACE_precision(), 0.);
+ stream << std::fixed << std::setprecision(trace_precision);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, event_type, trace_precision, 0.);
stream << event_type << " " << type.get_id() << " " << type.get_father()->get_id() << " " << type.get_name();
if (type.is_colored())
stream << " \"" << type.get_color() << "\"";
static void on_link_type_creation(Type& type, Type& source, Type& dest)
{
std::stringstream stream;
- XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, PAJE_DefineLinkType, TRACE_precision(), 0.);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, PAJE_DefineLinkType, trace_precision, 0.);
stream << PAJE_DefineLinkType << " " << type.get_id() << " " << type.get_father()->get_id();
stream << " " << source.get_id() << " " << dest.get_id() << " " << type.get_name();
XBT_DEBUG("Dump %s", stream.str().c_str());
tracing_file << stream.str() << std::endl;
}
+
static void on_simulation_start()
{
- if (trace_active)
+ if (trace_active || not TRACE_is_enabled())
return;
- // tracing system must be:
- // - enabled (with --cfg=tracing:yes)
- // - already configured (simgrid::instr::init already called)
- if (TRACE_is_enabled()) {
- define_callbacks();
-
- XBT_DEBUG("Tracing starts");
-
- /* init the tracing module to generate the right output */
- std::string format = config::get_value<std::string>("tracing/smpi/format");
- XBT_DEBUG("Tracing format %s", format.c_str());
-
- /* Connect the callbacks associated to the creation/destruction of containers*/
- if (format == "Paje") {
- Container::on_creation.connect(on_container_creation_paje);
- Container::on_destruction.connect(on_container_destruction_paje);
- EntityValue::on_creation.connect(on_entity_value_creation);
- Type::on_creation.connect(on_type_creation);
- LinkType::on_creation.connect(on_link_type_creation);
- } else {
- Container::on_creation.connect(on_container_creation_ti);
- Container::on_destruction.connect(on_container_destruction_ti);
- }
+ define_callbacks();
- /* open the trace file(s) */
- std::string filename = TRACE_get_filename();
- tracing_file.open(filename.c_str(), std::ofstream::out);
- if (tracing_file.fail()) {
- throw TracingError(XBT_THROW_POINT,
- xbt::string_printf("Tracefile %s could not be opened for writing.", filename.c_str()));
- }
+ XBT_DEBUG("Tracing starts");
+ trace_precision = config::get_value<int>("tracing/precision");
- XBT_DEBUG("Filename %s is open for writing", filename.c_str());
-
- if (format == "Paje") {
- /* output generator version */
- tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
- << "." << SIMGRID_VERSION_PATCH << std::endl;
- tracing_file << "#[";
- for (auto str : simgrid::xbt::cmdline) {
- tracing_file << str << " ";
- }
- tracing_file << "]" << std::endl;
- }
+ /* init the tracing module to generate the right output */
+ std::string format = config::get_value<std::string>("tracing/smpi/format");
+ XBT_DEBUG("Tracing format %s", format.c_str());
+
+ /* open the trace file(s) */
+ std::string filename = simgrid::config::get_value<std::string>("tracing/filename");
+ tracing_file.open(filename.c_str(), std::ofstream::out);
+ if (tracing_file.fail()) {
+ throw TracingError(XBT_THROW_POINT,
+ xbt::string_printf("Tracefile %s could not be opened for writing.", filename.c_str()));
+ }
+
+ XBT_DEBUG("Filename %s is open for writing", filename.c_str());
+
+ if (format == "Paje") {
+ Container::on_creation.connect(on_container_creation_paje);
+ Container::on_destruction.connect(on_container_destruction_paje);
+ EntityValue::on_creation.connect(on_entity_value_creation);
+ Type::on_creation.connect(on_type_creation);
+ LinkType::on_creation.connect(on_link_type_creation);
+
+ paje::dump_generator_version();
/* output one line comment */
std::string comment = simgrid::config::get_value<std::string>("tracing/comment");
tracing_file << "# " << comment << std::endl;
/* output comment file */
- dump_comment_file(simgrid::config::get_value<std::string>(OPT_TRACING_COMMENT_FILE));
-
- if (format == "Paje") {
- /* output Pajé header */
- TRACE_header(TRACE_basic(), TRACE_display_sizes());
- } else
- trace_format = TraceFormat::Ti;
-
- trace_active = true;
- XBT_DEBUG("Tracing is on");
+ paje::dump_comment_file(config::get_value<std::string>(OPT_TRACING_COMMENT_FILE));
+ paje::dump_header(trace_basic, TRACE_display_sizes());
+ } else {
+ trace_format = TraceFormat::Ti;
+ Container::on_creation.connect(on_container_creation_ti);
+ Container::on_destruction.connect(on_container_destruction_ti);
}
+
+ trace_active = true;
+ XBT_DEBUG("Tracing is on");
}
static void on_simulation_end()
return;
/* dump trace buffer */
- TRACE_last_timestamp_to_dump = surf_get_clock();
- TRACE_paje_dump_buffer(true);
+ last_timestamp_to_dump = surf_get_clock();
+ dump_buffer(true);
const Type* root_type = Container::get_root()->type_;
/* destroy all data structures of tracing (and free) */
/* close the trace files */
tracing_file.close();
- XBT_DEBUG("Filename %s is closed", TRACE_get_filename().c_str());
+ XBT_DEBUG("Filename %s is closed", config::get_value<std::string>("tracing/filename").c_str());
/* de-activate trace */
trace_active = false;
"(expressed in number of digits after decimal point)",
6);
- /* Connect callbacks */
+ /* Connect Engine callbacks */
s4u::Engine::on_platform_creation.connect(on_simulation_start);
+ s4u::Engine::on_time_advance.connect([](double /*time_delta*/) { dump_buffer(false); });
s4u::Engine::on_deadlock.connect(on_simulation_end);
s4u::Engine::on_simulation_end.connect(on_simulation_end);
}
static container_t rootContainer = nullptr; /* the root container */
static std::map<std::string, container_t> allContainers; /* all created containers indexed by name */
-long long int instr_new_paje_id ()
+namespace simgrid {
+namespace instr {
+
+long long int new_paje_id()
{
static long long int type_id = 0;
return type_id++;
}
-namespace simgrid {
-namespace instr {
-
Container* Container::get_root()
{
return rootContainer;
{
return static_cast<VariableType*>(type_->by_name(name)->set_calling_container(this));
}
+
+EntityValue::EntityValue(const std::string& name, const std::string& color, Type* father)
+ : name_(name), color_(color), father_(father)
+{
+ id_ = simgrid::instr::new_paje_id();
+ on_creation(*this);
+}
+
} // namespace instr
} // namespace simgrid
class HostContainer : public Container {
public:
- HostContainer(simgrid::s4u::Host const& host, NetZoneContainer* father);
+ HostContainer(s4u::Host const& host, NetZoneContainer* father);
};
} // namespace instr
} // namespace simgrid
PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType)
: container_(container), type_(type), timestamp_(timestamp), eventType_(eventType)
{
- XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, eventType_, TRACE_precision(), timestamp_);
+ XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, eventType_, trace_precision, timestamp_);
if (trace_format == TraceFormat::Paje) {
- stream_ << std::fixed << std::setprecision(TRACE_precision());
+ stream_ << std::fixed << std::setprecision(trace_precision);
stream_ << eventType_ << " " << timestamp_ << " " << type_->get_id() << " " << container_->get_id();
}
insert_into_buffer();
/* 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 "simgrid/sg_config.hpp"
+#include "simgrid/Exception.hpp"
#include "src/instr/instr_private.hpp"
+#include "xbt/virtu.h" /* xbt::cmdline */
extern std::ofstream tracing_file;
+namespace simgrid {
+namespace instr {
+namespace paje {
-static void TRACE_header_PajeTypes(bool basic)
+void dump_generator_version()
{
- tracing_file << "%EventDef PajeDefineContainerType " << simgrid::instr::PAJE_DefineContainerType << std::endl;
+ tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
+ << "." << SIMGRID_VERSION_PATCH << std::endl;
+ tracing_file << "#[";
+ for (auto str : simgrid::xbt::cmdline) {
+ tracing_file << str << " ";
+ }
+ tracing_file << "]" << std::endl;
+}
+
+void dump_comment_file(const std::string& filename)
+{
+ if (filename.empty())
+ return;
+ std::ifstream fs(filename.c_str(), std::ifstream::in);
+
+ if (fs.fail())
+ throw TracingError(XBT_THROW_POINT,
+ xbt::string_printf("Comment file %s could not be opened for reading.", filename.c_str()));
+
+ while (not fs.eof()) {
+ std::string line;
+ std::getline(fs, line);
+ tracing_file << "# " << line;
+ }
+ fs.close();
+}
+
+void dump_header(bool basic, bool display_sizes)
+{
+ // Types
+ tracing_file << "%EventDef PajeDefineContainerType " << PAJE_DefineContainerType << std::endl;
tracing_file << "% Alias string" << std::endl;
- if (basic){
+ if (basic)
tracing_file << "% ContainerType string" << std::endl;
- }else{
+ else
tracing_file << "% Type string" << std::endl;
- }
+
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeDefineVariableType " << simgrid::instr::PAJE_DefineVariableType << std::endl;
+ tracing_file << "%EventDef PajeDefineVariableType " << PAJE_DefineVariableType << std::endl;
tracing_file << "% Alias string" << std::endl;
- if (basic){
- tracing_file << "% ContainerType string" << std::endl;
- }else{
- tracing_file << "% Type string" << std::endl;
- }
+ tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "% Color color" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeDefineStateType " << simgrid::instr::PAJE_DefineStateType << std::endl;
+ tracing_file << "%EventDef PajeDefineStateType " << PAJE_DefineStateType << std::endl;
tracing_file << "% Alias string" << std::endl;
- if (basic){
- tracing_file << "% ContainerType string" << std::endl;
- }else{
- tracing_file << "% Type string" << std::endl;
- }
+ tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeDefineEventType " << simgrid::instr::PAJE_DefineEventType << std::endl;
+ tracing_file << "%EventDef PajeDefineEventType " << PAJE_DefineEventType << std::endl;
tracing_file << "% Alias string" << std::endl;
- if (basic){
- tracing_file << "% ContainerType string" << std::endl;
- }else{
- tracing_file << "% Type string" << std::endl;
- }
+ tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeDefineLinkType " << simgrid::instr::PAJE_DefineLinkType << std::endl;
+ tracing_file << "%EventDef PajeDefineLinkType " << PAJE_DefineLinkType << std::endl;
tracing_file << "% Alias string" << std::endl;
- if (basic){
- tracing_file << "% ContainerType string" << std::endl;
- tracing_file << "% SourceContainerType string" << std::endl;
- tracing_file << "% DestContainerType string" << std::endl;
- }else{
- tracing_file << "% Type string" << std::endl;
- tracing_file << "% StartContainerType string" << std::endl;
- tracing_file << "% EndContainerType string" << std::endl;
- }
+ tracing_file << "% " << (basic ? "Container" : "") << "Type string" << std::endl;
+ tracing_file << "% " << (basic ? "Source" : "Start") << "ContainerType string" << std::endl;
+ tracing_file << "% " << (basic ? "Dest" : "End") << "ContainerType string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
-}
-static void TRACE_header_PajeDefineEntityValue(bool basic)
-{
- tracing_file << "%EventDef PajeDefineEntityValue " << simgrid::instr::PAJE_DefineEntityValue << std::endl;
+ // EntityValue
+ tracing_file << "%EventDef PajeDefineEntityValue " << PAJE_DefineEntityValue << std::endl;
tracing_file << "% Alias string" << std::endl;
- if (basic){
- tracing_file << "% EntityType string" << std::endl;
- }else{
- tracing_file << "% Type string" << std::endl;
- }
+ tracing_file << "% " << (basic ? "Entity" : "") << "Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "% Color color" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
-}
-static void TRACE_header_PajeContainer()
-{
- tracing_file << "%EventDef PajeCreateContainer " << simgrid::instr::PAJE_CreateContainer << std::endl;
+ // Container
+ tracing_file << "%EventDef PajeCreateContainer " << PAJE_CreateContainer << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Alias string" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeDestroyContainer " << simgrid::instr::PAJE_DestroyContainer << std::endl;
+ tracing_file << "%EventDef PajeDestroyContainer " << PAJE_DestroyContainer << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Name string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
-}
-static void TRACE_header_PajeVariable()
-{
- tracing_file << "%EventDef PajeSetVariable " << simgrid::instr::PAJE_SetVariable << std::endl;
+ // Variable
+ tracing_file << "%EventDef PajeSetVariable " << PAJE_SetVariable << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value double" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeAddVariable " << simgrid::instr::PAJE_AddVariable << std::endl;
+ tracing_file << "%EventDef PajeAddVariable " << PAJE_AddVariable << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value double" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeSubVariable " << simgrid::instr::PAJE_SubVariable << std::endl;
+ tracing_file << "%EventDef PajeSubVariable " << PAJE_SubVariable << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value double" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
-}
-static void TRACE_header_PajeState(bool basic, int size)
-{
- tracing_file << "%EventDef PajeSetState " << simgrid::instr::PAJE_SetState << std::endl;
+ // State
+ tracing_file << "%EventDef PajeSetState " << PAJE_SetState << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajePushState " << simgrid::instr::PAJE_PushState << std::endl;
+ tracing_file << "%EventDef PajePushState " << PAJE_PushState << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value string" << std::endl;
- if (size)
+ if (display_sizes)
tracing_file << "% Size int" << std::endl;
#if HAVE_SMPI
if (simgrid::config::get_value<bool>("smpi/trace-call-location")) {
#endif
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajePopState " << simgrid::instr::PAJE_PopState << std::endl;
+ tracing_file << "%EventDef PajePopState " << PAJE_PopState << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- if (basic)
- return;
-
- tracing_file << "%EventDef PajeResetState " << simgrid::instr::PAJE_ResetState << std::endl;
- tracing_file << "% Time date" << std::endl;
- tracing_file << "% Type string" << std::endl;
- tracing_file << "% Container string" << std::endl;
- tracing_file << "%EndEventDef" << std::endl;
-}
+ if (not basic) {
+ tracing_file << "%EventDef PajeResetState " << PAJE_ResetState << std::endl;
+ tracing_file << "% Time date" << std::endl;
+ tracing_file << "% Type string" << std::endl;
+ tracing_file << "% Container string" << std::endl;
+ tracing_file << "%EndEventDef" << std::endl;
+ }
-static void TRACE_header_PajeLink(bool basic, bool size)
-{
- tracing_file << "%EventDef PajeStartLink " << simgrid::instr::PAJE_StartLink << std::endl;
+ // Link
+ tracing_file << "%EventDef PajeStartLink " << PAJE_StartLink << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value string" << std::endl;
- if (basic){
- tracing_file << "% SourceContainer string" << std::endl;
- } else {
- tracing_file << "% StartContainer string" << std::endl;
- }
+ tracing_file << "% " << (basic ? "Source" : "Start") << "Container string" << std::endl;
tracing_file << "% Key string" << std::endl;
- if (size)
+ if (display_sizes)
tracing_file << "% Size int" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
- tracing_file << "%EventDef PajeEndLink " << simgrid::instr::PAJE_EndLink << std::endl;
+ tracing_file << "%EventDef PajeEndLink " << PAJE_EndLink << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value string" << std::endl;
- if (basic){
- tracing_file << "% DestContainer string" << std::endl;
- }else{
- tracing_file << "% EndContainer string" << std::endl;
- }
+ tracing_file << "% " << (basic ? "Dest" : "End") << "Container string" << std::endl;
tracing_file << "% Key string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
-}
-static void TRACE_header_PajeNewEvent()
-{
- tracing_file << "%EventDef PajeNewEvent " << simgrid::instr::PAJE_NewEvent << std::endl;
+ // Event
+ tracing_file << "%EventDef PajeNewEvent " << PAJE_NewEvent << std::endl;
tracing_file << "% Time date" << std::endl;
tracing_file << "% Type string" << std::endl;
tracing_file << "% Container string" << std::endl;
tracing_file << "% Value string" << std::endl;
tracing_file << "%EndEventDef" << std::endl;
}
-
-void TRACE_header(bool basic, bool size)
-{
- TRACE_header_PajeTypes(basic);
- TRACE_header_PajeDefineEntityValue(basic);
- TRACE_header_PajeContainer();
- TRACE_header_PajeVariable();
- TRACE_header_PajeState(basic, size);
- TRACE_header_PajeLink(basic, size);
- TRACE_header_PajeNewEvent();
-}
+} // namespace paje
+} // namespace instr
+} // namespace simgrid
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "tracing event system");
-extern std::ofstream tracing_file;
+namespace simgrid {
+namespace instr {
+static std::vector<PajeEvent*> buffer;
-static std::vector<simgrid::instr::PajeEvent*> buffer;
-
-void dump_comment_file(const std::string& filename)
-{
- if (filename.empty())
- return;
- std::ifstream fs(filename.c_str(), std::ifstream::in);
-
- if (fs.fail())
- throw simgrid::TracingError(
- XBT_THROW_POINT,
- simgrid::xbt::string_printf("Comment file %s could not be opened for reading.", filename.c_str()));
-
- while (not fs.eof()) {
- std::string line;
- std::getline(fs, line);
- tracing_file << "# " << line;
- }
- fs.close();
-}
-
-double TRACE_last_timestamp_to_dump = 0;
-//dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
-void TRACE_paje_dump_buffer(bool force)
+double last_timestamp_to_dump = 0;
+// dumps the trace file until the last_timestamp_to_dump
+void dump_buffer(bool force)
{
if (not TRACE_is_enabled())
return;
- XBT_DEBUG("%s: dump until %f. starts", __func__, TRACE_last_timestamp_to_dump);
+ XBT_DEBUG("%s: dump until %f. starts", __func__, last_timestamp_to_dump);
if (force){
for (auto const& event : buffer) {
event->print();
}
buffer.clear();
} else {
- std::vector<simgrid::instr::PajeEvent*>::iterator i = buffer.begin();
+ std::vector<PajeEvent*>::iterator i = buffer.begin();
for (auto const& event : buffer) {
double head_timestamp = event->timestamp_;
- if (head_timestamp > TRACE_last_timestamp_to_dump)
+ if (head_timestamp > last_timestamp_to_dump)
break;
event->print();
delete event;
}
/* internal do the instrumentation module */
-void simgrid::instr::PajeEvent::insert_into_buffer()
+void PajeEvent::insert_into_buffer()
{
XBT_DEBUG("%s: insert event_type=%u, timestamp=%f, buffersize=%zu)", __func__, eventType_, timestamp_, buffer.size());
- std::vector<simgrid::instr::PajeEvent*>::reverse_iterator i;
+ std::vector<PajeEvent*>::reverse_iterator i;
for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
- simgrid::instr::PajeEvent* e1 = *i;
+ PajeEvent* e1 = *i;
XBT_DEBUG("compare to %p is of type %u; timestamp:%f", e1, e1->eventType_, e1->timestamp_);
if (e1->timestamp_ <= timestamp_)
break;
XBT_DEBUG("%s: inserted at pos= %zd from its end", __func__, std::distance(buffer.rbegin(), i));
buffer.insert(i.base(), this);
}
+
+} // namespace instr
+} // namespace simgrid
Type::Type(e_event_type event_type, const std::string& name, const std::string& alias, const std::string& color,
Type* father)
- : id_(instr_new_paje_id()), name_(name), color_(color), father_(father)
+ : id_(new_paje_id()), name_(name), color_(color), father_(father)
{
if (name_.empty() || alias.empty())
throw TracingError(XBT_THROW_POINT, "can't create a new type with no name or alias");
+++ /dev/null
-/* Copyright (c) 2012-2020. 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"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)");
-
-namespace simgrid {
-namespace instr {
-
-EntityValue::EntityValue(const std::string& name, const std::string& color, Type* father)
- : name_(name), color_(color), father_(father)
-{
- id_ = instr_new_paje_id();
- on_creation(*this);
-}
-} // namespace instr
-} // namespace simgrid
latency->set_calling_container(container);
latency->set_event(0, link.get_latency());
}
+
if (TRACE_uncategorized()) {
container->type_->by_name_or_create("bandwidth_used", "0.5 0.5 0.5");
}
recursiveGraphExtraction(s4u::Engine::get_instance()->get_netzone_root(), Container::get_root(), filter);
XBT_DEBUG("Graph extraction finished.");
delete filter;
- TRACE_paje_dump_buffer(true);
+ dump_buffer(true);
}
static void on_actor_creation(s4u::Actor const& actor)
kernel::routing::NetPoint::on_creation.connect(on_netpoint_creation);
}
s4u::NetZone::on_creation.connect(on_netzone_creation);
- s4u::Engine::on_time_advance.connect([](double /*time_delta*/) { TRACE_paje_dump_buffer(false); });
kernel::resource::CpuAction::on_state_change.connect(on_action_state_change);
s4u::Link::on_communication_state_change.connect(on_action_state_change);
namespace simgrid {
namespace instr {
-void init();
-void define_callbacks();
+namespace paje {
-void platform_graph_export_graphviz(const std::string& output_filename);
-
-void resource_set_utilization(const char* type, const char* name, const char* resource, const std::string& category,
- double value, double now, double delta);
+void dump_generator_version();
+void dump_comment_file(const std::string& filename);
+void dump_header(bool basic, bool display_sizes);
+} // namespace paje
/* Format of TRACING output.
* - paje is the regular format, that we all know
*/
enum class TraceFormat { Paje, /*TimeIndependent*/ Ti };
extern TraceFormat trace_format;
+extern int trace_precision;
+extern double last_timestamp_to_dump;
+
+long long int new_paje_id();
+
+void init();
+void define_callbacks();
+
+void platform_graph_export_graphviz(const std::string& output_filename);
+
+void resource_set_utilization(const char* type, const char* name, const char* resource, const std::string& category,
+ double value, double now, double delta);
+void dump_buffer(bool force);
class TIData {
std::string name_;
virtual ~TIData() {}
- const std::string& getName() const { return name_; }
- double getAmount() { return amount_; }
+ const std::string& get_name() const { return name_; }
+ double get_amount() const { return amount_; }
virtual std::string print() = 0;
virtual std::string display_size() = 0;
};
class NoOpTIData : public TIData {
public:
explicit NoOpTIData(const std::string& name) : TIData(name){};
- std::string print() override { return getName(); }
+ std::string print() override { return get_name(); }
std::string display_size() override { return "NA"; }
};
std::string print() override
{
std::stringstream stream;
- stream << getName() << " " << getAmount();
+ stream << get_name() << " " << get_amount();
return stream.str();
}
- std::string display_size() override { return std::to_string(getAmount()); }
+ std::string display_size() override { return std::to_string(get_amount()); }
};
class Pt2PtTIData : public TIData {
std::string print() override
{
std::stringstream stream;
- stream << getName() << " " << endpoint << " ";
+ stream << get_name() << " " << endpoint << " ";
stream << tag << " " << send_size << " " << send_type;
return stream.str();
}
std::string print() override
{
std::stringstream stream;
- stream << getName() << " " << send_size << " ";
+ stream << get_name() << " " << send_size << " ";
if (recv_size >= 0)
stream << recv_size << " ";
- if (getAmount() >= 0.0)
- stream << getAmount() << " ";
+ if (get_amount() >= 0.0)
+ stream << get_amount() << " ";
if (endpoint > 0 || (endpoint == 0 && not send_type.empty()))
stream << endpoint << " ";
stream << send_type << " " << recv_type;
std::string print() override
{
std::stringstream stream;
- stream << getName() << " ";
+ stream << get_name() << " ";
if (send_size >= 0)
stream << send_size << " ";
if (sendcounts != nullptr)
std::string print() override
{
std::stringstream stream;
- stream << getName() << " " << src << " " << dest << " " << tag;
+ stream << get_name() << " " << src << " " << dest << " " << tag;
return stream.str();
}
std::string print() override
{
std::stringstream stream;
- stream << getName() << " " << memory_consumption;
+ stream << get_name() << " " << memory_consumption;
return stream.str();
}
extern XBT_PRIVATE std::set<std::string> user_host_variables;
extern XBT_PRIVATE std::set<std::string> user_vm_variables;
extern XBT_PRIVATE std::set<std::string> user_link_variables;
-extern XBT_PRIVATE double TRACE_last_timestamp_to_dump;
-
-/* instr_paje_header.c */
-XBT_PRIVATE void TRACE_header(bool basic, bool size);
/* from instr_config.c */
XBT_PRIVATE bool TRACE_needs_platform();
XBT_PRIVATE bool TRACE_vm_is_enabled();
XBT_PRIVATE bool TRACE_disable_link();
XBT_PRIVATE bool TRACE_disable_speed();
-XBT_PRIVATE bool TRACE_basic();
XBT_PRIVATE bool TRACE_display_sizes();
-XBT_PRIVATE int TRACE_precision();
/* Public functions used in SMPI */
XBT_PUBLIC bool TRACE_smpi_is_enabled();
XBT_PUBLIC bool TRACE_smpi_view_internals();
/* instr_paje.c */
-XBT_PRIVATE long long int instr_new_paje_id();
void instr_new_variable_type(const std::string& new_typename, const std::string& color);
void instr_new_user_variable_type(const std::string& father_type, const std::string& new_typename,
const std::string& color);
XBT_PRIVATE void TRACE_help();
-XBT_PRIVATE void TRACE_paje_dump_buffer(bool force);
-XBT_PRIVATE void dump_comment_file(const std::string& filename);
-
-XBT_PRIVATE std::string TRACE_get_filename();
-
#endif
src/instr/instr_paje_trace.cpp
src/instr/instr_paje_types.cpp
src/instr/instr_paje_types.hpp
- src/instr/instr_paje_values.cpp
src/instr/instr_paje_values.hpp
src/instr/instr_platform.cpp
src/instr/instr_private.hpp