From: Arnaud Giersch Date: Mon, 12 Apr 2021 09:01:11 +0000 (+0200) Subject: Simcall COMM_TESTANY is not blocking either. Simplify. X-Git-Tag: v3.28~455^2~85 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c3c8a4edb0c9e5ac9d67f20ac2139845d727c79b?hp=67fe002098576f7b41efe7415407d313be6c818c Simcall COMM_TESTANY is not blocking either. Simplify. --- diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 3e80008346..5b5582ce4b 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -228,37 +228,19 @@ bool simcall_HANDLER_comm_test(smx_simcall_t, simgrid::kernel::activity::CommImp return comm->test(); } -void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comms[], size_t count) +int simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comms[], size_t count) { - // The default result is -1 -- this means, "nothing is ready". - // It can be changed below, but only if something matches. - simcall_comm_testany__set__result(simcall, -1); - if (MC_is_active() || MC_record_replay_is_active()) { int idx = simcall->mc_value_; - if (idx == -1) { - simcall->issuer_->simcall_answer(); - } else { - simgrid::kernel::activity::CommImpl* comm = comms[idx]; - simcall_comm_testany__set__result(simcall, idx); - comm->simcalls_.push_back(simcall); - comm->state_ = simgrid::kernel::activity::State::DONE; - comm->finish(); - } - return; + xbt_assert(idx == -1 || comms[idx]->test()); + return idx; } for (std::size_t i = 0; i != count; ++i) { - simgrid::kernel::activity::CommImpl* comm = comms[i]; - if (comm->state_ != simgrid::kernel::activity::State::WAITING && - comm->state_ != simgrid::kernel::activity::State::RUNNING) { - simcall_comm_testany__set__result(simcall, i); - comm->simcalls_.push_back(simcall); - comm->finish(); - return; - } + if (comms[i]->test()) + return i; } - simcall->issuer_->simcall_answer(); + return -1; } static void SIMIX_waitany_remove_simcall_from_actions(smx_simcall_t simcall) diff --git a/src/simix/popping_accessors.hpp b/src/simix/popping_accessors.hpp index 0f878b097e..78757f909b 100644 --- a/src/simix/popping_accessors.hpp +++ b/src/simix/popping_accessors.hpp @@ -668,6 +668,6 @@ XBT_PRIVATE boost::intrusive_ptr simcal XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout); XBT_PRIVATE boost::intrusive_ptr simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached); XBT_PRIVATE bool simcall_HANDLER_comm_test(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comm); -XBT_PRIVATE void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms, size_t count); +XBT_PRIVATE int simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms, size_t count); XBT_PRIVATE void simcall_HANDLER_comm_waitany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout); XBT_PRIVATE void simcall_HANDLER_comm_wait(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl* comm, double timeout); diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 36c4db8dac..3a736cb6c0 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -79,7 +79,8 @@ void simgrid::kernel::actor::ActorImpl::simcall_handle(int times_considered) break; case Simcall::COMM_TESTANY: - simcall_HANDLER_comm_testany(&simcall_, simgrid::simix::unmarshal(simcall_.args_[0]), simgrid::simix::unmarshal(simcall_.args_[1])); + simgrid::simix::marshal(simcall_.result_, simcall_HANDLER_comm_testany(&simcall_, simgrid::simix::unmarshal(simcall_.args_[0]), simgrid::simix::unmarshal(simcall_.args_[1]))); + simcall_answer(); break; case Simcall::COMM_WAITANY: diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index e745724fad..5571691e0e 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -40,7 +40,7 @@ boost::intrusive_ptr comm_irecv(smx_act void comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout) [[block]]; boost::intrusive_ptr comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, unsigned char* src_buff, size_t src_buff_size, simix_match_func_t match_fun, simix_clean_func_t clean_fun, simix_copy_data_func_t copy_data_fun, void* data, bool detached); bool comm_test(simgrid::kernel::activity::CommImpl* comm); -int comm_testany(simgrid::kernel::activity::CommImpl** comms, size_t count) [[block]]; +int comm_testany(simgrid::kernel::activity::CommImpl** comms, size_t count); int comm_waitany(simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout) [[block]]; void comm_wait(simgrid::kernel::activity::CommImpl* comm, double timeout) [[block]];