Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SIMIX_comm_cancel() -> simix::Comm->cancel()
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 7 May 2016 20:56:55 +0000 (22:56 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 7 May 2016 20:56:55 +0000 (22:56 +0200)
src/simix/SynchroComm.cpp
src/simix/SynchroComm.hpp
src/simix/libsmx.cpp
src/simix/popping_accessors.h
src/simix/popping_bodies.cpp
src/simix/popping_enum.h
src/simix/popping_generated.cpp
src/simix/simcalls.in
src/simix/smx_network.cpp
src/simix/smx_network_private.h
src/simix/smx_process.cpp

index 27ac085..69eca5d 100644 (file)
@@ -5,6 +5,10 @@
 
 #include "src/simix/SynchroComm.hpp"
 #include "src/surf/surf_interface.hpp"
+#include "src/simix/smx_network_private.h"
+#include "simgrid/modelchecker.h"
+#include "src/mc/mc_replay.h"
+
 
 void simgrid::simix::Comm::suspend() {
   /* FIXME: shall we suspend also the timeout synchro? */
@@ -20,3 +24,18 @@ void simgrid::simix::Comm::resume() {
     surf_comm->resume();
   /* in the other case, the synchro were not really suspended yet, see SIMIX_comm_suspend() and SIMIX_comm_start() */
 }
+
+void simgrid::simix::Comm::cancel() {
+  /* if the synchro is a waiting state means that it is still in a mbox */
+  /* so remove from it and delete it */
+  if (state == SIMIX_WAITING) {
+    SIMIX_mbox_remove(mbox, this);
+    state = SIMIX_CANCELED;
+  }
+  else if (!MC_is_active() /* when running the MC there are no surf actions */
+           && !MC_record_replay_is_active()
+           && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
+
+    surf_comm->cancel();
+  }
+}
index 58e0466..68a21e8 100644 (file)
@@ -23,6 +23,7 @@ namespace simix {
   public:
     void suspend();
     void resume();
+    void cancel();
 
     e_smx_comm_type_t type;         /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */
     smx_mailbox_t mbox;             /* Rendez-vous where the comm is queued */
index 3b36d09..883d2c7 100644 (file)
@@ -22,6 +22,8 @@
 #include "mc/mc.h"
 #include "src/simix/smx_host_private.h"
 
+#include "src/simix/SynchroComm.hpp"
+
 #include <simgrid/simix.hpp>
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
@@ -827,9 +829,12 @@ smx_synchro_t simcall_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag
 /**
  * \ingroup simix_comm_management
  */
-void simcall_comm_cancel(smx_synchro_t comm)
+void simcall_comm_cancel(smx_synchro_t synchro)
 {
-  simcall_BODY_comm_cancel(comm);
+  simgrid::simix::kernel([synchro]{
+    simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
+    comm->cancel();
+  });
 }
 
 /**
index d98bbc2..e336da9 100644 (file)
@@ -771,13 +771,6 @@ static inline void simcall_comm_irecv__set__result(smx_simcall_t simcall, void*
     simcall->result.dp = result;
 }
 
-static inline smx_synchro_t simcall_comm_cancel__get__comm(smx_simcall_t simcall) {
-  return (smx_synchro_t) simcall->args[0].dp;
-}
-static inline void simcall_comm_cancel__set__comm(smx_simcall_t simcall, void* arg) {
-    simcall->args[0].dp = arg;
-}
-
 static inline xbt_dynar_t simcall_comm_waitany__get__comms(smx_simcall_t simcall) {
   return (xbt_dynar_t) simcall->args[0].dp;
 }
index ffb3331..b7d5be4 100644 (file)
@@ -862,27 +862,6 @@ inline static smx_synchro_t simcall_BODY_comm_irecv(smx_process_t receiver, smx_
     return (smx_synchro_t) self->simcall.result.dp;
   }
   
-inline static void simcall_BODY_comm_cancel(smx_synchro_t comm) {
-    smx_process_t self = SIMIX_process_self();
-
-    /* Go to that function to follow the code flow through the simcall barrier */
-    if (0) SIMIX_comm_cancel(comm);
-    /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */
-
-    self->simcall.call = SIMCALL_COMM_CANCEL;
-    memset(&self->simcall.result, 0, sizeof(self->simcall.result));
-    memset(self->simcall.args, 0, sizeof(self->simcall.args));
-    self->simcall.args[0].dp = (void*) comm;
-    if (self != simix_global->maestro_process) {
-      XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name,
-                SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call);
-      SIMIX_process_yield(self);
-    } else {
-      SIMIX_simcall_handle(&self->simcall, 0);
-    }    
-    
-  }
-  
 inline static int simcall_BODY_comm_waitany(xbt_dynar_t comms) {
     smx_process_t self = SIMIX_process_self();
 
index cbac010..3ad74e6 100644 (file)
@@ -55,7 +55,6 @@ typedef enum {
   SIMCALL_COMM_ISEND,
   SIMCALL_COMM_RECV,
   SIMCALL_COMM_IRECV,
-  SIMCALL_COMM_CANCEL,
   SIMCALL_COMM_WAITANY,
   SIMCALL_COMM_WAIT,
   SIMCALL_COMM_TEST,
index 1d86189..c580366 100644 (file)
@@ -60,7 +60,6 @@ const char* simcall_names[] = {
   "SIMCALL_COMM_ISEND",
   "SIMCALL_COMM_RECV",
   "SIMCALL_COMM_IRECV",
-  "SIMCALL_COMM_CANCEL",
   "SIMCALL_COMM_WAITANY",
   "SIMCALL_COMM_WAIT",
   "SIMCALL_COMM_TEST",
@@ -294,11 +293,6 @@ case SIMCALL_COMM_IRECV:
       SIMIX_simcall_answer(simcall);
       break;  
 
-case SIMCALL_COMM_CANCEL:
-       SIMIX_comm_cancel((smx_synchro_t) simcall->args[0].dp);
-      SIMIX_simcall_answer(simcall);
-      break;  
-
 case SIMCALL_COMM_WAITANY:
        simcall_HANDLER_comm_waitany(simcall , (xbt_dynar_t) simcall->args[0].dp);
        break;  
index aaabae5..e75dd4e 100644 (file)
@@ -88,7 +88,6 @@ Blck H comm_send (void)                  (sender, void*, smx_process_t) (mbox, v
 Func H comm_isend (void*, smx_synchro_t) (sender, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (task_size, double) (rate, double) (src_buff, void*) (src_buff_size, size_t) (match_fun, FPtr, simix_match_func_t) (clean_fun, FPtr, simix_clean_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (detached, int)
 Blck H comm_recv (void)                  (receiver, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (timeout, double) (rate, double)
 Func H comm_irecv (void*, smx_synchro_t) (receiver, void*, smx_process_t) (mbox, void*, smx_mailbox_t) (dst_buff, void*) (dst_buff_size, void*, size_t*) (match_fun, FPtr, simix_match_func_t) (copy_data_fun, FPtr, simix_copy_data_func_t) (data, void*) (rate, double)
-Proc - comm_cancel (void) (comm, void*, smx_synchro_t)
 Blck H comm_waitany (int) (comms, void*, xbt_dynar_t)
 Blck H comm_wait (void) (comm, void*, smx_synchro_t) (timeout, double)
 Blck H comm_test (int) (comm, void*, smx_synchro_t)
index f913e7f..fa759cb 100644 (file)
@@ -833,24 +833,6 @@ void SIMIX_post_comm(smx_synchro_t synchro)
   }
 }
 
-void SIMIX_comm_cancel(smx_synchro_t synchro)
-{
-  simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
-
-  /* if the synchro is a waiting state means that it is still in a mbox */
-  /* so remove from it and delete it */
-  if (comm->state == SIMIX_WAITING) {
-    SIMIX_mbox_remove(comm->mbox, synchro);
-    comm->state = SIMIX_CANCELED;
-  }
-  else if (!MC_is_active() /* when running the MC there are no surf actions */
-           && !MC_record_replay_is_active()
-           && (comm->state == SIMIX_READY || comm->state == SIMIX_RUNNING)) {
-
-    comm->surf_comm->cancel();
-  }
-}
-
 /************* synchro Getters **************/
 
 /**
index f888ce2..965bf77 100644 (file)
@@ -39,7 +39,6 @@ XBT_PRIVATE void SIMIX_comm_destroy_internal_actions(smx_synchro_t synchro);
 XBT_PRIVATE smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int type, int src,
                               int tag, int (*match_fun)(void *, void *, smx_synchro_t), void *data);
 XBT_PRIVATE void SIMIX_post_comm(smx_synchro_t synchro);
-XBT_PRIVATE void SIMIX_comm_cancel(smx_synchro_t synchro);
 XBT_PRIVATE double SIMIX_comm_get_remains(smx_synchro_t synchro);
 XBT_PRIVATE e_smx_state_t SIMIX_comm_get_state(smx_synchro_t synchro);
 XBT_PRIVATE smx_process_t SIMIX_comm_get_src_proc(smx_synchro_t synchro);
index 450d081..1bd0a3b 100644 (file)
@@ -72,7 +72,7 @@ void SIMIX_process_cleanup(smx_process_t process)
 
     /* make sure no one will finish the comm after this process is destroyed,
      * because src_proc or dst_proc would be an invalid pointer */
-    SIMIX_comm_cancel(comm);
+    comm->cancel();
 
     if (comm->src_proc == process) {
       XBT_DEBUG("Found an unfinished send comm %p (detached = %d), state %d, src = %p, dst = %p",
@@ -506,7 +506,7 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) {
 
     } else if (comm != nullptr) {
       xbt_fifo_remove(process->comms, process->waiting_synchro);
-      SIMIX_comm_cancel(process->waiting_synchro);
+      comm->cancel();
       xbt_fifo_remove(process->waiting_synchro->simcalls, &process->simcall);
       SIMIX_comm_destroy(process->waiting_synchro);
 
@@ -559,8 +559,8 @@ void SIMIX_process_throw(smx_process_t process, xbt_errcat_t cat, int value, con
 
     simgrid::simix::Comm *comm = dynamic_cast<simgrid::simix::Comm*>(process->waiting_synchro);
     if (comm != nullptr) {
-      xbt_fifo_remove(process->comms, process->waiting_synchro);
-      SIMIX_comm_cancel(process->waiting_synchro);
+      xbt_fifo_remove(process->comms, comm);
+      comm->cancel();
     }
 
     simgrid::simix::Sleep *sleep = dynamic_cast<simgrid::simix::Sleep*>(process->waiting_synchro);