Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove all the events that are called and destroyed one time
authorTakishipp <toufik.boubehziz@gmail.com>
Tue, 13 Jun 2017 10:51:00 +0000 (12:51 +0200)
committerTakishipp <toufik.boubehziz@gmail.com>
Tue, 13 Jun 2017 10:51:00 +0000 (12:51 +0200)
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_trace.cpp
src/instr/instr_paje_types.cpp
src/instr/instr_paje_values.cpp
src/instr/instr_private.h

index f024629..16bbd9b 100644 (file)
@@ -138,7 +138,7 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe
   newContainer->children = xbt_dict_new_homogeneous(nullptr);
   if (newContainer->father){
     xbt_dict_set(newContainer->father->children, newContainer->name, newContainer, nullptr);
-    new CreateContainerEvent(newContainer);
+    CreateContainerEvent(newContainer);
   }
 
   //register all kinds by name
@@ -206,7 +206,7 @@ void PJ_container_free (container_t container)
   if (not TRACE_disable_destroy() && container != PJ_container_get_root()) {
     //do not trace the container destruction if user requests
     //or if the container is root
-    new DestroyContainerEvent(container);
+    DestroyContainerEvent(container);
   }
 
   //remove it from allContainers data structure
index cab9eef..5cabc10 100644 (file)
@@ -260,17 +260,25 @@ if (instr_fmt_type == instr_fmt_paje) {
 }
 
 
-DefineStateTypeEvent::DefineStateTypeEvent(type_t type)
+void DefineStateTypeEvent(type_t type)
 {
-  this->event_type                        = PAJE_DefineStateType;
-  this->timestamp                         = 0;
-  this->type = type;
+  e_event_type event_type                        = PAJE_DefineStateType;
+  double timestamp                         = 0;
 
   XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
 
   //print it
-  print();
-       delete this;
+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;
+  }
 }
 
 
@@ -287,20 +295,6 @@ DefineEventTypeEvent::DefineEventTypeEvent(type_t type)
 }
 
 
