X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/680d3333804979cca617afe9bef76ab1b1eb9f0e..4365fa8e81736673eae923310a05cdbf78ec88d8:/src/simix/smx_network.c diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 089c68e151..6cc1114ac5 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -7,10 +7,10 @@ #include "smx_private.h" #include "xbt/log.h" #include "mc/mc.h" +#include "mc/mc_replay.h" #include "xbt/dict.h" #include "smpi/private.h" - XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "SIMIX network-related synchronization"); @@ -258,9 +258,7 @@ smx_synchro_t SIMIX_comm_new(e_smx_comm_type_t type) synchro->latency_limited = -1; #endif -#ifdef HAVE_TRACING synchro->category = NULL; -#endif XBT_DEBUG("Create communicate synchro %p", synchro); ++smx_total_comms; @@ -423,7 +421,7 @@ smx_synchro_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv, other_synchro->comm.copy_data_fun = copy_data_fun; - if (MC_is_active()) { + if (MC_is_active() || MC_record_replay_is_active()) { other_synchro->state = SIMIX_RUNNING; return (detached ? NULL : other_synchro); } @@ -532,7 +530,7 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv, SIMIX_comm_copy_data(other_synchro);*/ - if (MC_is_active()) { + if (MC_is_active() || MC_record_replay_is_active()) { other_synchro->state = SIMIX_RUNNING; return other_synchro; } @@ -593,7 +591,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_synchro_t synchro, dou xbt_fifo_push(synchro->simcalls, simcall); simcall->issuer->waiting_synchro = synchro; - if (MC_is_active()) { + if (MC_is_active() || MC_record_replay_is_active()) { int idx = SIMCALL_GET_MC_VALUE(simcall); if (idx == 0) { synchro->state = SIMIX_DONE; @@ -618,7 +616,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_synchro_t synchro, dou if (synchro->state != SIMIX_WAITING && synchro->state != SIMIX_RUNNING) { SIMIX_comm_finish(synchro); } else { /* if (timeout >= 0) { we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host fails */ - sleep = surf_workstation_sleep(simcall->issuer->smx_host, timeout); + sleep = surf_host_sleep(simcall->issuer->smx_host, timeout); surf_action_set_data(sleep, synchro); if (simcall->issuer == synchro->comm.src_proc) @@ -630,7 +628,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_synchro_t synchro, dou void simcall_HANDLER_comm_test(smx_simcall_t simcall, smx_synchro_t synchro) { - if(MC_is_active()){ + if(MC_is_active() || MC_record_replay_is_active()){ simcall_comm_test__set__result(simcall, synchro->comm.src_proc && synchro->comm.dst_proc); if(simcall_comm_test__get__result(simcall)){ synchro->state = SIMIX_DONE; @@ -657,7 +655,7 @@ void simcall_HANDLER_comm_testany(smx_simcall_t simcall, xbt_dynar_t synchros) smx_synchro_t synchro; simcall_comm_testany__set__result(simcall, -1); - if (MC_is_active()){ + if (MC_is_active() || MC_record_replay_is_active()){ int idx = SIMCALL_GET_MC_VALUE(simcall); if(idx == -1){ SIMIX_simcall_answer(simcall); @@ -687,7 +685,7 @@ void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, xbt_dynar_t synchros) smx_synchro_t synchro; unsigned int cursor = 0; - if (MC_is_active()){ + if (MC_is_active() || MC_record_replay_is_active()){ int idx = SIMCALL_GET_MC_VALUE(simcall); synchro = xbt_dynar_get_as(synchros, idx, smx_synchro_t); xbt_fifo_push(synchro->simcalls, simcall); @@ -735,7 +733,7 @@ static XBT_INLINE void SIMIX_comm_start(smx_synchro_t synchro) XBT_DEBUG("Starting communication %p from '%s' to '%s'", synchro, SIMIX_host_get_name(sender), SIMIX_host_get_name(receiver)); - synchro->comm.surf_comm = surf_workstation_model_communicate(surf_workstation_model, + synchro->comm.surf_comm = surf_host_model_communicate(surf_host_model, sender, receiver, synchro->comm.task_size, synchro->comm.rate); @@ -779,7 +777,6 @@ void SIMIX_comm_finish(smx_synchro_t synchro) unsigned int destroy_count = 0; smx_simcall_t simcall; - while ((simcall = xbt_fifo_shift(synchro->simcalls))) { /* If a waitany simcall is waiting for this synchro to finish, then remove @@ -791,7 +788,7 @@ void SIMIX_comm_finish(smx_synchro_t synchro) continue; // if process handling comm is killed if (simcall->call == SIMCALL_COMM_WAITANY) { SIMIX_waitany_remove_simcall_from_actions(simcall); - if (!MC_is_active()) + if (!MC_is_active() && !MC_record_replay_is_active()) simcall_comm_waitany__set__result(simcall, xbt_dynar_search(simcall_comm_waitany__get__comms(simcall), &synchro)); } @@ -802,6 +799,13 @@ void SIMIX_comm_finish(smx_synchro_t synchro) XBT_DEBUG("SIMIX_comm_finish: synchro state = %d", (int)synchro->state); /* Check out for errors */ + + if (surf_resource_get_state(surf_host_resource_priv( + simcall->issuer->smx_host)) != SURF_RESOURCE_ON) { + simcall->issuer->context->iwannadie = 1; + SMX_EXCEPTION(simcall->issuer, host_error, 0, "Host failed"); + } else + switch (synchro->state) { case SIMIX_DONE: @@ -836,6 +840,7 @@ void SIMIX_comm_finish(smx_synchro_t synchro) break; case SIMIX_LINK_FAILURE: + XBT_DEBUG("Link failure in synchro %p between '%s' and '%s': posting an exception to the issuer: %s (%p) detached:%d", synchro, synchro->comm.src_proc ? sg_host_name(synchro->comm.src_proc->smx_host) : NULL, @@ -874,7 +879,7 @@ void SIMIX_comm_finish(smx_synchro_t synchro) } } - if (surf_resource_get_state(surf_workstation_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) { + if (surf_resource_get_state(surf_host_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) { simcall->issuer->context->iwannadie = 1; } @@ -945,6 +950,7 @@ void SIMIX_comm_cancel(smx_synchro_t synchro) synchro->state = SIMIX_CANCELED; } else if (!MC_is_active() /* when running the MC there are no surf actions */ + && !MC_record_replay_is_active() && (synchro->state == SIMIX_READY || synchro->state == SIMIX_RUNNING)) { surf_action_cancel(synchro->comm.surf_comm);