From 806504b9602a886e391b54e458b2c1f7f42d3afb Mon Sep 17 00:00:00 2001 From: pini Date: Tue, 7 Dec 2010 15:47:19 +0000 Subject: [PATCH 1/1] Distinguish access to sender-side and receiver-side user data in smx_action_t. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9073 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- include/simix/simix.h | 3 ++- src/gras/Msg/sg_msg.c | 2 +- src/msg/msg_mailbox.c | 2 +- src/simix/network_private.h | 3 ++- src/simix/private.h | 3 ++- src/simix/smurf_private.h | 12 +++++++++--- src/simix/smx_network.c | 38 ++++++++++++++++++++++++++----------- src/simix/smx_smurf.c | 9 +++++++-- src/simix/smx_user.c | 19 +++++++++++++++---- 9 files changed, 66 insertions(+), 25 deletions(-) diff --git a/include/simix/simix.h b/include/simix/simix.h index dfe2f250a9..d4237b2fec 100644 --- a/include/simix/simix.h +++ b/include/simix/simix.h @@ -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); diff --git a/src/gras/Msg/sg_msg.c b/src/gras/Msg/sg_msg.c index 59d8cd07d5..b2e4dfd1da 100644 --- a/src/gras/Msg/sg_msg.c +++ b/src/gras/Msg/sg_msg.c @@ -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", diff --git a/src/msg/msg_mailbox.c b/src/msg/msg_mailbox.c index dda4eb5c19..fad007c211 100644 --- a/src/msg/msg_mailbox.c +++ b/src/msg/msg_mailbox.c @@ -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 diff --git a/src/simix/network_private.h b/src/simix/network_private.h index 32b8777832..f7f2ce9066 100644 --- a/src/simix/network_private.h +++ b/src/simix/network_private.h @@ -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); diff --git a/src/simix/private.h b/src/simix/private.h index 475208e91b..fda2af9aa8 100644 --- a/src/simix/private.h +++ b/src/simix/private.h @@ -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 { diff --git a/src/simix/smurf_private.h b/src/simix/smurf_private.h index 8e6575399c..4f0a7ab52b 100644 --- a/src/simix/smurf_private.h +++ b/src/simix/smurf_private.h @@ -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; diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index f874dcc1f5..ded44f2000 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -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) diff --git a/src/simix/smx_smurf.c b/src/simix/smx_smurf.c index 0dd362a947..3d6bbf0659 100644 --- a/src/simix/smx_smurf.c +++ b/src/simix/smx_smurf.c @@ -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; diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 1280e30074..b42fc6bf5e 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -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) -- 2.20.1