Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 12 Aug 2018 16:34:33 +0000 (18:34 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 12 Aug 2018 16:34:33 +0000 (18:34 +0200)
src/kernel/context/Context.hpp
src/mc/Session.cpp
src/mc/checker/CommunicationDeterminismChecker.cpp
src/mc/remote/RemoteClient.cpp
src/plugins/host_dvfs.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/plugins/ampi/ampi.cpp
src/smpi/plugins/ampi/ampi.hpp
teshsuite/smpi/mpich3-test/util/dtypes.c

index dd4e482..674f02d 100644 (file)
@@ -65,6 +65,9 @@ public:
   bool iwannadie;
 
   Context(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process);
+  Context(const Context&) = delete;
+  Context& operator=(const Context&) = delete;
+
   void operator()() { code_(); }
   bool has_code() const { return static_cast<bool>(code_); }
   smx_actor_t process() { return this->process_; }
index da8c02b..1d7b32e 100644 (file)
@@ -86,8 +86,12 @@ pid_t do_fork(F code)
 Session::Session(pid_t pid, int socket)
 {
   std::unique_ptr<simgrid::mc::RemoteClient> process(new simgrid::mc::RemoteClient(pid, socket));
+#if HAVE_SMPI
   // TODO, automatic detection of the config from the process
   process->privatized(smpi_privatize_global_variables != SmpiPrivStrategies::NONE);
+#else
+  process->privatized(false);
+#endif
   modelChecker_ = std::unique_ptr<ModelChecker>(
     new simgrid::mc::ModelChecker(std::move(process)));
   xbt_assert(mc_model_checker == nullptr);
index c417b91..016d3bf 100644 (file)
@@ -14,7 +14,9 @@
 #include "src/mc/mc_state.hpp"
 #include "src/mc/remote/Client.hpp"
 
+#if HAVE_SMPI
 #include "smpi_request.hpp"
+#endif
 
 #include <cstdint>
 
@@ -194,14 +196,17 @@ void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_sim
     pattern->src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(synchro->src_proc))->pid_;
     pattern->src_host = MC_smx_actor_get_host_name(issuer);
 
+#if HAVE_SMPI
     simgrid::smpi::Request mpi_request = mc_model_checker->process().read<simgrid::smpi::Request>(
         RemotePtr<simgrid::smpi::Request>((std::uint64_t)simcall_comm_isend__get__data(request)));
     pattern->tag = mpi_request.tag();
+#endif
 
     if (synchro->src_buff != nullptr) {
       pattern->data.resize(synchro->src_buff_size);
       mc_model_checker->process().read_bytes(pattern->data.data(), pattern->data.size(), remote(synchro->src_buff));
     }
+#if HAVE_SMPI
     if(mpi_request.detached()){
       if (not this->initial_communications_pattern_done) {
         /* Store comm pattern */
@@ -216,14 +221,17 @@ void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_sim
       }
       return;
     }
+#endif
   } else if (call_type == MC_CALL_TYPE_RECV) {
     pattern->type = simgrid::mc::PatternCommunicationType::receive;
     pattern->comm_addr = static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_irecv__getraw__result(request));
 
+#if HAVE_SMPI
     simgrid::smpi::Request mpi_request;
     mc_model_checker->process().read(&mpi_request,
                                      remote((simgrid::smpi::Request*)simcall_comm_irecv__get__data(request)));
     pattern->tag = mpi_request.tag();
