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>
Mon, 25 Apr 2016 18:40:58 +0000 (20:40 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 25 Apr 2016 18:40:58 +0000 (20:40 +0200)
15 files changed:
CMakeLists.txt
include/simgrid_config.h.in
include/xbt/signal.hpp
src/mc/Process.cpp
src/smpi/colls/reduce-mvapich-knomial.c
src/smpi/colls/reduce-mvapich-two-level.c
src/smpi/colls/reduce-scatter-gather.c
src/smpi/private.h
src/smpi/smpi_comm.cpp
src/smpi/smpi_global.cpp
src/surf/cpu_interface.hpp
src/surf/ptask_L07.cpp
tools/cmake/DefinePackages.cmake
tools/cmake/MakeLib.cmake
tools/cmake/Modules/FindLibSigc++.cmake [deleted file]

index 00ebaf2..fa02471 100644 (file)
@@ -211,7 +211,6 @@ include(CheckSymbolExists)
 
 set(HAVE_GRAPHVIZ 0)
 include(FindGraphviz)
-include(FindLibSigc++)
 
 set(HAVE_LUA 0)
 if(enable_lua)
@@ -975,7 +974,6 @@ message("        Documentation................: ${enable_documentation}")
 message("        Model checking ..............: ${HAVE_MC}")
 message("        Jedule  mode ................: ${HAVE_JEDULE}")
 message("        Graphviz mode ...............: ${HAVE_GRAPHVIZ}")
-message("        Sigc++ mode .................: ${SIMGRID_HAVE_LIBSIG}")
 message("        Mallocators .................: ${enable_mallocators}")
 message("")
 message("        Simgrid dependencies ........: ${SIMGRID_DEP}")
index 1ff20fa..d6808fc 100644 (file)
@@ -24,6 +24,4 @@
 #define HAVE_MC         @HAVE_MC@ /* Was the model-checking compiled in? */
 #define HAVE_NS3        @HAVE_NS3@ /* Was the NS3 support compiled in? */
 
-#define SIMGRID_HAVE_LIBSIG @SIMGRID_HAVE_LIBSIG@ /* Used in the public interface xbt/signal.hpp :( */
-
 #endif /* SIMGRID_PUBLIC_CONFIG_H */
index 26bd2df..08fbff6 100644 (file)
@@ -6,53 +6,43 @@
 #ifndef SIMGRID_XBT_SIGNAL_HPP
 #define SIMGRID_XBT_SIGNAL_HPP
 
-#include "simgrid_config.h"
-#if SIMGRID_HAVE_LIBSIG
-#include <sigc++/sigc++.h>
-#else
-#include <boost/signals2.hpp>
-#endif
+#include <functional>
+#include <vector>
 
 namespace simgrid {
 namespace xbt {
 
-#if SIMGRID_HAVE_LIBSIG
+  template<class S> class signal;
 
-  // Wraps sigc++ signals with the interface of boost::signals2:
-  template<class T> class signal;
+  /** A signal/slot mechanism
+  *
+  *  S is expected to be the function signature of the signal.
+  *  I'm not sure we need a return value (it is currently ignored).
+  *  If we don't we might use `signal<P1, P2, ...>` instead.
+  */
   template<class R, class... P>
   class signal<R(P...)> {
   private:
-    sigc::signal<R, P...> sig_;
+    typedef std::function<R(P...)> callback_type;
+    std::vector<callback_type> handlers_;
   public:
     template<class U> XBT_ALWAYS_INLINE
-    void connect(U&& slot)
-    {
-      sig_.connect(std::forward<U>(slot));
-    }
-    template<class Res, class... Args> XBT_ALWAYS_INLINE
-    void connect(Res(*slot)(Args...))
+    void connect(U slot)
     {
-      sig_.connect(sigc::ptr_fun(slot));
+      handlers_.push_back(std::move(slot));
     }
-    template<class... Args> XBT_ALWAYS_INLINE
-    R operator()(Args&&... args) const
+    XBT_ALWAYS_INLINE
+    R operator()(P... args) const
     {
-      return sig_.emit(std::forward<Args>(args)...);
+      for (auto& handler : handlers_)
+        handler(args...);
     }
     void disconnect_all_slots()
     {
-      sig_.clear();
+      handlers_.clear();
     }
   };
 
-#else
-
-  template<class T>
-  using signal = ::boost::signals2::signal<T>;
-
-#endif
-
 }
 }
 
index de390cd..597710f 100644 (file)
@@ -77,7 +77,6 @@ static const char *const filtered_libraries[] = {
   "libm",
   "libpthread",
   "librt",
-  "libsigc",
   "libstdc++",
   "libunwind",
   "libunwind-x86_64",
index cbed125..7ec5c64 100644 (file)
@@ -215,6 +215,8 @@ int smpi_coll_tuned_reduce_mvapich2_knomial (
                 COLL_TAG_REDUCE,comm);
 
         smpi_mpi_waitall(1, &send_request, &status);
+
+        smpi_free_tmp_buffer((void *)((char*)recvbuf + true_lb));
     }
 
     /* --END ERROR HANDLING-- */
index 306bec9..be67ddd 100644 (file)
@@ -233,6 +233,7 @@ int smpi_coll_tuned_reduce_mvapich2_two_level( void *sendbuf,
                                       intra_node_root, shmem_comm);
         }
     } else { 
+        smpi_free_tmp_buffer((void *) ((char *) tmp_buf + true_lb));
         tmp_buf = in_buf; 
     } 
 
