From acf44fcf33605b66abc4ae2bbeff1459e957e545 Mon Sep 17 00:00:00 2001 From: Sean McGovern Date: Mon, 19 Sep 2022 16:11:57 +0000 Subject: [PATCH] #1941: remove Epoch Stack from ActiveMessenger --- src/vt/context/runnable_context/td.cc | 48 +++++++-------------------- src/vt/messaging/active.cc | 17 ++-------- src/vt/messaging/active.h | 20 ----------- src/vt/messaging/active.impl.h | 44 ++---------------------- src/vt/termination/termination.h | 2 +- 5 files changed, 19 insertions(+), 112 deletions(-) diff --git a/src/vt/context/runnable_context/td.cc b/src/vt/context/runnable_context/td.cc index 00958539db..1337dc37d4 100644 --- a/src/vt/context/runnable_context/td.cc +++ b/src/vt/context/runnable_context/td.cc @@ -62,29 +62,17 @@ TD::TD(EpochType in_ep) } void TD::begin() { - theMsg()->pushEpoch(ep_); + theTerm()->pushEpoch(ep_); - auto& epoch_stack = theMsg()->getEpochStack(); + auto& epoch_stack = theTerm()->getEpochStack(); - vt_debug_print( - verbose, context, - "TD::begin: top={:x}, size={}\n", - epoch_stack.size() > 0 ? epoch_stack.top(): no_epoch, - epoch_stack.size() - ); base_epoch_stack_size_ = epoch_stack.size(); } void TD::end() { - auto& epoch_stack = theMsg()->getEpochStack(); + auto& epoch_stack = theTerm()->getEpochStack(); - vt_debug_print( - verbose, context, - "TD::end: top={:x}, size={}, base_size={}\n", - epoch_stack.size() > 0 ? epoch_stack.top(): no_epoch, - epoch_stack.size(), base_epoch_stack_size_ - ); vtAssert( base_epoch_stack_size_ <= epoch_stack.size(), @@ -92,47 +80,35 @@ void TD::end() { ); while (epoch_stack.size() > base_epoch_stack_size_) { - theMsg()->popEpoch(); + theTerm()->popEpoch(); } - theMsg()->popEpoch(ep_); + theTerm()->popEpoch(ep_); } void TD::suspend() { - auto& epoch_stack = theMsg()->getEpochStack(); + auto& epoch_stack = theTerm()->getEpochStack(); - vt_debug_print( - verbose, context, - "TD::suspend: top={:x}, size={}, base_size={}\n", - epoch_stack.size() > 0 ? epoch_stack.top(): no_epoch, - epoch_stack.size(), base_epoch_stack_size_ - ); while (epoch_stack.size() > base_epoch_stack_size_) { - suspended_epochs_.push_back(theMsg()->getEpoch()); - theMsg()->popEpoch(); + suspended_epochs_.push_back(theTerm()->getEpoch()); + theTerm()->popEpoch(); } - theMsg()->popEpoch(ep_); + theTerm()->popEpoch(ep_); } void TD::resume() { - theMsg()->pushEpoch(ep_); + theTerm()->pushEpoch(ep_); - auto& epoch_stack = theMsg()->getEpochStack(); + auto& epoch_stack = theTerm()->getEpochStack(); base_epoch_stack_size_ = epoch_stack.size(); - vt_debug_print( - verbose, context, - "TD::resume: top={:x}, size={}, base_size={}\n", - epoch_stack.size() > 0 ? epoch_stack.top(): no_epoch, - epoch_stack.size(), base_epoch_stack_size_ - ); for (auto it = suspended_epochs_.rbegin(); it != suspended_epochs_.rend(); ++it) { - theMsg()->pushEpoch(*it); + theTerm()->pushEpoch(*it); } suspended_epochs_.clear(); diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 25db27fabf..ca9570e58c 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -157,6 +157,8 @@ void ActiveMessenger::initialize() { } void ActiveMessenger::startup() { + pushEpoch(term::any_epoch_sentinel); + auto const this_node = theContext()->getNode(); bare_handler_dummy_elm_id_for_lb_data_ = elm::ElmIDBits::createBareHandler(this_node); @@ -171,20 +173,7 @@ void ActiveMessenger::startup() { #endif } -/*virtual*/ ActiveMessenger::~ActiveMessenger() { - // Pop all extraneous epochs off the stack greater than 1 - auto stack_size = epoch_stack_.size(); - while (stack_size > 1) { - stack_size = (epoch_stack_.pop(), epoch_stack_.size()); - } - // Pop off the last epoch: term::any_epoch_sentinel - auto const ret_epoch = popEpoch(term::any_epoch_sentinel); - vtAssertInfo( - ret_epoch == term::any_epoch_sentinel, "Last pop must be any epoch", - ret_epoch, term::any_epoch_sentinel, epoch_stack_.size() - ); - vtAssertExpr(epoch_stack_.size() == 0); -} +/*virtual*/ ActiveMessenger::~ActiveMessenger() {}; trace::TraceEventIDType ActiveMessenger::makeTraceCreationSend( HandlerType const handler, ByteType serialized_msg_size, bool is_bcast diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index 3b50f71b47..2b44025004 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -325,7 +325,6 @@ struct ActiveMessenger : runtime::component::PollableComponent using ReadyHanTagType = std::tuple; using MaybeReadyType = std::vector; using HandlerManagerType = HandlerManager; - using EpochStackType = std::stack; using PendingSendType = PendingSend; /** @@ -1516,17 +1515,6 @@ struct ActiveMessenger : runtime::component::PollableComponent MsgSizeType const& msg_size, TagType const& send_tag ); - /** - * \internal - * \brief Get the current global epoch - * - * \c Returns the top epoch on the stack iff \c epoch_stack.size() > 0, else it - * returns \c vt::no_epoch - * - * \return the current global epoch - */ - inline EpochType getGlobalEpoch() const; - /** * \internal * \brief Push an epoch on the stack @@ -1563,12 +1551,6 @@ struct ActiveMessenger : runtime::component::PollableComponent */ inline EpochType getEpoch() const; - /** - * \internal - * \brief Access the epoch stack - */ - inline EpochStackType& getEpochStack() { return epoch_stack_; } - /** * \internal * \brief Get the epoch for a message based on the current context so an @@ -1644,7 +1626,6 @@ struct ActiveMessenger : runtime::component::PollableComponent | pending_handler_msgs_ | pending_recvs_ | cur_direct_buffer_tag_ - | epoch_stack_ | in_progress_active_msg_irecv | in_progress_data_irecv | in_progress_ops @@ -1755,7 +1736,6 @@ struct ActiveMessenger : runtime::component::PollableComponent ContWaitType pending_handler_msgs_ = {}; ContainerPendingType pending_recvs_ = {}; TagType cur_direct_buffer_tag_ = starting_direct_buffer_tag; - EpochStackType epoch_stack_; RequestHolder in_progress_active_msg_irecv; RequestHolder in_progress_data_irecv; RequestHolder in_progress_ops; diff --git a/src/vt/messaging/active.impl.h b/src/vt/messaging/active.impl.h index 6161b73fe5..705dc17a4e 100644 --- a/src/vt/messaging/active.impl.h +++ b/src/vt/messaging/active.impl.h @@ -445,54 +445,16 @@ ActiveMessenger::PendingSendType ActiveMessenger::broadcastMsgAuto( ); } -inline EpochType ActiveMessenger::getGlobalEpoch() const { - vtAssertInfo( - epoch_stack_.size() > 0, "Epoch stack size must be greater than zero", - epoch_stack_.size() - ); - return epoch_stack_.size() ? epoch_stack_.top() : term::any_epoch_sentinel; -} - inline void ActiveMessenger::pushEpoch(EpochType const& epoch) { - /* - * pushEpoch(epoch) pushes any epoch onto the local stack iff epoch != - * no_epoch; the epoch stack includes all locally pushed epochs and the - * current contexts pushed, transitively causally related active message - * handlers. - */ - vtAssertInfo( - epoch != no_epoch, "Do not push no_epoch onto the epoch stack", - epoch, no_epoch, epoch_stack_.size(), - epoch_stack_.size() > 0 ? epoch_stack_.top() : no_epoch - ); - if (epoch != no_epoch) { - epoch_stack_.push(epoch); - } + return theTerm()->pushEpoch(epoch); } inline EpochType ActiveMessenger::popEpoch(EpochType const& epoch) { - /* - * popEpoch(epoch) shall remove the top entry from epoch_size_, iif the size - * is non-zero and the `epoch' passed, if `epoch != no_epoch', is equal to the - * top of the `epoch_stack_.top()'; else, it shall remove any entry from the - * top of the stack. - */ - auto const& non_zero = epoch_stack_.size() > 0; - vtAssertExprInfo( - non_zero and (epoch_stack_.top() == epoch or epoch == no_epoch), - epoch, non_zero, epoch_stack_.top() - ); - if (epoch == no_epoch) { - return non_zero ? epoch_stack_.pop(),epoch_stack_.top() : no_epoch; - } else { - return non_zero && epoch == epoch_stack_.top() ? - epoch_stack_.pop(),epoch : - no_epoch; - } + return theTerm()->popEpoch(epoch); } inline EpochType ActiveMessenger::getEpoch() const { - return getGlobalEpoch(); + return theTerm()->getEpoch(); } template diff --git a/src/vt/termination/termination.h b/src/vt/termination/termination.h index 4baf0ca292..4c7774f349 100644 --- a/src/vt/termination/termination.h +++ b/src/vt/termination/termination.h @@ -77,7 +77,7 @@ struct EpochStack { void push(DataType in) { stack_[cur_++] = in; } DataType top() const { return stack_[cur_-1]; } void pop() { cur_--; } - int size() const { return cur_; } + unsigned int size() const { return cur_; } int cur_ = 0; std::array stack_;