Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of github.com:simgrid/simgrid into dev_11
authorEhsan Azimi <eazimi@ehsan.irisa.fr>
Thu, 26 Nov 2020 08:46:43 +0000 (09:46 +0100)
committerEhsan Azimi <eazimi@ehsan.irisa.fr>
Thu, 26 Nov 2020 08:46:43 +0000 (09:46 +0100)
40 files changed:
doc/doxygen/inside_extending.doc
doc/doxygen/uhood_switch.doc
src/kernel/activity/CommImpl.cpp
src/kernel/activity/ConditionVariableImpl.cpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/SynchroRaw.cpp
src/kernel/actor/ActorImpl.cpp
src/kernel/routing/DragonflyZone.cpp
src/kernel/routing/FloydZone.cpp
src/kernel/routing/FullZone.cpp
src/mc/ModelChecker.cpp
src/mc/Session.cpp
src/mc/checker/CommunicationDeterminismChecker.cpp
src/mc/checker/CommunicationDeterminismChecker.hpp
src/mc/checker/LivenessChecker.cpp
src/mc/checker/SafetyChecker.cpp
src/mc/mc_base.cpp
src/mc/mc_comm_pattern.cpp
src/mc/mc_comm_pattern.hpp
src/mc/mc_record.cpp
src/mc/mc_request.cpp
src/mc/mc_smx.cpp
src/mc/mc_state.cpp
src/mc/mc_state.hpp
src/mc/remote/AppSide.cpp
src/mc/remote/Channel.cpp
src/mc/remote/Channel.hpp
src/mc/remote/mc_protocol.cpp
src/mc/remote/mc_protocol.h
src/simix/libsmx.cpp
src/simix/popping_bodies.cpp
src/simix/popping_enum.hpp
src/simix/popping_generated.cpp
src/simix/popping_private.hpp
src/simix/simcalls.py
src/simix/smx_global.cpp
src/smpi/include/smpi_file.hpp
src/smpi/internals/smpi_bench.cpp
src/xbt/xbt_log_layout_format.cpp
tools/jenkins/project_description.sh

index d9ae393..54f7dcc 100644 (file)
@@ -165,7 +165,7 @@ generates the following files:
 - popping_bodies.cpp:
   The BODY function of each simcall
 - popping_enum.hpp:
-  Definition of type `enum e_smx_simcall_t` (one value per existing simcall)
+  Definition of type `enum class Simcall` (one value per existing simcall)
 - popping_generated.cpp:
   Definitions of `simcall_names[]` (debug name of each simcall), and
   ActorImpl::simcall_handle() that deals with the simcall from within the kernel
