Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
turn SIMIX_comm_new() into a proper constructor
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 8 May 2016 14:01:20 +0000 (16:01 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 8 May 2016 14:01:20 +0000 (16:01 +0200)
src/simix/Synchro.h
src/simix/SynchroComm.cpp
src/simix/SynchroComm.hpp
src/simix/smx_network.cpp
src/surf/xml/simgrid_dtd.c

index 9ed8f9f..d119a8d 100644 (file)
@@ -19,7 +19,7 @@ namespace simix {
     Synchro();
     virtual ~Synchro();
     e_smx_state_t state;               /* State of the synchro */
-    char *name;                        /* synchro name if any */
+    char *name = nullptr;              /* synchro name if any */
     xbt_fifo_t simcalls;               /* List of simcalls waiting for this synchro */
     char *category = nullptr;          /* For instrumentation */
 
index 69eca5d..8d3b6e8 100644 (file)
@@ -9,7 +9,17 @@
 #include "simgrid/modelchecker.h"
 #include "src/mc/mc_replay.h"
 
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_network);
 
+simgrid::simix::Comm::Comm(e_smx_comm_type_t _type) {
+  state = SIMIX_WAITING;
+  this->type = _type;
+  refcount = 1;
+  src_data=NULL;
+  dst_data=NULL;
+
+  XBT_DEBUG("Create communicate synchro %p", this);
+}
 void simgrid::simix::Comm::suspend() {
   /* FIXME: shall we suspend also the timeout synchro? */
   if (surf_comm)
index 68a21e8..2a2f661 100644 (file)
@@ -21,20 +21,21 @@ namespace simix {
 
   XBT_PUBLIC_CLASS Comm : public Synchro {
   public:
+    Comm(e_smx_comm_type_t type);
     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 */
+    smx_mailbox_t mbox = nullptr;   /* Rendez-vous where the comm is queued */
 
 #if HAVE_MC
     smx_mailbox_t mbox_cpy;         /* Copy of the rendez-vous where the comm is queued, MC needs it for DPOR
                                        (comm.mbox set to NULL when the communication is removed from the mailbox
                                        (used as garbage collector)) */
 #endif
-    int refcount;                   /* Number of processes involved in the cond */
-    int detached;                   /* If detached or not */
+    int refcount = 1;               /* Number of processes involved in the cond */
+    int detached = 0;               /* If detached or not */
 
     void (*clean_fun)(void*);       /* Function to clean the detached src_buf if something goes wrong */
     int (*match_fun)(void*,void*,smx_synchro_t);  /* Filter function used by the other side. It is used when
@@ -43,20 +44,20 @@ namespace simix {
     void (*copy_data_fun) (smx_synchro_t, void*, size_t);
 
     /* Surf action data */
-    surf_action_t surf_comm;        /* The Surf communication action encapsulated */
-    surf_action_t src_timeout;      /* Surf's actions to instrument the timeouts */
-    surf_action_t dst_timeout;      /* Surf's actions to instrument the timeouts */
-    smx_process_t src_proc;
-    smx_process_t dst_proc;
+    surf_action_t surf_comm = nullptr;        /* The Surf communication action encapsulated */
+    surf_action_t src_timeout = nullptr;      /* Surf's actions to instrument the timeouts */
+    surf_action_t dst_timeout = nullptr;      /* Surf's actions to instrument the timeouts */
+    smx_process_t src_proc = nullptr;
+    smx_process_t dst_proc = nullptr;
     double rate;
     double task_size;
 
     /* Data to be transfered */
-    void *src_buff;
-    void *dst_buff;
+    void *src_buff = nullptr;
+    void *dst_buff = nullptr;
     size_t src_buff_size;
     size_t *dst_buff_size;
-    unsigned copied:1;              /* whether the data were already copied */
+    unsigned copied = 0;          /* whether the data were already copied */
 
     void* src_data;                 /* User data associated to communication */
     void* dst_data;
index 850480f..82e37ad 100644 (file)
@@ -20,7 +20,6 @@ static xbt_dict_t mailboxes = xbt_dict_new_homogeneous(SIMIX_mbox_free);
 
 static void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall);
 static void SIMIX_comm_copy_data(smx_synchro_t comm);
-static smx_synchro_t SIMIX_comm_new(e_smx_comm_type_t type);
 static inline void SIMIX_mbox_push(smx_mailbox_t mbox, smx_synchro_t comm);
 static smx_synchro_t _find_matching_comm(std::deque<smx_synchro_t> *deque, e_smx_comm_type_t type,
     int (*match_fun)(void *, void *,smx_synchro_t), void *user_data, smx_synchro_t my_synchro, bool remove_matching);
@@ -172,25 +171,6 @@ static smx_synchro_t _find_matching_comm(std::deque<smx_synchro_t> *deque, e_smx
 /*                          Communication synchros                            */
 /******************************************************************************/
 
-/**
- *  \brief Creates a new communicate synchro
- *  \param type The direction of communication (comm_send, comm_recv)
- *  \return The new communicate synchro
- */
-smx_synchro_t SIMIX_comm_new(e_smx_comm_type_t type)
-{
-  simgrid::simix::Comm *comm = new simgrid::simix::Comm();
-  comm->state = SIMIX_WAITING;
-  comm->type = type;
-  comm->refcount = 1;
-  comm->src_data=NULL;
-  comm->dst_data=NULL;
-
-  XBT_DEBUG("Create communicate synchro %p", comm);
-
-  return comm;
-}
-
 /**
  *  \brief Destroy a communicate synchro
  *  \param synchro The communicate synchro to be destroyed
@@ -269,7 +249,7 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr
   XBT_DEBUG("send from %p", mbox);
 
   /* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */
-  smx_synchro_t this_synchro = SIMIX_comm_new(SIMIX_COMM_SEND);
+  smx_synchro_t this_synchro = new simgrid::simix::Comm(SIMIX_COMM_SEND);
 
   /* Look for communication synchro matching our needs. We also provide a description of
    * ourself so that the other side also gets a chance of choosing if it wants to match with us.
@@ -364,7 +344,7 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void
     void *data, double rate)
 {
   XBT_DEBUG("recv from %p %p", mbox, mbox->comm_queue);
-  smx_synchro_t this_synchro = SIMIX_comm_new(SIMIX_COMM_RECEIVE);
+  smx_synchro_t this_synchro = new simgrid::simix::Comm(SIMIX_COMM_RECEIVE);
 
   smx_synchro_t other_synchro;
   //communication already done, get it inside the fifo of completed comms
@@ -449,10 +429,10 @@ smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int
   smx_synchro_t this_synchro;
   int smx_type;
   if(type == 1){
-    this_synchro=SIMIX_comm_new(SIMIX_COMM_SEND);
+    this_synchro = new simgrid::simix::Comm(SIMIX_COMM_SEND);
     smx_type = SIMIX_COMM_RECEIVE;
   } else{
-    this_synchro=SIMIX_comm_new(SIMIX_COMM_RECEIVE);
+    this_synchro = new simgrid::simix::Comm(SIMIX_COMM_RECEIVE);
     smx_type = SIMIX_COMM_SEND;
   } 
   smx_synchro_t other_synchro=NULL;
index 9921f43..f316744 100644 (file)
@@ -5813,8 +5813,8 @@ YY_RULE_SETUP
   if (!AX_surfxml_ASroute_src) FAIL("Required attribute `src' not set for `ASroute' element.");
   LEAVE; STag_surfxml_ASroute(); surfxml_pcdata_ix = 0; ETag_surfxml_ASroute(); popbuffer(); /* attribute */
   switch (YY_START) {
-   case S_surfxml_AS: case S_surfxml_AS_3: case S_surfxml_AS_5: case S_surfxml_AS_6: SET(S_surfxml_AS_6); break;
-   case S_surfxml_AS_1: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break;
+   case S_surfxml_AS_1: case S_surfxml_AS_3: case S_surfxml_AS_5: case S_surfxml_AS_6: SET(S_surfxml_AS_6); break;
+   case S_surfxml_AS: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break;
   }
  }
        YY_BREAK
@@ -5838,8 +5838,8 @@ YY_RULE_SETUP
   ETag_surfxml_ASroute();
   popbuffer(); /* attribute */
   switch (YY_START) {
-   case S_surfxml_AS: case S_surfxml_AS_3: case S_surfxml_AS_5: case S_surfxml_AS_6: SET(S_surfxml_AS_6); break;
-   case S_surfxml_AS_1: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break;
+   case S_surfxml_AS_1: case S_surfxml_AS_3: case S_surfxml_AS_5: case S_surfxml_AS_6: SET(S_surfxml_AS_6); break;
+   case S_surfxml_AS: case S_surfxml_AS_4: case S_surfxml_AS_7: case S_surfxml_AS_8: SET(S_surfxml_AS_8); break;
   }
  }
        YY_BREAK