From 686336f25198e15f4d846d7639b5f221587b50b0 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 2 Apr 2019 14:32:25 +0200 Subject: [PATCH] detached really is a boolean. --- include/simgrid/s4u/Comm.hpp | 2 +- include/simgrid/simix.h | 2 +- src/kernel/activity/CommImpl.cpp | 19 +++++++++---------- src/kernel/activity/CommImpl.hpp | 2 +- src/mc/mc_base.cpp | 2 +- src/mc/mc_state.cpp | 2 +- src/simix/libsmx.cpp | 2 +- src/simix/popping_accessors.hpp | 29 ++++++++++++----------------- src/simix/popping_bodies.cpp | 7 +++---- src/simix/popping_generated.cpp | 19 ++++++------------- src/simix/simcalls.in | 2 +- src/smpi/internals/smpi_global.cpp | 2 +- 12 files changed, 38 insertions(+), 52 deletions(-) diff --git a/include/simgrid/s4u/Comm.hpp b/include/simgrid/s4u/Comm.hpp index 2502a97ae9..e944fabe64 100644 --- a/include/simgrid/s4u/Comm.hpp +++ b/include/simgrid/s4u/Comm.hpp @@ -31,7 +31,7 @@ class XBT_PUBLIC Comm : public Activity { std::string tracing_category_ = ""; std::atomic_int_fast32_t refcount_{0}; /* FIXME: expose these elements in the API */ - int detached_ = 0; + bool detached_ = false; int (*match_fun_)(void*, void*, kernel::activity::CommImpl*) = nullptr; void (*clean_fun_)(void*) = nullptr; void (*copy_data_function_)(kernel::activity::CommImpl*, void*, size_t) = nullptr; diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 1a6bb09d9d..8034635948 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -211,7 +211,7 @@ XBT_PUBLIC smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t m int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void (*clean_fun)(void*), void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), - void* data, int detached); + void* data, bool detached); XBT_PUBLIC void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index a87836256e..cdd8160393 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -35,7 +35,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend( size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), // used to copy data if not default one - void* data, int detached) + void* data, bool detached) { XBT_DEBUG("send from mailbox %p", mbox); @@ -73,7 +73,7 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend( } if (detached) { - other_comm->detached = true; + other_comm->detached_ = true; other_comm->clean_fun = clean_fun; } else { other_comm->clean_fun = nullptr; @@ -341,7 +341,7 @@ void SIMIX_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, { XBT_DEBUG("Copy the data over"); memcpy(comm->dst_buff_, buff, buff_size); - if (comm->detached) { // if this is a detached send, the source buffer was duplicated by SMPI sender to make the + if (comm->detached_) { // if this is a detached send, the source buffer was duplicated by SMPI sender to make the // original buffer available to the application ASAP xbt_free(buff); comm->src_buff_ = nullptr; @@ -397,12 +397,11 @@ CommImpl& CommImpl::set_dst_buff(void* buff, size_t* size) CommImpl::~CommImpl() { - XBT_DEBUG("Really free communication %p in state %d (detached = %d)", this, static_cast(state_), - static_cast(detached)); + XBT_DEBUG("Really free communication %p in state %d (detached = %d)", this, static_cast(state_), detached_); cleanupSurf(); - if (detached && state_ != SIMIX_DONE) { + if (detached_ && state_ != SIMIX_DONE) { /* the communication has failed and was detached: * we have to free the buffer */ if (clean_fun) @@ -508,7 +507,7 @@ void CommImpl::cancel() { /* if the synchro is a waiting state means that it is still in a mbox so remove from it and delete it */ if (state_ == SIMIX_WAITING) { - if (not detached) { + if (not detached_) { mbox->remove(this); state_ = SIMIX_CANCELED; } @@ -560,7 +559,7 @@ void CommImpl::post() state_ = SIMIX_DONE; XBT_DEBUG("SIMIX_post_comm: comm %p, state %d, src_proc %p, dst_proc %p, detached: %d", this, (int)state_, - src_actor_.get(), dst_actor_.get(), detached); + src_actor_.get(), dst_actor_.get(), detached_); /* destroy the surf actions associated with the Simix communication */ cleanupSurf(); @@ -647,7 +646,7 @@ void CommImpl::finish() "detached:%d", this, src_actor_ ? src_actor_->get_host()->get_cname() : nullptr, dst_actor_ ? dst_actor_->get_host()->get_cname() : nullptr, simcall->issuer->get_cname(), - simcall->issuer, detached); + simcall->issuer, detached_); if (src_actor_ == simcall->issuer) { XBT_DEBUG("I'm source"); } else if (dst_actor_ == simcall->issuer) { @@ -706,7 +705,7 @@ void CommImpl::finish() simcall->issuer->waiting_synchro = nullptr; simcall->issuer->comms.remove(this); - if (detached) { + if (detached_) { if (simcall->issuer == src_actor_) { if (dst_actor_) dst_actor_->comms.remove(this); diff --git a/src/kernel/activity/CommImpl.hpp b/src/kernel/activity/CommImpl.hpp index 7369c983dd..3ba48de213 100644 --- a/src/kernel/activity/CommImpl.hpp +++ b/src/kernel/activity/CommImpl.hpp @@ -49,7 +49,7 @@ public: (comm.mbox set to nullptr when the communication is removed from the mailbox (used as garbage collector)) */ #endif - bool detached = false; /* If detached or not */ + bool detached_ = false; /* If detached or not */ void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */ int (*match_fun)(void*, void*, CommImpl*) = nullptr; /* Filter function used by the other side. It is used when diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index d44192625b..64643ea277 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -97,7 +97,7 @@ bool actor_is_enabled(smx_actor_t actor) return true; } /* On the other hand if it hasn't a timeout, check if the comm is ready.*/ - else if (act->detached && act->src_actor_ == nullptr && + else if (act->detached_ && act->src_actor_ == nullptr && act->type_ == simgrid::kernel::activity::CommImpl::Type::READY) return (act->dst_actor_ != nullptr); return (act->src_actor_ && act->dst_actor_); diff --git a/src/mc/mc_state.cpp b/src/mc/mc_state.cpp index 035c8d7acd..436b425004 100644 --- a/src/mc/mc_state.cpp +++ b/src/mc/mc_state.cpp @@ -114,7 +114,7 @@ static inline smx_simcall_t MC_state_get_request_for_process(simgrid::mc::State* if (act->src_actor_.get() && act->dst_actor_.get()) state->transition.argument = 0; else if (act->src_actor_.get() == nullptr && act->type_ == simgrid::kernel::activity::CommImpl::Type::READY && - act->detached == 1) + act->detached_) state->transition.argument = 0; else state->transition.argument = -1; diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 2840515913..cd27911cc6 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -110,7 +110,7 @@ smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void (*clean_fun)(void*), void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), - void* data, int detached) + void* data, bool detached) { /* checking for infinite values */ xbt_assert(std::isfinite(task_size), "task_size is not finite!"); diff --git a/src/simix/popping_accessors.hpp b/src/simix/popping_accessors.hpp index 0d92249ae2..e4dc4f0c3e 100644 --- a/src/simix/popping_accessors.hpp +++ b/src/simix/popping_accessors.hpp @@ -98,8 +98,7 @@ static inline simgrid::kernel::activity::ExecImpl* simcall_execution_wait__getra { return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_execution_wait__set__execution(smx_simcall_t simcall, - simgrid::kernel::activity::ExecImpl* arg) +static inline void simcall_execution_wait__set__execution(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* arg) { simgrid::simix::marshal(simcall->args[0], arg); } @@ -124,8 +123,7 @@ static inline simgrid::kernel::activity::ExecImpl* simcall_execution_test__getra { return simgrid::simix::unmarshal_raw(simcall->args[0]); } -static inline void simcall_execution_test__set__execution(smx_simcall_t simcall, - simgrid::kernel::activity::ExecImpl* arg) +static inline void simcall_execution_test__set__execution(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* arg) { simgrid::simix::marshal(simcall->args[0], arg); } @@ -383,17 +381,17 @@ static inline void simcall_comm_isend__set__data(smx_simcall_t simcall, void* ar { simgrid::simix::marshal(simcall->args[9], arg); } -static inline int simcall_comm_isend__get__detached(smx_simcall_t simcall) +static inline bool simcall_comm_isend__get__detached(smx_simcall_t simcall) { - return simgrid::simix::unmarshal(simcall->args[10]); + return simgrid::simix::unmarshal(simcall->args[10]); } -static inline int simcall_comm_isend__getraw__detached(smx_simcall_t simcall) +static inline bool simcall_comm_isend__getraw__detached(smx_simcall_t simcall) { - return simgrid::simix::unmarshal_raw(simcall->args[10]); + return simgrid::simix::unmarshal_raw(simcall->args[10]); } -static inline void simcall_comm_isend__set__detached(smx_simcall_t simcall, int arg) +static inline void simcall_comm_isend__set__detached(smx_simcall_t simcall, bool arg) { - simgrid::simix::marshal(simcall->args[10], arg); + simgrid::simix::marshal(simcall->args[10], arg); } static inline boost::intrusive_ptr simcall_comm_isend__get__result(smx_simcall_t simcall) { @@ -1033,16 +1031,13 @@ XBT_PRIVATE void simcall_HANDLER_process_sleep(smx_simcall_t simcall, double dur XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution); XBT_PRIVATE void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution); XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* 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, void* 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, int detached); +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, void* 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 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, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate); XBT_PRIVATE boost::intrusive_ptr simcall_HANDLER_comm_irecv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate); -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); +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); XBT_PRIVATE void 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 void simcall_HANDLER_comm_testany(smx_simcall_t simcall, simgrid::kernel::activity::CommImpl** comms, size_t count); XBT_PRIVATE void simcall_HANDLER_mutex_lock(smx_simcall_t simcall, smx_mutex_t mutex); XBT_PRIVATE int simcall_HANDLER_mutex_trylock(smx_simcall_t simcall, smx_mutex_t mutex); XBT_PRIVATE void simcall_HANDLER_mutex_unlock(smx_simcall_t simcall, smx_mutex_t mutex); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index 17dfef1a5f..4234bb929c 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -78,11 +78,11 @@ inline static void simcall_BODY_comm_send(smx_actor_t sender, smx_mailbox_t mbox return simcall(SIMCALL_COMM_SEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, copy_data_fun, data, timeout); } -inline static boost::intrusive_ptr simcall_BODY_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* 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, int detached) +inline static boost::intrusive_ptr simcall_BODY_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* 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) { if (0) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_comm_isend(&SIMIX_process_self()->simcall, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached); - return simcall, smx_actor_t, smx_mailbox_t, double, double, void*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, int>(SIMCALL_COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached); + return simcall, smx_actor_t, smx_mailbox_t, double, double, void*, size_t, simix_match_func_t, simix_clean_func_t, simix_copy_data_func_t, void*, bool>(SIMCALL_COMM_ISEND, sender, mbox, task_size, rate, src_buff, src_buff_size, match_fun, clean_fun, copy_data_fun, data, detached); } inline static void simcall_BODY_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate) @@ -103,8 +103,7 @@ inline static int simcall_BODY_comm_waitany(simgrid::kernel::activity::CommImpl* { if (0) /* Go to that function to follow the code flow through the simcall barrier */ simcall_HANDLER_comm_waitany(&SIMIX_process_self()->simcall, comms, count, timeout); - return simcall(SIMCALL_COMM_WAITANY, comms, count, - timeout); + return simcall(SIMCALL_COMM_WAITANY, comms, count, timeout); } inline static void simcall_BODY_comm_wait(simgrid::kernel::activity::CommImpl* comm, double timeout) diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 9306f6c5ce..71542d49b6 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -76,13 +76,11 @@ case SIMCALL_PROCESS_SLEEP: break; case SIMCALL_EXECUTION_WAIT: - simcall_HANDLER_execution_wait(simcall, - simgrid::simix::unmarshal(simcall->args[0])); + simcall_HANDLER_execution_wait(simcall, simgrid::simix::unmarshal(simcall->args[0])); break; case SIMCALL_EXECUTION_TEST: - simcall_HANDLER_execution_test(simcall, - simgrid::simix::unmarshal(simcall->args[0])); + simcall_HANDLER_execution_test(simcall, simgrid::simix::unmarshal(simcall->args[0])); break; case SIMCALL_COMM_SEND: @@ -90,7 +88,7 @@ case SIMCALL_COMM_SEND: break; case SIMCALL_COMM_ISEND: - simgrid::simix::marshal>(simcall->result, simcall_HANDLER_comm_isend(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2]), simgrid::simix::unmarshal(simcall->args[3]), simgrid::simix::unmarshal(simcall->args[4]), simgrid::simix::unmarshal(simcall->args[5]), simgrid::simix::unmarshal(simcall->args[6]), simgrid::simix::unmarshal(simcall->args[7]), simgrid::simix::unmarshal(simcall->args[8]), simgrid::simix::unmarshal(simcall->args[9]), simgrid::simix::unmarshal(simcall->args[10]))); + simgrid::simix::marshal>(simcall->result, simcall_HANDLER_comm_isend(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2]), simgrid::simix::unmarshal(simcall->args[3]), simgrid::simix::unmarshal(simcall->args[4]), simgrid::simix::unmarshal(simcall->args[5]), simgrid::simix::unmarshal(simcall->args[6]), simgrid::simix::unmarshal(simcall->args[7]), simgrid::simix::unmarshal(simcall->args[8]), simgrid::simix::unmarshal(simcall->args[9]), simgrid::simix::unmarshal(simcall->args[10]))); SIMIX_simcall_answer(simcall); break; @@ -104,14 +102,11 @@ case SIMCALL_COMM_IRECV: break; case SIMCALL_COMM_WAITANY: - simcall_HANDLER_comm_waitany( - simcall, simgrid::simix::unmarshal(simcall->args[0]), - simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2])); + simcall_HANDLER_comm_waitany(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1]), simgrid::simix::unmarshal(simcall->args[2])); break; case SIMCALL_COMM_WAIT: - simcall_HANDLER_comm_wait(simcall, simgrid::simix::unmarshal(simcall->args[0]), - simgrid::simix::unmarshal(simcall->args[1])); + simcall_HANDLER_comm_wait(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1])); break; case SIMCALL_COMM_TEST: @@ -119,9 +114,7 @@ case SIMCALL_COMM_TEST: break; case SIMCALL_COMM_TESTANY: - simcall_HANDLER_comm_testany(simcall, - simgrid::simix::unmarshal(simcall->args[0]), - simgrid::simix::unmarshal(simcall->args[1])); + simcall_HANDLER_comm_testany(simcall, simgrid::simix::unmarshal(simcall->args[0]), simgrid::simix::unmarshal(simcall->args[1])); break; case SIMCALL_MUTEX_LOCK: diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index a657616435..5eeaa1a3d8 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -43,7 +43,7 @@ int execution_wait(simgrid::kernel::activity::ExecImpl* execution) [[b int execution_test(simgrid::kernel::activity::ExecImpl* execution) [[block]]; void comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* 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, void* 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, int detached); +boost::intrusive_ptr comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* 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); void comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double timeout, double rate) [[block]]; boost::intrusive_ptr comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, simix_match_func_t match_fun, simix_copy_data_func_t copy_data_fun, void* data, double rate); int comm_waitany(simgrid::kernel::activity::CommImpl** comms, size_t count, double timeout) [[block]]; diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 26aafa47cf..408be49dbd 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -216,7 +216,7 @@ void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, v XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff, comm->dst_buff_); memcpy_private(comm->dst_buff_, tmpbuff, private_blocks); - if (comm->detached) { + if (comm->detached_) { // if this is a detached send, the source buffer was duplicated by SMPI // sender to make the original buffer available to the application ASAP xbt_free(buff); -- 2.20.1