Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
merge with framagit/master
[simgrid.git] / src / mc / api.cpp
index c49b889..c4c6895 100644 (file)
@@ -118,7 +118,7 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
       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 &&
+      else if (act->src_actor_.get() == nullptr && act->state_ == simgrid::kernel::activity::State::READY &&
                act->detached())
         state->transition_.argument_ = 0; // OK
       else
@@ -214,7 +214,7 @@ simgrid::kernel::activity::CommImpl* Api::get_comm(smx_simcall_t const r) const
 }
 
 // Does half the job
-bool Api::request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2) const 
+bool Api::request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2) const
 {
   if (r1->call_ == Simcall::COMM_ISEND && r2->call_ == Simcall::COMM_IRECV)
     return false;
@@ -227,10 +227,10 @@ bool Api::request_depend_asymmetric(smx_simcall_t r1, smx_simcall_t r2) const
   const kernel::activity::CommImpl* synchro2 = get_comm(r2);
 
   if ((r1->call_ == Simcall::COMM_ISEND || r1->call_ == Simcall::COMM_IRECV) && r2->call_ == Simcall::COMM_WAIT) {
-    const kernel::activity::MailboxImpl* mbox = get_mbox_remote_addr(r1);
+    auto mbox                                                  = get_mbox_remote_addr(r1);
+    RemotePtr<kernel::activity::MailboxImpl> synchro2_mbox_cpy = remote(synchro2->mbox_cpy);
 
-    if (mbox != synchro2->mbox_cpy
-        && simcall_comm_wait__get__timeout(r2) <= 0)
+    if (mbox != synchro2_mbox_cpy && simcall_comm_wait__get__timeout(r2) <= 0)
       return false;
 
     if ((r1->issuer_ != synchro2->src_actor_.get()) && (r1->issuer_ != synchro2->dst_actor_.get()) &&
@@ -328,7 +328,7 @@ RemotePtr<kernel::activity::CommImpl> Api::get_comm_wait_raw_addr(smx_simcall_t
 
 RemotePtr<kernel::activity::CommImpl> Api::get_comm_waitany_raw_addr(smx_simcall_t request, int value) const
 {
-  auto addr = simgrid::simix::unmarshal_raw<simgrid::kernel::activity::CommImpl**>(request->args_[0]) + value;
+  auto addr      = simgrid::simix::unmarshal_raw<simgrid::kernel::activity::CommImpl**>(request->args_[0]) + value;
   auto comm_addr = mc_model_checker->get_remote_simulation().read(remote(addr));
   return RemotePtr<kernel::activity::CommImpl>(static_cast<kernel::activity::CommImpl*>(comm_addr));
 }
@@ -489,16 +489,38 @@ long Api::simcall_get_actor_id(s_smx_simcall const* req) const
   return simcall_get_issuer(req)->get_pid();
 }
 
-smx_mailbox_t Api::get_mbox_remote_addr(smx_simcall_t const req) const
+RemotePtr<kernel::activity::MailboxImpl> Api::get_mbox_remote_addr(smx_simcall_t const req) const
 {
+  RemotePtr<kernel::activity::MailboxImpl> mbox_addr;
   switch (req->call_) {
     case Simcall::COMM_ISEND:
-      return simix::unmarshal<smx_mailbox_t>(req->args_[1]); // simcall_comm_isend__get__mbox
-    case Simcall::COMM_IRECV:
-      return simix::unmarshal<smx_mailbox_t>(req->args_[1]); // simcall_comm_irecv__get__mbox
+    case Simcall::COMM_IRECV: {
+      auto mbox_addr_ptr = simix::unmarshal<smx_mailbox_t>(req->args_[1]);
+      mbox_addr          = remote(mbox_addr_ptr);
+      break;
+    }
     default:
-      return nullptr;
+      mbox_addr = RemotePtr<kernel::activity::MailboxImpl>();
+      break;
+  }
+  return mbox_addr;
+}
+
+RemotePtr<kernel::activity::ActivityImpl> Api::get_comm_remote_addr(smx_simcall_t const req) const
+{
+  RemotePtr<kernel::activity::ActivityImpl> comm_addr;
+  switch (req->call_) {
+    case Simcall::COMM_ISEND:
+    case Simcall::COMM_IRECV: {
+      auto comm_addr_ptr = simgrid::simix::unmarshal_raw<simgrid::kernel::activity::ActivityImpl*>(req->result_);
+      comm_addr          = remote(comm_addr_ptr);
+      break;
+    }
+    default:
+      comm_addr = RemotePtr<kernel::activity::ActivityImpl>();
+      break;
   }
+  return comm_addr;
 }
 
 bool Api::mc_is_null() const
@@ -563,7 +585,8 @@ bool Api::simcall_check_dependency(smx_simcall_t const req1, smx_simcall_t const
   if (req1->issuer_ == req2->issuer_)
     return false;
 
-  /* Wait with timeout transitions are not considered by the independence theorem, thus we consider them as dependent with all other transitions */
+  /* 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))
     return true;