Sfoglia il codice sorgente

pdevs/multithreading: fix (remove lookhead)

Eric Ramat 3 anni fa
parent
commit
23234f547e

+ 9 - 0
src/artis-star/common/Model.hpp

@@ -121,6 +121,15 @@ public:
     return _out_port_map.find(port_index) != _out_port_map.end();
   }
 
+  std::string get_full_name() const
+  {
+    if (_parent) {
+      return _parent->get_full_name() + ":" + _name;
+    } else {
+      return _name;
+    }
+  }
+
   std::string get_in_port_name(unsigned int port_index) const
   {
     assert(exist_in_port(port_index));

+ 3 - 0
src/artis-star/kernel/pdevs/Dynamics.hpp

@@ -95,6 +95,9 @@ public:
   const std::string &get_name() const
   { return _name; }
 
+  std::string get_full_name() const
+  { return _simulator->get_full_name(); }
+
   void input_port(common::Port p)
   {
     _simulator->add_in_port(p);

+ 5 - 5
src/artis-star/kernel/pdevs/Simulator.hpp

@@ -57,13 +57,13 @@ public :
   const Dynamics &dynamics() const
   { return _dynamics; }
 
-  virtual void restore(const common::context::State<Time> &state)
+  virtual void restore(const common::context::State <Time> &state)
   {
     common::Simulator<Time>::restore(state);
     _dynamics.restore(state);
   }
 
-  virtual void save(common::context::State<Time> &state) const
+  virtual void save(common::context::State <Time> &state) const
   {
     common::Simulator<Time>::save(state);
     _dynamics.save(state);
@@ -162,13 +162,13 @@ public :
 #endif
 
     if (t == type::_tn) {
-      common::Bag<Time> bag = _dynamics.lambda(t);
+      common::Bag <Time> bag = _dynamics.lambda(t);
 
       if (not bag.empty()) {
         for (auto &event : bag) {
           event.set_model(this);
         }
-        dynamic_cast < common::Coordinator<Time> * >(
+        dynamic_cast < common::Coordinator <Time> * >(
             type::get_parent())->dispatch_events(bag, t);
       }
     }
@@ -185,7 +185,7 @@ public :
 
   }
 
-  void post_event(const typename Time::type &t, const common::ExternalEvent<Time> &event)
+  void post_event(const typename Time::type &t, const common::ExternalEvent <Time> &event)
   {
 
 #ifndef WITH_TRACE

+ 17 - 4
src/artis-star/kernel/pdevs/multithreading/Coordinator.hpp

@@ -280,13 +280,26 @@ public:
     return type::_tn;
   }
 
+  void output(const typename Time::type &t)
+  {
+
+    assert(t == type::_tn);
+
+    common::Models <Time> IMM = type::_event_table.get_current_models(t);
+
+    for (auto &model : IMM) {
+      model->output(t);
+    }
+  }
+
   typename Time::type transition(const typename Time::type &t)
   {
     assert(t >= type::_tl and t <= type::_tn);
 
     common::Models <Time> receivers = type::get_receivers();
-    common::Models <Time> IMM =
-        type::_event_table.get_current_models(t, type::_graph_manager.lookahead(t));
+    common::Models <Time> IMM = type::_event_table.get_current_models(t);
+//    common::Models <Time>
+//        IMM = type::_event_table.get_current_models(t, type::_graph_manager.lookahead(t));
 
     _received = 0;
     for (auto &model : receivers) {
@@ -299,7 +312,7 @@ public:
     for (auto &model : IMM) {
       if (std::find(receivers.begin(), receivers.end(), model) == receivers.end()) {
         if (model->is_atomic()) {
-          type::_event_table.put(model->transition(t), model);
+          type::_event_table.put(model->transition(model->get_tn()), model);
         } else {
           ++_received;
         }
@@ -329,7 +342,7 @@ public:
                         if (it != _child_queues.end()) {
                           it->second->push_child_queue(
                               std::shared_ptr<artis::common::Message>(
-                                  new transition_message<Time>(t)));
+                                  new transition_message<Time>(model->get_tn())));
                         }
                       });
       }