-void DefineStateTypeEvent::print() {
-  if (instr_fmt_type == instr_fmt_paje) {
-    XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
-    stream << std::fixed << std::setprecision(TRACE_precision());
-    stream << (int)this->event_type;
-    stream << " " << type->id << " " << type->father->id << " " << type->name;
-    print_row();
-  } else if (instr_fmt_type == instr_fmt_TI) {
-    /* Nothing to do */
-  } else {
-    THROW_IMPOSSIBLE;
-  }
-}
-
 void DefineEventTypeEvent::print() {
   if (instr_fmt_type == instr_fmt_paje) {
     XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
@@ -315,26 +309,18 @@ void DefineEventTypeEvent::print() {
   }
 }
 
-DefineLinkTypeEvent::DefineLinkTypeEvent(type_t type, type_t source, type_t dest)
+void DefineLinkTypeEvent(type_t type, type_t source, type_t dest)
 {
-  this->event_type                         = PAJE_DefineLinkType;
-  this->timestamp                          = 0;
-  this->type   = type;
-  this->source = source;
-  this->dest   = dest;
+  e_event_type event_type                         = PAJE_DefineLinkType;
+  double timestamp                          = 0;
 
   XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
 
   //print it
-  print();
-       delete this;
-}
-
-void DefineLinkTypeEvent::print() {
-  if (instr_fmt_type == instr_fmt_paje) {
+if (instr_fmt_type == instr_fmt_paje) {
     XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
     stream << std::fixed << std::setprecision(TRACE_precision());
-    stream << (int)this->event_type;
+    stream << (int)event_type;
     stream << " " << type->id << " " << type->father->id << " " << source->id << " " << dest->id << " " << type->name;
     print_row();
   } else if (instr_fmt_type == instr_fmt_TI) {
@@ -344,25 +330,18 @@ void DefineLinkTypeEvent::print() {
   }
 }
 
-DefineEntityValueEvent::DefineEntityValueEvent (val_t value)
+void DefineEntityValueEvent (val_t value)
 {
-  this->event_type                           = PAJE_DefineEntityValue;
-  this->timestamp                            = 0;
-  this->value = value;
+  e_event_type event_type                           = PAJE_DefineEntityValue;
+  double timestamp                            = 0;
 
   XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
 
   //print it
-  print();
-       delete this;
-}
-
-
-void DefineEntityValueEvent::print() {
-  if (instr_fmt_type == instr_fmt_paje) {
+if (instr_fmt_type == instr_fmt_paje) {
     XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
     stream << std::fixed << std::setprecision(TRACE_precision());
-    stream << (int)this->event_type;
+    stream << (int)event_type;
     stream << " " << value->id << " " << value->father->id << " " << value->name;
     if (value->color)
       stream << " \"" << value->color << "\"";
@@ -374,26 +353,26 @@ void DefineEntityValueEvent::print() {
   }
 }
 
-CreateContainerEvent::CreateContainerEvent (container_t container)
-{
-  this->event_type                             = PAJE_CreateContainer;
-  this->timestamp                              = SIMIX_get_clock();
-  this->container = container;
 
-  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+void CreateContainerEvent (container_t container)
+{
+  e_event_type event_type                             = PAJE_CreateContainer;
+  double timestamp                              = SIMIX_get_clock();
 
-  print();
-       delete this;
-}
+  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type,timestamp);
 
-void CreateContainerEvent::print() {
-  if (instr_fmt_type == instr_fmt_paje) {
+if (instr_fmt_type == instr_fmt_paje) {
     XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
     stream << std::fixed << std::setprecision(TRACE_precision());
-    stream << (int)this->event_type;
-    print_timestamp(this);
-    stream << " " << container->id << " " << container->type->id << " " << container->father->id << " \""
-           << container->name << "\"";
+    stream << (int)event_type;
+    stream << " ";
+  /* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
+     if (timestamp < 1e-12)
+         stream << 0;
+      else 
+         stream << timestamp;
+         stream << " " << container->id << " " << container->type->id << " " << container->father->id << " \""
+            << container->name << "\"";
 
     print_row();
   } else if (instr_fmt_type == instr_fmt_TI) {
@@ -428,26 +407,24 @@ void CreateContainerEvent::print() {
   }
 }
 
-DestroyContainerEvent::DestroyContainerEvent (container_t container)
+void DestroyContainerEvent (container_t container)
 {
-  this->event_type                              = PAJE_DestroyContainer;
-  this->timestamp                               = SIMIX_get_clock();
-  this->container = container;
+  e_event_type event_type                              = PAJE_DestroyContainer;
+  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__, (int)event_type, timestamp);
 
-  print();
-       delete this;
-}
-
-void DestroyContainerEvent::print() {
-  if (instr_fmt_type == instr_fmt_paje) {
+if (instr_fmt_type == instr_fmt_paje) {
     XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
     stream << std::fixed << std::setprecision(TRACE_precision());
-    stream << (int)this->event_type;
-    print_timestamp(this);
+    stream << (int)event_type;
+    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,6 +437,7 @@ void DestroyContainerEvent::print() {
         }
 }
 
+
 SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value)
 {
   this->event_type                         = PAJE_SetVariable;
index af48148..461f96b 100644 (file)
@@ -179,7 +179,7 @@ type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t
   ret = newType (name, key, nullptr, TYPE_LINK, father);
   XBT_DEBUG("LinkType %s(%s), child of %s(%s)  %s(%s)->%s(%s)", ret->name, ret->id, father->name, father->id,
             source->name, source->id, dest->name, dest->id);
-  new DefineLinkTypeEvent(ret, source, dest);
+  DefineLinkTypeEvent(ret, source, dest);
   return ret;
 }
 
@@ -193,6 +193,6 @@ type_t PJ_type_state_new (const char *name, type_t father)
 
   ret = newType (name, name, nullptr, TYPE_STATE, father);
   XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-  new DefineStateTypeEvent(ret);
+  DefineStateTypeEvent(ret);
   return ret;
 }
index d07eb6f..f07a640 100644 (file)
@@ -27,7 +27,7 @@ val_t PJ_value_new (const char *name, const char *color, type_t father)
 
   xbt_dict_set (father->values, name, ret, nullptr);
   XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
-  new DefineEntityValueEvent(ret);
+  DefineEntityValueEvent(ret);
   return ret;
 }
 
index ac6366a..9b3d7a8 100644 (file)
@@ -125,15 +125,6 @@ class PajeEvent {
 
 //--------------------------------------------------
 
-//--------------------------------------------------
-
-class DefineStateTypeEvent : public PajeEvent  {
-  type_t type;
-  public:
-  DefineStateTypeEvent(type_t type);
-  void print() override;
-};
-
 class DefineEventTypeEvent : public PajeEvent  {
   type_t type;
   public: 
@@ -141,36 +132,6 @@ class DefineEventTypeEvent : public PajeEvent  {
   void print() override;
 };
 
-class DefineLinkTypeEvent : public PajeEvent  {
-  type_t type;
-  type_t source;
-  type_t dest;
-  public:
-  DefineLinkTypeEvent(type_t type, type_t source, type_t dest);
-  void print() override;
-};
-
-class DefineEntityValueEvent : public PajeEvent  {
-  val_t value;
-  public:
-  DefineEntityValueEvent (val_t type);
-  void print() override;
-};
-
-class CreateContainerEvent : public PajeEvent  {
-  public:
-  container_t container;
-  explicit CreateContainerEvent (container_t container);
-  void print() override;
-};
-
-class DestroyContainerEvent : public PajeEvent  {
-  public:
-  container_t container;
-  DestroyContainerEvent (container_t container);
-  void print() override;
-};
-
 
 class SetVariableEvent : public PajeEvent  {
   container_t container;
@@ -461,5 +422,10 @@ SG_END_DECL()
 
 void DefineContainerEvent(type_t type);
 void DefineVariableTypeEvent(type_t type);
+void DefineStateTypeEvent(type_t type);
+void DefineLinkTypeEvent(type_t type, type_t source, type_t dest);
+void DefineEntityValueEvent (val_t value);
+void CreateContainerEvent (container_t container);
+void DestroyContainerEvent (container_t container);
 
 #endif