Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use std::min.
[simgrid.git] / src / smpi / internals / smpi_global.cpp
index 33efd33..ce1c397 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -473,9 +473,7 @@ static void smpi_init_privatization_dlopen(const std::string& executable)
 
           // Copy the dynamic library, the new name must be the same length as the old one
           // just replace the name with 7 digits for the rank and the rest of the name.
-          unsigned int pad = 7;
-          if (libname.length() < pad)
-            pad = libname.length();
+          auto pad                   = std::min<unsigned>(7, libname.length());
           std::string target_libname = std::string(pad - std::to_string(rank).length(), '0') + std::to_string(rank) + libname.substr(pad);
           std::string target_lib = simgrid::config::get_value<std::string>("smpi/tmpdir") + "/" + target_libname;
           target_libs.push_back(target_lib);
@@ -497,8 +495,10 @@ static void smpi_init_privatization_dlopen(const std::string& executable)
         for (const std::string& target_lib : target_libs)
           unlink(target_lib.c_str());
       }
-      xbt_assert(handle != nullptr, "dlopen failed: %s (errno: %d -- %s)", dlerror(), saved_errno,
-                 strerror(saved_errno));
+      xbt_assert(handle != nullptr,
+                 "dlopen failed: %s (errno: %d -- %s).\nError: Did you compile the program with a SMPI-specific "
+                 "compiler (spmicc or friends)?",
+                 dlerror(), saved_errno, strerror(saved_errno));
 
       smpi_entry_point_type entry_point = smpi_resolve_function(handle);
       xbt_assert(entry_point, "Could not resolve entry point");