+#endif
 
     simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
     mc_model_checker->process().read(temp_comm,
index 0d63b68..6024c70 100644 (file)
@@ -455,10 +455,10 @@ std::string RemoteClient::read_string(RemotePtr<char> address) const
 const void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, int process_index,
                                      ReadOptions options) const
 {
+#if HAVE_SMPI
   if (process_index != simgrid::mc::ProcessIndexDisabled) {
     std::shared_ptr<simgrid::mc::ObjectInformation> const& info = this->find_object_info_rw(address);
-// Segment overlap is not handled.
-#if HAVE_SMPI
+    // Segment overlap is not handled.
     if (info.get() && this->privatized(*info)) {
       if (process_index < 0)
         xbt_die("Missing process index");
@@ -477,8 +477,8 @@ const void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr<v
       size_t offset = address.address() - (std::uint64_t)info->start_rw;
       address       = remote((char*)privatization_region.address + offset);
     }
-#endif
   }
+#endif
   if (pread_whole(this->memory_file, buffer, size, (size_t)address.address()) < 0)
     xbt_die("Read at %p from process %lli failed", (void*)address.address(), (long long)this->pid_);
   return buffer;
index 4cb1f04..e5a2f47 100644 (file)
@@ -6,9 +6,12 @@
 #include "simgrid/plugins/dvfs.h"
 #include "simgrid/plugins/load.h"
 #include "simgrid/s4u/Engine.hpp"
+#include "src/internal_config.h" // HAVE_SMPI
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
+#if HAVE_SMPI
 #include "src/smpi/plugins/ampi/ampi.hpp"
+#endif
 #include <xbt/config.hpp>
 
 #include <boost/algorithm/string.hpp>
@@ -267,6 +270,7 @@ public:
   explicit Adagio(simgrid::s4u::Host* ptr)
       : Governor(ptr), rates(100, std::vector<double>(ptr->get_pstate_count(), 0.0))
   {
+#if HAVE_SMPI
     simgrid::smpi::plugin::ampi::on_iteration_in.connect([this](simgrid::s4u::ActorPtr actor) {
       // Every instance of this class subscribes to this event, so one per host
       // This means that for any actor, all 'hosts' are normally notified of these
@@ -282,6 +286,7 @@ public:
         task_id           = 0;
       }
     });
+#endif
     simgrid::kernel::activity::ExecImpl::on_creation.connect([this](simgrid::kernel::activity::ExecImplPtr activity) {
       if (activity->host_ == get_host())
         pre_task();
@@ -331,7 +336,6 @@ public:
       for (int i = 1; i < get_host()->get_pstate_count(); i++) {
         rates[task_id][i] = rates[task_id][0] * (get_host()->get_pstate_speed(i) / get_host()->get_speed());
       }
-      is_initialized = true;
     }
 
     for (int pstate = get_host()->get_pstate_count() - 1; pstate >= 0; pstate--) {
index bd0b4e0..84c818a 100644 (file)
@@ -13,6 +13,7 @@
 #include "src/smpi/include/smpi_actor.hpp"
 #include "xbt/config.hpp"
 
+#include <algorithm>
 #include <cfloat> /* DBL_MAX */
 #include <dlfcn.h>
 #include <fcntl.h>
@@ -426,14 +427,16 @@ typedef void (*smpi_fortran_entry_point_type)();
 
 static int smpi_run_entry_point(smpi_entry_point_type entry_point, std::vector<std::string> args)
 {
-  int argc_saved = args.size();
-  int argc=argc_saved;
-  char** argv = new char*[argc + 1];
-  for (int i = 0; i != argc; ++i)
-    argv[i] = xbt_strdup(args[i].c_str());
-  argv[argc] = nullptr;
-  char* name = argv[0];
-  char* instance = argv[1];
+  // copy C strings, we need them writable
+  std::vector<char*>* args4argv = new std::vector<char*>(args.size());
+  std::transform(begin(args), end(args), begin(*args4argv), [](const std::string& s) { return xbt_strdup(s.c_str()); });
+
+  // take a copy of args4argv to keep reference of the allocated strings
+  const std::vector<char*> args2str(*args4argv);
+  int argc = args4argv->size();
+  args4argv->push_back(nullptr);
+  char** argv = args4argv->data();
+
   simgrid::smpi::ActorExt::init(&argc, &argv);
 #if SMPI_IFORT
   for_rtl_init_ (&argc, argv);
@@ -448,13 +451,9 @@ static int smpi_run_entry_point(smpi_entry_point_type entry_point, std::vector<s
 #if SMPI_IFORT
   for_rtl_finish_ ();
 #else
-  for (int i = 0; i != argc; ++i)
-    xbt_free(argv[i]);
-  if (argc_saved > 3) {
-    xbt_free(instance);
-    xbt_free(name);
-  }
-  delete[] argv;
+  for (char* s : args2str)
+    xbt_free(s);
+  delete args4argv;
 #endif
 
   if (res != 0){
index 6f400b8..d2780de 100644 (file)
@@ -30,6 +30,7 @@ extern "C" void _sampi_free(void* ptr)
   free(ptr);
 }
 
+#include "ampi.hpp"
 #include <smpi/sampi.h>
 namespace simgrid {
 namespace smpi {
index 0685cee..7f3912e 100644 (file)
@@ -3,6 +3,9 @@
 /* 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. */
 
+#ifndef AMPI_HPP
+#define AMPI_HPP
+
 #include <simgrid/s4u.hpp>
 
 namespace simgrid {
@@ -16,3 +19,4 @@ namespace ampi {
 }
 }
 
+#endif
index 8e60c20..b93fc9b 100644 (file)
@@ -56,6 +56,8 @@ static int basic_only = 0;
    has been received.
  */
 
+#define STR_SIZE 200
+
 /*
    Add a predefined MPI type to the tests.  _count instances of the
    type will be sent.
@@ -84,9 +86,9 @@ static int basic_only = 0;
   outbufs[cnt] = (void *)malloc(sizeof(_ctype) * (_count));    \
   a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i] = i;      \
   a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i] = 0;     \
-  myname = (char *)malloc(100);\
+  myname = (char *)malloc(STR_SIZE);\
   MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
-  snprintf(myname, 100, "Contig type %s", _basename);  \
+  snprintf(myname, STR_SIZE, "Contig type %s", _basename);     \
   MPI_Type_set_name(types[cnt], myname); \
   free(myname); \
   counts[cnt]  = 1;  bytesize[cnt] = sizeof(_ctype) * (_count); cnt++; }
@@ -105,9 +107,9 @@ static int basic_only = 0;
   outbufs[cnt] = (void *)calloc(sizeof(_ctype) * (_count) * (_stride),1); \
   a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = i; \
   a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = 0; \
-  myname = (char *)malloc(100);\
+  myname = (char *)malloc(STR_SIZE);\
   MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
-  snprintf(myname, 100, "Vector type %s", _basename);          \
+  snprintf(myname, STR_SIZE, "Vector type %s", _basename);             \
   MPI_Type_set_name(types[cnt], myname); \
   free(myname); \
   counts[cnt]  = 1; bytesize[cnt] = sizeof(_ctype) * (_count) * (_stride) ;\
@@ -130,9 +132,9 @@ static int basic_only = 0;
   outbufs[cnt] = (void *)malloc(sizeof(_ctype) * (_count)); \
   a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i] = i; \
   a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i] = 0; \
-  myname = (char *)malloc(100);\
+  myname = (char *)malloc(STR_SIZE);\
   MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
-  snprintf(myname, 100, "Index type %s", _basename);           \
+  snprintf(myname, STR_SIZE, "Index type %s", _basename);              \
   MPI_Type_set_name(types[cnt], myname); \
   free(myname); \
   counts[cnt]  = 1;  bytesize[cnt] = sizeof(_ctype) * (_count); cnt++; }
@@ -159,8 +161,8 @@ static int basic_only = 0;
       a[i].a2 = i; }                                                   \
   a = (struct name *)outbufs[cnt]; for (i=0; i<(_count); i++) { a[i].a1 = 0; \
       a[i].a2 = 0; }                                                   \
-  myname = (char *)malloc(100);                                        \
-  snprintf(myname, 100, "Struct type %s", _tname);             \
+  myname = (char *)malloc(STR_SIZE);                                   \
+  snprintf(myname, STR_SIZE, "Struct type %s", _tname);                \
   MPI_Type_set_name(types[cnt], myname); \
   free(myname); \
   counts[cnt]  = (_count);  bytesize[cnt] = sizeof(struct name) * (_count);cnt++; }
@@ -180,9 +182,9 @@ static int basic_only = 0;
   outbufs[cnt] = (void *)calloc(sizeof(_ctype) * (_count) * (_stride),1);\
   a = (_ctype *)inbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = i;  \
   a = (_ctype *)outbufs[cnt]; for (i=0; i<(_count); i++) a[i*(_stride)] = 0; \
-  myname = (char *)malloc(100);                                        \
+  myname = (char *)malloc(STR_SIZE);                                   \
   MPI_Type_get_name(_mpitype, _basename, &_basenamelen); \
-  snprintf(myname, 100, "Struct (MPI_UB) type %s", _basename); \
+  snprintf(myname, STR_SIZE, "Struct (MPI_UB) type %s", _basename);    \
   MPI_Type_set_name(types[cnt], myname); \
   free(myname); \
   counts[cnt]  = (_count);  \