Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 26 Apr 2016 20:17:56 +0000 (22:17 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 26 Apr 2016 20:17:56 +0000 (22:17 +0200)
Conflicts:
tools/cmake/Tests.cmake

17 files changed:
include/simgrid/s4u/engine.hpp
include/simgrid/s4u/mailbox.hpp
include/simgrid/s4u/storage.hpp
src/s4u/s4u_engine.cpp
src/s4u/s4u_mailbox.cpp
src/simix/RawContext.cpp
src/simix/smx_network_private.h
src/smpi/smpi_base.cpp
src/smpi/smpi_global.cpp
src/smpi/smpi_rma.cpp
src/surf/plugins/energy.cpp
src/surf/surf_interface.cpp
src/surf/vm_hl13.cpp
src/surf/vm_hl13.hpp
teshsuite/smpi/mpich3-test/perf/non_zero_root.c
teshsuite/smpi/mpich3-test/rma/transpose7.c
tools/cmake/Tests.cmake

index 68d3de2..ecd7f7d 100644 (file)
@@ -21,6 +21,9 @@ public:
   /** Constructor, taking the command line parameters of your main function */
   Engine(int *argc, char **argv);
 
+  /** Finalize the default engine and all its dependencies */
+  static void shutdown();
+
   /** @brief Load a platform file describing the environment
    *
    * The environment is either a XML file following the simgrid.dtd formalism, or a lua file.
index 387f63b..aa5f327 100644 (file)
@@ -43,10 +43,20 @@ public:
   /** Returns whether the mailbox contains queued communications */
   bool empty();
 
+  /** Declare that the specified process is a permanent receiver on that mailbox
+   *
+   * It means that the communications sent to this mailbox will start flowing to its host even before he does a recv().
+   * This models the real behavior of TCP and MPI communications, amongst other.
+   */
+  void setReceiver(smx_process_t process);
+  /** Return the process declared as permanent receiver, or nullptr if none **/
+  smx_process_t receiver();
+
 private:
   std::string name_;
   smx_mailbox_t inferior_;
   static boost::unordered_map<std::string, Mailbox *> *mailboxes;
+  friend s4u::Engine;
 };
 }} // namespace simgrid::s4u
 
@@ -54,5 +64,7 @@ private:
 
 XBT_PUBLIC(sg_mbox_t) sg_mbox_by_name(const char*name);
 XBT_PUBLIC(int) sg_mbox_is_empty(sg_mbox_t mbox);
+XBT_PUBLIC(void)sg_mbox_setReceiver(sg_mbox_t mbox, smx_process_t process);
+XBT_PUBLIC(smx_process_t) sg_mbox_receiver(sg_mbox_t mbox);
 
 #endif /* SIMGRID_S4U_MAILBOX_HPP */
index 4b4d98a..e67a1a9 100644 (file)
@@ -40,6 +40,8 @@ XBT_PUBLIC(const char *) MSG_storage_get_host(msg_storage_t storage);
 protected:
   smx_storage_t inferior();
 private:
+  friend s4u::Engine;
+
   static boost::unordered_map<std::string, Storage *> *storages_;
   std::string name_;
   smx_storage_t inferior_;
index f7b078e..1f6a490 100644 (file)
@@ -9,6 +9,8 @@
 #include "mc/mc.h"
 #include "simgrid/s4u/As.hpp"
 #include "simgrid/s4u/engine.hpp"
+#include "simgrid/s4u/mailbox.hpp"
+#include "simgrid/s4u/storage.hpp"
 
 XBT_LOG_NEW_CATEGORY(s4u,"Log channels of the S4U (Simgrid for you) interface");
 using namespace simgrid;
@@ -29,6 +31,13 @@ s4u::Engine *s4u::Engine::instance() {
   return s4u::Engine::instance_;
 }
 
