X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/544e6fac3fc91ae81d5daa4481562240c2cb2467..7821a711252f51d66c6bb5eb47e3f6f568f31564:/src/simix/smx_network.cpp diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index a685c8700a..fcf65a3244 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -17,9 +17,10 @@ #include "mc/mc.h" #include "src/mc/mc_replay.h" #include "xbt/dict.h" -#include "simgrid/s4u/mailbox.hpp" +#include "simgrid/s4u/Mailbox.hpp" #include "src/kernel/activity/SynchroComm.hpp" +#include "src/surf/network_interface.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix, "SIMIX network-related synchronization"); @@ -46,7 +47,7 @@ smx_mailbox_t SIMIX_mbox_create(const char *name) { xbt_assert(name, "Mailboxes must have a name"); /* two processes may have pushed the same mbox_create simcall at the same time */ - smx_mailbox_t mbox = (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name); + smx_mailbox_t mbox = static_cast(xbt_dict_get_or_null(mailboxes, name)); if (!mbox) { mbox = new simgrid::simix::Mailbox(name); XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name); @@ -58,13 +59,13 @@ smx_mailbox_t SIMIX_mbox_create(const char *name) void SIMIX_mbox_free(void *data) { XBT_DEBUG("mbox free %p", data); - smx_mailbox_t mbox = (smx_mailbox_t) data; + smx_mailbox_t mbox = static_cast(data); delete mbox; } smx_mailbox_t SIMIX_mbox_get_by_name(const char *name) { - return (smx_mailbox_t) xbt_dict_get_or_null(mailboxes, name); + return static_cast(xbt_dict_get_or_null(mailboxes, name)); } /** @@ -72,7 +73,7 @@ smx_mailbox_t SIMIX_mbox_get_by_name(const char *name) * \param mbox The rendez-vous point * \param process The receiving process */ -void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t process) +void SIMIX_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t process) { mbox->permanent_receiver = process; } @@ -150,7 +151,7 @@ static smx_activity_t _find_matching_comm(std::deque *deque, e_s /******************************************************************************/ /* Communication synchros */ /******************************************************************************/ -XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_process_t src, smx_mailbox_t mbox, +XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t src, smx_mailbox_t mbox, double task_size, double rate, void *src_buff, size_t src_buff_size, int (*match_fun)(void *, void *,smx_activity_t), @@ -162,7 +163,7 @@ XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_process_t SIMCALL_SET_MC_VALUE(simcall, 0); simcall_HANDLER_comm_wait(simcall, comm, timeout); } -XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t src_proc, smx_mailbox_t mbox, +XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_actor_t src_proc, smx_mailbox_t mbox, double task_size, double rate, void *src_buff, size_t src_buff_size, int (*match_fun)(void *, void *,smx_activity_t), @@ -238,7 +239,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx return (detached ? nullptr : other_comm); } -XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_process_t receiver, smx_mailbox_t mbox, +XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size, int (*match_fun)(void *, void *, smx_activity_t), void (*copy_data_fun)(smx_activity_t, void*, size_t), @@ -249,7 +250,7 @@ XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_process_t simcall_HANDLER_comm_wait(simcall, comm, timeout); } -XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_irecv(smx_simcall_t simcall, smx_process_t receiver, smx_mailbox_t mbox, +XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_irecv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size, int (*match_fun)(void *, void *, smx_activity_t), void (*copy_data_fun)(smx_activity_t, void*, size_t), @@ -258,7 +259,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_irecv(smx_simcall_t simcall, smx return SIMIX_comm_irecv(receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate); } -smx_activity_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size, +smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size, int (*match_fun)(void *, void *, smx_activity_t), void (*copy_data_fun)(smx_activity_t, void*, size_t), // used to copy data if not default one void *data, double rate) @@ -281,7 +282,7 @@ smx_activity_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void } else { simgrid::kernel::activity::Comm *other_comm = static_cast(other_synchro); - if(other_comm->surf_comm && other_comm->remains()==0.0) { + if(other_comm->surf_comm && other_comm->remains() < 1e-12) { XBT_DEBUG("comm %p has been already sent, and is finished, destroy it",other_comm); other_comm->state = SIMIX_DONE; other_comm->type = SIMIX_COMM_DONE; @@ -320,7 +321,7 @@ smx_activity_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void other_comm->dst_buff_size = dst_buff_size; other_comm->dst_data = data; - if (rate != -1.0 && (other_comm->rate == -1.0 || rate < other_comm->rate)) + if (rate > -1.0 && (other_comm->rate < 0.0 || rate < other_comm->rate)) other_comm->rate = rate; other_comm->match_fun = match_fun; @@ -342,7 +343,7 @@ smx_activity_t simcall_HANDLER_comm_iprobe(smx_simcall_t simcall, smx_mailbox_t return SIMIX_comm_iprobe(simcall->issuer, mbox, type, src, tag, match_fun, data); } -smx_activity_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int type, int src, +smx_activity_t SIMIX_comm_iprobe(smx_actor_t dst_proc, smx_mailbox_t mbox, int type, int src, int tag, int (*match_fun)(void *, void *, smx_activity_t), void *data) { XBT_DEBUG("iprobe from %p %p", mbox, &mbox->comm_queue); @@ -389,7 +390,7 @@ void simcall_HANDLER_comm_wait(smx_simcall_t simcall, smx_activity_t synchro, do } else { /* If we reached this point, the wait simcall must have a timeout */ /* Otherwise it shouldn't be enabled and executed by the MC */ - if (timeout == -1) + if (timeout < 0.0) THROW_IMPOSSIBLE; simgrid::kernel::activity::Comm *comm = static_cast(synchro); @@ -483,7 +484,7 @@ void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, xbt_dynar_t synchros, d unsigned int cursor = 0; if (MC_is_active() || MC_record_replay_is_active()){ - if (timeout != -1) + if (timeout > 0.0) xbt_die("Timeout not implemented for waitany in the model-checker"); int idx = SIMCALL_GET_MC_VALUE(simcall); synchro = xbt_dynar_get_as(synchros, idx, smx_activity_t); @@ -494,10 +495,10 @@ void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, xbt_dynar_t synchros, d return; } - if (timeout == -1 ){ + if (timeout < 0.0){ simcall->timer = NULL; } else { - simcall->timer = SIMIX_timer_set(timeout, [simcall]() { + simcall->timer = SIMIX_timer_set(SIMIX_get_clock() + timeout, [simcall]() { SIMIX_waitany_remove_simcall_from_actions(simcall); simcall_comm_waitany__set__result(simcall, -1); SIMIX_simcall_answer(simcall); @@ -541,12 +542,12 @@ static inline void SIMIX_comm_start(smx_activity_t synchro) /* If both the sender and the receiver are already there, start the communication */ if (synchro->state == SIMIX_READY) { - sg_host_t sender = comm->src_proc->host; - sg_host_t receiver = comm->dst_proc->host; + simgrid::s4u::Host* sender = comm->src_proc->host; + simgrid::s4u::Host* receiver = comm->dst_proc->host; XBT_DEBUG("Starting communication %p from '%s' to '%s'", synchro, sg_host_get_name(sender), sg_host_get_name(receiver)); - comm->surf_comm = surf_network_model_communicate(surf_network_model, sender, receiver, comm->task_size, comm->rate); + comm->surf_comm = surf_network_model->communicate(sender, receiver, comm->task_size, comm->rate); comm->surf_comm->setData(synchro); comm->state = SIMIX_RUNNING;