Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / examples / smpi / replay_multiple_manual_deploy / replay_multiple_manual.cpp
index ae7a7df..fc55056 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2020. The SimGrid Team.
+/* Copyright (c) 2009-2021. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -48,13 +48,6 @@ struct Job {
 static std::vector<simgrid::s4u::Host*> hosts;
 static int noise_between_jobs;
 
-static bool job_comparator(const std::unique_ptr<Job>& j1, const std::unique_ptr<Job>& j2)
-{
-  if (j1->starting_time == j2->starting_time)
-    return j1->smpi_app_name < j2->smpi_app_name;
-  return j1->starting_time < j2->starting_time;
-}
-
 static void smpi_replay_process(Job* job, simgrid::s4u::BarrierPtr barrier, int rank)
 {
   XBT_INFO("Replaying rank %d of job %d (smpi_app '%s')", rank, job->unique_job_number, job->smpi_app_name.c_str());
@@ -66,13 +59,10 @@ static void smpi_replay_process(Job* job, simgrid::s4u::BarrierPtr barrier, int
 }
 
 // Sleeps for a given amount of time
-static int sleeper_process(const int* param)
+static int sleeper_process(int param)
 {
-  XBT_DEBUG("Sleeping for %d seconds", *param);
-  simgrid::s4u::this_actor::sleep_for(*param);
-
-  delete param;
-
+  XBT_DEBUG("Sleeping for %d seconds", param);
+  simgrid::s4u::this_actor::sleep_for(param);
   return 0;
 }
 
@@ -80,7 +70,7 @@ static int sleeper_process(const int* param)
 static void pop_some_processes(int nb_processes, simgrid::s4u::Host* host)
 {
   for (int i = 0; i < nb_processes; ++i) {
-    auto* param = new int(i + 1);
+    int param = i + 1;
     simgrid::s4u::Actor::create("meh", host, sleeper_process, param);
   }
 }
@@ -200,8 +190,11 @@ static std::vector<std::unique_ptr<Job>> all_jobs(const std::string& workload_fi
 
   // Jobs are sorted by ascending date, then by lexicographical order of their
   // application names
-  sort(jobs.begin(), jobs.end(), job_comparator);
-
+  sort(jobs.begin(), jobs.end(), [](auto const& j1, auto const& j2) {
+    if (j1->starting_time == j2->starting_time)
+      return j1->smpi_app_name < j2->smpi_app_name;
+    return j1->starting_time < j2->starting_time;
+  });
   for (unsigned int i = 0; i < jobs.size(); ++i)
     jobs[i]->unique_job_number = i;