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, 31 May 2016 11:40:19 +0000 (13:40 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 31 May 2016 11:40:19 +0000 (13:40 +0200)
24 files changed:
include/simgrid/forward.h
src/instr/instr_trace.cpp
src/mc/LivenessChecker.cpp
src/mc/VisitedState.cpp
src/mc/mc_base.cpp
src/mc/mc_base.h
src/mc/mc_dwarf.cpp
src/mc/mc_state.cpp
src/simgrid/util.hpp
src/simix/Synchro.cpp
src/simix/Synchro.h
src/simix/SynchroComm.cpp
src/simix/SynchroExec.cpp
src/simix/SynchroIo.cpp
src/simix/SynchroSleep.cpp
src/simix/popping_private.h
src/simix/smx_host.cpp
src/simix/smx_io.cpp
src/simix/smx_network.cpp
src/simix/smx_process.cpp
src/simix/smx_synchro.cpp
src/surf/host_clm03.cpp
src/surf/network_ib.cpp
src/surf/vm_hl13.cpp

index 437d794..3e2ac32 100644 (file)
@@ -68,6 +68,9 @@ typedef struct s_xbt_dictelm *sg_storage_t;
 
 typedef tmgr_Trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */
 
+typedef struct s_smx_simcall s_smx_simcall_t;
+typedef struct s_smx_simcall* smx_simcall_t;
+
 typedef enum {
   SURF_LINK_FULLDUPLEX = 2,
   SURF_LINK_SHARED = 1,
index 850f75e..e5ebbf2 100644 (file)
@@ -343,11 +343,13 @@ void new_pajeSetState (double timestamp, container_t container, type_t type, val
   ((setState_t)(event->data))->container = container;
   ((setState_t)(event->data))->value = value;
 
+#if HAVE_SMPI
   if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
     smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
     ((setState_t)(event->data))->filename   = loc->filename;
     ((setState_t)(event->data))->linenumber = loc->linenumber;
   }
+#endif
 
   XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
 
@@ -368,11 +370,13 @@ void new_pajePushStateWithExtra (double timestamp, container_t container, type_t
   ((pushState_t)(event->data))->value = value;
   ((pushState_t)(event->data))->extra = extra;
 
+#if HAVE_SMPI
   if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
     smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
     ((pushState_t)(event->data))->filename   = loc->filename;
     ((pushState_t)(event->data))->linenumber = loc->linenumber;
   }
+#endif
 
   XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
 
index 3853e2b..4f60bc1 100644 (file)
@@ -6,10 +6,11 @@
 
 #include <cstring>
 
-#include <algorithm>
 #include <memory>
 #include <list>
 
+#include <boost/range/algorithm.hpp>
+
 #include <unistd.h>
 #include <sys/wait.h>
 
@@ -124,7 +125,7 @@ std::shared_ptr<VisitedPair> LivenessChecker::insertAcceptancePair(simgrid::mc::
     pair->num, pair->automaton_state, pair->atomic_propositions,
     pair->graph_state);
 
-  auto res = std::equal_range(acceptancePairs_.begin(), acceptancePairs_.end(),
+  auto res = boost::range::equal_range(acceptancePairs_,
     new_pair.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap());
 
   if (pair->search_cycle) for (auto i = res.first; i != res.second; ++i) {
@@ -245,7 +246,7 @@ int LivenessChecker::insertVisitedPair(std::shared_ptr<VisitedPair> visited_pair
       pair->num, pair->automaton_state, pair->atomic_propositions,
       pair->graph_state);
 
-  auto range = std::equal_range(visitedPairs_.begin(), visitedPairs_.end(),
+  auto range = boost::range::equal_range(visitedPairs_,
     visited_pair.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap());
 
   for (auto i = range.first; i != range.second; ++i) {
@@ -277,8 +278,7 @@ void LivenessChecker::purgeVisitedPairs()
 {
   if (_sg_mc_visited != 0 && visitedPairs_.size() > (std::size_t) _sg_mc_visited) {
     // Remove the oldest entry with a linear search:
-    visitedPairs_.erase(std::min_element(
-      visitedPairs_.begin(), visitedPairs_.end(),
+    visitedPairs_.erase(boost::min_element(visitedPairs_,
       [](std::shared_ptr<VisitedPair> const a, std::shared_ptr<VisitedPair> const& b) {
         return a->num < b->num; } ));
   }
index 6d0e87e..3aa0e5f 100644 (file)
@@ -8,7 +8,8 @@
 #include <sys/wait.h>
 
 #include <memory>
-#include <algorithm>
+
+#include <boost/range/algorithm.hpp>
 
 #include <xbt/log.h>
 #include <xbt/sysdep.h>
@@ -62,7 +63,7 @@ void VisitedStates::prune()
 {
   while (states_.size() > (std::size_t) _sg_mc_visited) {
     XBT_DEBUG("Try to remove visited state (maximum number of stored states reached)");
-    auto min_element = std::min_element(states_.begin(), states_.end(),
+    auto min_element = boost::range::min_element(states_,
       [](std::unique_ptr<simgrid::mc::VisitedState>& a, std::unique_ptr<simgrid::mc::VisitedState>& b) {
         return a->num < b->num;
       });
@@ -85,7 +86,7 @@ std::unique_ptr<simgrid::mc::VisitedState> VisitedStates::addVisitedState(
   XBT_DEBUG("Snapshot %p of visited state %d (exploration stack state %d)",
     new_state->system_state.get(), new_state->num, graph_state->num);
 
-  auto range = std::equal_range(states_.begin(), states_.end(),
+  auto range = boost::range::equal_range(states_,
     new_state.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap());
 
   if (compare_snpashots)
index 708f3c5..df068fa 100644 (file)
@@ -6,8 +6,6 @@
 
 #include <cassert>
 
-#include <algorithm>
-
 #include <simgrid_config.h>
 
 #include <xbt/log.h>
index fc1c184..5d9baa0 100644 (file)
@@ -12,9 +12,7 @@
 #endif
 
 #include <xbt/base.h>
-
-typedef struct s_smx_simcall  s_smx_simcall_t;
-typedef struct s_smx_simcall* smx_simcall_t;
+#include <simgrid/forward.h>
 
 #ifdef __cplusplus
 
index 30b5f38..64b71b0 100644 (file)
@@ -7,10 +7,11 @@
 #include <cinttypes>
 #include <cstdint>
 
-#include <algorithm>
 #include <memory>
 #include <utility>
 
+#include <boost/range/algorithm.hpp>
+
 #include <fcntl.h>
 #include <cstdlib>
 #define DW_LANG_Objc DW_LANG_ObjC       /* fix spelling error in older dwarf.h */
@@ -934,8 +935,7 @@ static void MC_dwarf_handle_scope_die(simgrid::mc::ObjectInformation* info, Dwar
 
   // We sort them in order to have an (somewhat) efficient by name
   // lookup:
-  std::sort(frame.variables.begin(), frame.variables.end(),
-    MC_compare_variable);
+  boost::range::sort(frame.variables, MC_compare_variable);
 
   // Register it:
   if (klass == simgrid::dwarf::TagClass::Subprogram)
@@ -1252,7 +1252,7 @@ static void MC_make_functions_index(simgrid::mc::ObjectInformation* info)
   info->functions_index.shrink_to_fit();
 
   // Sort the array by low_pc:
-  std::sort(info->functions_index.begin(), info->functions_index.end(),
+  boost::range::sort(info->functions_index,
         [](simgrid::mc::FunctionIndexEntry const& a,
           simgrid::mc::FunctionIndexEntry const& b)
         {
@@ -1263,8 +1263,7 @@ static void MC_make_functions_index(simgrid::mc::ObjectInformation* info)
 static void MC_post_process_variables(simgrid::mc::ObjectInformation* info)
 {
   // Someone needs this to be sorted but who?
-  std::sort(info->global_variables.begin(), info->global_variables.end(),
-    MC_compare_variable);
+  boost::range::sort(info->global_variables, MC_compare_variable);
 
   for(simgrid::mc::Variable& variable : info->global_variables)
     if (variable.type_id)
index 4f467f2..a919c30 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <assert.h>
 
-#include <algorithm>
+#include <boost/range/algorithm.hpp>
 
 #include <xbt/log.h>
 #include <xbt/sysdep.h>
@@ -56,8 +56,8 @@ State::State()
 
 std::size_t State::interleaveSize() const
 {
-  return std::count_if(this->processStates.begin(), this->processStates.end(),
-    [](simgrid::mc::ProcessState const& state) { return state.isToInterleave(); });
+  return boost::range::count_if(this->processStates,
+    [](simgrid::mc::ProcessState const& p) { return p.isToInterleave(); });
 }
 
 Transition State::getTransition() const
index 1950707..03d81b8 100644 (file)
@@ -7,8 +7,6 @@
 #ifndef SIMGRID_UTIL_HTPP
 #define SIMGRID_UTIL_HTPP
 
-#include <algorithm>
-
 #include <xbt/base.h>
 
 namespace simgrid {
index db8d8d6..e64a060 100644 (file)
@@ -5,19 +5,19 @@
 
 #include "src/simix/Synchro.h"
 
-simgrid::simix::Synchro::Synchro() {
-  simcalls = xbt_fifo_new();
+simgrid::simix::Synchro::Synchro()
+{
 }
 
 simgrid::simix::Synchro::~Synchro()
 {
-  xbt_fifo_free(simcalls);
 }
 
 void simgrid::simix::Synchro::ref()
 {
   refcount++;
 }
+
 void simgrid::simix::Synchro::unref()
 {
   xbt_assert(refcount > 0,
index da0e8e0..6421d5c 100644 (file)
@@ -7,6 +7,7 @@
 #define _SIMIX_SYNCHRO_HPP
 
 #include <string>
+#include <list>
 
 #include <xbt/base.h>
 #include "simgrid/forward.h"
@@ -24,8 +25,7 @@ namespace simix {
     virtual ~Synchro();
     e_smx_state_t state = SIMIX_WAITING; /* State of the synchro */
     std::string name;                  /* synchro name if any */
-    xbt_fifo_t simcalls = nullptr;     /* List of simcalls waiting for this synchro */
-    char *category = nullptr;          /* For instrumentation */
+    std::list<smx_simcall_t> simcalls; /* List of simcalls waiting for this synchro */
 
     virtual void suspend()=0;
     virtual void resume()=0;
index 4342cb1..994583e 100644 (file)
@@ -133,6 +133,6 @@ void simgrid::simix::Comm::post()
   cleanupSurf();
 
   /* if there are simcalls associated with the synchro, then answer them */
-  if (xbt_fifo_size(simcalls))
+  if (!simcalls.empty())
     SIMIX_comm_finish(this);
 }
index 2e04846..8ab8f2e 100644 (file)
@@ -59,6 +59,6 @@ void simgrid::simix::Exec::post()
   }
 
   /* If there are simcalls associated with the synchro, then answer them */
-  if (xbt_fifo_size(simcalls))
+  if (!simcalls.empty())
     SIMIX_execution_finish(this);
 }
index dd2f2e2..812bbaf 100644 (file)
@@ -22,10 +22,7 @@ void simgrid::simix::Io::resume()
 
 void simgrid::simix::Io::post()
 {
-  xbt_fifo_item_t i;
-  smx_simcall_t simcall;
-
-  xbt_fifo_foreach(simcalls,i,simcall,smx_simcall_t) {
+  for (smx_simcall_t simcall : simcalls) {
     switch (simcall->call) {
     case SIMCALL_FILE_OPEN: {
       smx_file_t tmp = xbt_new(s_smx_file_t,1);
index 853dd31..579f06d 100644 (file)
@@ -22,11 +22,11 @@ void simgrid::simix::Sleep::resume()
 
 void simgrid::simix::Sleep::post()
 {
-  smx_simcall_t simcall;
-  e_smx_state_t state;
-
-  while ((simcall = (smx_simcall_t) xbt_fifo_shift(simcalls))) {
+  while (!simcalls.empty()) {
+    smx_simcall_t simcall = simcalls.front();
+    simcalls.pop_front();
 
+    e_smx_state_t state;
     switch (surf_sleep->getState()){
       case simgrid::surf::Action::State::failed:
         simcall->issuer->context->iwannadie = 1;
index e8e76b7..3c33b23 100644 (file)
@@ -42,13 +42,13 @@ union u_smx_scalar {
 /**
  * \brief Represents a simcall to the kernel.
  */
-typedef struct s_smx_simcall {
+struct s_smx_simcall {
   e_smx_simcall_t call;
   smx_process_t issuer;
   int mc_value;
   union u_smx_scalar args[11];
   union u_smx_scalar result;
-} s_smx_simcall_t, *smx_simcall_t;
+};
 
 #define SIMCALL_SET_MC_VALUE(simcall, value) ((simcall)->mc_value = (value))
 #define SIMCALL_GET_MC_VALUE(simcall) ((simcall)->mc_value)
index fee9062..3b17a20 100644 (file)
@@ -318,7 +318,7 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_synchro_t synchro
   XBT_DEBUG("Wait for execution of synchro %p, state %d", synchro, (int)synchro->state);
 
   /* Associate this simcall to the synchro */
-  xbt_fifo_push(synchro->simcalls, simcall);
+  synchro->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = synchro;
 
   /* set surf's synchro */
@@ -335,11 +335,7 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, smx_synchro_t synchro
 
 void SIMIX_execution_finish(simgrid::simix::Exec *exec)
 {
-  xbt_fifo_item_t item;
-  smx_simcall_t simcall;
-
-  xbt_fifo_foreach(exec->simcalls, item, simcall, smx_simcall_t) {
-
+  for (smx_simcall_t simcall : exec->simcalls) {
     switch (exec->state) {
 
       case SIMIX_DONE:
index c465d62..c4a1033 100644 (file)
@@ -54,7 +54,7 @@ void SIMIX_storage_destroy(void *s)
 void simcall_HANDLER_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, sg_host_t host)
 {
   smx_synchro_t synchro = SIMIX_file_read(fd, size, host);
-  xbt_fifo_push(synchro->simcalls, simcall);
+  synchro->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = synchro;
 }
 
@@ -79,7 +79,7 @@ smx_synchro_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
 void simcall_HANDLER_file_write(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, sg_host_t host)
 {
   smx_synchro_t synchro = SIMIX_file_write(fd,  size, host);
-  xbt_fifo_push(synchro->simcalls, simcall);
+  synchro->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = synchro;
 }
 
@@ -101,7 +101,7 @@ smx_synchro_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
 void simcall_HANDLER_file_open(smx_simcall_t simcall, const char* fullpath, sg_host_t host)
 {
   smx_synchro_t synchro = SIMIX_file_open(fullpath, host);
-  xbt_fifo_push(synchro->simcalls, simcall);
+  synchro->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = synchro;
 }
 
@@ -123,7 +123,7 @@ smx_synchro_t SIMIX_file_open(const char* fullpath, sg_host_t host)
 void simcall_HANDLER_file_close(smx_simcall_t simcall, smx_file_t fd, sg_host_t host)
 {
   smx_synchro_t synchro = SIMIX_file_close(fd, host);
-  xbt_fifo_push(synchro->simcalls, simcall);
+  synchro->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = synchro;
 }
 
@@ -264,10 +264,7 @@ void SIMIX_io_destroy(smx_synchro_t synchro)
 
 void SIMIX_io_finish(smx_synchro_t synchro)
 {
-  xbt_fifo_item_t item;
-  smx_simcall_t simcall;
-
-  xbt_fifo_foreach(synchro->simcalls, item, simcall, smx_simcall_t) {
+  for (smx_simcall_t simcall : synchro->simcalls) {
 
     switch (synchro->state) {
 
index 569d72f..a0c83cb 100644 (file)
@@ -3,6 +3,8 @@
 /* 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 <boost/range/algorithm.hpp>
+
 #include "src/surf/surf_interface.hpp"
 #include "src/simix/smx_private.h"
 #include "xbt/log.h"
@@ -384,7 +386,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_synchro_t synchro, dou
   /* Associate this simcall to the wait synchro */
   XBT_DEBUG("simcall_HANDLER_comm_wait, %p", synchro);
 
-  xbt_fifo_push(synchro->simcalls, simcall);
+  synchro->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = synchro;
 
   if (MC_is_active() || MC_record_replay_is_active()) {
@@ -432,7 +434,7 @@ void simcall_HANDLER_comm_test(smx_simcall_t simcall, smx_synchro_t synchro)
     simcall_comm_test__set__result(simcall, comm->src_proc && comm->dst_proc);
     if (simcall_comm_test__get__result(simcall)){
       synchro->state = SIMIX_DONE;
-      xbt_fifo_push(synchro->simcalls, simcall);
+      synchro->simcalls.push_back(simcall);
       SIMIX_comm_finish(synchro);
     } else {
       SIMIX_simcall_answer(simcall);
@@ -442,7 +444,7 @@ void simcall_HANDLER_comm_test(smx_simcall_t simcall, smx_synchro_t synchro)
 
   simcall_comm_test__set__result(simcall, (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING));
   if (simcall_comm_test__get__result(simcall)) {
-    xbt_fifo_push(synchro->simcalls, simcall);
+    synchro->simcalls.push_back(simcall);
     SIMIX_comm_finish(synchro);
   } else {
     SIMIX_simcall_answer(simcall);
@@ -462,7 +464,7 @@ void simcall_HANDLER_comm_testany(smx_simcall_t simcall, xbt_dynar_t synchros)
     }else{
       synchro = xbt_dynar_get_as(synchros, idx, smx_synchro_t);
       simcall_comm_testany__set__result(simcall, idx);
-      xbt_fifo_push(synchro->simcalls, simcall);
+      synchro->simcalls.push_back(simcall);
       synchro->state = SIMIX_DONE;
       SIMIX_comm_finish(synchro);
     }
@@ -472,7 +474,7 @@ void simcall_HANDLER_comm_testany(smx_simcall_t simcall, xbt_dynar_t synchros)
   xbt_dynar_foreach(simcall_comm_testany__get__comms(simcall), cursor,synchro) {
     if (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING) {
       simcall_comm_testany__set__result(simcall, cursor);
-      xbt_fifo_push(synchro->simcalls, simcall);
+      synchro->simcalls.push_back(simcall);
       SIMIX_comm_finish(synchro);
       return;
     }
@@ -488,7 +490,7 @@ void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, xbt_dynar_t synchros)
   if (MC_is_active() || MC_record_replay_is_active()){
     int idx = SIMCALL_GET_MC_VALUE(simcall);
     synchro = xbt_dynar_get_as(synchros, idx, smx_synchro_t);
-    xbt_fifo_push(synchro->simcalls, simcall);
+    synchro->simcalls.push_back(simcall);
     simcall_comm_waitany__set__result(simcall, idx);
     synchro->state = SIMIX_DONE;
     SIMIX_comm_finish(synchro);
@@ -497,7 +499,7 @@ void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, xbt_dynar_t synchros)
 
   xbt_dynar_foreach(synchros, cursor, synchro){
     /* associate this simcall to the the synchro */
-    xbt_fifo_push(synchro->simcalls, simcall);
+    synchro->simcalls.push_back(simcall);
 
     /* see if the synchro is already finished */
     if (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING){
@@ -513,8 +515,12 @@ void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall)
   unsigned int cursor = 0;
   xbt_dynar_t synchros = simcall_comm_waitany__get__comms(simcall);
 
-  xbt_dynar_foreach(synchros, cursor, synchro)
-    xbt_fifo_remove(synchro->simcalls, simcall);
+  xbt_dynar_foreach(synchros, cursor, synchro) {
+    // Remove the first occurence of simcall:
+    auto i = boost::range::find(synchro->simcalls, simcall);
+    if (i !=  synchro->simcalls.end())
+      synchro->simcalls.erase(i);
+  }
 }
 
 /**
@@ -568,9 +574,10 @@ void SIMIX_comm_finish(smx_synchro_t synchro)
 {
   simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
   unsigned int destroy_count = 0;
-  smx_simcall_t simcall;
 
-  while ((simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls))) {
+  while (!synchro->simcalls.empty()) {
+    smx_simcall_t simcall = synchro->simcalls.front();
+    synchro->simcalls.pop_front();
 
     /* If a waitany simcall is waiting for this synchro to finish, then remove
        it from the other synchros in the waitany list. Afterwards, get the
@@ -596,65 +603,65 @@ void SIMIX_comm_finish(smx_synchro_t synchro)
     if (simcall->issuer->host->isOff()) {
       simcall->issuer->context->iwannadie = 1;
       SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
-    } else
-
-    switch (synchro->state) {
-
-    case SIMIX_DONE:
-      XBT_DEBUG("Communication %p complete!", synchro);
-      SIMIX_comm_copy_data(synchro);
-      break;
-
-    case SIMIX_SRC_TIMEOUT:
-      SMX_EXCEPTION(simcall->issuer, timeout_error, 0, "Communication timeouted because of sender");
-      break;
-
-    case SIMIX_DST_TIMEOUT:
-      SMX_EXCEPTION(simcall->issuer, timeout_error, 0, "Communication timeouted because of receiver");
-      break;
-
-    case SIMIX_SRC_HOST_FAILURE:
-      if (simcall->issuer == comm->src_proc)
-        simcall->issuer->context->iwannadie = 1;
-//          SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
-      else
-        SMX_EXCEPTION(simcall->issuer, network_error, 0, "Remote peer failed");
-      break;
-
-    case SIMIX_DST_HOST_FAILURE:
-      if (simcall->issuer == comm->dst_proc)
-        simcall->issuer->context->iwannadie = 1;
-//          SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
-      else
-        SMX_EXCEPTION(simcall->issuer, network_error, 0, "Remote peer failed");
-      break;
-
-    case SIMIX_LINK_FAILURE:
-
-      XBT_DEBUG("Link failure in synchro %p between '%s' and '%s': posting an exception to the issuer: %s (%p) detached:%d",
-                synchro,
-                comm->src_proc ? sg_host_get_name(comm->src_proc->host) : NULL,
-                comm->dst_proc ? sg_host_get_name(comm->dst_proc->host) : NULL,
-                simcall->issuer->name.c_str(), simcall->issuer, comm->detached);
-      if (comm->src_proc == simcall->issuer) {
-        XBT_DEBUG("I'm source");
-      } else if (comm->dst_proc == simcall->issuer) {
-        XBT_DEBUG("I'm dest");
-      } else {
-        XBT_DEBUG("I'm neither source nor dest");
+    } else {
+      switch (synchro->state) {
+
+      case SIMIX_DONE:
+        XBT_DEBUG("Communication %p complete!", synchro);
+        SIMIX_comm_copy_data(synchro);
+        break;
+
+      case SIMIX_SRC_TIMEOUT:
+        SMX_EXCEPTION(simcall->issuer, timeout_error, 0, "Communication timeouted because of sender");
+        break;
+
+      case SIMIX_DST_TIMEOUT:
+        SMX_EXCEPTION(simcall->issuer, timeout_error, 0, "Communication timeouted because of receiver");
+        break;
+
+      case SIMIX_SRC_HOST_FAILURE:
+        if (simcall->issuer == comm->src_proc)
+          simcall->issuer->context->iwannadie = 1;
+  //          SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
+        else
+          SMX_EXCEPTION(simcall->issuer, network_error, 0, "Remote peer failed");
+        break;
+
+      case SIMIX_DST_HOST_FAILURE:
+        if (simcall->issuer == comm->dst_proc)
+          simcall->issuer->context->iwannadie = 1;
+  //          SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed");
+        else
+          SMX_EXCEPTION(simcall->issuer, network_error, 0, "Remote peer failed");
+        break;
+
+      case SIMIX_LINK_FAILURE:
+
+        XBT_DEBUG("Link failure in synchro %p between '%s' and '%s': posting an exception to the issuer: %s (%p) detached:%d",
+                  synchro,
+                  comm->src_proc ? sg_host_get_name(comm->src_proc->host) : NULL,
+                  comm->dst_proc ? sg_host_get_name(comm->dst_proc->host) : NULL,
+                  simcall->issuer->name.c_str(), simcall->issuer, comm->detached);
+        if (comm->src_proc == simcall->issuer) {
+          XBT_DEBUG("I'm source");
+        } else if (comm->dst_proc == simcall->issuer) {
+          XBT_DEBUG("I'm dest");
+        } else {
+          XBT_DEBUG("I'm neither source nor dest");
+        }
+        SMX_EXCEPTION(simcall->issuer, network_error, 0, "Link failure");
+        break;
+
+      case SIMIX_CANCELED:
+        if (simcall->issuer == comm->dst_proc)
+          SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Communication canceled by the sender");
+        else
+          SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Communication canceled by the receiver");
+        break;
+
+      default:
+        xbt_die("Unexpected synchro state in SIMIX_comm_finish: %d", (int)synchro->state);
       }
-      SMX_EXCEPTION(simcall->issuer, network_error, 0, "Link failure");
-      break;
-
-    case SIMIX_CANCELED:
-      if (simcall->issuer == comm->dst_proc)
-        SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Communication canceled by the sender");
-      else
-        SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Communication canceled by the receiver");
-      break;
-
-    default:
-      xbt_die("Unexpected synchro state in SIMIX_comm_finish: %d", (int)synchro->state);
     }
 
     /* if there is an exception during a waitany or a testany, indicate the position of the failed communication */
index 35e783c..0fce5df 100644 (file)
@@ -4,6 +4,8 @@
 /* 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 <boost/range/algorithm.hpp>
+
 #include "src/surf/surf_interface.hpp"
 #include "smx_private.h"
 #include "xbt/sysdep.h"
@@ -465,7 +467,14 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) {
     } else if (comm != nullptr) {
       xbt_fifo_remove(process->comms, process->waiting_synchro);
       comm->cancel();
-      xbt_fifo_remove(process->waiting_synchro->simcalls, &process->simcall);
+
+      // Remove first occurence of &process->simcall:
+      auto i = boost::range::find(
+        process->waiting_synchro->simcalls,
+        &process->simcall);
+      if (i != process->waiting_synchro->simcalls.end())
+        process->waiting_synchro->simcalls.remove(&process->simcall);
+
       comm->unref();
 
     } else if (sleep != nullptr) {
@@ -590,7 +599,7 @@ void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_process_t proces
   if (process != simcall->issuer) {
     SIMIX_simcall_answer(simcall);
   } else {
-    xbt_fifo_push(sync_suspend->simcalls, simcall);
+    sync_suspend->simcalls.push_back(simcall);
     process->waiting_synchro = sync_suspend;
     process->waiting_synchro->suspend();
   }
@@ -742,7 +751,7 @@ xbt_dict_t SIMIX_process_get_properties(smx_process_t process)
 void simcall_HANDLER_process_join(smx_simcall_t simcall, smx_process_t process, double timeout)
 {
   smx_synchro_t sync = SIMIX_process_join(simcall->issuer, process, timeout);
-  xbt_fifo_push(sync->simcalls, simcall);
+  sync->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = sync;
 }
 
@@ -752,8 +761,9 @@ static int SIMIX_process_join_finish(smx_process_exit_status_t status, smx_synch
   if (sleep->surf_sleep) {
     sleep->surf_sleep->cancel();
 
-    smx_simcall_t simcall;
-    while ((simcall = (smx_simcall_t) xbt_fifo_shift(sleep->simcalls))) {
+    while (!sleep->simcalls.empty()) {
+      smx_simcall_t simcall = sleep->simcalls.front();
+      sleep->simcalls.pop_front();
       simcall_process_sleep__set__result(simcall, SIMIX_DONE);
       simcall->issuer->waiting_synchro = NULL;
       if (simcall->issuer->suspended) {
@@ -787,7 +797,7 @@ void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double duration)
     return;
   }
   smx_synchro_t sync = SIMIX_process_sleep(simcall->issuer, duration);
-  xbt_fifo_push(sync->simcalls, simcall);
+  sync->simcalls.push_back(simcall);
   simcall->issuer->waiting_synchro = sync;
 }
 
index 67e4eaa..b0eba6f 100644 (file)
@@ -66,7 +66,8 @@ void SIMIX_synchro_stop_waiting(smx_process_t process, smx_simcall_t simcall)
 void SIMIX_synchro_finish(smx_synchro_t synchro)
 {
   XBT_IN("(%p)",synchro);
-  smx_simcall_t simcall = (smx_simcall_t) xbt_fifo_shift(synchro->simcalls);
+  smx_simcall_t simcall = synchro->simcalls.front();
+  synchro->simcalls.pop_front();
 
   switch (synchro->state) {
 
@@ -128,7 +129,7 @@ void simcall_HANDLER_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex)
     /* FIXME: check if the host is active ? */
     /* Somebody using the mutex, use a synchronization to get host failures */
     synchro = SIMIX_synchro_wait(process->host, -1);
-    xbt_fifo_push(synchro->simcalls, simcall);
+    synchro->simcalls.push_back(simcall);
     simcall->issuer->waiting_synchro = synchro;
     xbt_swag_insert(simcall->issuer, mutex->sleeping);   
   } else {
@@ -282,7 +283,7 @@ static void _SIMIX_cond_wait(smx_cond_t cond, smx_mutex_t mutex, double timeout,
   }
 
   synchro = SIMIX_synchro_wait(issuer->host, timeout);
-  xbt_fifo_unshift(synchro->simcalls, simcall);
+  synchro->simcalls.push_front(simcall);
   issuer->waiting_synchro = synchro;
   xbt_swag_insert(simcall->issuer, cond->sleeping);   
   XBT_OUT();
@@ -446,7 +447,7 @@ static void _SIMIX_sem_wait(smx_sem_t sem, double timeout, smx_process_t issuer,
   XBT_DEBUG("Wait semaphore %p (timeout:%f)", sem, timeout);
   if (sem->value <= 0) {
     synchro = SIMIX_synchro_wait(issuer->host, timeout);
-    xbt_fifo_unshift(synchro->simcalls, simcall);
+    synchro->simcalls.push_front(simcall);
     issuer->waiting_synchro = synchro;
     xbt_swag_insert(issuer, sem->sleeping);
   } else {
index 4c9c6b8..e76df1d 100644 (file)
@@ -60,7 +60,7 @@ double HostCLM03Model::next_occuring_event(double now){
       typeid(surf_network_model).name(), min_by_net,
       typeid(surf_storage_model).name(), min_by_sto);
 
-  double res = std::max(std::max(min_by_cpu, min_by_net), min_by_sto);
+  double res = std::max({min_by_cpu, min_by_net, min_by_sto});
   if (min_by_cpu >= 0.0 && min_by_cpu < res)
     res = min_by_cpu;
   if (min_by_net >= 0.0 && min_by_net < res)
index ff2211b..69baee9 100644 (file)
@@ -4,7 +4,6 @@
 /* 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 <algorithm>
 #include <utility>
 
 #include "network_ib.hpp"
index 8d54b3c..e655127 100644 (file)
@@ -4,8 +4,6 @@
 /* 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 <algorithm>
-
 #include <simgrid/host.h>
 
 #include "cpu_cas01.hpp"