Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[INSTR] Move enum instr_fmt_type_t to enum class TraceFormat
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Mon, 16 Apr 2018 11:47:51 +0000 (13:47 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Mon, 16 Apr 2018 11:47:51 +0000 (13:47 +0200)
src/instr/instr_config.cpp
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_events.cpp
src/instr/instr_paje_types.cpp
src/instr/instr_paje_values.cpp
src/instr/instr_private.hpp

index fb4d44d..5726f1f 100644 (file)
@@ -59,7 +59,7 @@ static bool trace_disable_power;
 static bool trace_configured = false;
 static bool trace_active     = false;
 
-instr_fmt_type_t instr_fmt_type = instr_fmt_paje;
+simgrid::instr::TraceFormat simgrid::instr::trace_format = simgrid::instr::TraceFormat::Paje;
 
 static void TRACE_getopts()
 {
@@ -102,7 +102,7 @@ int TRACE_start()
     if (format == "Paje") {
       TRACE_paje_start();
     } else if (format == "TI") {
-      instr_fmt_type = instr_fmt_TI;
+      simgrid::instr::trace_format = simgrid::instr::TraceFormat::Ti;
       TRACE_TI_start();
     }else{
       xbt_die("Unknown trace format :%s ", format.c_str());
index 68fadc0..23f44b3 100644 (file)
@@ -150,12 +150,12 @@ void Container::logCreation()
 
   XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_CreateContainer, timestamp);
 
-  if (instr_fmt_type == instr_fmt_paje) {
+  if (trace_format == simgrid::instr::TraceFormat::Paje) {
     stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_CreateContainer << " ";
     stream << timestamp << " " << id_ << " " << type_->get_id() << " " << father_->id_ << " \"" << name_ << "\"";
     XBT_DEBUG("Dump %s", stream.str().c_str());
     fprintf(tracing_file, "%s\n", stream.str().c_str());
-  } else if (instr_fmt_type == instr_fmt_TI) {
+  } else if (trace_format == simgrid::instr::TraceFormat::Ti) {
     // if we are in the mode with only one file
     static FILE* ti_unique_file = nullptr;
 
@@ -189,12 +189,12 @@ void Container::logDestruction()
 
   XBT_DEBUG("%s: event_type=%u, timestamp=%f", __func__, PAJE_DestroyContainer, timestamp);
 
-  if (instr_fmt_type == instr_fmt_paje) {
+  if (trace_format == simgrid::instr::TraceFormat::Paje) {
     stream << std::fixed << std::setprecision(TRACE_precision()) << PAJE_DestroyContainer << " ";
     stream << timestamp << " " << type_->get_id() << " " << id_;
     XBT_DEBUG("Dump %s", stream.str().c_str());
     fprintf(tracing_file, "%s\n", stream.str().c_str());
-  } else if (instr_fmt_type == instr_fmt_TI) {
+  } else if (trace_format == simgrid::instr::TraceFormat::Ti) {
     if (not xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || tracing_files.size() == 1) {
       fclose(tracing_files.at(this));
     }
index 22faeb5..4aacda9 100644 (file)
@@ -19,7 +19,7 @@ PajeEvent::PajeEvent(Container* container, Type* type, double timestamp, e_event
     : container_(container), type_(type), timestamp_(timestamp), eventType_(eventType)
 {
   XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, eventType_, TRACE_precision(), timestamp_);
-  if (instr_fmt_type == instr_fmt_paje) {
+  if (trace_format == simgrid::instr::TraceFormat::Paje) {
     stream_ << std::fixed << std::setprecision(TRACE_precision());
     stream_ << eventType_ << " " << timestamp_ << " " << type_->get_id() << " " << container_->get_id();
   }
@@ -40,7 +40,7 @@ StateEvent::StateEvent(Container* container, Type* type, e_event_type event_type
 
 void NewEvent::print()
 {
-  if (instr_fmt_type != instr_fmt_paje)
+  if (trace_format != simgrid::instr::TraceFormat::Paje)
     return;
 
   stream_ << " " << value->getId();
@@ -51,7 +51,7 @@ void NewEvent::print()
 
 void LinkEvent::print()
 {
-  if (instr_fmt_type != instr_fmt_paje)
+  if (trace_format != simgrid::instr::TraceFormat::Paje)
     return;
 
   stream_ << " " << value_ << " " << endpoint_->get_id() << " " << key_;
@@ -65,7 +65,7 @@ void LinkEvent::print()
 
 void VariableEvent::print()
 {
-  if (instr_fmt_type != instr_fmt_paje)
+  if (trace_format != simgrid::instr::TraceFormat::Paje)
     return;
 
   stream_ << " " << value;
@@ -76,7 +76,7 @@ void VariableEvent::print()
 
 void StateEvent::print()
 {
-  if (instr_fmt_type == instr_fmt_paje) {
+  if (trace_format == simgrid::instr::TraceFormat::Paje) {
 
     if (value != nullptr) // PAJE_PopState Event does not need to have a value
       stream_ << " " << value->getId();
@@ -91,7 +91,7 @@ void StateEvent::print()
 #endif
     XBT_DEBUG("Dump %s", stream_.str().c_str());
     fprintf(tracing_file, "%s\n", stream_.str().c_str());
-  } else if (instr_fmt_type == instr_fmt_TI) {
+  } else if (trace_format == simgrid::instr::TraceFormat::Ti) {
     if (extra_ == nullptr)
       return;
 
index 5cbd75f..c77cef2 100644 (file)
@@ -126,7 +126,7 @@ void LinkType::endEvent(container_t endContainer, std::string value, std::string
 
 void Type::logDefinition(e_event_type event_type)
 {
-  if (instr_fmt_type != instr_fmt_paje)
+  if (trace_format != simgrid::instr::TraceFormat::Paje)
     return;
   std::stringstream stream;
   XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, event_type, TRACE_precision(), 0.);
@@ -141,7 +141,7 @@ void Type::logDefinition(e_event_type event_type)
 
 void Type::logDefinition(simgrid::instr::Type* source, simgrid::instr::Type* dest)
 {
-  if (instr_fmt_type != instr_fmt_paje)
+  if (trace_format != simgrid::instr::TraceFormat::Paje)
     return;
   std::stringstream stream;
   XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, PAJE_DefineLinkType, TRACE_precision(), 0.);
index 63da7ee..27ef1e1 100644 (file)
@@ -17,7 +17,7 @@ EntityValue::EntityValue(std::string name, std::string color, Type* father)
 
 void EntityValue::print()
 {
-  if (instr_fmt_type != instr_fmt_paje)
+  if (trace_format != simgrid::instr::TraceFormat::Paje)
     return;
   std::stringstream stream;
   XBT_DEBUG("%s: event_type=%u", __func__, PAJE_DefineEntityValue);
index 7f6b5cd..dc421da 100644 (file)
@@ -37,6 +37,15 @@ typedef simgrid::instr::Container* container_t;
 namespace simgrid {
 namespace instr {
 
+/* Format of TRACING output.
+ *   - paje is the regular format, that we all know
+ *   - TI is a trick to reuse the tracing functions to generate a time independent trace during the execution. Such
+ *     trace can easily be replayed with smpi_replay afterward. This trick should be removed and replaced by some code
+ *     using the signal that we will create to cleanup the TRACING
+ */
+enum class TraceFormat { Paje, /*TimeIndependent*/ Ti };
+extern TraceFormat trace_format;
+
 class TIData {
   std::string name_;
   double amount_ = 0;
@@ -254,14 +263,6 @@ XBT_PRIVATE void TRACE_paje_dump_buffer(bool force);
 XBT_PRIVATE void dump_comment_file(std::string filename);
 XBT_PRIVATE void dump_comment(std::string comment);
 
-/* Format of TRACING output.
- *   - paje is the regular format, that we all know
- *   - TI is a trick to reuse the tracing functions to generate a time independent trace during the execution. Such
- *     trace can easily be replayed with smpi_replay afterward. This trick should be removed and replaced by some code
- *     using the signal that we will create to cleanup the TRACING
- */
-enum instr_fmt_type_t { instr_fmt_paje, instr_fmt_TI };
-extern instr_fmt_type_t instr_fmt_type;
 XBT_PRIVATE std::string TRACE_get_comment();
 XBT_PRIVATE std::string TRACE_get_comment_file();
 XBT_PRIVATE std::string TRACE_get_filename();