+void s4u::Engine::shutdown() {
+  delete s4u::Engine::instance_;
+  s4u::Engine::instance_ = nullptr;
+  delete s4u::Mailbox::mailboxes;
+  delete s4u::Storage::storages_;
+}
+
 double s4u::Engine::getClock()
 {
   return SIMIX_get_clock();
index c057113..ace9d8c 100644 (file)
@@ -45,9 +45,24 @@ bool s4u::Mailbox::empty() {
   return nullptr == simcall_mbox_get_head(inferior_);
 }
 
+void s4u::Mailbox::setReceiver(smx_process_t process) {
+  simcall_mbox_set_receiver(inferior_, process);
+}
+smx_process_t s4u::Mailbox::receiver() {
+  return simcall_mbox_get_receiver(inferior_);
+}
+
+/*------- C functions -------*/
+
 sg_mbox_t sg_mbox_by_name(const char*name){
   return s4u::Mailbox::byName(name);
 }
 int sg_mbox_is_empty(sg_mbox_t mbox) {
   return mbox->empty();
 }
+void sg_mbox_setReceiver(sg_mbox_t mbox, smx_process_t process) {
+  mbox->setReceiver(process);
+}
+smx_process_t sg_mbox_receiver(sg_mbox_t mbox) {
+  return mbox->receiver();
+}
index 4405027..94770ae 100644 (file)
@@ -123,6 +123,8 @@ extern "C" raw_stack_t raw_makecontext(void* malloced_stack, int stack_size,
                                    rawctx_entry_point_t entry_point, void* arg);
 extern "C" void raw_swapcontext(raw_stack_t* old, raw_stack_t new_context);
 
+// TODO, we should handle FP, MMX and the x87 control-word (for x86 and x86_64)
+
 #if SIMGRID_PROCESSOR_x86_64
 __asm__ (
 #if defined(__APPLE__)
@@ -242,18 +244,24 @@ __asm__ (
    ".type raw_swapcontext,@function\n"
    "raw_swapcontext:\n"
 #endif
-   "   movl 4(%esp),%eax\n" /* old */
-   "   movl 8(%esp),%edx\n" /* new */
+   // Fetch the parameters:
+   "   movl 4(%esp),%eax\n" /* old (raw_stack_t*) */
+   "   movl 8(%esp),%edx\n" /* new (raw_stack_t)  */
+   // Save registers of the current context on the stack:
    "   pushl %ebp\n"
    "   pushl %ebx\n"
    "   pushl %esi\n"
    "   pushl %edi\n"
+   // Save the current context (stack pointer) in *old:
    "   movl %esp,(%eax)\n"
+   // Switch to the stack of the new context:
    "   movl %edx,%esp\n"
+   // Pop the values of the new context:
    "   popl %edi\n"
    "   popl %esi\n"
    "   popl %ebx\n"
    "   popl %ebp\n"
+   // Return using the return address of the new context:
    "   retl\n"
 );
 #else
index cc6e381..039f8f5 100644 (file)
@@ -17,7 +17,6 @@
 typedef struct s_smx_mailbox {
   char *name;
   std::deque<smx_synchro_t> *comm_queue;
-  void *data;
   smx_process_t permanent_receiver; //process which the mailbox is attached to
   std::deque<smx_synchro_t> *done_comm_queue;//messages already received in the permanent receive mode
 } s_smx_mailbox_t;
index 62699a1..4f8742e 100644 (file)
@@ -687,7 +687,7 @@ static void finish_wait(MPI_Request * request, MPI_Status * status)
         if(req->flags & RECV)
           subtype->unserialize(req->buf, req->old_buf, req->real_size/smpi_datatype_size(datatype) ,
                                datatype->substruct, req->op);
-        if(req->detached == 0) free(req->buf);
+        xbt_free(req->buf);
       }else if(req->flags & RECV){//apply op on contiguous buffer for accumulate
           int n =req->real_size/smpi_datatype_size(datatype);
           smpi_op_apply(req->op, req->buf, req->old_buf, &n, &datatype);
index 9a8f5d2..1da6308 100644 (file)
@@ -476,6 +476,10 @@ void smpi_global_destroy(void)
 
   MPI_COMM_WORLD = MPI_COMM_NULL;
 
+  if (!MC_is_active()) {
+    xbt_os_timer_free(global_timer);
+  }
+
   xbt_free(index_to_process_data);
   if(smpi_privatize_global_variables)
     smpi_destroy_global_memory_segments();
index 98d3ae5..0514b83 100644 (file)
@@ -355,6 +355,7 @@ int smpi_mpi_win_complete(MPI_Win win){
   win->requests=xbt_dynar_new(sizeof(MPI_Request), NULL);
   smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE);
   xbt_free(treqs);
+  smpi_group_unuse(win->group);
   win->opened--; //we're closed for business !
   return MPI_SUCCESS;
 }
@@ -404,6 +405,7 @@ int smpi_mpi_win_wait(MPI_Win win){
   win->requests=xbt_dynar_new(sizeof(MPI_Request), NULL);
   smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE);
   xbt_free(treqs);
+  smpi_group_unuse(win->group);
   win->opened--; //we're opened for business !
   return MPI_SUCCESS;
 }
index 8abd780..49b3558 100644 (file)
@@ -104,9 +104,11 @@ HostEnergy::HostEnergy(simgrid::s4u::Host *ptr) :
 
   if (host->properties() != NULL) {
     char* off_power_str = (char*)xbt_dict_get_or_null(host->properties(), "watt_off");
-    if (off_power_str != NULL)
-      watts_off = xbt_str_parse_double(off_power_str,
-          bprintf("Invalid value for property watt_off of host %s: %%s",host->name().c_str()));
+    if (off_power_str != NULL) {
+      char *msg = bprintf("Invalid value for property watt_off of host %s: %%s",host->name().c_str());
+      watts_off = xbt_str_parse_double(off_power_str, msg);
+      xbt_free(msg);
+    }
     else
       watts_off = 0;
   }
