Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Distinguish access to sender-side and receiver-side user data in smx_action_t.
[simgrid.git] / src / simix / smx_user.c
index ea732ee..b42fc6b 100644 (file)
@@ -1,5 +1,6 @@
 #include "private.h"
 
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
 /**
  * \brief Returns a host given its name.
  *
@@ -527,10 +528,10 @@ e_smx_state_t SIMIX_req_process_sleep(double duration)
 smx_rdv_t SIMIX_req_rdv_create(const char *name)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_RDV_CREATE;
   req.rdv_create.name = name;
-  
+
   SIMIX_request_push(&req);
   return req.rdv_create.result;
 }
@@ -543,10 +544,10 @@ smx_rdv_t SIMIX_req_rdv_create(const char *name)
 void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_RDV_DESTROY; 
   req.rdv_destroy.rdv = rdv;
-  
+
   SIMIX_request_push(&req);
 }
 
@@ -570,11 +571,11 @@ smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
 int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_RDV_COMM_COUNT_BY_HOST; 
   req.rdv_comm_count_by_host.rdv = rdv;
   req.rdv_comm_count_by_host.host = host;
-  
+
   SIMIX_request_push(&req);
   return req.rdv_comm_count_by_host.result;
 }
@@ -587,16 +588,17 @@ int SIMIX_req_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
 smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_RDV_GET_HEAD; 
   req.rdv_get_head.rdv = rdv;
-  
+
   SIMIX_request_push(&req);
   return req.rdv_get_head.result;
 }
 
 smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
-                              void *src_buff, size_t src_buff_size, void *data)
+                              void *src_buff, size_t src_buff_size,
+                              int (*match_fun)(void *, void *), void *data)
 {
   s_smx_req_t req;
 
@@ -608,13 +610,15 @@ smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
   req.comm_isend.rate = rate;
   req.comm_isend.src_buff = src_buff;
   req.comm_isend.src_buff_size = src_buff_size;
+  req.comm_isend.match_fun = match_fun;
   req.comm_isend.data = data;
-  
+
   SIMIX_request_push(&req);
   return req.comm_isend.result;
 }
 
-smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size)
+smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
+                                                                 int (*match_fun)(void *, void *), void *data)
 {
   s_smx_req_t req;
 
@@ -624,6 +628,8 @@ smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_bu
   req.comm_irecv.rdv = rdv;
   req.comm_irecv.dst_buff = dst_buff;
   req.comm_irecv.dst_buff_size = dst_buff_size;
+  req.comm_irecv.match_fun = match_fun;
+  req.comm_irecv.data = data;
 
   SIMIX_request_push(&req);
   return req.comm_irecv.result;
@@ -632,52 +638,85 @@ smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_bu
 void SIMIX_req_comm_destroy(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_DESTROY;
   req.comm_destroy.comm = comm;
-  
+
   SIMIX_request_push(&req);
 }
 
 void SIMIX_req_comm_cancel(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_CANCEL;
   req.comm_cancel.comm = comm;
-  
+
   SIMIX_request_push(&req);
 }
 
 unsigned int SIMIX_req_comm_waitany(xbt_dynar_t comms)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_WAITANY;
   req.comm_waitany.comms = comms;
-  
+
   SIMIX_request_push(&req);
   return req.comm_waitany.result;
 }
 
+int SIMIX_req_comm_testany(xbt_dynar_t comms)
+{
+  s_smx_req_t req;
+  if (xbt_dynar_length(comms)==0)
+    return -1;
+
+  req.call = REQ_COMM_TESTANY;
+  req.comm_testany.comms = comms;
+
+  SIMIX_request_push(&req);
+  return req.comm_testany.result;
+}
+
 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_WAIT;
   req.comm_wait.comm = comm;
   req.comm_wait.timeout = timeout;
-  
+
   SIMIX_request_push(&req);
 }
 
+#ifdef HAVE_TRACING
+/**
+ * \brief Set the category of an action.
+ *
+ * This functions changes the category only. It calls a surf function.
+ * \param execution The execution action
+ * \param category The tracing category
+ */
+void SIMIX_req_set_category(smx_action_t action, const char *category)
+{
+  s_smx_req_t req;
+
+  req.call = REQ_SET_CATEGORY;
+  req.set_category.action = action;
+  req.set_category.category = category;
+
+  SIMIX_request_push(&req);
+}
+#endif
+
 int SIMIX_req_comm_test(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_TEST;
   req.comm_test.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_test.result;
 }
@@ -685,10 +724,10 @@ int SIMIX_req_comm_test(smx_action_t comm)
 double SIMIX_req_comm_get_remains(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_REMAINS;
   req.comm_get_remains.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_remains.result;
 }
@@ -696,32 +735,43 @@ double SIMIX_req_comm_get_remains(smx_action_t comm)
 e_smx_state_t SIMIX_req_comm_get_state(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_STATE;
   req.comm_get_state.comm = comm;
-  
+
   SIMIX_request_push(&req);
   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)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_SRC_BUFF;
   req.comm_get_src_buff.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_src_buff.result;
 }
@@ -729,10 +779,10 @@ void *SIMIX_req_comm_get_src_buff(smx_action_t comm)
 void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_DST_BUFF;
   req.comm_get_dst_buff.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_dst_buff.result;
 }
@@ -740,10 +790,10 @@ void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
 size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_SRC_BUFF_SIZE;
   req.comm_get_src_buff_size.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_src_buff_size.result;
 }
@@ -751,10 +801,10 @@ size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
 size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_DST_BUFF_SIZE;
   req.comm_get_dst_buff_size.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_dst_buff_size.result;
 }
@@ -762,10 +812,10 @@ size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_SRC_PROC;
   req.comm_get_src_proc.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_src_proc.result;
 }
@@ -773,10 +823,10 @@ smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
 smx_process_t SIMIX_req_comm_get_dst_proc(smx_action_t comm)
 {
   s_smx_req_t req;
-  
+
   req.call = REQ_COMM_GET_DST_PROC;
   req.comm_get_dst_proc.comm = comm;
-  
+
   SIMIX_request_push(&req);
   return req.comm_get_dst_proc.result;
 }
@@ -888,8 +938,8 @@ void SIMIX_req_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
 }
 
 void SIMIX_req_cond_wait_timeout(smx_cond_t cond,
-                                         smx_mutex_t mutex,
-                                         double timeout)
+                                 smx_mutex_t mutex,
+                                 double timeout)
 {
   s_smx_req_t req;