@@ -286,15 +287,23 @@ int smpi_coll_tuned_reduce_mvapich2_two_level( void *sendbuf,
             smpi_mpi_send(tmp_buf, count, datatype, root,
                                      COLL_TAG_REDUCE+1, comm);
         }
-
         if ((local_rank != 0) && (root == my_rank)) {
             smpi_mpi_recv(recvbuf, count, datatype,
                                      leader_of_root,
                                      COLL_TAG_REDUCE+1, comm,
                                      MPI_STATUS_IGNORE);
         }
+      smpi_free_tmp_buffer((void *) ((char *) tmp_buf + true_lb));
+
+      if (leader_comm_rank == leader_root) {
+        if (my_rank != root || (my_rank == root && tmp_buf == recvbuf)) { 
+          smpi_free_tmp_buffer(in_buf);
+        }
+      }
     }
 
+
+
   fn_exit:
     return mpi_errno;
 }
index 57161ff..98f2a09 100644 (file)
@@ -21,7 +21,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf,
   int recv_idx, last_idx = 0, newdst;
   int dst, send_cnt, recv_cnt, newroot, newdst_tree_root;
   int newroot_tree_root, new_count;
-  int tag = COLL_TAG_REDUCE;
+  int tag = COLL_TAG_REDUCE,temporary_buffer=0;
   void *send_ptr, *recv_ptr, *tmp_buf;
 
   cnts = NULL;
@@ -40,6 +40,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf,
   /* If I'm not the root, then my recvbuf may not be valid, therefore
   I have to allocate a temporary one */
   if (rank != root && !recvbuf) {
+    temporary_buffer=1;
     recvbuf = (void *)smpi_get_tmp_recvbuffer(count * extent);
   }
   /* find nearest power-of-two less than or equal to comm_size */
@@ -401,6 +402,7 @@ int smpi_coll_tuned_reduce_scatter_gather(void *sendbuf, void *recvbuf,
   }
   if (tmp_buf)
     smpi_free_tmp_buffer(tmp_buf);
+  if(temporary_buffer==1) smpi_free_tmp_buffer(recvbuf);
   if (cnts)
     free(cnts);
   if (disps)
index b5f2743..746abc8 100644 (file)
@@ -262,6 +262,8 @@ XBT_PRIVATE MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key);
 XBT_PRIVATE int smpi_comm_dup(MPI_Comm comm, MPI_Comm* newcomm);
 XBT_PRIVATE void smpi_comm_use(MPI_Comm comm);
 XBT_PRIVATE void smpi_comm_unuse(MPI_Comm comm);
+XBT_PRIVATE void smpi_comm_cleanup_attributes(MPI_Comm comm);
+XBT_PRIVATE void smpi_comm_cleanup_smp(MPI_Comm comm);
 XBT_PRIVATE void smpi_comm_set_leaders_comm(MPI_Comm comm, MPI_Comm leaders);
 XBT_PRIVATE void smpi_comm_set_intra_comm(MPI_Comm comm, MPI_Comm leaders);
 XBT_PRIVATE int* smpi_comm_get_non_uniform_map(MPI_Comm comm);
index 4e45a21..e5370df 100644 (file)
@@ -314,12 +314,22 @@ void smpi_comm_use(MPI_Comm comm){
   comm->refcount++;
 }
 