@@ -182,12 +184,14 @@ void HostEnergy::initWattsRangeList()
 
     /* min_power corresponds to the idle power (cpu load = 0) */
     /* max_power is the power consumed at 100% cpu load       */
+    char *msg_min = bprintf("Invalid min value for pstate %d on host %s: %%s", i, host->name().c_str());
+    char *msg_max = bprintf("Invalid min value for pstate %d on host %s: %%s", i, host->name().c_str());
     power_range_watts_list.push_back(power_range(
-      xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 0, char*),
-          bprintf("Invalid min value for pstate %d on host %s: %%s", i, host->name().c_str())),
-      xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 1, char*),
-          bprintf("Invalid min value for pstate %d on host %s: %%s", i, host->name().c_str()))
+      xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 0, char*), msg_min),
+      xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 1, char*), msg_max)
     ));
+    xbt_free(msg_min);
+    xbt_free(msg_max);
 
     xbt_dynar_free(&current_power_values);
   }
index a6a4825..4b948c1 100644 (file)
@@ -16,6 +16,7 @@
 #include "mc/mc.h"
 #include "virtual_machine.hpp"
 #include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals
+#include "simgrid/s4u/engine.hpp"
 
 XBT_LOG_NEW_CATEGORY(surf, "All SURF categories");
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (kernel)");
@@ -348,6 +349,7 @@ void surf_exit(void)
 
   tmgr_finalize();
   sg_platf_exit();
+  simgrid::s4u::Engine::shutdown();
 
   NOW = 0;                      /* Just in case the user plans to restart the simulation afterward */
 }
index fde670b..8d54b3c 100644 (file)
@@ -127,6 +127,9 @@ VMHL13::VMHL13(VMModel *model, const char* name, sg_host_t host_PM)
 
   XBT_VERB("Create VM(%s)@PM(%s) with %ld mounted disks", name, hostPM_->name().c_str(), xbt_dynar_length(p_storage));
 }
+VMHL13::~VMHL13() {
+  delete p_cpu;
+}
 
 void VMHL13::suspend()
 {
index a901656..3bcd9b8 100644 (file)
@@ -46,7 +46,7 @@ public:
 class VMHL13 : public VirtualMachine {
 public:
   VMHL13(VMModel *model, const char* name, sg_host_t host_PM);
-  ~VMHL13() {}
+  ~VMHL13();
 
   void suspend() override;
   void resume() override;
index 9384d6b..0be3f88 100644 (file)
@@ -72,6 +72,7 @@ int main(int argc, char* argv[])
        }
        
        MPI_Finalize();
-
+    free(sbuf);
+    free(rbuf);
        return 0;
 }
index d78b2dd..3d2a549 100644 (file)
@@ -97,6 +97,7 @@ int main(int argc, char *argv[])
             MPI_Win_fence(0, win);
         }
         MPI_Win_free(&win);
+        free(A);
     }
     MPI_Comm_free(&CommDeuce);
     MTest_Finalize(errs);
index 65c928f..f98eb40 100644 (file)
@@ -71,9 +71,9 @@ IF(HAVE_MC)
 ENDIF()
 
 IF(enable_smpi_MPICH3_testsuite AND SMPI_FORTRAN AND HAVE_THREAD_CONTEXTS)
-  ADD_TEST(test-smpi-mpich3-thread-f77     ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/f77/ ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests ${TESH_OPTION} -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f77/ -tests=testlist -execarg=--cfg=contexts/stack_size:8000 -execarg=--cfg=smpi/privatize-global-variables:${HAVE_PRIVATIZATION})
+  ADD_TEST(test-smpi-mpich3-thread-f77     ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/f77/ ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests ${TESH_OPTION} -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f77/ -tests=testlist -execarg=--cfg=contexts/stack_size:8000 -execarg=--cfg=contexts/factory:thread -execarg=--cfg=smpi/privatize-global-variables:${HAVE_PRIVATIZATION})
   SET_TESTS_PROPERTIES(test-smpi-mpich3-thread-f77 PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
-  ADD_TEST(test-smpi-mpich3-thread-f90     ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/f90/ ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests ${TESH_OPTION} -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f90/ -tests=testlist -execarg=--cfg=smpi/privatize-global-variables:${HAVE_PRIVATIZATION})
+  ADD_TEST(test-smpi-mpich3-thread-f90     ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR}/teshsuite/smpi/mpich3-test/f90/ ${PERL_EXECUTABLE} ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/runtests ${TESH_OPTION} -mpiexec=${CMAKE_BINARY_DIR}/smpi_script/bin/smpirun -srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/mpich3-test/f90/ -tests=testlist -execarg=--cfg=smpi/privatize-global-variables:${HAVE_PRIVATIZATION} -execarg=--cfg=contexts/factory:thread)
   SET_TESTS_PROPERTIES(test-smpi-mpich3-thread-f90 PROPERTIES PASS_REGULAR_EXPRESSION "tests passed!")
 ENDIF()