index ff66dbf..ae65213 100644 (file)
@@ -328,7 +328,7 @@ number and its arguments (among some other things):
 @code{cpp}
 struct s_smx_simcall {
   // Simcall number:
-  e_smx_simcall_t call;
+  Simcall call;
   // Issuing actor:
   smx_actor_t issuer;
   // Arguments of the simcall:
index d213694..c10e7b2 100644 (file)
@@ -581,9 +581,9 @@ void CommImpl::finish()
      * list. Afterwards, get the position of the actual synchro in the waitany list and return it as the result of the
      * simcall */
 
-    if (simcall->call_ == SIMCALL_NONE) // FIXME: maybe a better way to handle this case
-      continue;                         // if actor handling comm is killed
-    if (simcall->call_ == SIMCALL_COMM_WAITANY) {
+    if (simcall->call_ == simix::Simcall::NONE) // FIXME: maybe a better way to handle this case
+      continue;                                 // if actor handling comm is killed
+    if (simcall->call_ == simix::Simcall::COMM_WAITANY) {
       SIMIX_waitany_remove_simcall_from_actions(simcall);
       if (simcall->timeout_cb_) {
         simcall->timeout_cb_->remove();
@@ -674,15 +674,15 @@ void CommImpl::finish()
     }
     /* if there is an exception during a waitany or a testany, indicate the position of the failed communication */
     if (simcall->issuer_->exception_ &&
-        (simcall->call_ == SIMCALL_COMM_WAITANY || simcall->call_ == SIMCALL_COMM_TESTANY)) {
+        (simcall->call_ == simix::Simcall::COMM_WAITANY || simcall->call_ == simix::Simcall::COMM_TESTANY)) {
       // First retrieve the rank of our failing synchro
       CommImpl** comms;
       size_t count;
-      if (simcall->call_ == SIMCALL_COMM_WAITANY) {
+      if (simcall->call_ == simix::Simcall::COMM_WAITANY) {
         comms = simcall_comm_waitany__get__comms(simcall);
         count = simcall_comm_waitany__get__count(simcall);
       } else {
-        /* simcall->call_ == SIMCALL_COMM_TESTANY */
+        /* simcall->call_ == simix::Simcall::COMM_TESTANY */
         comms = simcall_comm_testany__get__comms(simcall);
         count = simcall_comm_testany__get__count(simcall);
       }
index fdc1def..6193dfd 100644 (file)
@@ -51,11 +51,11 @@ void ConditionVariableImpl::signal()
     /* Now transform the cond wait simcall into a mutex lock one */
     smx_simcall_t simcall = &proc.simcall_;
     MutexImpl* simcall_mutex;
-    if (simcall->call_ == SIMCALL_COND_WAIT)
+    if (simcall->call_ == simix::Simcall::COND_WAIT)
       simcall_mutex = simcall_cond_wait__get__mutex(simcall);
     else
       simcall_mutex = simcall_cond_wait_timeout__get__mutex(simcall);
-    simcall->call_ = SIMCALL_MUTEX_LOCK;
+    simcall->call_ = simix::Simcall::MUTEX_LOCK;
 
     simcall_mutex->lock(simcall->issuer_);
   }
index 74129f3..73e6384 100644 (file)
@@ -183,9 +183,9 @@ void ExecImpl::finish()
      * list. Afterwards, get the position of the actual synchro in the waitany list and return it as the result of the
      * simcall */
 
-    if (simcall->call_ == SIMCALL_NONE) // FIXME: maybe a better way to handle this case
+    if (simcall->call_ == simix::Simcall::NONE) // FIXME: maybe a better way to handle this case
       continue;                        // if process handling comm is killed
-    if (simcall->call_ == SIMCALL_EXECUTION_WAITANY_FOR) {
+    if (simcall->call_ == simix::Simcall::EXECUTION_WAITANY_FOR) {
       simgrid::kernel::activity::ExecImpl** execs = simcall_execution_waitany_for__get__execs(simcall);
       size_t count                                = simcall_execution_waitany_for__get__count(simcall);
 
index 8ff59c5..f759c7a 100644 (file)
@@ -78,24 +78,24 @@ void RawImpl::finish()
   }
 
   switch (simcall->call_) {
-    case SIMCALL_MUTEX_LOCK:
+    case simix::Simcall::MUTEX_LOCK:
       simcall_mutex_lock__get__mutex(simcall)->remove_sleeping_actor(*simcall->issuer_);
       break;
 
-    case SIMCALL_COND_WAIT:
+    case simix::Simcall::COND_WAIT:
       simcall_cond_wait_timeout__get__cond(simcall)->remove_sleeping_actor(*simcall->issuer_);
       break;
 
-    case SIMCALL_COND_WAIT_TIMEOUT:
+    case simix::Simcall::COND_WAIT_TIMEOUT:
       simcall_cond_wait_timeout__get__cond(simcall)->remove_sleeping_actor(*simcall->issuer_);
       simcall_cond_wait_timeout__set__result(simcall, 1); // signal a timeout
       break;
 
-    case SIMCALL_SEM_ACQUIRE:
+    case simix::Simcall::SEM_ACQUIRE:
       simcall_sem_acquire_timeout__get__sem(simcall)->remove_sleeping_actor(*simcall->issuer_);
       break;
 
-    case SIMCALL_SEM_ACQUIRE_TIMEOUT:
+    case simix::Simcall::SEM_ACQUIRE_TIMEOUT:
       simcall_sem_acquire_timeout__get__sem(simcall)->remove_sleeping_actor(*simcall->issuer_);
       simcall_sem_acquire_timeout__set__result(simcall, 1); // signal a timeout
       break;
index fa893bd..33cae24 100644 (file)
@@ -436,8 +436,8 @@ void ActorImpl::simcall_answer()
   if (this != simix_global->maestro_) {
     XBT_DEBUG("Answer simcall %s (%d) issued by %s (%p)", SIMIX_simcall_name(simcall_.call_), (int)simcall_.call_,
               get_cname(), this);
-    xbt_assert(simcall_.call_ != SIMCALL_NONE);
-    simcall_.call_ = SIMCALL_NONE;
+    xbt_assert(simcall_.call_ != simix::Simcall::NONE);
+    simcall_.call_ = simix::Simcall::NONE;
     xbt_assert(not XBT_LOG_ISENABLED(simix_process, xbt_log_priority_debug) ||
                    std::find(begin(simix_global->actors_to_run), end(simix_global->actors_to_run), this) ==
                        end(simix_global->actors_to_run),
index e310310..5f9bba5 100644 (file)
@@ -51,7 +51,7 @@ void DragonflyZone::parse_specific_arguments(ClusterCreationArgs* cluster)
   std::vector<std::string> tmp;
   boost::split(parameters, cluster->topo_parameters, boost::is_any_of(";"));
 
-  if (parameters.size() != 4 || parameters.empty()) {
+  if (parameters.size() != 4) {
     surf_parse_error(
         "Dragonfly are defined by the number of groups, chassis per groups, blades per chassis, nodes per blade");
   }
index c414f96..111355c 100644 (file)
@@ -96,7 +96,7 @@ void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoi
   add_route_check_params(src, dst, gw_src, gw_dst, link_list, symmetrical);
 
   /* Check that the route does not already exist */
-  if (gw_dst) // netzone route (to adapt the error message, if any)
+  if (gw_dst && gw_src) // netzone route (to adapt the error message, if any)
     xbt_assert(nullptr == TO_FLOYD_LINK(src->id(), dst->id()),
                "The route between %s@%s and %s@%s already exists (Rq: routes are symmetrical by default).",
                src->get_cname(), gw_src->get_cname(), dst->get_cname(), gw_dst->get_cname());
@@ -110,7 +110,7 @@ void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoi
   TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list.size();
 
   if (symmetrical) {
-    if (gw_dst) // netzone route (to adapt the error message, if any)
+    if (gw_dst && gw_src) // netzone route (to adapt the error message, if any)
       xbt_assert(
           nullptr == TO_FLOYD_LINK(dst->id(), src->id()),
           "The route between %s@%s and %s@%s already exists. You should not declare the reverse path as symmetrical.",
index 1defdac..c6273b6 100644 (file)
@@ -78,7 +78,7 @@ void FullZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoin
     routing_table_.resize(table_size * table_size, nullptr);
 
   /* Check that the route does not already exist */
-  if (gw_dst) // inter-zone route (to adapt the error message, if any)
+  if (gw_dst && gw_src) // inter-zone route (to adapt the error message, if any)
     xbt_assert(nullptr == TO_ROUTE_FULL(src->id(), dst->id()),
                "The route between %s@%s and %s@%s already exists (Rq: routes are symmetrical by default).",
                src->get_cname(), gw_src->get_cname(), dst->get_cname(), gw_dst->get_cname());
index f461691..93400ed 100644 (file)
@@ -117,7 +117,7 @@ void ModelChecker::shutdown()
 
 void ModelChecker::resume(RemoteSimulation& process)
 {
-  int res = checker_side_.get_channel().send(MC_MESSAGE_CONTINUE);
+  int res = checker_side_.get_channel().send(MessageType::CONTINUE);
   if (res)
     throw xbt::errno_error();
   process.clear_cache();
@@ -166,75 +166,69 @@ bool ModelChecker::handle_message(const char* buffer, ssize_t size)
   memcpy(&base_message, buffer, sizeof(base_message));
 
   switch(base_message.type) {
-  case MC_MESSAGE_IGNORE_HEAP:
-    {
-    s_mc_message_ignore_heap_t message;
-    xbt_assert(size == sizeof(message), "Broken message");
-    memcpy(&message, buffer, sizeof(message));
-
-    IgnoredHeapRegion region;
-    region.block    = message.block;
-    region.fragment = message.fragment;
-    region.address  = message.address;
-    region.size     = message.size;
-    get_remote_simulation().ignore_heap(region);
-    break;
+    case MessageType::IGNORE_HEAP: {
+      s_mc_message_ignore_heap_t message;
+      xbt_assert(size == sizeof(message), "Broken message");
+      memcpy(&message, buffer, sizeof(message));
+
+      IgnoredHeapRegion region;
+      region.block    = message.block;
+      region.fragment = message.fragment;
+      region.address  = message.address;
+      region.size     = message.size;
+      get_remote_simulation().ignore_heap(region);
+      break;
     }
 
-  case MC_MESSAGE_UNIGNORE_HEAP:
-    {
-    s_mc_message_ignore_memory_t message;
-    xbt_assert(size == sizeof(message), "Broken message");
-    memcpy(&message, buffer, sizeof(message));
-    get_remote_simulation().unignore_heap((void*)(std::uintptr_t)message.addr, message.size);
-    break;
+    case MessageType::UNIGNORE_HEAP: {
+      s_mc_message_ignore_memory_t message;
+      xbt_assert(size == sizeof(message), "Broken message");
+      memcpy(&message, buffer, sizeof(message));
+      get_remote_simulation().unignore_heap((void*)(std::uintptr_t)message.addr, message.size);
+      break;
     }
 
-  case MC_MESSAGE_IGNORE_MEMORY:
-    {
-    s_mc_message_ignore_memory_t message;
-    xbt_assert(size == sizeof(message), "Broken message");
-    memcpy(&message, buffer, sizeof(message));
-    this->get_remote_simulation().ignore_region(message.addr, message.size);
-    break;
+    case MessageType::IGNORE_MEMORY: {
+      s_mc_message_ignore_memory_t message;
+      xbt_assert(size == sizeof(message), "Broken message");
+      memcpy(&message, buffer, sizeof(message));
+      this->get_remote_simulation().ignore_region(message.addr, message.size);
+      break;
     }
 
-  case MC_MESSAGE_STACK_REGION:
-    {
-    s_mc_message_stack_region_t message;
-    xbt_assert(size == sizeof(message), "Broken message");
-    memcpy(&message, buffer, sizeof(message));
-    this->get_remote_simulation().stack_areas().push_back(message.stack_region);
-    }
-    break;
+    case MessageType::STACK_REGION: {
+      s_mc_message_stack_region_t message;
+      xbt_assert(size == sizeof(message), "Broken message");
+      memcpy(&message, buffer, sizeof(message));
+      this->get_remote_simulation().stack_areas().push_back(message.stack_region);
+    } break;
 
-  case MC_MESSAGE_REGISTER_SYMBOL:
-    {
-    s_mc_message_register_symbol_t message;
-    xbt_assert(size == sizeof(message), "Broken message");
-    memcpy(&message, buffer, sizeof(message));
-    xbt_assert(not message.callback, "Support for client-side function proposition is not implemented.");
-    XBT_DEBUG("Received symbol: %s", message.name);
+    case MessageType::REGISTER_SYMBOL: {
+      s_mc_message_register_symbol_t message;
+      xbt_assert(size == sizeof(message), "Broken message");
+      memcpy(&message, buffer, sizeof(message));
+      xbt_assert(not message.callback, "Support for client-side function proposition is not implemented.");
+      XBT_DEBUG("Received symbol: %s", message.name);
 
-    if (property_automaton == nullptr)
-      property_automaton = xbt_automaton_new();
+      if (property_automaton == nullptr)
+        property_automaton = xbt_automaton_new();
 
-    const RemoteSimulation* process = &this->get_remote_simulation();
-    RemotePtr<int> address = remote((int*)message.data);
-    xbt::add_proposition(property_automaton, message.name, [process, address]() { return process->read(address); });
+      const RemoteSimulation* process = &this->get_remote_simulation();
+      RemotePtr<int> address          = remote((int*)message.data);
+      xbt::add_proposition(property_automaton, message.name, [process, address]() { return process->read(address); });
 
-    break;
+      break;
     }
 
-  case MC_MESSAGE_WAITING:
-    return false;
+    case MessageType::WAITING:
+      return false;
 
-  case MC_MESSAGE_ASSERTION_FAILED:
-    MC_report_assertion_error();
-    this->exit(SIMGRID_MC_EXIT_SAFETY);
+    case MessageType::ASSERTION_FAILED:
+      MC_report_assertion_error();
+      this->exit(SIMGRID_MC_EXIT_SAFETY);
 
-  default:
-    xbt_die("Unexpected message from model-checked application");
+    default:
+      xbt_die("Unexpected message from model-checked application");
   }
   return true;
 }
@@ -312,7 +306,7 @@ void ModelChecker::handle_simcall(Transition const& transition)
 {
   s_mc_message_simcall_handle_t m;
   memset(&m, 0, sizeof(m));
-  m.type  = MC_MESSAGE_SIMCALL_HANDLE;
+  m.type  = MessageType::SIMCALL_HANDLE;
   m.pid   = transition.pid_;
   m.value = transition.argument_;
   checker_side_.get_channel().send(m);
@@ -323,15 +317,15 @@ void ModelChecker::handle_simcall(Transition const& transition)
 
 bool ModelChecker::checkDeadlock()
 {
-  int res = checker_side_.get_channel().send(MC_MESSAGE_DEADLOCK_CHECK);
+  int res = checker_side_.get_channel().send(MessageType::DEADLOCK_CHECK);
   xbt_assert(res == 0, "Could not check deadlock state");
   s_mc_message_int_t message;
   ssize_t s = checker_side_.get_channel().receive(message);
   xbt_assert(s != -1, "Could not receive message");
-  xbt_assert(s == sizeof(message) && message.type == MC_MESSAGE_DEADLOCK_CHECK_REPLY,
+  xbt_assert(s == sizeof(message) && message.type == MessageType::DEADLOCK_CHECK_REPLY,
              "Received unexpected message %s (%i, size=%i) "
-             "expected MC_MESSAGE_DEADLOCK_CHECK_REPLY (%i, size=%i)",
-             MC_message_type_name(message.type), (int)message.type, (int)s, (int)MC_MESSAGE_DEADLOCK_CHECK_REPLY,
+             "expected MessageType::DEADLOCK_CHECK_REPLY (%i, size=%i)",
+             MC_message_type_name(message.type), (int)message.type, (int)s, (int)MessageType::DEADLOCK_CHECK_REPLY,
              (int)sizeof(message));
   return message.value != 0;
 }
index fc286bd..e467d7a 100644 (file)
@@ -144,7 +144,7 @@ void Session::close()
 
 bool Session::actor_is_enabled(aid_t pid) const
 {
-  s_mc_message_actor_enabled_t msg{MC_MESSAGE_ACTOR_ENABLED, pid};
+  s_mc_message_actor_enabled_t msg{simgrid::mc::MessageType::ACTOR_ENABLED, pid};
   model_checker_->channel().send(msg);
   std::array<char, MC_MESSAGE_LENGTH> buff;
   ssize_t received = model_checker_->channel().receive(buff.data(), buff.size(), true);
index 7e269ea..c6eb6a3 100644 (file)
@@ -31,27 +31,28 @@ std::vector<std::vector<simgrid::mc::PatternCommunication*>> incomplete_communic
 
 /********** Static functions ***********/
 
-static e_mc_comm_pattern_difference_t compare_comm_pattern(const simgrid::mc::PatternCommunication* comm1,
-                                                           const simgrid::mc::PatternCommunication* comm2)
+static simgrid::mc::CommPatternDifference compare_comm_pattern(const simgrid::mc::PatternCommunication* comm1,
+                                                               const simgrid::mc::PatternCommunication* comm2)
 {
+  using simgrid::mc::CommPatternDifference;
   if(comm1->type != comm2->type)
-    return TYPE_DIFF;
+    return CommPatternDifference::TYPE;
   if (comm1->rdv != comm2->rdv)
-    return RDV_DIFF;
+    return CommPatternDifference::RDV;
   if (comm1->src_proc != comm2->src_proc)
-    return SRC_PROC_DIFF;
+    return CommPatternDifference::SRC_PROC;
   if (comm1->dst_proc != comm2->dst_proc)
-    return DST_PROC_DIFF;
+    return CommPatternDifference::DST_PROC;
   if (comm1->tag != comm2->tag)
-    return TAG_DIFF;
+    return CommPatternDifference::TAG;
   if (comm1->data.size() != comm2->data.size())
-    return DATA_SIZE_DIFF;
+    return CommPatternDifference::DATA_SIZE;
   if (comm1->data != comm2->data)
-    return DATA_DIFF;
-  return NONE_DIFF;
+    return CommPatternDifference::DATA;
+  return CommPatternDifference::NONE;
 }
 
-static char* print_determinism_result(e_mc_comm_pattern_difference_t diff, int process,
+static char* print_determinism_result(simgrid::mc::CommPatternDifference diff, int process,
                                       const simgrid::mc::PatternCommunication* comm, unsigned int cursor)
 {
   char* type;
@@ -62,31 +63,32 @@ static char* print_determinism_result(e_mc_comm_pattern_difference_t diff, int p
   else
     type = bprintf("The recv communications pattern of the process %d is different!", process - 1);
 
+  using simgrid::mc::CommPatternDifference;
   switch(diff) {
-  case TYPE_DIFF:
-    res = bprintf("%s Different type for communication #%u", type, cursor);
-    break;
-  case RDV_DIFF:
-    res = bprintf("%s Different rdv for communication #%u", type, cursor);
-    break;
-  case TAG_DIFF:
-    res = bprintf("%s Different tag for communication #%u", type, cursor);
-    break;
-  case SRC_PROC_DIFF:
-    res = bprintf("%s Different source for communication #%u", type, cursor);
-    break;
-  case DST_PROC_DIFF:
-    res = bprintf("%s Different destination for communication #%u", type, cursor);
-    break;
-  case DATA_SIZE_DIFF:
-    res = bprintf("%s Different data size for communication #%u", type, cursor);
-    break;
-  case DATA_DIFF:
-    res = bprintf("%s Different data for communication #%u", type, cursor);
-    break;
-  default:
-    res = nullptr;
-    break;
+    case CommPatternDifference::TYPE:
+      res = bprintf("%s Different type for communication #%u", type, cursor);
+      break;
+    case CommPatternDifference::RDV:
+      res = bprintf("%s Different rdv for communication #%u", type, cursor);
+      break;
+    case CommPatternDifference::TAG:
+      res = bprintf("%s Different tag for communication #%u", type, cursor);
+      break;
+    case CommPatternDifference::SRC_PROC:
+      res = bprintf("%s Different source for communication #%u", type, cursor);
+      break;
+    case CommPatternDifference::DST_PROC:
+      res = bprintf("%s Different destination for communication #%u", type, cursor);
+      break;
+    case CommPatternDifference::DATA_SIZE:
+      res = bprintf("%s Different data size for communication #%u", type, cursor);
+      break;
+    case CommPatternDifference::DATA:
+      res = bprintf("%s Different data for communication #%u", type, cursor);
+      break;
+    default:
+      res = nullptr;
+      break;
   }
 
   return res;
@@ -125,9 +127,9 @@ void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, co
 {
   if (not backtracking) {
     PatternCommunicationList& list      = initial_communications_pattern[process];
-    e_mc_comm_pattern_difference_t diff = compare_comm_pattern(list.list[list.index_comm].get(), comm);
+    CommPatternDifference diff          = compare_comm_pattern(list.list[list.index_comm].get(), comm);
 
-    if (diff != NONE_DIFF) {
+    if (diff != CommPatternDifference::NONE) {
       if (comm->type == PatternCommunicationType::send) {
         this->send_deterministic = false;
         if (this->send_diff != nullptr)
@@ -171,8 +173,7 @@ void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, co
 
 /********** Non Static functions ***********/
 
-void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, e_mc_call_type_t call_type,
-                                                       int backtracking)
+void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, CallType call_type, int backtracking)
 {
   const smx_actor_t issuer = mcapi::get().mc_smx_simcall_get_issuer(request);
   const mc::PatternCommunicationList& initial_pattern          = initial_communications_pattern[issuer->get_pid()];
@@ -181,7 +182,7 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, e_
   auto pattern   = std::make_unique<PatternCommunication>();
   pattern->index = initial_pattern.index_comm + incomplete_pattern.size();
 
-  if (call_type == MC_CALL_TYPE_SEND) {
+  if (call_type == CallType::SEND) {
     /* Create comm pattern */
     pattern->type      = PatternCommunicationType::send;
     pattern->comm_addr = mcapi::get().get_pattern_comm_addr(request);
@@ -228,7 +229,7 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, e_
       return;
     }
 #endif
-  } else if (call_type == MC_CALL_TYPE_RECV) {
+  } else if (call_type == CallType::RECV) {
     pattern->type      = PatternCommunicationType::receive;
     pattern->comm_addr = static_cast<kernel::activity::CommImpl*>(simcall_comm_irecv__getraw__result(request));
 
@@ -304,8 +305,7 @@ std::vector<std::string> CommunicationDeterminismChecker::get_textual_trace() //
   std::vector<std::string> trace;
   for (auto const& state : stack_) {
     smx_simcall_t req = &state->executed_req_;
-    if (req)
-      trace.push_back(mcapi::get().request_to_string(req, state->transition_.argument_, RequestType::executed));
+    trace.push_back(request_to_string(req, state->transition_.argument_, RequestType::executed));
   }
   return trace;
 }
@@ -404,8 +404,8 @@ void CommunicationDeterminismChecker::restoreState()
     smx_simcall_t req        = &issuer->simcall_;
 
     /* TODO : handle test and testany simcalls */
-    e_mc_call_type_t call = MC_get_call_type(req);
-    mcapi::get().handle_simcall(state->transition_);
+    CallType call = MC_get_call_type(req);
+    mc_model_checker->handle_simcall(state->transition_);
     MC_handle_comm_pattern(call, req, req_num, 1);
     mcapi::get().mc_wait_for_requests();
 
@@ -448,7 +448,7 @@ void CommunicationDeterminismChecker::real_run()
       mcapi::get().mc_inc_executed_trans();
 
       /* TODO : handle test and testany simcalls */
-      e_mc_call_type_t call = MC_CALL_TYPE_NONE;
+      CallType call = CallType::NONE;
       if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
         call = MC_get_call_type(req);
 
index 01daeee..3d3a910 100644 (file)
@@ -33,7 +33,7 @@ private:
 
 public:
   // These are used by functions which should be moved in CommunicationDeterminismChecker:
-  void get_comm_pattern(smx_simcall_t request, e_mc_call_type_t call_type, int backtracking);
+  void get_comm_pattern(smx_simcall_t request, CallType call_type, int backtracking);
   void complete_comm_pattern(RemotePtr<kernel::activity::CommImpl> comm_addr, unsigned int issuer, int backtracking);
 
 private:
index b829b4a..4d36052 100644 (file)
@@ -147,16 +147,14 @@ void LivenessChecker::replay()
 
       smx_simcall_t req = nullptr;
 
-      if (saved_req != nullptr) {
-        /* because we got a copy of the executed request, we have to fetch the
-             real one, pointed by the request field of the issuer process */
-        const smx_actor_t issuer = MC_smx_simcall_get_issuer(saved_req);
-        req                      = &issuer->simcall_;
-
-        /* Debug information */
-        XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth,
-                  request_to_string(req, req_num, simgrid::mc::RequestType::simix).c_str(), state.get());
-      }
+      /* because we got a copy of the executed request, we have to fetch the
+         real one, pointed by the request field of the issuer process */
+      const smx_actor_t issuer = MC_smx_simcall_get_issuer(saved_req);
+      req                      = &issuer->simcall_;
+
+      /* Debug information */
+      XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth,
+                request_to_string(req, req_num, simgrid::mc::RequestType::simix).c_str(), state.get());
 
       this->get_session().execute(state->transition_);
     }
@@ -256,7 +254,7 @@ std::vector<std::string> LivenessChecker::get_textual_trace() // override
   for (std::shared_ptr<Pair> const& pair : exploration_stack_) {
     int req_num       = pair->graph_state->transition_.argument_;
     smx_simcall_t req = &pair->graph_state->executed_req_;
-    if (req && req->call_ != SIMCALL_NONE)
+    if (req->call_ != simix::Simcall::NONE)
       trace.push_back(request_to_string(req, req_num, RequestType::executed));
   }
   return trace;
index 3a97114..43e70f6 100644 (file)
@@ -67,8 +67,7 @@ std::vector<std::string> SafetyChecker::get_textual_trace() // override
   for (auto const& state : stack_) {
     int value         = state->transition_.argument_;
     smx_simcall_t req = &state->executed_req_;
-    if (req)
-      trace.push_back(mcapi::get().request_to_string(req, value, RequestType::executed));
+    trace.push_back(request_to_string(req, value, RequestType::executed));
   }
   return trace;
 }
@@ -197,7 +196,7 @@ void SafetyChecker::backtrack()
     stack_.pop_back();
     if (reductionMode_ == ReductionMode::dpor) {
       smx_simcall_t req = &state->internal_req_;
-      if (req->call_ == SIMCALL_MUTEX_LOCK || req->call_ == SIMCALL_MUTEX_TRYLOCK)
+      if (req->call_ == simix::Simcall::MUTEX_LOCK || req->call_ == simix::Simcall::MUTEX_TRYLOCK)
         xbt_die("Mutex is currently not supported with DPOR,  use --cfg=model-check/reduction:none");
 
       const kernel::actor::ActorImpl* issuer = mcapi::get().mc_smx_simcall_get_issuer(req);
index c081163..ab35bd1 100644 (file)
@@ -44,7 +44,7 @@ void wait_for_requests()
     simix_global->run_all_actors();
     for (smx_actor_t const& process : simix_global->actors_that_ran) {
       const s_smx_simcall* req = &process->simcall_;
-      if (req->call_ != SIMCALL_NONE && not simgrid::mc::request_is_visible(req))
+      if (req->call_ != simix::Simcall::NONE && not simgrid::mc::request_is_visible(req))
         process->simcall_handle(0);
     }
   }
@@ -85,11 +85,12 @@ bool actor_is_enabled(smx_actor_t actor)
   if (req->inspector_ != nullptr)
     return req->inspector_->is_enabled();
 
+  using simix::Simcall;
   switch (req->call_) {
-    case SIMCALL_NONE:
+    case Simcall::NONE:
       return false;
 
-    case SIMCALL_COMM_WAIT: {
+    case Simcall::COMM_WAIT: {
       /* FIXME: check also that src and dst processes are not suspended */
       const kernel::activity::CommImpl* act = simcall_comm_wait__getraw__comm(req);
 
@@ -106,7 +107,7 @@ bool actor_is_enabled(smx_actor_t actor)
       return (act->src_actor_ && act->dst_actor_);
     }
 
-    case SIMCALL_COMM_WAITANY: {
+    case Simcall::COMM_WAITANY: {
       simgrid::kernel::activity::CommImpl** comms = simcall_comm_waitany__get__comms(req);
       size_t count                                = simcall_comm_waitany__get__count(req);
       for (unsigned int index = 0; index < count; ++index) {
@@ -117,7 +118,7 @@ bool actor_is_enabled(smx_actor_t actor)
       return false;
     }
 
-    case SIMCALL_MUTEX_LOCK: {
+    case Simcall::MUTEX_LOCK: {
       const kernel::activity::MutexImpl* mutex = simcall_mutex_lock__get__mutex(req);
 
       if (mutex->get_owner() == nullptr)
@@ -125,7 +126,7 @@ bool actor_is_enabled(smx_actor_t actor)
       return mutex->get_owner()->get_pid() == req->issuer_->get_pid();
     }
 
-    case SIMCALL_SEM_ACQUIRE: {
+    case Simcall::SEM_ACQUIRE: {
       static int warned = 0;
       if (not warned)
         XBT_INFO("Using semaphore in model-checked code is still experimental. Use at your own risk");
@@ -133,7 +134,7 @@ bool actor_is_enabled(smx_actor_t actor)
       return true;
     }
 
-    case SIMCALL_COND_WAIT: {
+    case Simcall::COND_WAIT: {
       static int warned = 0;
       if (not warned)
         XBT_INFO("Using condition variables in model-checked code is still experimental. Use at your own risk");
@@ -156,10 +157,12 @@ bool request_is_visible(const s_smx_simcall* req)
   xbt_assert(mc_model_checker == nullptr, "This should be called from the client side");
 #endif
 
-  return (req->inspector_ != nullptr && req->inspector_->is_visible()) || req->call_ == SIMCALL_COMM_ISEND ||
-         req->call_ == SIMCALL_COMM_IRECV || req->call_ == SIMCALL_COMM_WAIT || req->call_ == SIMCALL_COMM_WAITANY ||
-         req->call_ == SIMCALL_COMM_TEST || req->call_ == SIMCALL_COMM_TESTANY || req->call_ == SIMCALL_MC_RANDOM ||
-         req->call_ == SIMCALL_MUTEX_LOCK || req->call_ == SIMCALL_MUTEX_TRYLOCK || req->call_ == SIMCALL_MUTEX_UNLOCK;
+  using simix::Simcall;
+  return (req->inspector_ != nullptr && req->inspector_->is_visible()) || req->call_ == Simcall::COMM_ISEND ||
+         req->call_ == Simcall::COMM_IRECV || req->call_ == Simcall::COMM_WAIT || req->call_ == Simcall::COMM_WAITANY ||
+         req->call_ == Simcall::COMM_TEST || req->call_ == Simcall::COMM_TESTANY || req->call_ == Simcall::MC_RANDOM ||
+         req->call_ == Simcall::MUTEX_LOCK || req->call_ == Simcall::MUTEX_TRYLOCK ||
+         req->call_ == Simcall::MUTEX_UNLOCK;
 }
 
 }
index d2fb5e6..3f066a7 100644 (file)
@@ -47,33 +47,32 @@ void MC_state_copy_index_communications_pattern(simgrid::mc::State* state)
     state->communication_indices_.push_back(list_process_comm.index_comm);
 }
 
-void MC_handle_comm_pattern(e_mc_call_type_t call_type, smx_simcall_t req, int value, int backtracking)
+void MC_handle_comm_pattern(simgrid::mc::CallType call_type, smx_simcall_t req, int value, int backtracking)
 {
   // HACK, do not rely on the Checker implementation outside of it
   auto* checker = static_cast<simgrid::mc::CommunicationDeterminismChecker*>(mc_model_checker->getChecker());
 
+  using simgrid::mc::CallType;
   switch(call_type) {
-  case MC_CALL_TYPE_NONE:
-    break;
-  case MC_CALL_TYPE_SEND:
-  case MC_CALL_TYPE_RECV:
-    checker->get_comm_pattern(req, call_type, backtracking);
-    break;
-  case MC_CALL_TYPE_WAIT:
-  case MC_CALL_TYPE_WAITANY:
-    {
-    simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr{nullptr};
-    if (call_type == MC_CALL_TYPE_WAIT)
-      comm_addr = remote(simcall_comm_wait__getraw__comm(req));
+    case CallType::NONE:
+      break;
+    case CallType::SEND:
+    case CallType::RECV:
+      checker->get_comm_pattern(req, call_type, backtracking);
+      break;
+    case CallType::WAIT:
+    case CallType::WAITANY: {
+      simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr{nullptr};
+      if (call_type == CallType::WAIT)
+        comm_addr = remote(simcall_comm_wait__getraw__comm(req));
 
-    else {
-      simgrid::kernel::activity::ActivityImpl* addr;
-      addr = mc_model_checker->get_remote_simulation().read(remote(simcall_comm_waitany__getraw__comms(req) + value));
-      comm_addr = remote(static_cast<simgrid::kernel::activity::CommImpl*>(addr));
+      else {
+        simgrid::kernel::activity::ActivityImpl* addr;
+        addr = mc_model_checker->get_remote_simulation().read(remote(simcall_comm_waitany__getraw__comms(req) + value));
+        comm_addr = remote(static_cast<simgrid::kernel::activity::CommImpl*>(addr));
       }
       checker->complete_comm_pattern(comm_addr, MC_smx_simcall_get_issuer(req)->get_pid(), backtracking);
-    }
-    break;
+    } break;
   default:
     xbt_die("Unexpected call type %i", (int)call_type);
   }
index 68a42e5..70e6a30 100644 (file)
 namespace simgrid {
 namespace mc {
 
+enum class CallType {
+  NONE,
+  SEND,
+  RECV,
+  WAIT,
+  WAITANY,
+};
+
+enum class CommPatternDifference {
+  NONE,
+  TYPE,
+  RDV,
+  TAG,
+  SRC_PROC,
+  DST_PROC,
+  DATA_SIZE,
+  DATA,
+};
+
 struct PatternCommunicationList {
   unsigned int index_comm = 0;
   std::vector<std::unique_ptr<simgrid::mc::PatternCommunication>> list;
 };
-}
-}
+} // namespace mc
+} // namespace simgrid
 
 extern XBT_PRIVATE std::vector<simgrid::mc::PatternCommunicationList> initial_communications_pattern;
 extern XBT_PRIVATE std::vector<std::vector<simgrid::mc::PatternCommunication*>> incomplete_communications_pattern;
 
-enum e_mc_call_type_t {
-  MC_CALL_TYPE_NONE,
-  MC_CALL_TYPE_SEND,
-  MC_CALL_TYPE_RECV,
-  MC_CALL_TYPE_WAIT,
-  MC_CALL_TYPE_WAITANY,
-};
-
-enum e_mc_comm_pattern_difference_t {
-  NONE_DIFF,
-  TYPE_DIFF,
-  RDV_DIFF,
-  TAG_DIFF,
-  SRC_PROC_DIFF,
-  DST_PROC_DIFF,
-  DATA_SIZE_DIFF,
-  DATA_DIFF,
-};
-
-static inline e_mc_call_type_t MC_get_call_type(const s_smx_simcall* req)
+static inline simgrid::mc::CallType MC_get_call_type(const s_smx_simcall* req)
 {
+  using simgrid::mc::CallType;
+  using simgrid::simix::Simcall;
   switch (req->call_) {
-    case SIMCALL_COMM_ISEND:
-      return MC_CALL_TYPE_SEND;
-    case SIMCALL_COMM_IRECV:
-      return MC_CALL_TYPE_RECV;
-    case SIMCALL_COMM_WAIT:
-      return MC_CALL_TYPE_WAIT;
-    case SIMCALL_COMM_WAITANY:
-      return MC_CALL_TYPE_WAITANY;
+    case Simcall::COMM_ISEND:
+      return CallType::SEND;
+    case Simcall::COMM_IRECV:
+      return CallType::RECV;
+    case Simcall::COMM_WAIT:
+      return CallType::WAIT;
+    case Simcall::COMM_WAITANY:
+      return CallType::WAITANY;
     default:
-      return MC_CALL_TYPE_NONE;
+      return CallType::NONE;
   }
 }
 
-XBT_PRIVATE void MC_handle_comm_pattern(e_mc_call_type_t call_type, smx_simcall_t request, int value, int backtracking);
+XBT_PRIVATE void MC_handle_comm_pattern(simgrid::mc::CallType call_type, smx_simcall_t request, int value,
+                                        int backtracking);
 
 XBT_PRIVATE void MC_restore_communications_pattern(simgrid::mc::State* state);
 
index bfd5482..2edd855 100644 (file)
@@ -35,7 +35,7 @@ void replay(RecordTrace const& trace)
     if (not process)
       xbt_die("Unexpected process (pid:%d).", transition.pid_);
     const s_smx_simcall* simcall = &(process->simcall_);
-    if (simcall == nullptr || simcall->call_ == SIMCALL_NONE)
+    if (simcall->call_ == simix::Simcall::NONE)
       xbt_die("No simcall for process %d.", transition.pid_);
     if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(process))
       xbt_die("Unexpected simcall.");
index 94d0d91..cea6c69 100644 (file)
@@ -13,6 +13,7 @@
 #include <array>
 
 using simgrid::mc::remote;
+using simgrid::simix::Simcall;
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_request, mc, "Logging specific to MC (request)");
 
@@ -22,9 +23,9 @@ static char *buff_size_to_string(size_t size);
 static inline simgrid::kernel::activity::CommImpl* MC_get_comm(smx_simcall_t r)
 {
   switch (r->call_) {
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       return simcall_comm_wait__getraw__comm(r);
-    case SIMCALL_COMM_TEST:
+    case Simcall::COMM_TEST:
       return simcall_comm_test__getraw__comm(r);
     default:
       return nullptr;
@@ -35,9 +36,9 @@ static inline
 smx_mailbox_t MC_get_mbox(smx_simcall_t r)
 {
   switch (r->call_) {
-    case SIMCALL_COMM_ISEND:
+    case Simcall::COMM_ISEND:
       return simcall_comm_isend__get__mbox(r);
-    case SIMCALL_COMM_IRECV:
+    case Simcall::COMM_IRECV:
       return simcall_comm_irecv__get__mbox(r);
     default:
       return nullptr;
@@ -51,17 +52,17 @@ namespace mc {
 static inline
 bool request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2)
 {
-  if (r1->call_ == SIMCALL_COMM_ISEND && r2->call_ == SIMCALL_COMM_IRECV)
+  if (r1->call_ == Simcall::COMM_ISEND && r2->call_ == Simcall::COMM_IRECV)
     return false;
 
-  if (r1->call_ == SIMCALL_COMM_IRECV && r2->call_ == SIMCALL_COMM_ISEND)
+  if (r1->call_ == Simcall::COMM_IRECV && r2->call_ == Simcall::COMM_ISEND)
     return false;
 
   // Those are internal requests, we do not need indirection because those objects are copies:
   const kernel::activity::CommImpl* synchro1 = MC_get_comm(r1);
   const kernel::activity::CommImpl* synchro2 = MC_get_comm(r2);
 
-  if ((r1->call_ == SIMCALL_COMM_ISEND || r1->call_ == SIMCALL_COMM_IRECV) && r2->call_ == SIMCALL_COMM_WAIT) {
+  if ((r1->call_ == Simcall::COMM_ISEND || r1->call_ == Simcall::COMM_IRECV) && r2->call_ == Simcall::COMM_WAIT) {
     const kernel::activity::MailboxImpl* mbox = MC_get_mbox(r1);
 
     if (mbox != synchro2->mbox_cpy
@@ -72,11 +73,11 @@ bool request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2)
         simcall_comm_wait__get__timeout(r2) <= 0)
       return false;
 
-    if ((r1->call_ == SIMCALL_COMM_ISEND) && (synchro2->type_ == kernel::activity::CommImpl::Type::SEND) &&
+    if ((r1->call_ == Simcall::COMM_ISEND) && (synchro2->type_ == kernel::activity::CommImpl::Type::SEND) &&
         (synchro2->src_buff_ != simcall_comm_isend__get__src_buff(r1)) && simcall_comm_wait__get__timeout(r2) <= 0)
       return false;
 
-    if ((r1->call_ == SIMCALL_COMM_IRECV) && (synchro2->type_ == kernel::activity::CommImpl::Type::RECEIVE) &&
+    if ((r1->call_ == Simcall::COMM_IRECV) && (synchro2->type_ == kernel::activity::CommImpl::Type::RECEIVE) &&
         (synchro2->dst_buff_ != simcall_comm_irecv__get__dst_buff(r1)) && simcall_comm_wait__get__timeout(r2) <= 0)
       return false;
   }
@@ -84,24 +85,24 @@ bool request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2)
   /* FIXME: the following rule assumes that the result of the isend/irecv call is not stored in a buffer used in the
    * test call. */
 #if 0
-  if((r1->call == SIMCALL_COMM_ISEND || r1->call == SIMCALL_COMM_IRECV)
-      &&  r2->call == SIMCALL_COMM_TEST)
+  if((r1->call == Simcall::COMM_ISEND || r1->call == Simcall::COMM_IRECV)
+      &&  r2->call == Simcall::COMM_TEST)
     return false;
 #endif
 
-  if (r1->call_ == SIMCALL_COMM_WAIT && (r2->call_ == SIMCALL_COMM_WAIT || r2->call_ == SIMCALL_COMM_TEST) &&
+  if (r1->call_ == Simcall::COMM_WAIT && (r2->call_ == Simcall::COMM_WAIT || r2->call_ == Simcall::COMM_TEST) &&
       (synchro1->src_actor_.get() == nullptr || synchro1->dst_actor_.get() == nullptr))
     return false;
 
-  if (r1->call_ == SIMCALL_COMM_TEST &&
+  if (r1->call_ == Simcall::COMM_TEST &&
       (simcall_comm_test__get__comm(r1) == nullptr || synchro1->src_buff_ == nullptr || synchro1->dst_buff_ == nullptr))
     return false;
 
-  if (r1->call_ == SIMCALL_COMM_TEST && r2->call_ == SIMCALL_COMM_WAIT && synchro1->src_buff_ == synchro2->src_buff_ &&
-      synchro1->dst_buff_ == synchro2->dst_buff_)
+  if (r1->call_ == Simcall::COMM_TEST && r2->call_ == Simcall::COMM_WAIT &&
+      synchro1->src_buff_ == synchro2->src_buff_ && synchro1->dst_buff_ == synchro2->dst_buff_)
     return false;
 
-  if (r1->call_ == SIMCALL_COMM_WAIT && r2->call_ == SIMCALL_COMM_TEST && synchro1->src_buff_ != nullptr &&
+  if (r1->call_ == Simcall::COMM_WAIT && r2->call_ == Simcall::COMM_TEST && synchro1->src_buff_ != nullptr &&
       synchro1->dst_buff_ != nullptr && synchro2->src_buff_ != nullptr && synchro2->dst_buff_ != nullptr &&
       synchro1->dst_buff_ != synchro2->src_buff_ && synchro1->dst_buff_ != synchro2->dst_buff_ &&
       synchro2->dst_buff_ != synchro1->src_buff_)
@@ -117,8 +118,8 @@ bool request_depend(smx_simcall_t req1, smx_simcall_t req2)
     return false;
 
   /* Wait with timeout transitions are not considered by the independence theorem, thus we consider them as dependent with all other transitions */
-  if ((req1->call_ == SIMCALL_COMM_WAIT && simcall_comm_wait__get__timeout(req1) > 0) ||
-      (req2->call_ == SIMCALL_COMM_WAIT && simcall_comm_wait__get__timeout(req2) > 0))
+  if ((req1->call_ == Simcall::COMM_WAIT && simcall_comm_wait__get__timeout(req1) > 0) ||
+      (req2->call_ == Simcall::COMM_WAIT && simcall_comm_wait__get__timeout(req2) > 0))
     return true;
 
   if (req1->call_ != req2->call_)
@@ -129,11 +130,11 @@ bool request_depend(smx_simcall_t req1, smx_simcall_t req2)
   const kernel::activity::CommImpl* synchro2 = MC_get_comm(req2);
 
   switch (req1->call_) {
-    case SIMCALL_COMM_ISEND:
+    case Simcall::COMM_ISEND:
       return simcall_comm_isend__get__mbox(req1) == simcall_comm_isend__get__mbox(req2);
-    case SIMCALL_COMM_IRECV:
+    case Simcall::COMM_IRECV:
       return simcall_comm_irecv__get__mbox(req1) == simcall_comm_irecv__get__mbox(req2);
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       if (synchro1->src_buff_ == synchro2->src_buff_ && synchro1->dst_buff_ == synchro2->dst_buff_)
         return false;
       if (synchro1->src_buff_ != nullptr && synchro1->dst_buff_ != nullptr && synchro2->src_buff_ != nullptr &&
@@ -192,7 +193,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
   smx_actor_t issuer = MC_smx_simcall_get_issuer(req);
 
   switch (req->call_) {
-    case SIMCALL_COMM_ISEND: {
+    case Simcall::COMM_ISEND: {
       type     = "iSend";
       char* p  = pointer_to_string(simcall_comm_isend__get__src_buff(req));
       char* bs = buff_size_to_string(simcall_comm_isend__get__src_buff_size(req));
@@ -206,7 +207,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_COMM_IRECV: {
+    case Simcall::COMM_IRECV: {
       size_t* remote_size = simcall_comm_irecv__get__dst_buff_size(req);
       size_t size         = 0;
       if (remote_size)
@@ -225,7 +226,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_COMM_WAIT: {
+    case Simcall::COMM_WAIT: {
       simgrid::kernel::activity::CommImpl* remote_act = simcall_comm_wait__getraw__comm(req);
       char* p;
       if (value == -1) {
@@ -258,7 +259,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_COMM_TEST: {
+    case Simcall::COMM_TEST: {
       simgrid::kernel::activity::CommImpl* remote_act = simcall_comm_test__getraw__comm(req);
       simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
       const simgrid::kernel::activity::CommImpl* act;
@@ -289,7 +290,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_COMM_WAITANY: {
+    case Simcall::COMM_WAITANY: {
       type         = "WaitAny";
       size_t count = simcall_comm_waitany__get__count(req);
       if (count > 0) {
@@ -304,7 +305,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_COMM_TESTANY:
+    case Simcall::COMM_TESTANY:
       if (value == -1) {
         type = "TestAny FALSE";
         args = xbt_strdup("-");
@@ -314,16 +315,16 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       }
       break;
 
-    case SIMCALL_MUTEX_TRYLOCK:
-    case SIMCALL_MUTEX_LOCK: {
-      if (req->call_ == SIMCALL_MUTEX_LOCK)
+    case Simcall::MUTEX_TRYLOCK:
+    case Simcall::MUTEX_LOCK: {
+      if (req->call_ == Simcall::MUTEX_LOCK)
         type = "Mutex LOCK";
       else
         type = "Mutex TRYLOCK";
 
       simgrid::mc::Remote<simgrid::kernel::activity::MutexImpl> mutex;
       mc_model_checker->get_remote_simulation().read_bytes(mutex.get_buffer(), sizeof(mutex),
-                                                           remote(req->call_ == SIMCALL_MUTEX_LOCK
+                                                           remote(req->call_ == Simcall::MUTEX_LOCK
                                                                       ? simcall_mutex_lock__get__mutex(req)
                                                                       : simcall_mutex_trylock__get__mutex(req)));
       args = bprintf("locked = %d, owner = %d, sleeping = n/a", mutex.get_buffer()->is_locked(),
@@ -335,7 +336,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
       break;
     }
 
-    case SIMCALL_MC_RANDOM:
+    case Simcall::MC_RANDOM:
       type = "MC_RANDOM";
       args = bprintf("%d", value);
       break;
@@ -364,16 +365,16 @@ bool request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx)
 {
   kernel::activity::CommImpl* remote_act = nullptr;
   switch (req->call_) {
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       /* FIXME: check also that src and dst processes are not suspended */
       remote_act = simcall_comm_wait__getraw__comm(req);
       break;
 
-    case SIMCALL_COMM_WAITANY:
+    case Simcall::COMM_WAITANY:
       remote_act = mc_model_checker->get_remote_simulation().read(remote(simcall_comm_testany__get__comms(req) + idx));
       break;
 
-    case SIMCALL_COMM_TESTANY:
+    case Simcall::COMM_TESTANY:
       remote_act = mc_model_checker->get_remote_simulation().read(remote(simcall_comm_testany__get__comms(req) + idx));
       break;
 
@@ -407,21 +408,21 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
   std::string label;
 
   switch (req->call_) {
-    case SIMCALL_COMM_ISEND:
+    case Simcall::COMM_ISEND:
       if (issuer->get_host())
         label = xbt::string_printf("[(%ld)%s] iSend", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
       else
         label = bprintf("[(%ld)] iSend", issuer->get_pid());
       break;
 
-    case SIMCALL_COMM_IRECV:
+    case Simcall::COMM_IRECV:
       if (issuer->get_host())
         label = xbt::string_printf("[(%ld)%s] iRecv", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
       else
         label = xbt::string_printf("[(%ld)] iRecv", issuer->get_pid());
       break;
 
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       if (value == -1) {
         if (issuer->get_host())
           label = xbt::string_printf("[(%ld)%s] WaitTimeout", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
@@ -448,7 +449,7 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       }
       break;
 
-    case SIMCALL_COMM_TEST: {
+    case Simcall::COMM_TEST: {
       kernel::activity::ActivityImpl* remote_act = simcall_comm_test__getraw__comm(req);
       Remote<simgrid::kernel::activity::CommImpl> temp_comm;
       mc_model_checker->get_remote_simulation().read(temp_comm,
@@ -468,7 +469,7 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       break;
     }
 
-    case SIMCALL_COMM_WAITANY: {
+    case Simcall::COMM_WAITANY: {
       size_t comms_size = simcall_comm_waitany__get__count(req);
       if (issuer->get_host())
         label = xbt::string_printf("[(%ld)%s] WaitAny [%d of %zu]", issuer->get_pid(),
@@ -478,7 +479,7 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       break;
     }
 
-    case SIMCALL_COMM_TESTANY:
+    case Simcall::COMM_TESTANY:
       if (value == -1) {
         if (issuer->get_host())
           label = xbt::string_printf("[(%ld)%s] TestAny FALSE", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
@@ -495,15 +496,15 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       }
       break;
 
-    case SIMCALL_MUTEX_TRYLOCK:
+    case Simcall::MUTEX_TRYLOCK:
       label = xbt::string_printf("[(%ld)] Mutex TRYLOCK", issuer->get_pid());
       break;
 
-    case SIMCALL_MUTEX_LOCK:
+    case Simcall::MUTEX_LOCK:
       label = xbt::string_printf("[(%ld)] Mutex LOCK", issuer->get_pid());
       break;
 
-    case SIMCALL_MC_RANDOM:
+    case Simcall::MC_RANDOM:
       if (issuer->get_host())
         label = xbt::string_printf("[(%ld)%s] MC_RANDOM (%d)", issuer->get_pid(), MC_smx_actor_get_host_name(issuer),
                                    value);
index 4049cbb..6c8e630 100644 (file)
@@ -135,10 +135,11 @@ const char* MC_smx_actor_get_host_name(smx_actor_t actor)
 
 const char* MC_smx_actor_get_name(smx_actor_t actor)
 {
-  const simgrid::mc::RemoteSimulation* process = &mc_model_checker->get_remote_simulation();
   if (mc_model_checker == nullptr)
     return actor->get_cname();
 
+  const simgrid::mc::RemoteSimulation* process = &mc_model_checker->get_remote_simulation();
+
   simgrid::mc::ActorInformation* info = actor_info_cast(actor);
   if (info->name.empty()) {
     simgrid::xbt::string_data string_data = simgrid::xbt::string::to_string_data(actor->name_);
index c078742..c251505 100644 (file)
@@ -43,3 +43,173 @@ Transition State::get_transition() const
 
 }
 }
+
+/* Search an enabled transition for the given process.
+ *
+ * This can be seen as an iterator returning the next transition of the process.
+ *
+ * We only consider the processes that are both
+ *  - marked "to be interleaved" in their ActorState (controlled by the checker algorithm).
+ *  - which simcall can currently be executed (like a comm where the other partner is already known)
+ * Once we returned the last enabled transition of a process, it is marked done.
+ *
+ * Things can get muddled with the WAITANY and TESTANY simcalls, that are rewritten on the fly to a bunch of WAIT
+ * (resp TEST) transitions using the transition.argument field to remember what was the last returned sub-transition.
+ */
+static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::State* state, smx_actor_t actor)
+{
+  using simgrid::simix::Simcall;
+
+  /* reset the outgoing transition */
+  simgrid::mc::ActorState* procstate   = &state->actor_states_[actor->get_pid()];
+  state->transition_.pid_              = -1;
+  state->transition_.argument_         = -1;
+  state->executed_req_.call_           = Simcall::NONE;
+
+  if (not simgrid::mc::actor_is_enabled(actor))
+    return nullptr; // Not executable in the application
+
+  smx_simcall_t req = nullptr;
+  switch (actor->simcall_.call_) {
+    case Simcall::COMM_WAITANY:
+      state->transition_.argument_ = -1;
+      while (procstate->times_considered < simcall_comm_waitany__get__count(&actor->simcall_)) {
+        if (simgrid::mc::request_is_enabled_by_idx(&actor->simcall_, procstate->times_considered)) {
+          state->transition_.argument_ = procstate->times_considered;
+          ++procstate->times_considered;
+          break;
+        }
+        ++procstate->times_considered;
+      }
+
+      if (procstate->times_considered >= simcall_comm_waitany__get__count(&actor->simcall_))
+        procstate->set_done();
+      if (state->transition_.argument_ != -1)
+        req = &actor->simcall_;
+      break;
+
+    case Simcall::COMM_TESTANY: {
+      unsigned start_count       = procstate->times_considered;
+      state->transition_.argument_ = -1;
+      while (procstate->times_considered < simcall_comm_testany__get__count(&actor->simcall_)) {
+        if (simgrid::mc::request_is_enabled_by_idx(&actor->simcall_, procstate->times_considered)) {
+          state->transition_.argument_ = procstate->times_considered;
+          ++procstate->times_considered;
+          break;
+        }
+        ++procstate->times_considered;
+      }
+
+      if (procstate->times_considered >= simcall_comm_testany__get__count(&actor->simcall_))
+        procstate->set_done();
+
+      if (state->transition_.argument_ != -1 || start_count == 0)
+        req = &actor->simcall_;
+
+      break;
+    }
+
+    case Simcall::COMM_WAIT: {
+      simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> remote_act =
+          remote(simcall_comm_wait__getraw__comm(&actor->simcall_));
+      simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_act;
+      mc_model_checker->get_remote_simulation().read(temp_act, remote_act);
+      const simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer();
+      if (act->src_actor_.get() && act->dst_actor_.get())
+        state->transition_.argument_ = 0; // OK
+      else if (act->src_actor_.get() == nullptr && act->type_ == simgrid::kernel::activity::CommImpl::Type::READY &&
+               act->detached())
+        state->transition_.argument_ = 0; // OK
+      else
+        state->transition_.argument_ = -1; // timeout
+      procstate->set_done();
+      req = &actor->simcall_;
+      break;
+    }
+
+    case Simcall::MC_RANDOM: {
+      int min_value                = simcall_mc_random__get__min(&actor->simcall_);
+      state->transition_.argument_ = procstate->times_considered + min_value;
+      procstate->times_considered++;
+      if (state->transition_.argument_ == simcall_mc_random__get__max(&actor->simcall_))
+        procstate->set_done();
+      req = &actor->simcall_;
+      break;
+    }
+
+    default:
+      procstate->set_done();
+      state->transition_.argument_ = 0;
+      req                          = &actor->simcall_;
+      break;
+  }
+  if (not req)
+    return nullptr;
+
+  state->transition_.pid_ = actor->get_pid();
+  state->executed_req_    = *req;
+  // Fetch the data of the request and translate it:
+  state->internal_req_ = *req;
+
+  /* The waitany and testany request are transformed into a wait or test request over the corresponding communication
+   * action so it can be treated later by the dependence function. */
+  switch (req->call_) {
+    case Simcall::COMM_WAITANY: {
+      state->internal_req_.call_ = Simcall::COMM_WAIT;
+      simgrid::kernel::activity::CommImpl* remote_comm;
+      remote_comm = mc_model_checker->get_remote_simulation().read(
+          remote(simcall_comm_waitany__get__comms(req) + state->transition_.argument_));
+      mc_model_checker->get_remote_simulation().read(state->internal_comm_, remote(remote_comm));
+      simcall_comm_wait__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
+      simcall_comm_wait__set__timeout(&state->internal_req_, 0);
+      break;
+    }
+
+    case Simcall::COMM_TESTANY:
+      state->internal_req_.call_ = Simcall::COMM_TEST;
+
+      if (state->transition_.argument_ > 0) {
+        simgrid::kernel::activity::CommImpl* remote_comm = mc_model_checker->get_remote_simulation().read(
+            remote(simcall_comm_testany__get__comms(req) + state->transition_.argument_));
+        mc_model_checker->get_remote_simulation().read(state->internal_comm_, remote(remote_comm));
+      }
+
+      simcall_comm_test__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
+      simcall_comm_test__set__result(&state->internal_req_, state->transition_.argument_);
+      break;
+
+    case Simcall::COMM_WAIT:
+      mc_model_checker->get_remote_simulation().read_bytes(&state->internal_comm_, sizeof(state->internal_comm_),
+                                                           remote(simcall_comm_wait__getraw__comm(req)));
+      simcall_comm_wait__set__comm(&state->executed_req_, state->internal_comm_.get_buffer());
+      simcall_comm_wait__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
+      break;
+
+    case Simcall::COMM_TEST:
+      mc_model_checker->get_remote_simulation().read_bytes(&state->internal_comm_, sizeof(state->internal_comm_),
+                                                           remote(simcall_comm_test__getraw__comm(req)));
+      simcall_comm_test__set__comm(&state->executed_req_, state->internal_comm_.get_buffer());
+      simcall_comm_test__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
+      break;
+
+    default:
+      /* No translation needed */
+      break;
+  }
+
+  return req;
+}
+
+smx_simcall_t MC_state_choose_request(simgrid::mc::State* state)
+{
+  for (auto& actor : mc_model_checker->get_remote_simulation().actors()) {
+    /* Only consider the actors that were marked as interleaving by the checker algorithm */
+    if (not state->actor_states_[actor.copy.get_buffer()->get_pid()].is_todo())
+      continue;
+
+    smx_simcall_t res = MC_state_choose_request_for_process(state, actor.copy.get_buffer());
+    if (res)
+      return res;
+  }
+  return nullptr;
+}
index b2ce0cc..2cac8f9 100644 (file)
@@ -29,8 +29,8 @@ public:
 
   /* Internal translation of the executed_req simcall
    *
-   * SIMCALL_COMM_TESTANY is translated to a SIMCALL_COMM_TEST
-   * and SIMCALL_COMM_WAITANY to a SIMCALL_COMM_WAIT.
+   * Simcall::COMM_TESTANY is translated to a Simcall::COMM_TEST
+   * and Simcall::COMM_WAITANY to a Simcall::COMM_WAIT.
    */
   s_smx_simcall internal_req_;
 
index 9a72d04..829a2c7 100644 (file)
@@ -80,7 +80,7 @@ void AppSide::handle_deadlock_check(const s_mc_message_t*) const
   }
 
   // Send result:
-  s_mc_message_int_t answer{MC_MESSAGE_DEADLOCK_CHECK_REPLY, deadlock};
+  s_mc_message_int_t answer{MessageType::DEADLOCK_CHECK_REPLY, deadlock};
   xbt_assert(channel_.send(answer) == 0, "Could not send response");
 }
 void AppSide::handle_continue(const s_mc_message_t*) const
@@ -92,14 +92,14 @@ void AppSide::handle_simcall(const s_mc_message_simcall_handle_t* message) const
   smx_actor_t process = SIMIX_process_from_PID(message->pid);
   xbt_assert(process != nullptr, "Invalid pid %lu", message->pid);
   process->simcall_handle(message->value);
-  if (channel_.send(MC_MESSAGE_WAITING))
+  if (channel_.send(MessageType::WAITING))
     xbt_die("Could not send MESSAGE_WAITING to model-checker");
 }
 
 void AppSide::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) const
 {
   bool res = simgrid::mc::actor_is_enabled(SIMIX_process_from_PID(msg->aid));
-  s_mc_message_int_t answer{MC_MESSAGE_ACTOR_ENABLED_REPLY, res};
+  s_mc_message_int_t answer{MessageType::ACTOR_ENABLED_REPLY, res};
   channel_.send(answer);
 }
 
@@ -119,28 +119,29 @@ void AppSide::handle_messages() const
 
     const s_mc_message_t* message = (s_mc_message_t*)message_buffer.data();
     switch (message->type) {
-      case MC_MESSAGE_DEADLOCK_CHECK:
+      case MessageType::DEADLOCK_CHECK:
         assert_msg_size("DEADLOCK_CHECK", s_mc_message_t);
         handle_deadlock_check(message);
         break;
 
-      case MC_MESSAGE_CONTINUE:
+      case MessageType::CONTINUE:
         assert_msg_size("MESSAGE_CONTINUE", s_mc_message_t);
         handle_continue(message);
         return;
 
-      case MC_MESSAGE_SIMCALL_HANDLE:
+      case MessageType::SIMCALL_HANDLE:
         assert_msg_size("SIMCALL_HANDLE", s_mc_message_simcall_handle_t);
         handle_simcall((s_mc_message_simcall_handle_t*)message_buffer.data());
         break;
 
-      case MC_MESSAGE_ACTOR_ENABLED:
+      case MessageType::ACTOR_ENABLED:
         assert_msg_size("ACTOR_ENABLED", s_mc_message_actor_enabled_t);
         handle_actor_enabled((s_mc_message_actor_enabled_t*)message_buffer.data());
         break;
 
       default:
-        xbt_die("Received unexpected message %s (%i)", MC_message_type_name(message->type), message->type);
+        xbt_die("Received unexpected message %s (%i)", MC_message_type_name(message->type),
+                static_cast<int>(message->type));
         break;
     }
   }
@@ -150,14 +151,14 @@ void AppSide::main_loop() const
 {
   while (true) {
     simgrid::mc::wait_for_requests();
-    xbt_assert(channel_.send(MC_MESSAGE_WAITING) == 0, "Could not send WAITING message to model-checker");
+    xbt_assert(channel_.send(MessageType::WAITING) == 0, "Could not send WAITING message to model-checker");
     this->handle_messages();
   }
 }
 
 void AppSide::report_assertion_failure() const
 {
-  if (channel_.send(MC_MESSAGE_ASSERTION_FAILED))
+  if (channel_.send(MessageType::ASSERTION_FAILED))
     xbt_die("Could not send assertion to model-checker");
   this->handle_messages();
 }
@@ -165,7 +166,7 @@ void AppSide::report_assertion_failure() const
 void AppSide::ignore_memory(void* addr, std::size_t size) const
 {
   s_mc_message_ignore_memory_t message;
-  message.type = MC_MESSAGE_IGNORE_MEMORY;
+  message.type = MessageType::IGNORE_MEMORY;
   message.addr = (std::uintptr_t)addr;
   message.size = size;
   if (channel_.send(message))
@@ -177,7 +178,7 @@ void AppSide::ignore_heap(void* address, std::size_t size) const
   const s_xbt_mheap_t* heap = mmalloc_get_current_heap();
 
   s_mc_message_ignore_heap_t message;
-  message.type    = MC_MESSAGE_IGNORE_HEAP;
+  message.type    = MessageType::IGNORE_HEAP;
   message.address = address;
   message.size    = size;
   message.block   = ((char*)address - (char*)heap->heapbase) / BLOCKSIZE + 1;
@@ -196,7 +197,7 @@ void AppSide::ignore_heap(void* address, std::size_t size) const
 void AppSide::unignore_heap(void* address, std::size_t size) const
 {
   s_mc_message_ignore_memory_t message;
-  message.type = MC_MESSAGE_UNIGNORE_HEAP;
+  message.type = MessageType::UNIGNORE_HEAP;
   message.addr = (std::uintptr_t)address;
   message.size = size;
   if (channel_.send(message))
@@ -206,7 +207,7 @@ void AppSide::unignore_heap(void* address, std::size_t size) const
 void AppSide::declare_symbol(const char* name, int* value) const
 {
   s_mc_message_register_symbol_t message;
-  message.type = MC_MESSAGE_REGISTER_SYMBOL;
+  message.type = MessageType::REGISTER_SYMBOL;
   if (strlen(name) + 1 > sizeof(message.name))
     xbt_die("Symbol is too long");
   strncpy(message.name, name, sizeof(message.name));
@@ -228,7 +229,7 @@ void AppSide::declare_stack(void* stack, size_t size, ucontext_t* context) const
   region.block   = ((char*)stack - (char*)heap->heapbase) / BLOCKSIZE + 1;
 
   s_mc_message_stack_region_t message;
-  message.type         = MC_MESSAGE_STACK_REGION;
+  message.type         = MessageType::STACK_REGION;
   message.stack_region = region;
   if (channel_.send(message))
     xbt_die("Could not send STACK_REGION to model-checker");
index 782a563..ae2a0fb 100644 (file)
@@ -26,7 +26,7 @@ Channel::~Channel()
 /** @brief Send a message; returns 0 on success or errno on failure */
 int Channel::send(const void* message, size_t size) const
 {
-  XBT_DEBUG("Send %s", MC_message_type_name(*(e_mc_message_type*)message));
+  XBT_DEBUG("Send %s", MC_message_type_name(*(MessageType*)message));
   while (::send(this->socket_, message, size, 0) == -1) {
     if (errno != EINTR)
       return errno;
@@ -38,7 +38,7 @@ ssize_t Channel::receive(void* message, size_t size, bool block) const
 {
   ssize_t res = recv(this->socket_, message, size, block ? 0 : MSG_DONTWAIT);
   if (res != -1)
-    XBT_DEBUG("Receive %s", MC_message_type_name(*(e_mc_message_type*)message));
+    XBT_DEBUG("Receive %s", MC_message_type_name(*(MessageType*)message));
   return res;
 }
 }
index 30161b5..029ef68 100644 (file)
@@ -35,7 +35,7 @@ public:
 
   // Send
   int send(const void* message, size_t size) const;
-  int send(e_mc_message_type type) const
+  int send(MessageType type) const
   {
     s_mc_message_t message = {type};
     return this->send(&message, sizeof(message));
index 690f910..111983e 100644 (file)
@@ -5,41 +5,13 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/mc/remote/mc_protocol.h"
+#include <array>
 
-const char* MC_message_type_name(e_mc_message_type type)
+const char* MC_message_type_name(simgrid::mc::MessageType type)
 {
-  switch (type) {
-    case MC_MESSAGE_NONE:
-      return "NONE";
-    case MC_MESSAGE_CONTINUE:
-      return "CONTINUE";
-    case MC_MESSAGE_IGNORE_HEAP:
-      return "IGNORE_HEAP";
-    case MC_MESSAGE_UNIGNORE_HEAP:
-      return "UNIGNORE_HEAP";
-    case MC_MESSAGE_IGNORE_MEMORY:
-      return "IGNORE_MEMORY";
-    case MC_MESSAGE_STACK_REGION:
-      return "STACK_REGION";
-    case MC_MESSAGE_REGISTER_SYMBOL:
-      return "REGISTER_SYMBOL";
-    case MC_MESSAGE_DEADLOCK_CHECK:
-      return "DEADLOCK_CHECK";
-    case MC_MESSAGE_DEADLOCK_CHECK_REPLY:
-      return "DEADLOCK_CHECK_REPLY";
-    case MC_MESSAGE_WAITING:
-      return "WAITING";
-    case MC_MESSAGE_SIMCALL_HANDLE:
-      return "SIMCALL_HANDLE";
-    case MC_MESSAGE_ASSERTION_FAILED:
-      return "ASSERTION_FAILED";
-
-    case MC_MESSAGE_ACTOR_ENABLED:
-      return "ACTOR_ENABLED";
-    case MC_MESSAGE_ACTOR_ENABLED_REPLY:
-      return "ACTOR_ENABLED_REPLY";
-
-    default:
-      return "?";
-  }
+  constexpr std::array<const char*, 14> names{{"NONE", "CONTINUE", "IGNORE_HEAP", "UNIGNORE_HEAP", "IGNORE_MEMORY",
+                                               "STACK_REGION", "REGISTER_SYMBOL", "DEADLOCK_CHECK",
+                                               "DEADLOCK_CHECK_REPLY", "WAITING", "SIMCALL_HANDLE", "ASSERTION_FAILED",
+                                               "ACTOR_ENABLED", "ACTOR_ENABLED_REPLY"}};
+  return names[static_cast<int>(type)];
 }
index ab6f855..e620fc6 100644 (file)
@@ -6,12 +6,6 @@
 #ifndef SIMGRID_MC_PROTOCOL_H
 #define SIMGRID_MC_PROTOCOL_H
 
-#include "mc/datatypes.h"
-#include "simgrid/forward.h"
-#include "stdint.h"
-
-SG_BEGIN_DECL
-
 // ***** Environment variables for passing context to the model-checked process
 
 /** Environment variable name used to pass the communication socket.
@@ -20,25 +14,36 @@ SG_BEGIN_DECL
  */
 #define MC_ENV_SOCKET_FD "SIMGRID_MC_SOCKET_FD"
 
-// ***** Messages
+#ifdef __cplusplus
 
-enum e_mc_message_type {
-  MC_MESSAGE_NONE,
-  MC_MESSAGE_CONTINUE,
-  MC_MESSAGE_IGNORE_HEAP,
-  MC_MESSAGE_UNIGNORE_HEAP,
-  MC_MESSAGE_IGNORE_MEMORY,
-  MC_MESSAGE_STACK_REGION,
-  MC_MESSAGE_REGISTER_SYMBOL,
-  MC_MESSAGE_DEADLOCK_CHECK,
-  MC_MESSAGE_DEADLOCK_CHECK_REPLY,
-  MC_MESSAGE_WAITING,
-  MC_MESSAGE_SIMCALL_HANDLE,
-  MC_MESSAGE_ASSERTION_FAILED,
-  MC_MESSAGE_ACTOR_ENABLED,
-  MC_MESSAGE_ACTOR_ENABLED_REPLY
+#include "cstdint"
+#include "mc/datatypes.h"
+#include "simgrid/forward.h" // aid_t
+
+// ***** Messages
+namespace simgrid {
+namespace mc {
+
+enum class MessageType {
+  NONE,
+  CONTINUE,
+  IGNORE_HEAP,
+  UNIGNORE_HEAP,
+  IGNORE_MEMORY,
+  STACK_REGION,
+  REGISTER_SYMBOL,
+  DEADLOCK_CHECK,
+  DEADLOCK_CHECK_REPLY,
+  WAITING,
+  SIMCALL_HANDLE,
+  ASSERTION_FAILED,
+  ACTOR_ENABLED,
+  ACTOR_ENABLED_REPLY
 };
 
+} // namespace mc
+} // namespace simgrid
+
 #define MC_MESSAGE_LENGTH 512
 
 /** Basic structure for a MC message
@@ -53,17 +58,17 @@ enum e_mc_message_type {
 
 /* Basic structure: all message start with a message type */
 struct s_mc_message_t {
-  enum e_mc_message_type type;
+  simgrid::mc::MessageType type;
 };
 
 struct s_mc_message_int_t {
-  enum e_mc_message_type type;
+  simgrid::mc::MessageType type;
   uint64_t value;
 };
 
 /* Client->Server */
 struct s_mc_message_ignore_heap_t {
-  enum e_mc_message_type type;
+  simgrid::mc::MessageType type;
   int block;
   int fragment;
   void* address;
@@ -71,18 +76,18 @@ struct s_mc_message_ignore_heap_t {
 };
 
 struct s_mc_message_ignore_memory_t {
-  enum e_mc_message_type type;
+  simgrid::mc::MessageType type;
   uint64_t addr;
   size_t size;
 };
 
 struct s_mc_message_stack_region_t {
-  enum e_mc_message_type type;
+  simgrid::mc::MessageType type;
   s_stack_region_t stack_region;
 };
 
 struct s_mc_message_register_symbol_t {
-  enum e_mc_message_type type;
+  simgrid::mc::MessageType type;
   char name[128];
   int (*callback)(void*);
   void* data;
@@ -90,23 +95,22 @@ struct s_mc_message_register_symbol_t {
 
 /* Server -> client */
 struct s_mc_message_simcall_handle_t {
-  enum e_mc_message_type type;
+  simgrid::mc::MessageType type;
   unsigned long pid;
   int value;
 };
 
 struct s_mc_message_restore_t {
-  enum e_mc_message_type type;
+  simgrid::mc::MessageType type;
   int index;
 };
 
 struct s_mc_message_actor_enabled_t {
-  enum e_mc_message_type type;
+  simgrid::mc::MessageType type;
   aid_t aid; // actor ID
 };
 
-XBT_PRIVATE const char* MC_message_type_name(enum e_mc_message_type type);
-
-SG_END_DECL
+XBT_PRIVATE const char* MC_message_type_name(simgrid::mc::MessageType type);
 
+#endif // __cplusplus
 #endif
index 4356978..2a0f564 100644 (file)
@@ -368,8 +368,9 @@ int simcall_mc_random(int min, int max) {
 /* ************************************************************************** */
 
 /** @brief returns a printable string representing a simcall */
-const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
-  return simcall_names[kind];
+const char* SIMIX_simcall_name(Simcall kind)
+{
+  return simcall_names[static_cast<int>(kind)];
 }
 
 namespace simgrid {
index c659920..8611fad 100644 (file)
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 
+using simgrid::simix::Simcall;
+
 template<class R, class... T>
-inline static R simcall(e_smx_simcall_t call, T const&... t)
+inline static R simcall(Simcall call, T const&... t)
 {
   smx_actor_t self = SIMIX_process_self();
   simgrid::simix::marshal(&self->simcall_, call, t...);
@@ -43,132 +45,132 @@ inline static int simcall_BODY_execution_waitany_for(simgrid::kernel::activity::
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_execution_waitany_for(&SIMIX_process_self()->simcall_, execs, count, timeout);
-  return simcall<int, simgrid::kernel::activity::ExecImpl**, size_t, double>(SIMCALL_EXECUTION_WAITANY_FOR, execs, count, timeout);
+  return simcall<int, simgrid::kernel::activity::ExecImpl**, size_t, double>(Simcall::EXECUTION_WAITANY_FOR, execs, count, timeout);
 }
 
 inline static void simcall_BODY_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_send(&SIMIX_process_self()->simcall_, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
-  return simcall<void, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_copy_data_func_t, void*, double>(SIMCALL_COMM_SEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
+  return simcall<void, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_copy_data_func_t, void*, double>(Simcall::COMM_SEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout);
 }
 
 inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_BODY_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_isend(&SIMIX_process_self()->simcall_, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
-  return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, bool>(SIMCALL_COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
+  return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, double, double, unsigned char*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, bool>(Simcall::COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached);
 }
 
 inline static void simcall_BODY_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_recv(&SIMIX_process_self()->simcall_, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate);
-  return simcall<void, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double, double>(SIMCALL_COMM_RECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate);
+  return simcall<void, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double, double>(Simcall::COMM_RECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, timeout, rate);
 }
 
 inline static boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> simcall_BODY_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_irecv(&SIMIX_process_self()->simcall_, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
-  return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double>(SIMCALL_COMM_IRECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
+  return simcall<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>, smx_actor_t, smx_mailbox_t, unsigned char*, size_t*, simix_match_func_t, simix_copy_data_func_t, void*, double>(Simcall::COMM_IRECV, receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate);
 }
 
 inline static int simcall_BODY_comm_waitany(simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_waitany(&SIMIX_process_self()->simcall_, comms, count, timeout);
-  return simcall<int, simgrid::kernel::activity::CommImpl**, size_t, double>(SIMCALL_COMM_WAITANY, comms, count, timeout);
+  return simcall<int, simgrid::kernel::activity::CommImpl**, size_t, double>(Simcall::COMM_WAITANY, comms, count, timeout);
 }
 
 inline static void simcall_BODY_comm_wait(simgrid::kernel::activity::CommImpl* comm, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_wait(&SIMIX_process_self()->simcall_, comm, timeout);
-  return simcall<void, simgrid::kernel::activity::CommImpl*, double>(SIMCALL_COMM_WAIT, comm, timeout);
+  return simcall<void, simgrid::kernel::activity::CommImpl*, double>(Simcall::COMM_WAIT, comm, timeout);
 }
 
 inline static bool simcall_BODY_comm_test(simgrid::kernel::activity::CommImpl* comm)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_test(&SIMIX_process_self()->simcall_, comm);
-  return simcall<bool, simgrid::kernel::activity::CommImpl*>(SIMCALL_COMM_TEST, comm);
+  return simcall<bool, simgrid::kernel::activity::CommImpl*>(Simcall::COMM_TEST, comm);
 }
 
 inline static int simcall_BODY_comm_testany(simgrid::kernel::activity::CommImpl** comms, size_t count)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_comm_testany(&SIMIX_process_self()->simcall_, comms, count);
-  return simcall<int, simgrid::kernel::activity::CommImpl**, size_t>(SIMCALL_COMM_TESTANY, comms, count);
+  return simcall<int, simgrid::kernel::activity::CommImpl**, size_t>(Simcall::COMM_TESTANY, comms, count);
 }
 
 inline static void simcall_BODY_mutex_lock(smx_mutex_t mutex)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_mutex_lock(&SIMIX_process_self()->simcall_, mutex);
-  return simcall<void, smx_mutex_t>(SIMCALL_MUTEX_LOCK, mutex);
+  return simcall<void, smx_mutex_t>(Simcall::MUTEX_LOCK, mutex);
 }
 
 inline static int simcall_BODY_mutex_trylock(smx_mutex_t mutex)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_mutex_trylock(&SIMIX_process_self()->simcall_, mutex);
-  return simcall<int, smx_mutex_t>(SIMCALL_MUTEX_TRYLOCK, mutex);
+  return simcall<int, smx_mutex_t>(Simcall::MUTEX_TRYLOCK, mutex);
 }
 
 inline static void simcall_BODY_mutex_unlock(smx_mutex_t mutex)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_mutex_unlock(&SIMIX_process_self()->simcall_, mutex);
-  return simcall<void, smx_mutex_t>(SIMCALL_MUTEX_UNLOCK, mutex);
+  return simcall<void, smx_mutex_t>(Simcall::MUTEX_UNLOCK, mutex);
 }
 
 inline static void simcall_BODY_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_cond_wait(&SIMIX_process_self()->simcall_, cond, mutex);
-  return simcall<void, smx_cond_t, smx_mutex_t>(SIMCALL_COND_WAIT, cond, mutex);
+  return simcall<void, smx_cond_t, smx_mutex_t>(Simcall::COND_WAIT, cond, mutex);
 }
 
 inline static int simcall_BODY_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_cond_wait_timeout(&SIMIX_process_self()->simcall_, cond, mutex, timeout);
-  return simcall<int, smx_cond_t, smx_mutex_t, double>(SIMCALL_COND_WAIT_TIMEOUT, cond, mutex, timeout);
+  return simcall<int, smx_cond_t, smx_mutex_t, double>(Simcall::COND_WAIT_TIMEOUT, cond, mutex, timeout);
 }
 
 inline static void simcall_BODY_sem_acquire(smx_sem_t sem)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_sem_acquire(&SIMIX_process_self()->simcall_, sem);
-  return simcall<void, smx_sem_t>(SIMCALL_SEM_ACQUIRE, sem);
+  return simcall<void, smx_sem_t>(Simcall::SEM_ACQUIRE, sem);
 }
 
 inline static int simcall_BODY_sem_acquire_timeout(smx_sem_t sem, double timeout)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_sem_acquire_timeout(&SIMIX_process_self()->simcall_, sem, timeout);
-  return simcall<int, smx_sem_t, double>(SIMCALL_SEM_ACQUIRE_TIMEOUT, sem, timeout);
+  return simcall<int, smx_sem_t, double>(Simcall::SEM_ACQUIRE_TIMEOUT, sem, timeout);
 }
 
 inline static int simcall_BODY_mc_random(int min, int max)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     simcall_HANDLER_mc_random(&SIMIX_process_self()->simcall_, min, max);
-  return simcall<int, int, int>(SIMCALL_MC_RANDOM, min, max);
+  return simcall<int, int, int>(Simcall::MC_RANDOM, min, max);
 }
 
 inline static void simcall_BODY_run_kernel(std::function<void()> const* code)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     SIMIX_run_kernel(code);
-  return simcall<void, std::function<void()> const*>(SIMCALL_RUN_KERNEL, code);
+  return simcall<void, std::function<void()> const*>(Simcall::RUN_KERNEL, code);
 }
 
 inline static void simcall_BODY_run_blocking(std::function<void()> const* code)
 {
   if (false) /* Go to that function to follow the code flow through the simcall barrier */
     SIMIX_run_blocking(code);
-  return simcall<void, std::function<void()> const*>(SIMCALL_RUN_BLOCKING, code);
+  return simcall<void, std::function<void()> const*>(Simcall::RUN_BLOCKING, code);
 }
 /** @endcond */
index a6062b4..99f89af 100644 (file)
  * That's not about http://en.wikipedia.org/wiki/Poop, despite the odor :)
  */
 
+namespace simgrid {
+namespace simix {
 /**
  * @brief All possible simcalls.
  */
-enum e_smx_simcall_t {
-  SIMCALL_NONE,
-  SIMCALL_EXECUTION_WAITANY_FOR,
-  SIMCALL_COMM_SEND,
-  SIMCALL_COMM_ISEND,
-  SIMCALL_COMM_RECV,
-  SIMCALL_COMM_IRECV,
-  SIMCALL_COMM_WAITANY,
-  SIMCALL_COMM_WAIT,
-  SIMCALL_COMM_TEST,
-  SIMCALL_COMM_TESTANY,
-  SIMCALL_MUTEX_LOCK,
-  SIMCALL_MUTEX_TRYLOCK,
-  SIMCALL_MUTEX_UNLOCK,
-  SIMCALL_COND_WAIT,
-  SIMCALL_COND_WAIT_TIMEOUT,
-  SIMCALL_SEM_ACQUIRE,
-  SIMCALL_SEM_ACQUIRE_TIMEOUT,
-  SIMCALL_MC_RANDOM,
-  SIMCALL_RUN_KERNEL,
-  SIMCALL_RUN_BLOCKING,
+enum class Simcall {
+  NONE,
+  EXECUTION_WAITANY_FOR,
+  COMM_SEND,
+  COMM_ISEND,
+  COMM_RECV,
+  COMM_IRECV,
+  COMM_WAITANY,
+  COMM_WAIT,
+  COMM_TEST,
+  COMM_TESTANY,
+  MUTEX_LOCK,
+  MUTEX_TRYLOCK,
+  MUTEX_UNLOCK,
+  COND_WAIT,
+  COND_WAIT_TIMEOUT,
+  SEM_ACQUIRE,
+  SEM_ACQUIRE_TIMEOUT,
+  MC_RANDOM,
+  RUN_KERNEL,
+  RUN_BLOCKING,
 };
 
 constexpr int NUM_SIMCALLS = 20;
+} // namespace simix
+} // namespace simgrid
index aa1a849..bb30f86 100644 (file)
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);
 
+using simgrid::simix::Simcall;
 /** @brief Simcalls' names (generated from src/simix/simcalls.in) */
-constexpr std::array<const char*, NUM_SIMCALLS> simcall_names{{
-    "SIMCALL_NONE",
-    "SIMCALL_EXECUTION_WAITANY_FOR",
-    "SIMCALL_COMM_SEND",
-    "SIMCALL_COMM_ISEND",
-    "SIMCALL_COMM_RECV",
-    "SIMCALL_COMM_IRECV",
-    "SIMCALL_COMM_WAITANY",
-    "SIMCALL_COMM_WAIT",
-    "SIMCALL_COMM_TEST",
-    "SIMCALL_COMM_TESTANY",
-    "SIMCALL_MUTEX_LOCK",
-    "SIMCALL_MUTEX_TRYLOCK",
-    "SIMCALL_MUTEX_UNLOCK",
-    "SIMCALL_COND_WAIT",
-    "SIMCALL_COND_WAIT_TIMEOUT",
-    "SIMCALL_SEM_ACQUIRE",
-    "SIMCALL_SEM_ACQUIRE_TIMEOUT",
-    "SIMCALL_MC_RANDOM",
-    "SIMCALL_RUN_KERNEL",
-    "SIMCALL_RUN_BLOCKING",
+constexpr std::array<const char*, simgrid::simix::NUM_SIMCALLS> simcall_names{{
+    "Simcall::NONE",
+    "Simcall::EXECUTION_WAITANY_FOR",
+    "Simcall::COMM_SEND",
+    "Simcall::COMM_ISEND",
+    "Simcall::COMM_RECV",
+    "Simcall::COMM_IRECV",
+    "Simcall::COMM_WAITANY",
+    "Simcall::COMM_WAIT",
+    "Simcall::COMM_TEST",
+    "Simcall::COMM_TESTANY",
+    "Simcall::MUTEX_LOCK",
+    "Simcall::MUTEX_TRYLOCK",
+    "Simcall::MUTEX_UNLOCK",
+    "Simcall::COND_WAIT",
+    "Simcall::COND_WAIT_TIMEOUT",
+    "Simcall::SEM_ACQUIRE",
+    "Simcall::SEM_ACQUIRE_TIMEOUT",
+    "Simcall::MC_RANDOM",
+    "Simcall::RUN_KERNEL",
+    "Simcall::RUN_BLOCKING",
 }};
 
 /** @private
@@ -59,89 +60,89 @@ void simgrid::kernel::actor::ActorImpl::simcall_handle(int value) {
   if (context_->wannadie())
     return;
   switch (simcall_.call_) {
-    case SIMCALL_EXECUTION_WAITANY_FOR:
+    case Simcall::EXECUTION_WAITANY_FOR:
       simcall_HANDLER_execution_waitany_for(&simcall_, simgrid::simix::unmarshal<simgrid::kernel::activity::ExecImpl**>(simcall_.args_[0]), simgrid::simix::unmarshal<size_t>(simcall_.args_[1]), simgrid::simix::unmarshal<double>(simcall_.args_[2]));
       break;
 
-    case SIMCALL_COMM_SEND:
+    case Simcall::COMM_SEND:
       simcall_HANDLER_comm_send(&simcall_, simgrid::simix::unmarshal<smx_actor_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall_.args_[1]), simgrid::simix::unmarshal<double>(simcall_.args_[2]), simgrid::simix::unmarshal<double>(simcall_.args_[3]), simgrid::simix::unmarshal<unsigned char*>(simcall_.args_[4]), simgrid::simix::unmarshal<size_t>(simcall_.args_[5]), simgrid::simix::unmarshal<simix_match_func_t>(simcall_.args_[6]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall_.args_[7]), simgrid::simix::unmarshal<void*>(simcall_.args_[8]), simgrid::simix::unmarshal<double>(simcall_.args_[9]));
       break;
 
-    case SIMCALL_COMM_ISEND:
+    case Simcall::COMM_ISEND:
       simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall_.result_, simcall_HANDLER_comm_isend(&simcall_, simgrid::simix::unmarshal<smx_actor_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall_.args_[1]), simgrid::simix::unmarshal<double>(simcall_.args_[2]), simgrid::simix::unmarshal<double>(simcall_.args_[3]), simgrid::simix::unmarshal<unsigned char*>(simcall_.args_[4]), simgrid::simix::unmarshal<size_t>(simcall_.args_[5]), simgrid::simix::unmarshal<simix_match_func_t>(simcall_.args_[6]), simgrid::simix::unmarshal<simix_clean_func_t>(simcall_.args_[7]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall_.args_[8]), simgrid::simix::unmarshal<void*>(simcall_.args_[9]), simgrid::simix::unmarshal<bool>(simcall_.args_[10])));
       simcall_answer();
       break;
 
-    case SIMCALL_COMM_RECV:
+    case Simcall::COMM_RECV:
       simcall_HANDLER_comm_recv(&simcall_, simgrid::simix::unmarshal<smx_actor_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall_.args_[1]), simgrid::simix::unmarshal<unsigned char*>(simcall_.args_[2]), simgrid::simix::unmarshal<size_t*>(simcall_.args_[3]), simgrid::simix::unmarshal<simix_match_func_t>(simcall_.args_[4]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall_.args_[5]), simgrid::simix::unmarshal<void*>(simcall_.args_[6]), simgrid::simix::unmarshal<double>(simcall_.args_[7]), simgrid::simix::unmarshal<double>(simcall_.args_[8]));
       break;
 
-    case SIMCALL_COMM_IRECV:
+    case Simcall::COMM_IRECV:
       simgrid::simix::marshal<boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl>>(simcall_.result_, simcall_HANDLER_comm_irecv(&simcall_, simgrid::simix::unmarshal<smx_actor_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mailbox_t>(simcall_.args_[1]), simgrid::simix::unmarshal<unsigned char*>(simcall_.args_[2]), simgrid::simix::unmarshal<size_t*>(simcall_.args_[3]), simgrid::simix::unmarshal<simix_match_func_t>(simcall_.args_[4]), simgrid::simix::unmarshal<simix_copy_data_func_t>(simcall_.args_[5]), simgrid::simix::unmarshal<void*>(simcall_.args_[6]), simgrid::simix::unmarshal<double>(simcall_.args_[7])));
       simcall_answer();
       break;
 
-    case SIMCALL_COMM_WAITANY:
+    case Simcall::COMM_WAITANY:
       simcall_HANDLER_comm_waitany(&simcall_, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall_.args_[0]), simgrid::simix::unmarshal<size_t>(simcall_.args_[1]), simgrid::simix::unmarshal<double>(simcall_.args_[2]));
       break;
 
-    case SIMCALL_COMM_WAIT:
+    case Simcall::COMM_WAIT:
       simcall_HANDLER_comm_wait(&simcall_, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl*>(simcall_.args_[0]), simgrid::simix::unmarshal<double>(simcall_.args_[1]));
       break;
 
-    case SIMCALL_COMM_TEST:
+    case Simcall::COMM_TEST:
       simcall_HANDLER_comm_test(&simcall_, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl*>(simcall_.args_[0]));
       break;
 
-    case SIMCALL_COMM_TESTANY:
+    case Simcall::COMM_TESTANY:
       simcall_HANDLER_comm_testany(&simcall_, simgrid::simix::unmarshal<simgrid::kernel::activity::CommImpl**>(simcall_.args_[0]), simgrid::simix::unmarshal<size_t>(simcall_.args_[1]));
       break;
 
-    case SIMCALL_MUTEX_LOCK:
+    case Simcall::MUTEX_LOCK:
       simcall_HANDLER_mutex_lock(&simcall_, simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[0]));
       break;
 
-    case SIMCALL_MUTEX_TRYLOCK:
+    case Simcall::MUTEX_TRYLOCK:
       simgrid::simix::marshal<int>(simcall_.result_, simcall_HANDLER_mutex_trylock(&simcall_, simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[0])));
       simcall_answer();
       break;
 
-    case SIMCALL_MUTEX_UNLOCK:
+    case Simcall::MUTEX_UNLOCK:
       simcall_HANDLER_mutex_unlock(&simcall_, simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[0]));
       simcall_answer();
       break;
 
-    case SIMCALL_COND_WAIT:
+    case Simcall::COND_WAIT:
       simcall_HANDLER_cond_wait(&simcall_, simgrid::simix::unmarshal<smx_cond_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[1]));
       break;
 
-    case SIMCALL_COND_WAIT_TIMEOUT:
+    case Simcall::COND_WAIT_TIMEOUT:
       simcall_HANDLER_cond_wait_timeout(&simcall_, simgrid::simix::unmarshal<smx_cond_t>(simcall_.args_[0]), simgrid::simix::unmarshal<smx_mutex_t>(simcall_.args_[1]), simgrid::simix::unmarshal<double>(simcall_.args_[2]));
       break;
 
-    case SIMCALL_SEM_ACQUIRE:
+    case Simcall::SEM_ACQUIRE:
       simcall_HANDLER_sem_acquire(&simcall_, simgrid::simix::unmarshal<smx_sem_t>(simcall_.args_[0]));
       break;
 
-    case SIMCALL_SEM_ACQUIRE_TIMEOUT:
+    case Simcall::SEM_ACQUIRE_TIMEOUT:
       simcall_HANDLER_sem_acquire_timeout(&simcall_, simgrid::simix::unmarshal<smx_sem_t>(simcall_.args_[0]), simgrid::simix::unmarshal<double>(simcall_.args_[1]));
       break;
 
-    case SIMCALL_MC_RANDOM:
+    case Simcall::MC_RANDOM:
       simgrid::simix::marshal<int>(simcall_.result_, simcall_HANDLER_mc_random(&simcall_, simgrid::simix::unmarshal<int>(simcall_.args_[0]), simgrid::simix::unmarshal<int>(simcall_.args_[1])));
       simcall_answer();
       break;
 
-    case SIMCALL_RUN_KERNEL:
+    case Simcall::RUN_KERNEL:
       SIMIX_run_kernel(simgrid::simix::unmarshal<std::function<void()> const*>(simcall_.args_[0]));
       simcall_answer();
       break;
 
-    case SIMCALL_RUN_BLOCKING:
+    case Simcall::RUN_BLOCKING:
       SIMIX_run_blocking(simgrid::simix::unmarshal<std::function<void()> const*>(simcall_.args_[0]));
       break;
 
-    case SIMCALL_NONE:
+    case Simcall::NONE:
       throw std::invalid_argument(simgrid::xbt::string_printf("Asked to do the noop syscall on %s@%s",
                                                               get_cname(),
                                                               sg_host_get_name(get_host())));
index d0079a6..a095be6 100644 (file)
@@ -13,9 +13,9 @@
 #include <boost/intrusive_ptr.hpp>
 
 /********************************* Simcalls *********************************/
-#include "popping_enum.hpp" /* Definition of e_smx_simcall_t, with one value per simcall */
+#include "popping_enum.hpp" /* Definition of Simcall, with one value per simcall */
 
-XBT_PUBLIC_DATA const std::array<const char*, NUM_SIMCALLS> simcall_names; /* Name of each simcall */
+XBT_PUBLIC_DATA const std::array<const char*, simgrid::simix::NUM_SIMCALLS> simcall_names; /* Name of each simcall */
 
 using simix_match_func_t     = bool (*)(void*, void*, simgrid::kernel::activity::CommImpl*);
 using simix_copy_data_func_t = void (*)(simgrid::kernel::activity::CommImpl*, void*, size_t);
@@ -44,7 +44,7 @@ union u_smx_scalar {
  * @brief Represents a simcall to the kernel.
  */
 struct s_smx_simcall {
-  e_smx_simcall_t call_                     = SIMCALL_NONE;
+  simgrid::simix::Simcall call_             = simgrid::simix::Simcall::NONE;
   smx_actor_t issuer_                       = nullptr;
   smx_timer_t timeout_cb_                   = nullptr; // Callback to timeouts
   simgrid::mc::SimcallInspector* inspector_ = nullptr; // makes that simcall observable by the MC
@@ -58,7 +58,7 @@ struct s_smx_simcall {
 
 /******************************** General *************************************/
 
-XBT_PRIVATE const char* SIMIX_simcall_name(e_smx_simcall_t kind);
+XBT_PRIVATE const char* SIMIX_simcall_name(simgrid::simix::Simcall kind);
 XBT_PRIVATE void SIMIX_run_kernel(std::function<void()> const* code);
 XBT_PRIVATE void SIMIX_run_blocking(std::function<void()> const* code);
 
@@ -195,7 +195,7 @@ template <std::size_t I, class A, class... B> inline void marshal_args(smx_simca
 }
 
 /** Initialize the simcall */
-template <class... A> inline void marshal(smx_simcall_t simcall, e_smx_simcall_t call, A const&... a)
+template <class... A> inline void marshal(smx_simcall_t simcall, Simcall call, A const&... a)
 {
   simcall->call_ = call;
   memset(&simcall->result_, 0, sizeof simcall->result_);
index 96b621f..51b2b4d 100755 (executable)
@@ -79,10 +79,10 @@ class Simcall(object):
         return True
 
     def enum(self):
-        return '  SIMCALL_%s,' % (self.name.upper())
+        return '  %s,' % (self.name.upper())
 
     def string(self):
-        return '    "SIMCALL_%s",' % self.name.upper()
+        return '    "Simcall::%s",' % self.name.upper()
 
     def accessors(self):
         res = []
@@ -132,7 +132,7 @@ class Simcall(object):
         indent = '    '
         args = ["simgrid::simix::unmarshal<%s>(simcall_.args_[%d])" % (arg.rettype(), i)
                 for i, arg in enumerate(self.args)]
-        res.append(indent + 'case SIMCALL_%s:' % (self.name.upper()))
+        res.append(indent + 'case Simcall::%s:' % (self.name.upper()))
         if self.need_handler:
             call = "simcall_HANDLER_%s(&simcall_%s%s)" % (self.name,
                                                         ", " if args else "",
@@ -163,7 +163,7 @@ class Simcall(object):
         else:
             res.append('    SIMIX_%s(%s);' % (self.name,
                                               ', '.join(arg.name for arg in self.args)))
-        res.append('  return simcall<%s%s>(SIMCALL_%s%s);' % (
+        res.append('  return simcall<%s%s>(Simcall::%s%s);' % (
             self.res.rettype(),
             "".join([", " + arg.rettype() for i, arg in enumerate(self.args)]),
             self.name.upper(),
@@ -295,17 +295,21 @@ if __name__ == '__main__':
     # popping_enum.hpp
     #
     fd = header("popping_enum.hpp")
+    fd.write('namespace simgrid {\n');
+    fd.write('namespace simix {\n');
     fd.write('/**\n')
     fd.write(' * @brief All possible simcalls.\n')
     fd.write(' */\n')
-    fd.write('enum e_smx_simcall_t {\n')
-    fd.write('  SIMCALL_NONE,\n')
+    fd.write('enum class Simcall {\n')
+    fd.write('  NONE,\n')
 
     handle(fd, Simcall.enum, simcalls, simcalls_dict)
 
     fd.write('};\n')
     fd.write('\n')
     fd.write('constexpr int NUM_SIMCALLS = ' + str(1 + len(simcalls)) + ';\n');
+    fd.write('} // namespace simix\n');
+    fd.write('} // namespace simgrid\n');
     fd.close()
 
     #
@@ -325,11 +329,13 @@ if __name__ == '__main__':
     fd.write('\n')
     fd.write('XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_popping);\n\n')
 
+    fd.write('using simgrid::simix::Simcall;')
+    fd.write('\n')
     fd.write(
         '/** @brief Simcalls\' names (generated from src/simix/simcalls.in) */\n')
-    fd.write('constexpr std::array<const char*, NUM_SIMCALLS> simcall_names{{\n')
+    fd.write('constexpr std::array<const char*, simgrid::simix::NUM_SIMCALLS> simcall_names{{\n')
 
-    fd.write('    "SIMCALL_NONE",\n')
+    fd.write('    "Simcall::NONE",\n')
     handle(fd, Simcall.string, simcalls, simcalls_dict)
 
     fd.write('}};\n\n')
@@ -352,7 +358,7 @@ if __name__ == '__main__':
 
     handle(fd, Simcall.case, simcalls, simcalls_dict)
 
-    fd.write('    case SIMCALL_NONE:\n')
+    fd.write('    case Simcall::NONE:\n')
     fd.write('      throw std::invalid_argument(simgrid::xbt::string_printf("Asked to do the noop syscall on %s@%s",\n')
     fd.write('                                                              get_cname(),\n')
     fd.write('                                                              sg_host_get_name(get_host())));\n')
@@ -378,8 +384,10 @@ if __name__ == '__main__':
     fd.write('''
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 
+using simgrid::simix::Simcall;
+
 template<class R, class... T>
-inline static R simcall(e_smx_simcall_t call, T const&... t)
+inline static R simcall(Simcall call, T const&... t)
 {
   smx_actor_t self = SIMIX_process_self();
   simgrid::simix::marshal(&self->simcall_, call, t...);
index 034e5be..0c95e07 100644 (file)
@@ -499,7 +499,7 @@ void SIMIX_run()
        */
 
       for (auto const& actor : simix_global->actors_that_ran) {
-        if (actor->simcall_.call_ != SIMCALL_NONE) {
+        if (actor->simcall_.call_ != simgrid::simix::Simcall::NONE) {
           actor->simcall_handle(0);
         }
       }
index 17969e5..9abac40 100644 (file)
@@ -103,7 +103,8 @@ int File::op_all(void* buf, int count, const Datatype* datatype, MPI_Status* sta
   XBT_CDEBUG(smpi_pmpi, "my offsets to read : %lld:%lld, global min and max %lld:%lld", min_offset, max_offset, min,
              max);
   if (empty == 1) {
-    status->count = 0;
+    if (status != MPI_STATUS_IGNORE)
+      status->count = 0;
     return MPI_SUCCESS;
   }
   MPI_Offset total = max - min;
index 9d8fb0b..0c2d89b 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef WIN32
 #include <sys/mman.h>
 #endif
+#include <cerrno>
 #include <cmath>
 
 #if HAVE_PAPI
@@ -235,15 +236,17 @@ int smpi_gettimeofday(struct timeval* tv, struct timezone* tz)
 #if _POSIX_TIMERS > 0
 int smpi_clock_gettime(clockid_t clk_id, struct timespec* tp)
 {
+  if (not tp) {
+    errno = EFAULT;
+    return -1;
+  }
   if (not smpi_process())
     return clock_gettime(clk_id, tp);
   //there is only one time in SMPI, so clk_id is ignored.
   smpi_bench_end();
   double now = SIMIX_get_clock();
-  if (tp) {
-    tp->tv_sec = static_cast<time_t>(now);
-    tp->tv_nsec = static_cast<long int>((now - tp->tv_sec) * 1e9);
-  }
+  tp->tv_sec  = static_cast<time_t>(now);
+  tp->tv_nsec = static_cast<long int>((now - tp->tv_sec) * 1e9);
   if (smpi_wtime_sleep > 0)
     simgrid::s4u::this_actor::sleep_for(smpi_wtime_sleep);
   smpi_bench_begin();
index 6ba73f7..3ea9ad1 100644 (file)
@@ -145,8 +145,6 @@ static int xbt_log_layout_format_doit(const s_xbt_log_layout_t* l, xbt_log_event
             show_string(ev->functionName);
             break;
           case 'd': /* date; LOG4J compliant */
-            show_double(simgrid_get_clock());
-            break;
           case 'r': /* application age; LOG4J compliant */
             show_double(simgrid_get_clock());
             break;
index 1be7898..529ed19 100755 (executable)
@@ -133,7 +133,10 @@ function sortTable(n, type) {
 
 for node in "${nodes[@]}"
 do
-    wget --quiet ${BUILD_URL}/build_mode=Debug,node=${node}/consoleText >/dev/null 2>&1
+    wget --quiet --output-document=consoleText \
+         ${BUILD_URL}/build_mode=Debug,node=${node}/consoleText \
+         ${BUILD_URL}/build_mode=ModelChecker,node=${node}/consoleText \
+         >/dev/null 2>&1
     if [ ! -f consoleText ]; then
       echo "file not existing for node ${node}"
       exit 1