Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use empty() to check for container emptiness.
[simgrid.git] / src / smpi / internals / smpi_deployment.cpp
index d69dbed..93c7e61 100644 (file)
@@ -10,7 +10,7 @@
 #include "smpi_comm.hpp"
 #include <map>
 
-XBT_LOG_EXTERNAL_CATEGORY(smpi);
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi);
 
 namespace simgrid {
 namespace smpi {
@@ -92,7 +92,7 @@ MPI_Comm* smpi_deployment_comm_world(const std::string& instance_id)
 
 void smpi_deployment_cleanup_instances(){
   for (auto const& item : smpi_instances) {
-    XBT_CINFO(smpi, "Stalling SMPI instance: %s. Do all your MPI ranks call MPI_Finalize()?", item.first.c_str());
+    XBT_INFO("Stalling SMPI instance: %s. Do all your MPI ranks call MPI_Finalize()?", item.first.c_str());
     Instance instance = item.second;
     simgrid::smpi::Comm::destroy(instance.comm_world_);
   }
@@ -115,10 +115,10 @@ static std::vector<simgrid::s4u::Host*> smpi_get_hosts(simgrid::s4u::Engine* e,
   xbt_assert(in, "smpirun: Cannot open the host file: %s", hostfile.c_str());
   std::string str;
   while (std::getline(in, str)) {
-    if (str.size() > 0)
+    if (not str.empty())
       hosts.emplace_back(e->host_by_name(str));
   }
-  xbt_assert(hosts.size(), "smpirun: the hostfile '%s' is empty", hostfile.c_str());
+  xbt_assert(not hosts.empty(), "smpirun: the hostfile '%s' is empty", hostfile.c_str());
   return hosts;
 }
 
@@ -133,7 +133,7 @@ static std::vector<std::string> smpi_read_replay(const std::string& replayfile)
   xbt_assert(in, "smpirun: Cannot open the replay file: %s", replayfile.c_str());
   std::string str;
   while (std::getline(in, str)) {
-    if (str.size() > 0)
+    if (not str.empty())
       replay.emplace_back(str);
   }
 
@@ -146,7 +146,7 @@ static std::vector<std::string> smpi_deployment_get_args(int rank_id, const std:
 {
   std::vector<std::string> args{std::to_string(rank_id)};
   // pass arguments to process only if not a replay execution
-  if (replay.size() == 0) {
+  if (replay.empty()) {
     for (int i = 0; i < argc; i++) {
       args.push_back(argv[i]);
     }
@@ -176,7 +176,7 @@ int smpi_deployment_smpirun(simgrid::s4u::Engine* e, const std::string& hostfile
   xbt_assert(np > 0, "Invalid number of process (np must be > 0). Check your np parameter, platform or hostfile");
 
   if (np > hosts_size) {
-    printf("You requested to use %d ranks, but there is only %d processes in your hostfile...\n", np, hosts_size);
+    XBT_INFO("You requested to use %d ranks, but there is only %d processes in your hostfile...", np, hosts_size);
   }
 
   for (int i = 0; i < np; i++) {
@@ -186,15 +186,15 @@ int smpi_deployment_smpirun(simgrid::s4u::Engine* e, const std::string& hostfile
     auto actor               = simgrid::s4u::Actor::create(rank_id, host, rank_id, args);
     /* keeping the same behavior as done in smpirun script, print mapping rank/process */
     if (map != 0) {
-      printf("[rank %d] -> %s\n", i, host->get_cname());
+      XBT_INFO("[rank %d] -> %s", i, host->get_cname());
     }
     actor->set_property("instance_id", "smpirun");
     actor->set_property("rank", rank_id);
-    if (replay.size() > 0)
+    if (not replay.empty())
       actor->set_property("smpi_replay", "true");
     /* shared trace file, set it to rank 0 */
     if (i == 0 && replay.size() == 1)
       actor->set_property("tracefile", replay[0]);
   }
   return np;
-}
\ No newline at end of file
+}