X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/36246161381665fecb9a5a074b081d8d712f94e6..31b7fa457f9267af8eda2eee06aae74dd78eb412:/src/simix/smx_network.c diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index e396a2df0f..11b84c6d64 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -19,8 +19,6 @@ static void SIMIX_comm_finish(smx_action_t action); static void SIMIX_waitany_req_remove_from_actions(smx_req_t req); static void SIMIX_comm_copy_data(smx_action_t comm); static smx_action_t SIMIX_comm_new(e_smx_comm_type_t type); -static XBT_INLINE void SIMIX_comm_wait_for_completion(smx_action_t comm, - double timeout); static XBT_INLINE void SIMIX_rdv_push(smx_rdv_t rdv, smx_action_t comm); static XBT_INLINE void SIMIX_rdv_remove(smx_rdv_t rdv, smx_action_t comm); static smx_action_t SIMIX_rdv_get_request(smx_rdv_t rdv, e_smx_comm_type_t type, @@ -248,7 +246,8 @@ void SIMIX_comm_destroy_internal_actions(smx_action_t action) smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv, double task_size, double rate, void *src_buff, size_t src_buff_size, - int (*match_fun)(void *, void *), void *data) + int (*match_fun)(void *, void *), void *data, + int detached) { smx_action_t action; @@ -264,6 +263,11 @@ smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv, action->comm.type = SIMIX_COMM_READY; } + /* If the communication action is detached then decrease the refcount + * by one, so it will be eliminated by the receivers destroy call */ + if(detached) + action->comm.refcount--; + /* Setup the communication request */ action->comm.src_proc = src_proc; action->comm.task_size = task_size; @@ -315,7 +319,7 @@ smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv, return action; } -void SIMIX_pre_comm_wait(smx_req_t req) +void SIMIX_pre_comm_wait(smx_req_t req, int idx) { smx_action_t action = req->comm_wait.comm; double timeout = req->comm_wait.timeout; @@ -326,7 +330,7 @@ void SIMIX_pre_comm_wait(smx_req_t req) req->issuer->waiting_action = action; if (MC_IS_ENABLED){ - if(action->comm.src_proc && action->comm.dst_proc){ + if(idx == 0){ action->state = SIMIX_DONE; }else{ /* If we reached this point, the wait request must have a timeout */ @@ -362,8 +366,20 @@ void SIMIX_pre_comm_wait(smx_req_t req) void SIMIX_pre_comm_test(smx_req_t req) { smx_action_t action = req->comm_test.comm; - req->comm_test.result = (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING); + if(MC_IS_ENABLED){ + req->comm_test.result = action->comm.src_proc && action->comm.dst_proc; + if(req->comm_test.result){ + action->state = SIMIX_DONE; + xbt_fifo_push(action->request_list, req); + SIMIX_comm_finish(action); + }else{ + SIMIX_request_answer(req); + } + return; + } + + req->comm_test.result = (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING); if (req->comm_test.result) { xbt_fifo_push(action->request_list, req); SIMIX_comm_finish(action); @@ -384,6 +400,7 @@ void SIMIX_pre_comm_testany(smx_req_t req, int idx) SIMIX_request_answer(req); }else{ action = xbt_dynar_get_as(actions, idx, smx_action_t); + req->comm_testany.result = idx; xbt_fifo_push(action->request_list, req); action->state = SIMIX_DONE; SIMIX_comm_finish(action);