Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Distinguish access to sender-side and receiver-side user data in smx_action_t.
authorpini <pini@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 7 Dec 2010 15:47:19 +0000 (15:47 +0000)
committerpini <pini@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 7 Dec 2010 15:47:19 +0000 (15:47 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9073 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/simix/simix.h
src/gras/Msg/sg_msg.c
src/msg/msg_mailbox.c
src/simix/network_private.h
src/simix/private.h
src/simix/smurf_private.h
src/simix/smx_network.c
src/simix/smx_smurf.c
src/simix/smx_user.c

index dfe2f25..d4237b2 100644 (file)
@@ -186,7 +186,8 @@ XBT_PUBLIC(int) SIMIX_req_comm_testany(xbt_dynar_t comms);
 /* Getters and setters */
 XBT_PUBLIC(double) SIMIX_req_comm_get_remains(smx_action_t comm);
 XBT_PUBLIC(e_smx_state_t) SIMIX_req_comm_get_state(smx_action_t comm);
-XBT_PUBLIC(void *) SIMIX_req_comm_get_data(smx_action_t comm);
+XBT_PUBLIC(void *) SIMIX_req_comm_get_src_data(smx_action_t comm);
+XBT_PUBLIC(void *) SIMIX_req_comm_get_dst_data(smx_action_t comm);
 XBT_PUBLIC(void *) SIMIX_req_comm_get_src_buff(smx_action_t comm);
 XBT_PUBLIC(void *) SIMIX_req_comm_get_dst_buff(smx_action_t comm);
 XBT_PUBLIC(size_t) SIMIX_req_comm_get_src_buff_size(smx_action_t comm);
index 59d8cd0..b2e4dfd 100644 (file)
@@ -166,7 +166,7 @@ gras_msg_t gras_msg_recv_any(void)
 
   /* retrieve the message sent in that communication */
   xbt_dynar_get_cpy(comms, got, &(comm));
-  msg = SIMIX_req_comm_get_data(comm);
+  msg = SIMIX_req_comm_get_src_data(comm);
   sock = xbt_dynar_get_as(trp_proc->sockets, got, gras_socket_t);
   sock_data = (gras_trp_sg_sock_data_t) sock->data;
   VERB3("Got something. Communication %p's over rdv_server=%p, rdv_client=%p",
index dda4eb5..fad007c 100644 (file)
@@ -33,7 +33,7 @@ m_task_t MSG_mailbox_get_head(msg_mailbox_t mailbox)
   if (!comm)
     return NULL;
 
-  return (m_task_t) SIMIX_req_comm_get_data(comm);
+  return (m_task_t) SIMIX_req_comm_get_src_data(comm);
 }
 
 int
index 32b8777..f7f2ce9 100644 (file)
@@ -48,7 +48,8 @@ double SIMIX_comm_get_remains(smx_action_t action);
 e_smx_state_t SIMIX_comm_get_state(smx_action_t action);
 void SIMIX_comm_suspend(smx_action_t action);
 void SIMIX_comm_resume(smx_action_t action);
-void* SIMIX_comm_get_data(smx_action_t action);
+void* SIMIX_comm_get_src_data(smx_action_t action);
+void* SIMIX_comm_get_dst_data(smx_action_t action);
 void* SIMIX_comm_get_src_buff(smx_action_t action);
 void* SIMIX_comm_get_dst_buff(smx_action_t action);
 size_t SIMIX_comm_get_src_buff_size(smx_action_t action);
index 475208e..fda2af9 100644 (file)
@@ -109,7 +109,8 @@ typedef struct s_smx_action {
       size_t *dst_buff_size;
       char copied;
 
-      void *data;                     /* User data associated to communication */
+      void* src_data;                     /* User data associated to communication */
+      void* dst_data;
     } comm;    
 
     struct {
index 8e65753..4f0a7ab 100644 (file)
@@ -53,7 +53,8 @@ typedef enum {
   REQ_COMM_TESTANY,
   REQ_COMM_GET_REMAINS,
   REQ_COMM_GET_STATE,
-  REQ_COMM_GET_DATA,
+  REQ_COMM_GET_SRC_DATA,
+  REQ_COMM_GET_DST_DATA,
   REQ_COMM_GET_SRC_BUFF,
   REQ_COMM_GET_DST_BUFF,
   REQ_COMM_GET_SRC_BUFF_SIZE,
@@ -331,8 +332,13 @@ typedef struct s_smx_req {
 
     struct {
       smx_action_t comm;
-      void *result;    
-    } comm_get_data;
+      void *result;
+    } comm_get_src_data;
+
+    struct {
+      smx_action_t comm;
+      void *result;
+    } comm_get_dst_data;
 
     struct {
       smx_action_t comm;
index f874dcc..ded44f2 100644 (file)
@@ -128,16 +128,21 @@ smx_action_t SIMIX_rdv_get_request(smx_rdv_t rdv, e_smx_comm_type_t type,
 {
   smx_action_t req;
   xbt_fifo_item_t item;
+  void* req_data = NULL;
 
   xbt_fifo_foreach(rdv->comm_fifo, item, req, smx_action_t){
-       if(req->comm.type == type && (!match_fun || match_fun(data, req->comm.data))){
-         xbt_fifo_remove_item(rdv->comm_fifo, item);
-         req->comm.refcount++;
-         req->comm.rdv = NULL;
-         return req;
-       }
+    if(req->comm.type == SIMIX_COMM_SEND) {
+      req_data = req->comm.src_data;
+    } else if(req->comm.type == SIMIX_COMM_RECEIVE) {
+      req_data = req->comm.dst_data;
+    }
+        if(req->comm.type == type && (!match_fun || match_fun(data, req_data))) {
+          xbt_fifo_remove_item(rdv->comm_fifo, item);
+          req->comm.refcount++;
+          req->comm.rdv = NULL;
+          return req;
+        }
   }
-
   DEBUG0("Communication request not found");
   return NULL;
 }
@@ -258,7 +263,7 @@ smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
   action->comm.rate = rate;
   action->comm.src_buff = src_buff;
   action->comm.src_buff_size = src_buff_size;
-  action->comm.data = data;
+  action->comm.src_data = data;
 
   if (MC_IS_ENABLED) {
     action->state = SIMIX_RUNNING;
@@ -292,6 +297,7 @@ smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
   action->comm.dst_proc = dst_proc;
   action->comm.dst_buff = dst_buff;
   action->comm.dst_buff_size = dst_buff_size;
+  action->comm.dst_data = data;
 
   if (MC_IS_ENABLED) {
     action->state = SIMIX_RUNNING;
@@ -613,13 +619,23 @@ e_smx_state_t SIMIX_comm_get_state(smx_action_t action)
 }
 
 /**
- *  \brief Return the user data associated to the communication
+ *  \brief Return the user data associated to the sender of the communication
+ *  \param action The communication
+ *  \return the user data
+ */
+void* SIMIX_comm_get_src_data(smx_action_t action)
+{
+  return action->comm.src_data;
+}
+
+/**
+ *  \brief Return the user data associated to the receiver of the communication
  *  \param action The communication
  *  \return the user data
  */
-void* SIMIX_comm_get_data(smx_action_t action)
+void* SIMIX_comm_get_dst_data(smx_action_t action)
 {
-  return action->comm.data;
+  return action->comm.dst_data;
 }
 
 void* SIMIX_comm_get_src_buff(smx_action_t action)
index 0dd362a..3d6bbf0 100644 (file)
@@ -366,8 +366,13 @@ void SIMIX_request_pre(smx_req_t req)
       SIMIX_request_answer(req);
       break;
 
-    case REQ_COMM_GET_DATA:
-      req->comm_get_data.result = SIMIX_comm_get_data(req->comm_get_data.comm);
+    case REQ_COMM_GET_SRC_DATA:
+      req->comm_get_src_data.result = SIMIX_comm_get_src_data(req->comm_get_src_data.comm);
+      SIMIX_request_answer(req);
+      break;
+
+    case REQ_COMM_GET_DST_DATA:
+      req->comm_get_dst_data.result = SIMIX_comm_get_dst_data(req->comm_get_dst_data.comm);
       SIMIX_request_answer(req);
       break;
 
index 1280e30..b42fc6b 100644 (file)
@@ -743,15 +743,26 @@ e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
   return req.comm_get_state.result;
 }
 
-void *SIMIX_req_comm_get_data(smx_action_t comm)
+void *SIMIX_req_comm_get_src_data(smx_action_t comm)
 {
   s_smx_req_t req;
 
-  req.call = REQ_COMM_GET_DATA;
-  req.comm_get_data.comm = comm;
+  req.call = REQ_COMM_GET_SRC_DATA;
+  req.comm_get_src_data.comm = comm;
 
   SIMIX_request_push(&req);
-  return req.comm_get_data.result;
+  return req.comm_get_src_data.result;
+}
+
+void *SIMIX_req_comm_get_dst_data(smx_action_t comm)
+{
+  s_smx_req_t req;
+
+  req.call = REQ_COMM_GET_DST_DATA;
+  req.comm_get_dst_data.comm = comm;
+
+  SIMIX_request_push(&req);
+  return req.comm_get_dst_data.result;
 }
 
 void *SIMIX_req_comm_get_src_buff(smx_action_t comm)