-void smpi_comm_unuse(MPI_Comm comm){
-  if (comm == MPI_COMM_UNINITIALIZED)
-    comm = smpi_process_comm_world();
-  comm->refcount--;
-  smpi_group_unuse(comm->group);
-  if(comm->refcount==0){
+void smpi_comm_cleanup_attributes(MPI_Comm comm){
+  if(comm->attributes !=NULL){
+    xbt_dict_cursor_t cursor = NULL;
+    int* key;
+    void * value;
+    int flag;
+    xbt_dict_foreach(comm->attributes, cursor, key, value){
+      smpi_comm_key_elem elem =
+         static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)key));
+      if(elem &&  elem->delete_fn)
+        elem->delete_fn(comm, *key, value, &flag);
+    }
+  }
+}
+
+void smpi_comm_cleanup_smp(MPI_Comm comm){
     if(comm->intra_comm != MPI_COMM_NULL)
       smpi_comm_unuse(comm->intra_comm);
     if(comm->leaders_comm != MPI_COMM_NULL)
@@ -328,18 +338,17 @@ void smpi_comm_unuse(MPI_Comm comm){
       xbt_free(comm->non_uniform_map);
     if(comm->leaders_map !=NULL)
       xbt_free(comm->leaders_map);
-    if(comm->attributes !=NULL){
-      xbt_dict_cursor_t cursor = NULL;
-      int* key;
-      void * value;
-      int flag;
-      xbt_dict_foreach(comm->attributes, cursor, key, value){
-        smpi_comm_key_elem elem =
-           static_cast<smpi_comm_key_elem>(xbt_dict_get_or_null(smpi_comm_keyvals, (const char*)key));
-        if(elem &&  elem->delete_fn)
-          elem->delete_fn(comm, *key, value, &flag);
-      }
-    }
+}
+
+void smpi_comm_unuse(MPI_Comm comm){
+  if (comm == MPI_COMM_UNINITIALIZED)
+    comm = smpi_process_comm_world();
+  comm->refcount--;
+  smpi_group_unuse(comm->group);
+
+  if(comm->refcount==0){
+    smpi_comm_cleanup_smp(comm);
+    smpi_comm_cleanup_attributes(comm);
     xbt_free(comm);
   }
 }
@@ -467,9 +476,13 @@ void smpi_comm_init_smp(MPI_Comm comm){
     for (i=0; i< leader_group_size;i++)
       smpi_group_set_mapping(leaders_group, leader_list[i], i);
 
-    leader_comm = smpi_comm_new(leaders_group, NULL);
-    if(smpi_comm_get_leaders_comm(comm)==MPI_COMM_NULL)
+    if(smpi_comm_get_leaders_comm(comm)==MPI_COMM_NULL){
+      leader_comm = smpi_comm_new(leaders_group, NULL);
       smpi_comm_set_leaders_comm(comm, leader_comm);
+    }else{
+      leader_comm=smpi_comm_get_leaders_comm(comm);
+      smpi_group_unuse(leaders_group);
+    }
     smpi_process_set_comm_intra(comm_intra);
   }
 
index 6fa71ac..7f6c52c 100644 (file)
@@ -466,8 +466,12 @@ void smpi_global_destroy(void)
   xbt_free(process_data);
   process_data = NULL;
 
-  if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED)
+  if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){
+    smpi_comm_cleanup_smp(MPI_COMM_WORLD);
+    smpi_comm_cleanup_attributes(MPI_COMM_WORLD);
     xbt_free(MPI_COMM_WORLD);
+  }
+
   MPI_COMM_WORLD = MPI_COMM_NULL;
 
   xbt_free(index_to_process_data);
index 82763d4..bd42a47 100644 (file)
@@ -4,8 +4,19 @@
 /* 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. */
 
+#include <list>
+
+#include <xbt/base.h>
+#include <xbt/dynar.h>
+#include <xbt/signal.hpp>
+
+#include <simgrid/forward.h>
+#include <simgrid/s4u/host.hpp>
+
+#include "surf/datatypes.h"
 #include "surf_interface.hpp"
 #include "maxmin_private.hpp"
+#include "trace_mgr.hpp"
 
 #ifndef SURF_CPU_INTERFACE_HPP_
 #define SURF_CPU_INTERFACE_HPP_
