X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/924238393995588eb022cf28344c5e62527e0dde..ea74f5d95928a521a588737e81f1de94eef25d19:/examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp diff --git a/examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp b/examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp index c82a7c7e5a..7495814a7d 100644 --- a/examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp +++ b/examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2020. The SimGrid Team. +/* Copyright (c) 2009-2022. 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 hosts; static int noise_between_jobs; -static bool job_comparator(const std::unique_ptr& j1, const std::unique_ptr& 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()); @@ -103,9 +96,9 @@ static int job_executor_process(Job* job) } // Executes a workload of SMPI processes -static int workload_executor_process(const std::vector>* workload) +static int workload_executor_process(const std::vector>& workload) { - for (auto const& job : *workload) { + for (auto const& job : workload) { // Let's wait until the job's waiting time if needed double curr_time = simgrid::s4u::Engine::get_clock(); if (job->starting_time > curr_time) { @@ -171,7 +164,7 @@ static std::vector> all_jobs(const std::string& workload_fi // Let's read the filename std::ifstream traces_file(job->filename); - if (!traces_file.is_open()) + if (not traces_file.is_open()) throw std::invalid_argument("Cannot open file " + job->filename); std::string traces_line; @@ -197,8 +190,11 @@ static std::vector> 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; @@ -240,10 +236,10 @@ int main(int argc, char* argv[]) } // Let's execute the workload - simgrid::s4u::Actor::create("workload", hosts[0], workload_executor_process, &jobs); + simgrid::s4u::Actor::create("workload", hosts[0], workload_executor_process, std::cref(jobs)); e.run(); - XBT_INFO("Simulation finished! Final time: %g", e.get_clock()); + XBT_INFO("Simulation finished! Final time: %g", simgrid::s4u::Engine::get_clock()); SMPI_finalize();