From 4a4d0d50d8a6fbd0b50172905f7ad5cf5ed0f9a0 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 7 Feb 2020 14:28:24 +0100 Subject: [PATCH] Modernize simcall_execution_test(). --- include/simgrid/simix.h | 10 ++++------ src/kernel/activity/ActivityImpl.cpp | 9 +++++++++ src/kernel/activity/ActivityImpl.hpp | 2 ++ src/kernel/activity/ExecImpl.cpp | 13 ------------- src/s4u/s4u_Exec.cpp | 2 +- src/simix/libsmx.cpp | 4 ++-- src/simix/popping_accessors.hpp | 26 -------------------------- src/simix/popping_bodies.cpp | 7 ------- src/simix/popping_enum.h | 1 - src/simix/popping_generated.cpp | 5 ----- src/simix/simcalls.in | 1 - 11 files changed, 18 insertions(+), 62 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 24fbc8e61c..017f6be6c7 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -117,18 +117,16 @@ XBT_PUBLIC void SIMIX_comm_copy_buffer_callback(simgrid::kernel::activity::CommI XBT_PUBLIC e_smx_state_t simcall_execution_wait(simgrid::kernel::activity::ActivityImpl* execution, double timeout); XBT_PUBLIC unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count, double timeout); -XBT_PUBLIC bool simcall_execution_test(simgrid::kernel::activity::ActivityImpl* execution); +XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Exec::test()") XBT_PUBLIC + bool simcall_execution_test(simgrid::kernel::activity::ActivityImpl* execution); +XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Exec::test()") XBT_PUBLIC + bool simcall_execution_test(const simgrid::kernel::activity::ActivityImplPtr& execution); XBT_ATTRIB_DEPRECATED_v330("Please use an ActivityImpl* for first parameter") inline e_smx_state_t simcall_execution_wait(const simgrid::kernel::activity::ActivityImplPtr& execution, double timeout) { return simcall_execution_wait(execution.get(), timeout); } -XBT_ATTRIB_DEPRECATED_v330("Please use an ActivityImpl* for first parameter") inline bool simcall_execution_test( - const simgrid::kernel::activity::ActivityImplPtr& execution) -{ - return simcall_execution_test(execution.get()); -} #endif /**************************** Process simcalls ********************************/ diff --git a/src/kernel/activity/ActivityImpl.cpp b/src/kernel/activity/ActivityImpl.cpp index baa4dc03f2..a4060f643e 100644 --- a/src/kernel/activity/ActivityImpl.cpp +++ b/src/kernel/activity/ActivityImpl.cpp @@ -37,6 +37,15 @@ double ActivityImpl::get_remaining() const return surf_action_ ? surf_action_->get_remains() : 0; } +bool ActivityImpl::test() +{ + if (state_ != State::WAITING && state_ != State::RUNNING) { + finish(); + return true; + } + return false; +} + void ActivityImpl::suspend() { if (surf_action_ == nullptr) diff --git a/src/kernel/activity/ActivityImpl.hpp b/src/kernel/activity/ActivityImpl.hpp index 7d870f13ac..b0562ff207 100644 --- a/src/kernel/activity/ActivityImpl.hpp +++ b/src/kernel/activity/ActivityImpl.hpp @@ -44,6 +44,8 @@ public: std::list simcalls_; /* List of simcalls waiting for this activity */ resource::Action* surf_action_ = nullptr; + bool test(); + virtual void suspend(); virtual void resume(); virtual void cancel(); diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 5ab240dd42..d80b853037 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -49,19 +49,6 @@ void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::acti } } -void simcall_HANDLER_execution_test(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* synchro) -{ - bool res = (synchro->state_ != simgrid::kernel::activity::State::WAITING && - synchro->state_ != simgrid::kernel::activity::State::RUNNING); - if (res) { - synchro->simcalls_.push_back(simcall); - synchro->finish(); - } else { - simcall->issuer_->simcall_answer(); - } - simcall_execution_test__set__result(simcall, res); -} - void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execs[], size_t count, double timeout) { diff --git a/src/s4u/s4u_Exec.cpp b/src/s4u/s4u_Exec.cpp index 72ab23817d..f443e16663 100644 --- a/src/s4u/s4u_Exec.cpp +++ b/src/s4u/s4u_Exec.cpp @@ -31,7 +31,7 @@ bool Exec::test() if (state_ == State::INITED || state_ == State::STARTING) this->vetoable_start(); - if (simcall_execution_test(get_impl())) { + if (kernel::actor::simcall([this] { return this->get_impl()->test(); })) { state_ = State::FINISHED; this->release_dependencies(); return true; diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index e66028a699..3c1804b35c 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -35,9 +35,9 @@ e_smx_state_t simcall_execution_wait(simgrid::kernel::activity::ActivityImpl* ex timeout); } -bool simcall_execution_test(simgrid::kernel::activity::ActivityImpl* execution) +bool simcall_execution_test(simgrid::kernel::activity::ActivityImpl* execution) // XBT_ATTRIB_DEPRECATED_v330 { - return simcall_BODY_execution_test(static_cast(execution)); + return simgrid::kernel::actor::simcall([execution] { return execution->test(); }); } unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count, double timeout) diff --git a/src/simix/popping_accessors.hpp b/src/simix/popping_accessors.hpp index 379db02d1e..58ccce4b63 100644 --- a/src/simix/popping_accessors.hpp +++ b/src/simix/popping_accessors.hpp @@ -101,31 +101,6 @@ static inline void simcall_execution_waitany_for__set__result(smx_simcall_t simc simgrid::simix::marshal(simcall->result_, result); } -static inline simgrid::kernel::activity::ExecImpl* simcall_execution_test__get__execution(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->args_[0]); -} -static inline simgrid::kernel::activity::ExecImpl* simcall_execution_test__getraw__execution(smx_simcall_t simcall) -{ - 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) -{ - simgrid::simix::marshal(simcall->args_[0], arg); -} -static inline bool simcall_execution_test__get__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal(simcall->result_); -} -static inline bool simcall_execution_test__getraw__result(smx_simcall_t simcall) -{ - return simgrid::simix::unmarshal_raw(simcall->result_); -} -static inline void simcall_execution_test__set__result(smx_simcall_t simcall, bool result) -{ - simgrid::simix::marshal(simcall->result_, result); -} - static inline smx_actor_t simcall_comm_send__get__sender(smx_simcall_t simcall) { return simgrid::simix::unmarshal(simcall->args_[0]); @@ -1050,7 +1025,6 @@ static inline void simcall_run_blocking__set__code(smx_simcall_t simcall, std::f XBT_PRIVATE void simcall_HANDLER_execution_wait(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl* execution, double timeout); XBT_PRIVATE void simcall_HANDLER_execution_waitany_for(smx_simcall_t simcall, simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout); -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, 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 void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, unsigned char* 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); diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index da28700f09..1975723b5a 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -53,13 +53,6 @@ inline static int simcall_BODY_execution_waitany_for(simgrid::kernel::activity:: return simcall(SIMCALL_EXECUTION_WAITANY_FOR, execs, count, timeout); } -inline static bool simcall_BODY_execution_test(simgrid::kernel::activity::ExecImpl* execution) -{ - if (0) /* Go to that function to follow the code flow through the simcall barrier */ - simcall_HANDLER_execution_test(&SIMIX_process_self()->simcall, execution); - return simcall(SIMCALL_EXECUTION_TEST, execution); -} - inline static void simcall_BODY_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) { if (0) /* Go to that function to follow the code flow through the simcall barrier */ diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 0006e872eb..c73e4ba6cd 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -21,7 +21,6 @@ typedef enum { SIMCALL_NONE, SIMCALL_EXECUTION_WAIT, SIMCALL_EXECUTION_WAITANY_FOR, - SIMCALL_EXECUTION_TEST, SIMCALL_COMM_SEND, SIMCALL_COMM_ISEND, SIMCALL_COMM_RECV, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index 8d4fd42e89..9b73978fbd 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -28,7 +28,6 @@ const char* simcall_names[] = { "SIMCALL_NONE", "SIMCALL_EXECUTION_WAIT", "SIMCALL_EXECUTION_WAITANY_FOR", - "SIMCALL_EXECUTION_TEST", "SIMCALL_COMM_SEND", "SIMCALL_COMM_ISEND", "SIMCALL_COMM_RECV", @@ -70,10 +69,6 @@ void simgrid::kernel::actor::ActorImpl::simcall_handle(int value) { simcall_HANDLER_execution_waitany_for(&simcall, simgrid::simix::unmarshal(simcall.args_[0]), simgrid::simix::unmarshal(simcall.args_[1]), simgrid::simix::unmarshal(simcall.args_[2])); break; - case SIMCALL_EXECUTION_TEST: - simcall_HANDLER_execution_test(&simcall, simgrid::simix::unmarshal(simcall.args_[0])); - break; - case SIMCALL_COMM_SEND: simcall_HANDLER_comm_send(&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])); break; diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index 270b52394d..25687b1496 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -37,7 +37,6 @@ int execution_wait(simgrid::kernel::activity::ExecImpl* execution, double timeout) [[block]]; int execution_waitany_for(simgrid::kernel::activity::ExecImpl** execs, size_t count, double timeout) [[block]]; -bool execution_test(simgrid::kernel::activity::ExecImpl* execution) [[block]]; 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); -- 2.20.1