index 8d21b65..9a7179f 100644 (file)
@@ -152,8 +152,7 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) {
 
       while ((cnst = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i++))) {
         void *constraint_id = lmm_constraint_id(cnst);
-
-        if (static_cast<HostImpl*>(constraint_id)->isOff()) {
+        if (static_cast<simgrid::surf::Resource*>(constraint_id)->isOff()) {
           XBT_DEBUG("Action (%p) Failed!!", action);
           action->finish();
           action->setState(Action::State::failed);
index c9aa053..683a623 100644 (file)
@@ -986,7 +986,6 @@ set(CMAKE_SOURCE_FILES
   tools/cmake/MakeLibWin.cmake
   tools/cmake/Modules/FindGFortran.cmake
   tools/cmake/Modules/FindGraphviz.cmake
-  tools/cmake/Modules/FindLibSigc++.cmake
   tools/cmake/Modules/FindLibdw.cmake
   tools/cmake/Modules/FindLibunwind.cmake
   tools/cmake/Modules/FindLuaSimgrid.cmake
index 4115a97..6b825b2 100644 (file)
@@ -66,11 +66,6 @@ if(HAVE_GRAPHVIZ)
   endif()
 endif()
 
-if(SIMGRID_HAVE_LIBSIG)
-  SET(SIMGRID_DEP "${SIMGRID_DEP} -lsigc-2.0")
-  add_definitions(-DLIBSIGC)
-endif()
-
 if(HAVE_MC)
   # The availability of libunwind was checked in CompleteInFiles.cmake
   #   (that includes FindLibunwind.cmake), so simply load it now.
diff --git a/tools/cmake/Modules/FindLibSigc++.cmake b/tools/cmake/Modules/FindLibSigc++.cmake
deleted file mode 100644 (file)
index 55de343..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-find_path(PATH_LIBSIGC++_H "sigc++/sigc++.h"
-  HINTS
-  $ENV{LD_LIBRARY_PATH}
-  PATH_SUFFIXES include/sigc++-2.0/ include/
-  PATHS
-  /opt
-  /opt/local
-  /opt/csw
-  /sw
-  /usr)
-
-find_path(PATH_LIBSIGC++CONFIG_H "sigc++config.h"
-  HINTS
-  $ENV{LD_LIBRARY_PATH}
-  PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE}/sigc++-2.0/include/ include/
-  PATHS
-  /opt
-  /opt/local
-  /opt/csw
-  /sw
-  /usr)
-
-find_library(PATH_LIBSIGC++_LIB
-  NAMES sigc-2.0
-  HINTS
-  $ENV{LD_LIBRARY_PATH}
-  PATH_SUFFIXES lib/${CMAKE_LIBRARY_ARCHITECTURE}/ lib/sigc++/ lib/
-  PATHS
-  /opt
-  /opt/local
-  /opt/csw
-  /sw
-  /usr)
-
-message(STATUS "Looking for sigc++/sigc++.h")
-if(PATH_LIBSIGC++_H)
-  message(STATUS "Looking for sigc++/sigc++.h - found")
-else()
-  message(STATUS "Looking for sigc++/sigc++.h - not found")
-endif()
-
-message(STATUS "Looking for sigc++config.h")
-if(PATH_LIBSIGC++CONFIG_H)
-  message(STATUS "Looking for sigc++config.h - found")
-else()
-  message(STATUS "Looking for sigc++config.h - not found")
-endif()
-
-message(STATUS "Looking for libsigc++")
-if(PATH_LIBSIGC++_LIB)
-  message(STATUS "Looking for libsigc++ - found")
-else()
-  message(STATUS "Looking for libsigc++ - not found")
-endif()
-
-if(PATH_LIBSIGC++_LIB AND PATH_LIBSIGC++_H AND PATH_LIBSIGC++CONFIG_H)
-  string(REGEX REPLACE "/sigc\\+\\+/sigc\\+\\+.h" "" PATH_LIBSIGC++_H   "${PATH_LIBSIGC++_H}")
-  string(REGEX REPLACE "/sigc\\+\\+config.h" "" PATH_LIBSIGC++CONFIG_H   "${PATH_LIBSIGC++CONFIG_H}")
-  string(REGEX REPLACE "/libsig.*" "" PATH_LIBSIGC++_LIB "${PATH_LIBSIGC++_LIB}")
-      
-  include_directories(${PATH_LIBSIGC++_H})
-  include_directories(${PATH_LIBSIGC++CONFIG_H})
-  link_directories(${PATH_LIBSIGC++_LIB})
-  set(SIMGRID_HAVE_LIBSIG "1")
-else()
-  set(SIMGRID_HAVE_LIBSIG "0")
-endif()
-
-mark_as_advanced(PATH_LIBSIGC++_H)
-mark_as_advanced(PATH_LIBSIGC++CONFIG_H)
-mark_as_advanced(PATH_LIBSIGC++_LIB)