Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce scope for variables.
[simgrid.git] / src / smpi / internals / smpi_replay.cpp
index b901e96..2af987f 100644 (file)
@@ -61,7 +61,7 @@ public:
 };
 }
 
-typedef std::tuple</*sender*/ int, /* reciever */ int, /* tag */int> req_key_t;
+typedef std::tuple</*sender*/ int, /* receiver */ int, /* tag */ int> req_key_t;
 typedef std::unordered_map<req_key_t, MPI_Request, hash_tuple::hash<std::tuple<int,int,int>>> req_storage_t;
 
 void log_timed_action(simgrid::xbt::ReplayAction& action, double clock)
@@ -165,6 +165,19 @@ void ComputeParser::parse(simgrid::xbt::ReplayAction& action, const std::string&
   flops = parse_double(action[2]);
 }
 
+void SleepParser::parse(simgrid::xbt::ReplayAction& action, const std::string&)
+{
+  CHECK_ACTION_PARAMS(action, 1, 0)
+  time = parse_double(action[2]);
+}
+
+void LocationParser::parse(simgrid::xbt::ReplayAction& action, const std::string&)
+{
+  CHECK_ACTION_PARAMS(action, 2, 0)
+  filename = std::string(action[2]);
+  line = std::stoi(action[3]);
+}
+
 void BcastArgParser::parse(simgrid::xbt::ReplayAction& action, const std::string&)
 {
   CHECK_ACTION_PARAMS(action, 1, 2)
@@ -260,13 +273,12 @@ void GatherVArgParser::parse(simgrid::xbt::ReplayAction& action, const std::stri
     if (action.size() > 5 + comm_size)
       datatype2 = simgrid::smpi::Datatype::decode(action[5 + comm_size]);
   } else {
-    int datatype_index = 0;
     int disp_index     = 0;
     /* The 3 comes from "0 gather <sendcount>", which must always be present.
      * The + comm_size is the recvcounts array, which must also be present
      */
     if (action.size() > 3 + comm_size + comm_size) { /* datatype + disp are specified */
-      datatype_index = 3 + comm_size;
+      int datatype_index = 3 + comm_size;
       disp_index     = datatype_index + 1;
       datatype1      = simgrid::smpi::Datatype::decode(action[datatype_index]);
       datatype2      = simgrid::smpi::Datatype::decode(action[datatype_index]);
@@ -274,7 +286,7 @@ void GatherVArgParser::parse(simgrid::xbt::ReplayAction& action, const std::stri
                3 + comm_size + 2) { /* disps specified; datatype is not specified; use the default one */
       disp_index = 3 + comm_size;
     } else if (action.size() > 3 + comm_size) { /* only datatype, no disp specified */
-      datatype_index = 3 + comm_size;
+      int datatype_index = 3 + comm_size;
       datatype1      = simgrid::smpi::Datatype::decode(action[datatype_index]);
       datatype2      = simgrid::smpi::Datatype::decode(action[datatype_index]);
     }
@@ -477,7 +489,23 @@ void RecvAction::kernel(simgrid::xbt::ReplayAction&)
 
 void ComputeAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  smpi_execute_flops(args.flops);
+  if (simgrid::config::get_value<bool>("smpi/simulate-computation")) {
+    smpi_execute_flops(args.flops/smpi_adjust_comp_speed());
+  }
+}
+
+void SleepAction::kernel(simgrid::xbt::ReplayAction&)
+{
+  XBT_DEBUG("Sleep for: %lf secs", args.time);
+  int rank = simgrid::s4u::this_actor::get_pid();
+  TRACE_smpi_sleeping_in(rank, args.time);
+  simgrid::s4u::this_actor::sleep_for(args.time/smpi_adjust_comp_speed());
+  TRACE_smpi_sleeping_out(rank);
+}
+
+void LocationAction::kernel(simgrid::xbt::ReplayAction&)
+{
+  smpi_trace_set_call_location(args.filename.c_str(), args.line);
 }
 
 void TestAction::kernel(simgrid::xbt::ReplayAction&)
@@ -746,6 +774,8 @@ void smpi_replay_init(const char* instance_id, int rank, double start_delay_flop
   xbt_replay_action_register("allgatherv", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::GatherVAction("allgatherv").execute(action); });
   xbt_replay_action_register("reducescatter", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::ReduceScatterAction().execute(action); });
   xbt_replay_action_register("compute", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::ComputeAction().execute(action); });
+  xbt_replay_action_register("sleep", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::SleepAction().execute(action); });
+  xbt_replay_action_register("location", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::LocationAction().execute(action); });
 
   //if we have a delayed start, sleep here.
   if (start_delay_flops > 0) {