From 852db4bff154425549ef092e1cd6bce3650e18e3 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Fri, 5 Aug 2022 10:40:43 -0700 Subject: [PATCH 01/27] #1899: context: combine SetContext and FromNode --- src/vt/context/context.cc | 4 +- src/vt/context/runnable_context/from_node.h | 81 ------------------- src/vt/context/runnable_context/set_context.h | 15 +++- src/vt/runnable/make_runnable.h | 7 +- 4 files changed, 17 insertions(+), 90 deletions(-) delete mode 100644 src/vt/context/runnable_context/from_node.h diff --git a/src/vt/context/context.cc b/src/vt/context/context.cc index d18fbb7d07..5215863db1 100644 --- a/src/vt/context/context.cc +++ b/src/vt/context/context.cc @@ -42,7 +42,7 @@ */ #include "vt/context/context.h" -#include "vt/context/runnable_context/from_node.h" +#include "vt/context/runnable_context/set_context.h" #if vt_check_enabled(trace_only) namespace vt { namespace runnable { @@ -111,7 +111,7 @@ void Context::setTask(runnable::RunnableNew* in_task) { NodeType Context::getFromNodeCurrentTask() const { #if !vt_check_enabled(trace_only) if (getTask() != nullptr) { - auto from = getTask()->get(); + auto from = getTask()->get(); if (from != nullptr) { return from->get(); } diff --git a/src/vt/context/runnable_context/from_node.h b/src/vt/context/runnable_context/from_node.h deleted file mode 100644 index 8555ff2bf9..0000000000 --- a/src/vt/context/runnable_context/from_node.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// from_node.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_FROM_NODE_H -#define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_FROM_NODE_H - -#include "vt/context/runnable_context/base.h" - -namespace vt { namespace ctx { - -/** - * \struct FromNode - * - * \brief Get the node that instigated the current task running. Typically the - * logical node that caused an handler or event to run. - */ -struct FromNode final : Base { - - /** - * \brief Construct a \c FromNode - * - * \param[in] in_node the node - */ - explicit FromNode(NodeType const in_node) - : node_(in_node) - { } - - /** - * \brief Get the node that instigated the current task - * - * \return the node - */ - NodeType get() const { return node_; } - -private: - NodeType node_ = uninitialized_destination; /**< The from node */ -}; - -}} /* end namespace vt::ctx */ - -#endif /*INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_FROM_NODE_H*/ diff --git a/src/vt/context/runnable_context/set_context.h b/src/vt/context/runnable_context/set_context.h index 37bb5e2ca0..2fa1c6f8b1 100644 --- a/src/vt/context/runnable_context/set_context.h +++ b/src/vt/context/runnable_context/set_context.h @@ -62,11 +62,21 @@ struct SetContext final : Base { * \brief Construct a \c SetContext * * \param[in] in_nonowning_cur_task the current task (non-owning ptr held) + * \param[in] in_from_node the from node on the message that caused a task to + * run */ - explicit SetContext(runnable::RunnableNew* in_cur_task) - : cur_task_(in_cur_task) + SetContext(runnable::RunnableNew* in_cur_task, NodeType in_from_node) + : cur_task_(in_cur_task), + node_(in_from_node) {} + /** + * \brief Get the node that instigated the current task + * + * \return the node + */ + NodeType get() const { return node_; } + /** * \brief Preserve the existing task and replace with a new one */ @@ -86,6 +96,7 @@ struct SetContext final : Base { util::ObserverPtr prev_task_ = nullptr; /// The new runnable that is replacing it util::ObserverPtr cur_task_ = nullptr; + NodeType node_ = uninitialized_destination; /**< The from node */ }; }} /* end namespace vt::ctx */ diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index 79442c790d..be7d386b89 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -47,7 +47,6 @@ #include "vt/runnable/runnable.h" #include "vt/context/runnable_context/td.h" #include "vt/context/runnable_context/trace.h" -#include "vt/context/runnable_context/from_node.h" #include "vt/context/runnable_context/set_context.h" #include "vt/context/runnable_context/collection.h" #include "vt/context/runnable_context/lb_data.h" @@ -324,8 +323,7 @@ RunnableMaker makeRunnable( han_type == auto_registry::RegistryTypeEnum::RegObjGroup) { r->template addContext(msg, handler, from); } - r->template addContext(from); - r->template addContext(r.get()); + r->template addContext(r.get(), from); return RunnableMaker{std::move(r), msg, handler, from}; } @@ -344,8 +342,7 @@ inline RunnableMaker makeRunnableVoid( // These are currently only types of registry entries that can be void auto r = std::make_unique(is_threaded); // @todo: figure out how to trace this? - r->template addContext(from); - r->template addContext(r.get()); + r->template addContext(r.get(), from); return RunnableMaker{std::move(r), nullptr, handler, from}; } From aadcc8c5572bb5f1cc8dc4f1160c49aac841d7e2 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Fri, 5 Aug 2022 10:35:00 -0700 Subject: [PATCH 02/27] #1899: context: remove template from collection --- src/vt/context/runnable_context/collection.cc | 64 +++++++++++++++++++ src/vt/context/runnable_context/collection.h | 8 ++- .../runnable_context/collection.impl.h | 33 +++------- 3 files changed, 79 insertions(+), 26 deletions(-) create mode 100644 src/vt/context/runnable_context/collection.cc diff --git a/src/vt/context/runnable_context/collection.cc b/src/vt/context/runnable_context/collection.cc new file mode 100644 index 0000000000..9dfe954549 --- /dev/null +++ b/src/vt/context/runnable_context/collection.cc @@ -0,0 +1,64 @@ +/* +//@HEADER +// ***************************************************************************** +// +// collection.cc +// DARMA/vt => Virtual Transport +// +// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact darma@sandia.gov +// +// ***************************************************************************** +//@HEADER +*/ + +#include "vt/context/runnable_context/collection.h" + +namespace vt { namespace ctx { + +void Collection::begin() { + set_(); +} + +void Collection::end() { + clear_(); +} + +void Collection::suspend() { + end(); +} + +void Collection::resume() { + begin(); +} + +}} /* end namespace vt::ctx */ diff --git a/src/vt/context/runnable_context/collection.h b/src/vt/context/runnable_context/collection.h index 7a730fca78..e6039ae782 100644 --- a/src/vt/context/runnable_context/collection.h +++ b/src/vt/context/runnable_context/collection.h @@ -46,6 +46,8 @@ #include "vt/context/runnable_context/base.h" +#include + namespace vt { namespace vrt { namespace collection { template @@ -61,7 +63,6 @@ namespace vt { namespace ctx { * \brief Context for a collection element that is running. Includes the index * and proxy for the collection. */ -template struct Collection final : Base { /** @@ -69,6 +70,7 @@ struct Collection final : Base { * * \param[in] elm the collection element to extract the index and proxy */ + template explicit Collection(vrt::collection::Indexable* elm); /** @@ -85,8 +87,8 @@ struct Collection final : Base { void resume() final override; private: - IndexT idx_ = {}; /**< the collection element index */ - VirtualProxyType proxy_ = no_vrt_proxy; /**< the collection proxy */ + std::function set_; /**< Set context function */ + std::function clear_; /**< Clear context function */ }; }} /* end namespace vt::ctx */ diff --git a/src/vt/context/runnable_context/collection.impl.h b/src/vt/context/runnable_context/collection.impl.h index bffbb35c3a..9a22c23bc4 100644 --- a/src/vt/context/runnable_context/collection.impl.h +++ b/src/vt/context/runnable_context/collection.impl.h @@ -51,30 +51,17 @@ namespace vt { namespace ctx { template -/*explicit*/ Collection::Collection( +/*explicit*/ Collection::Collection( vrt::collection::Indexable* elm -) : idx_(elm->getIndex()), - proxy_(elm->getProxy()) -{ } - -template -void Collection::begin() { - vrt::collection::CollectionContextHolder::set(&idx_, proxy_); -} - -template -void Collection::end() { - vrt::collection::CollectionContextHolder::clear(); -} - -template -void Collection::suspend() { - end(); -} - -template -void Collection::resume() { - begin(); +) { + auto idx_ = elm->getIndex(); + auto proxy_ = elm->getProxy(); + set_ = [=]{ + vrt::collection::CollectionContextHolder::set(&idx_, proxy_); + }; + clear_ = []{ + vrt::collection::CollectionContextHolder::clear(); + }; } }} /* end namespace vt::ctx */ From 888e88e6c54b587684d2217a9a14470e29ccf971 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 7 Sep 2022 10:49:46 -0700 Subject: [PATCH 03/27] #1899: runnable: store contexts directly instead of using pointers --- src/vt/context/runnable_context/collection.h | 2 + .../context/runnable_context/continuation.h | 2 + src/vt/context/runnable_context/lb_data.h | 2 + src/vt/context/runnable_context/set_context.h | 2 + src/vt/context/runnable_context/td.h | 2 + src/vt/context/runnable_context/trace.h | 2 + src/vt/runnable/make_runnable.h | 26 +++--- src/vt/runnable/runnable.cc | 50 +++++++---- src/vt/runnable/runnable.h | 85 +++++++++++++++++-- src/vt/runnable/runnable.impl.h | 57 +++++++++++-- src/vt/vrt/collection/manager.impl.h | 8 ++ 11 files changed, 195 insertions(+), 43 deletions(-) diff --git a/src/vt/context/runnable_context/collection.h b/src/vt/context/runnable_context/collection.h index e6039ae782..6f477cfbde 100644 --- a/src/vt/context/runnable_context/collection.h +++ b/src/vt/context/runnable_context/collection.h @@ -65,6 +65,8 @@ namespace vt { namespace ctx { */ struct Collection final : Base { + Collection() = default; + /** * \brief Construct a \c Collection * diff --git a/src/vt/context/runnable_context/continuation.h b/src/vt/context/runnable_context/continuation.h index 76030d3b9e..6d82f2f138 100644 --- a/src/vt/context/runnable_context/continuation.h +++ b/src/vt/context/runnable_context/continuation.h @@ -55,6 +55,8 @@ namespace vt { namespace ctx { */ struct Continuation final : Base { + Continuation() = default; + /** * \brief Construct a \c Continuation * diff --git a/src/vt/context/runnable_context/lb_data.h b/src/vt/context/runnable_context/lb_data.h index 0ca9a27ad2..10f1bd0269 100644 --- a/src/vt/context/runnable_context/lb_data.h +++ b/src/vt/context/runnable_context/lb_data.h @@ -59,6 +59,8 @@ struct LBData final : Base { using ElementIDStruct = elm::ElementIDStruct; using ElementLBData = elm::ElementLBData; + LBData() = default; + /** * \brief Construct a \c LBData * diff --git a/src/vt/context/runnable_context/set_context.h b/src/vt/context/runnable_context/set_context.h index 2fa1c6f8b1..47613a5a76 100644 --- a/src/vt/context/runnable_context/set_context.h +++ b/src/vt/context/runnable_context/set_context.h @@ -58,6 +58,8 @@ namespace vt { namespace ctx { */ struct SetContext final : Base { + SetContext() = default; + /** * \brief Construct a \c SetContext * diff --git a/src/vt/context/runnable_context/td.h b/src/vt/context/runnable_context/td.h index b991a8760e..c4a726b230 100644 --- a/src/vt/context/runnable_context/td.h +++ b/src/vt/context/runnable_context/td.h @@ -62,6 +62,8 @@ namespace vt { namespace ctx { */ struct TD final : Base { + TD() = default; + /** * \brief Construct with a given epoch; produce on that epoch. * diff --git a/src/vt/context/runnable_context/trace.h b/src/vt/context/runnable_context/trace.h index c63b733832..14ae2561c7 100644 --- a/src/vt/context/runnable_context/trace.h +++ b/src/vt/context/runnable_context/trace.h @@ -60,6 +60,8 @@ namespace vt { namespace ctx { */ struct Trace final : Base { + Trace() = default; + /** * \brief Construct a new trace context (basic processing event) * diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index be7d386b89..a3b66a7c74 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -96,7 +96,7 @@ struct RunnableMaker { * \param[in] cont the continuation */ RunnableMaker&& withContinuation(ActionType cont) { - impl_->template addContext(cont); + impl_->addContextCont(cont); return std::move(*this); } @@ -108,7 +108,7 @@ struct RunnableMaker { */ RunnableMaker&& withTDEpoch(EpochType ep, bool is_term = false) { if (not is_term) { - impl_->template addContext(ep); + impl_->addContextTD(ep); } return std::move(*this); } @@ -120,7 +120,7 @@ struct RunnableMaker { */ RunnableMaker&& withTDEpochFromMsg(bool is_term = false) { if (not is_term) { - impl_->template addContext(msg_); + impl_->addContextTD(msg_); } return std::move(*this); } @@ -144,7 +144,7 @@ struct RunnableMaker { */ template RunnableMaker&& withCollection(ElmT* elm) { - impl_->template addContext>(elm); + impl_->addContextCol(elm); set_handler_ = true; if (handler_ != uninitialized_handler) { @@ -169,7 +169,7 @@ struct RunnableMaker { template RunnableMaker&& withLBData(ElmT* elm, MsgU* msg) { #if vt_check_enabled(lblite) - impl_->template addContext(elm, msg); + impl_->addContextLB(elm, msg); #endif return std::move(*this); } @@ -193,7 +193,7 @@ struct RunnableMaker { template RunnableMaker&& withLBData(LBDataT* lb_data, T elm_id) { #if vt_check_enabled(lblite) - impl_->template addContext(lb_data, elm_id); + impl_->addContextLB(lb_data, elm_id); #endif return std::move(*this); } @@ -206,11 +206,12 @@ struct RunnableMaker { template RunnableMaker&& withLBData(ElmT* elm) { #if vt_check_enabled(lblite) - impl_->template addContext(elm, msg_.get()); + impl_->addContextLB(elm, msg_.get()); #endif return std::move(*this); } +#if vt_check_enabled(trace_enabled) /** * \brief Add a trace index (for collection elements) * @@ -224,11 +225,12 @@ struct RunnableMaker { trace::TraceEventIDType trace_event, uint64_t idx1, uint64_t idx2, uint64_t idx3, uint64_t idx4 ) { - impl_->template addContext( + impl_->addContextTrace( msg_, trace_event, handler_, from_node_, idx1, idx2, idx3, idx4 ); return std::move(*this); } +#endif /** * \brief Add a tag to the handler @@ -317,13 +319,15 @@ RunnableMaker makeRunnable( MsgSharedPtr const& msg, bool is_threaded, HandlerType handler, NodeType from ) { auto r = std::make_unique(msg, is_threaded); +#if vt_check_enabled(trace_enabled) auto const han_type = HandlerManager::getHandlerRegistryType(handler); if (han_type == auto_registry::RegistryTypeEnum::RegVrt or han_type == auto_registry::RegistryTypeEnum::RegGeneral or han_type == auto_registry::RegistryTypeEnum::RegObjGroup) { - r->template addContext(msg, handler, from); + r->addContextTrace(msg, handler, from); } - r->template addContext(r.get(), from); +#endif + r->addContextSetContext(r.get(), from); return RunnableMaker{std::move(r), msg, handler, from}; } @@ -342,7 +346,7 @@ inline RunnableMaker makeRunnableVoid( // These are currently only types of registry entries that can be void auto r = std::make_unique(is_threaded); // @todo: figure out how to trace this? - r->template addContext(r.get(), from); + r->addContextSetContext(r.get(), from); return RunnableMaker{std::move(r), nullptr, handler, from}; } diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index a867cc4d6f..366063b7b2 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -199,33 +199,53 @@ void RunnableNew::run() { } void RunnableNew::begin() { - for (auto&& ctx : contexts_) { - ctx->begin(); - } + contexts_.setcontext.begin(); + if (contexts_.has_td) contexts_.td.begin(); + if (contexts_.has_col) contexts_.col.begin(); + if (contexts_.has_lb) contexts_.lb.begin(); +#if vt_check_enabled(trace_enabled) + if (contexts_.has_trace) contexts_.trace.begin(); +#endif } void RunnableNew::end() { - for (auto&& ctx : contexts_) { - ctx->end(); - } + contexts_.setcontext.end(); + if (contexts_.has_td) contexts_.td.end(); + if (contexts_.has_col) contexts_.col.end(); + if (contexts_.has_lb) contexts_.lb.end(); +#if vt_check_enabled(trace_enabled) + if (contexts_.has_trace) contexts_.trace.end(); +#endif } void RunnableNew::suspend() { - for (auto&& ctx : contexts_) { - ctx->suspend(); - } +#if vt_check_enabled(fcontext) + contexts_.setcontext.suspend(); + if (contexts_.has_td) contexts_.td.suspend(); + if (contexts_.has_col) contexts_.col.suspend(); + if (contexts_.has_lb) contexts_.lb.suspend(); + +# if vt_check_enabled(trace_enabled) + if (contexts_.has_trace) contexts_.trace.suspend(); +# endif +#endif } void RunnableNew::resume() { - for (auto&& ctx : contexts_) { - ctx->resume(); - } +#if vt_check_enabled(fcontext) + contexts_.setcontext.resume(); + if (contexts_.has_td) contexts_.td.resume(); + if (contexts_.has_col) contexts_.col.resume(); + if (contexts_.has_lb) contexts_.lb.resume(); + +# if vt_check_enabled(trace_enabled) + if (contexts_.has_trace) contexts_.trace.resume(); +# endif +#endif } void RunnableNew::send(elm::ElementIDStruct elm, MsgSizeType bytes) { - for (auto&& ctx : contexts_) { - ctx->send(elm, bytes); - } + if (contexts_.has_lb) contexts_.lb.send(elm, bytes); } }} /* end namespace vt::runnable */ diff --git a/src/vt/runnable/runnable.h b/src/vt/runnable/runnable.h index 3634fa7e57..64e667d2ae 100644 --- a/src/vt/runnable/runnable.h +++ b/src/vt/runnable/runnable.h @@ -46,6 +46,12 @@ #include "vt/messaging/message/smart_ptr.h" #include "vt/context/runnable_context/base.h" +#include "vt/context/runnable_context/td.h" +#include "vt/context/runnable_context/trace.h" +#include "vt/context/runnable_context/set_context.h" +#include "vt/context/runnable_context/collection.h" +#include "vt/context/runnable_context/lb_data.h" +#include "vt/context/runnable_context/continuation.h" #include "vt/elm/elm_id.h" // fwd-declarations for the element types @@ -61,6 +67,26 @@ struct UntypedCollection; namespace vt { namespace runnable { +namespace detail { + +struct Contexts { + ctx::SetContext setcontext; + bool has_td = false; + ctx::TD td; + bool has_cont = false; + ctx::Continuation cont; + bool has_col = false; + ctx::Collection col; + bool has_lb = false; + ctx::LBData lb; +#if vt_check_enabled(trace_enabled) + bool has_trace = false; + ctx::Trace trace; +#endif +}; + +} /* end namespace detail */ + /** * \struct RunnableNew * @@ -68,8 +94,6 @@ namespace vt { namespace runnable { * with it to run it independently of the where in the stack it was created. */ struct RunnableNew { - using CtxBasePtr = std::unique_ptr; - template using FnParamType = void(*)(Args...); @@ -101,15 +125,60 @@ struct RunnableNew { public: /** - * \brief Add a new context for this handler + * \brief Add a new \c SetContext for this handler * * \param[in] args arguments to build the context, forwarded to constructor of * \c T */ - template - void addContext(Args&&... args) { - contexts_.emplace_back(std::make_unique(std::forward(args)...)); - } + template + void addContextSetContext(Args&&... args); + + /** + * \brief Add a new \c TD for this handler + * + * \param[in] args arguments to build the context, forwarded to constructor of + * \c T + */ + template + void addContextTD(Args&&... args); + + /** + * \brief Add a new \c Cont for this handler + * + * \param[in] args arguments to build the context, forwarded to constructor of + * \c T + */ + template + void addContextCont(Args&&... args); + + /** + * \brief Add a new \c Col for this handler + * + * \param[in] args arguments to build the context, forwarded to constructor of + * \c T + */ + template + void addContextCol(Args&&... args); + + /** + * \brief Add a new \c LB for this handler + * + * \param[in] args arguments to build the context, forwarded to constructor of + * \c T + */ + template + void addContextLB(Args&&... args); + +#if vt_check_enabled(trace_enabled) + /** + * \brief Add a new \c Trace for this handler + * + * \param[in] args arguments to build the context, forwarded to constructor of + * \c T + */ + template + void addContextTrace(Args&&... args); +#endif /** * \brief Set up a handler to run on an collection object @@ -242,9 +311,9 @@ struct RunnableNew { } private: + detail::Contexts contexts_; /**< The contexts */ MsgSharedPtr msg_ = nullptr; /**< The associated message */ bool is_threaded_ = false; /**< Whether ULTs are supported */ - std::vector contexts_; /**< Vector of contexts */ ActionType task_ = nullptr; /**< The runnable's task */ bool done_ = false; /**< Whether task is complete */ bool suspended_ = false; /**< Whether task is suspended */ diff --git a/src/vt/runnable/runnable.impl.h b/src/vt/runnable/runnable.impl.h index 647cb4660f..d4b3015a6f 100644 --- a/src/vt/runnable/runnable.impl.h +++ b/src/vt/runnable/runnable.impl.h @@ -50,17 +50,56 @@ namespace vt { namespace runnable { -template -T* RunnableNew::get() { - for (auto&& ctx : contexts_) { - auto t = dynamic_cast(ctx.get()); - if (t) { - return t; - } - } - return nullptr; +template <> +inline ctx::SetContext* RunnableNew::get() { + return &contexts_.setcontext; } +template <> +inline ctx::LBData* RunnableNew::get() { + if (contexts_.has_lb) + return &contexts_.lb; + else + return nullptr; +} + +template +void RunnableNew::addContextSetContext(Args&&... args) { + contexts_.setcontext = ctx::SetContext{std::forward(args)...}; +} + +template +void RunnableNew::addContextTD(Args&&... args) { + contexts_.td = ctx::TD{std::forward(args)...}; + contexts_.has_td = true; +} + +template +void RunnableNew::addContextCont(Args&&... args) { + contexts_.cont = ctx::Continuation{std::forward(args)...}; + contexts_.has_cont = true; +} + +template +void RunnableNew::addContextCol(Args&&... args) { + contexts_.col = ctx::Collection{std::forward(args)...}; + contexts_.has_col = true; +} + +template +void RunnableNew::addContextLB(Args&&... args) { + contexts_.lb = ctx::LBData{std::forward(args)...}; + contexts_.has_lb = true; +} + +#if vt_check_enabled(trace_enabled) +template +void RunnableNew::addContextTrace(Args&&... args) { + contexts_.trace = ctx::Trace{std::forward(args)...}; + contexts_.has_trace = true; +} +#endif + }} /* end namespace vt::runnable */ #endif /*INCLUDED_VT_RUNNABLE_RUNNABLE_IMPL_H*/ diff --git a/src/vt/vrt/collection/manager.impl.h b/src/vt/vrt/collection/manager.impl.h index ca2af41855..c43e92354c 100644 --- a/src/vt/vrt/collection/manager.impl.h +++ b/src/vt/vrt/collection/manager.impl.h @@ -213,16 +213,20 @@ CollectionManager::collectionAutoMsgDeliver( // Expand out the index for tracing purposes; Projections takes up to // 4-dimensions +#if vt_check_enabled(trace_enabled) auto idx = base->getIndex(); uint64_t const idx1 = idx.ndims() > 0 ? idx[0] : 0; uint64_t const idx2 = idx.ndims() > 1 ? idx[1] : 0; uint64_t const idx3 = idx.ndims() > 2 ? idx[2] : 0; uint64_t const idx4 = idx.ndims() > 3 ? idx[3] : 0; +#endif runnable::makeRunnable(user_msg, true, han, from) .withTDEpoch(theMsg()->getEpochContextMsg(msg)) .withCollection(base) +#if vt_check_enabled(trace_enabled) .withTraceIndex(event, idx1, idx2, idx3, idx4) +#endif .withLBData(base, msg) .runOrEnqueue(immediate); } @@ -235,17 +239,21 @@ CollectionManager::collectionAutoMsgDeliver( ) { // Expand out the index for tracing purposes; Projections takes up to // 4-dimensions +#if vt_check_enabled(trace_enabled) auto idx = base->getIndex(); uint64_t const idx1 = idx.ndims() > 0 ? idx[0] : 0; uint64_t const idx2 = idx.ndims() > 1 ? idx[1] : 0; uint64_t const idx3 = idx.ndims() > 2 ? idx[2] : 0; uint64_t const idx4 = idx.ndims() > 3 ? idx[3] : 0; +#endif auto m = promoteMsg(msg); runnable::makeRunnable(m, true, han, from) .withTDEpoch(theMsg()->getEpochContextMsg(msg)) .withCollection(base) +#if vt_check_enabled(trace_enabled) .withTraceIndex(event, idx1, idx2, idx3, idx4) +#endif .withLBData(base) .runOrEnqueue(immediate); } From 486e858cd1418741b33a3a21036713da1efb3ee5 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 7 Sep 2022 13:51:06 -0700 Subject: [PATCH 04/27] #1899: runnable: fix TD construct/destruct --- src/vt/context/runnable_context/td.cc | 11 ++--------- src/vt/context/runnable_context/td.h | 5 ----- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/vt/context/runnable_context/td.cc b/src/vt/context/runnable_context/td.cc index 1337dc37d4..a989c0d460 100644 --- a/src/vt/context/runnable_context/td.cc +++ b/src/vt/context/runnable_context/td.cc @@ -50,15 +50,7 @@ namespace vt { namespace ctx { TD::TD(EpochType in_ep) : ep_(in_ep == no_epoch ? term::any_epoch_sentinel : in_ep) { - if (ep_ != no_epoch) { - theTerm()->produce(ep_); - } -} - -/*virtual*/ TD::~TD() { - if (ep_ != no_epoch) { - theTerm()->consume(ep_); - } + theTerm()->produce(ep_); } void TD::begin() { @@ -84,6 +76,7 @@ void TD::end() { } theTerm()->popEpoch(ep_); + theTerm()->consume(ep_); } void TD::suspend() { diff --git a/src/vt/context/runnable_context/td.h b/src/vt/context/runnable_context/td.h index c4a726b230..c15d984558 100644 --- a/src/vt/context/runnable_context/td.h +++ b/src/vt/context/runnable_context/td.h @@ -71,11 +71,6 @@ struct TD final : Base { */ explicit TD(EpochType in_ep); - /** - * \brief When destroyed, consume the epoch held by the context. - */ - virtual ~TD(); - /** * \brief Construct with a message to extract the epoch; produce on that * epoch. From 902a73312927d19863e3f0b621a9786499a0915a Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 7 Sep 2022 14:43:47 -0700 Subject: [PATCH 05/27] #1899: runnable: remove Base class for contexts --- src/vt/context/runnable_context/base.h | 107 ------------------ src/vt/context/runnable_context/collection.h | 12 +- .../context/runnable_context/continuation.h | 6 +- src/vt/context/runnable_context/lb_data.h | 13 +-- src/vt/context/runnable_context/set_context.h | 11 +- src/vt/context/runnable_context/td.h | 11 +- src/vt/context/runnable_context/trace.h | 13 +-- src/vt/runnable/runnable.h | 1 - 8 files changed, 29 insertions(+), 145 deletions(-) delete mode 100644 src/vt/context/runnable_context/base.h diff --git a/src/vt/context/runnable_context/base.h b/src/vt/context/runnable_context/base.h deleted file mode 100644 index b02138a420..0000000000 --- a/src/vt/context/runnable_context/base.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// base.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_BASE_H -#define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_BASE_H - -#include "vt/configs/types/types_type.h" -#include "vt/elm/elm_id.h" - -namespace vt { namespace ctx { - -/** - * \struct Base - * - * \brief Base context for runnable tasks. - * - * \c ctx::Base is used to create contexts that are associated with tasks - * wrapped with the \c runnable::Runnable class. When messages arrive and - * trigger a handler or other actions occur, contexts that inherit from \c Base - * can be used to maintain a particular context when that runnable is passed to - * the scheduler for later execution. The \c begin() and \c end() methods are - * called when the task starts and stops. If VT is built with user-level threads - * (ULTs), \c suspend() and \c resume might be called if the thread that a task - * is running in suspends the stack mid-execution (typically waiting for a - * dependency). Thus, any context is expected to save all state in suspend and - * then return that state back during resume when the ULT is resumed. - * - * \warning Note that contexts should not hold on to a message pointer and read - * values from the message after the \c begin() method is called as the user - * might modify the message or forward it. - */ -struct Base { - - virtual ~Base() = default; - - /** - * \brief Invoked immediately before a task is executed - */ - virtual void begin() {} - - /** - * \brief Invoked immediately after a task is executed - */ - virtual void end() {} - - /** - * \brief Invoked when a task is suspended (for ULTs, when enabled) - */ - virtual void suspend() {} - - /** - * \brief Invoked when a handler is resumed (for ULTs, when enabled) - */ - virtual void resume() {} - - /** - * \brief Invoked when a message is sent to any node - * - * \param[in] dest the destination of the message - * \param[in] size the size of the message - */ - virtual void send(elm::ElementIDStruct dest, MsgSizeType bytes) { } -}; - -}} /* end namespace vt::ctx */ - -#endif /*INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_BASE_H*/ diff --git a/src/vt/context/runnable_context/collection.h b/src/vt/context/runnable_context/collection.h index 6f477cfbde..2a1dd58291 100644 --- a/src/vt/context/runnable_context/collection.h +++ b/src/vt/context/runnable_context/collection.h @@ -44,8 +44,6 @@ #if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_COLLECTION_H #define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_COLLECTION_H -#include "vt/context/runnable_context/base.h" - #include namespace vt { namespace vrt { namespace collection { @@ -63,7 +61,7 @@ namespace vt { namespace ctx { * \brief Context for a collection element that is running. Includes the index * and proxy for the collection. */ -struct Collection final : Base { +struct Collection { Collection() = default; @@ -78,15 +76,15 @@ struct Collection final : Base { /** * \brief Set the collection context */ - void begin() final override; + void begin(); /** * \brief Remove the collection context */ - void end() final override; + void end(); - void suspend() final override; - void resume() final override; + void suspend(); + void resume(); private: std::function set_; /**< Set context function */ diff --git a/src/vt/context/runnable_context/continuation.h b/src/vt/context/runnable_context/continuation.h index 6d82f2f138..40041017fd 100644 --- a/src/vt/context/runnable_context/continuation.h +++ b/src/vt/context/runnable_context/continuation.h @@ -44,8 +44,6 @@ #if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_CONTINUATION_H #define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_CONTINUATION_H -#include "vt/context/runnable_context/base.h" - namespace vt { namespace ctx { /** @@ -53,7 +51,7 @@ namespace vt { namespace ctx { * * \brief A continuation that runs after a task is complete. */ -struct Continuation final : Base { +struct Continuation { Continuation() = default; @@ -69,7 +67,7 @@ struct Continuation final : Base { /** * \brief After the task runs, invoke the continuation if non-null */ - void end() final override { + void end() { if (cont_) { cont_(); } diff --git a/src/vt/context/runnable_context/lb_data.h b/src/vt/context/runnable_context/lb_data.h index 10f1bd0269..78b177a240 100644 --- a/src/vt/context/runnable_context/lb_data.h +++ b/src/vt/context/runnable_context/lb_data.h @@ -44,7 +44,6 @@ #if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_LB_DATA_H #define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_LB_DATA_H -#include "vt/context/runnable_context/base.h" #include "vt/vrt/collection/balance/lb_common.h" #include "vt/elm/elm_lb_data.fwd.h" @@ -55,7 +54,7 @@ namespace vt { namespace ctx { * * \brief Context for collection of LB data when a task runs */ -struct LBData final : Base { +struct LBData { using ElementIDStruct = elm::ElementIDStruct; using ElementLBData = elm::ElementLBData; @@ -85,12 +84,12 @@ struct LBData final : Base { /** * \brief Set the context and timing for a collection task */ - void begin() final override; + void begin(); /** * \brief Remove the context and store timing for a collection task */ - void end() final override; + void end(); /** * \brief Record LB data whenever a message is sent and a collection @@ -99,10 +98,10 @@ struct LBData final : Base { * \param[in] dest the destination of the message * \param[in] size the size of the message */ - void send(elm::ElementIDStruct dest, MsgSizeType bytes) final override; + void send(elm::ElementIDStruct dest, MsgSizeType bytes); - void suspend() final override; - void resume() final override; + void suspend(); + void resume(); /** * \brief Get the current element ID struct for the running context diff --git a/src/vt/context/runnable_context/set_context.h b/src/vt/context/runnable_context/set_context.h index 47613a5a76..6073a1354c 100644 --- a/src/vt/context/runnable_context/set_context.h +++ b/src/vt/context/runnable_context/set_context.h @@ -44,7 +44,6 @@ #if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_SET_CONTEXT_H #define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_SET_CONTEXT_H -#include "vt/context/runnable_context/base.h" #include "vt/runnable/runnable.fwd.h" #include "vt/utils/ptr/observer.h" @@ -56,7 +55,7 @@ namespace vt { namespace ctx { * \brief Set the context of the current running task for query by other * components or users. */ -struct SetContext final : Base { +struct SetContext { SetContext() = default; @@ -82,16 +81,16 @@ struct SetContext final : Base { /** * \brief Preserve the existing task and replace with a new one */ - void begin() final override; + void begin(); /** * \brief Restore the previous existing task to the context (if there was one) */ - void end() final override; + void end(); - void suspend() final override; + void suspend(); - void resume() final override; + void resume(); private: /// The previous runnable that was in the context diff --git a/src/vt/context/runnable_context/td.h b/src/vt/context/runnable_context/td.h index c15d984558..53b99770c5 100644 --- a/src/vt/context/runnable_context/td.h +++ b/src/vt/context/runnable_context/td.h @@ -44,7 +44,6 @@ #if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_TD_H #define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_TD_H -#include "vt/context/runnable_context/base.h" #include "vt/configs/types/types_type.h" #include "vt/configs/types/types_sentinels.h" #include "vt/epoch/epoch_type.h" @@ -60,7 +59,7 @@ namespace vt { namespace ctx { * the epoch stack associated with running tasks. Produces and consumes in the * constructor and destructor to ensure termination is not detected early. */ -struct TD final : Base { +struct TD { TD() = default; @@ -83,26 +82,26 @@ struct TD final : Base { /** * \brief During begin \c TD will capture the epoch stack size and push \c ep_ */ - void begin() final override; + void begin(); /** * \brief During end \c TD will pop all epochs off of the stack down to the * size in captured in \c begin() */ - void end() final override; + void end(); /** * \brief When suspended, \c TD will preserve any epochs pushed on the stack * after begin and restore the stack back to the state before begin was * invoked */ - void suspend() final override; + void suspend(); /** * \brief When resumed, \c TD will restore the stack back from when it was * suspended */ - void resume() final override; + void resume(); private: EpochType ep_ = no_epoch; /**< The epoch for the task */ diff --git a/src/vt/context/runnable_context/trace.h b/src/vt/context/runnable_context/trace.h index 14ae2561c7..8e6e93d30e 100644 --- a/src/vt/context/runnable_context/trace.h +++ b/src/vt/context/runnable_context/trace.h @@ -44,7 +44,6 @@ #if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_TRACE_H #define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_TRACE_H -#include "vt/context/runnable_context/base.h" #include "vt/trace/trace_common.h" #include "vt/messaging/envelope/envelope_get.h" #include "vt/registry/auto/auto_registry_common.h" @@ -58,7 +57,7 @@ namespace vt { namespace ctx { * * \brief Manages tracing a task's execution for outputting logs */ -struct Trace final : Base { +struct Trace { Trace() = default; @@ -102,10 +101,10 @@ struct Trace final : Base { */ trace::TraceEventIDType getEvent() const { return event_; } - void begin() final override; - void end() final override; - void suspend() final override; - void resume() final override; + void begin(); + void end(); + void suspend(); + void resume(); private: /// Whether it's a collection or not @@ -128,7 +127,7 @@ struct Trace final : Base { #else -struct Trace : Base { +struct Trace { template Trace(Args&&... args) {} diff --git a/src/vt/runnable/runnable.h b/src/vt/runnable/runnable.h index 64e667d2ae..48f9403f27 100644 --- a/src/vt/runnable/runnable.h +++ b/src/vt/runnable/runnable.h @@ -45,7 +45,6 @@ #define INCLUDED_VT_RUNNABLE_RUNNABLE_H #include "vt/messaging/message/smart_ptr.h" -#include "vt/context/runnable_context/base.h" #include "vt/context/runnable_context/td.h" #include "vt/context/runnable_context/trace.h" #include "vt/context/runnable_context/set_context.h" From 0192e55bd83f145c6cb387cd910f46092065aa72 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 7 Sep 2022 14:59:51 -0700 Subject: [PATCH 06/27] #1899: runnable: allocate through pool --- src/vt/runnable/runnable.cc | 14 ++++++++++++++ src/vt/runnable/runnable.h | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index 366063b7b2..f6a06244b0 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -248,4 +248,18 @@ void RunnableNew::send(elm::ElementIDStruct elm, MsgSizeType bytes) { if (contexts_.has_lb) contexts_.lb.send(elm, bytes); } +/*static*/ void* RunnableNew::operator new(std::size_t sz) { + return RunnableNewAlloc::runnable->alloc(sz,0); +} + +/*static*/ void RunnableNew::operator delete(void* ptr) { + RunnableNewAlloc::runnable->dealloc(ptr); +} + +/*static*/ +std::unique_ptr> +RunnableNewAlloc::runnable = std::make_unique< + pool::MemoryPoolEqual +>(256); + }} /* end namespace vt::runnable */ diff --git a/src/vt/runnable/runnable.h b/src/vt/runnable/runnable.h index 48f9403f27..a7332e1269 100644 --- a/src/vt/runnable/runnable.h +++ b/src/vt/runnable/runnable.h @@ -51,6 +51,7 @@ #include "vt/context/runnable_context/collection.h" #include "vt/context/runnable_context/lb_data.h" #include "vt/context/runnable_context/continuation.h" +#include "vt/pool/static_sized/memory_pool_equal.h" #include "vt/elm/elm_id.h" // fwd-declarations for the element types @@ -309,6 +310,22 @@ struct RunnableNew { task_ = task_in; } + /** + * \internal \brief Operator new for runnables targeting pool + * + * \param[in] sz the allocation size + * + * \return the new allocation + */ + static void* operator new(std::size_t sz); + + /** + * \internal \brief Operator develop for runnables + * + * \param[in] ptr the pointer + */ + static void operator delete(void* ptr); + private: detail::Contexts contexts_; /**< The contexts */ MsgSharedPtr msg_ = nullptr; /**< The associated message */ @@ -319,6 +336,10 @@ struct RunnableNew { ThreadIDType tid_ = no_thread_id; /**< The thread ID for the task */ }; +struct RunnableNewAlloc { + static std::unique_ptr> runnable; +}; + }} /* end namespace vt::runnable */ #include "vt/runnable/runnable.impl.h" From 2111af5263da6e2d1741ff8be3695cb94e6ed5b4 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 7 Sep 2022 15:04:39 -0700 Subject: [PATCH 07/27] #1899: runnable: use raw pointer for RunnableNew --- src/vt/runnable/make_runnable.h | 20 +++++++++++--------- src/vt/runnable/make_runnable.impl.h | 4 ++-- src/vt/scheduler/base_unit.cc | 1 + src/vt/scheduler/base_unit.h | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index a3b66a7c74..fbe4130bf5 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -73,9 +73,9 @@ struct RunnableMaker { * \param[in] in_from_node the from node for the runnable */ RunnableMaker( - std::unique_ptr in_impl, MsgSharedPtr const& in_msg, + RunnableNew* in_impl, MsgSharedPtr const& in_msg, HandlerType in_handler, NodeType in_from_node - ) : impl_(std::move(in_impl)), + ) : impl_(in_impl), msg_(in_msg), handler_(in_handler), is_void_(in_msg == nullptr), @@ -262,6 +262,8 @@ struct RunnableMaker { void run() { setup(); impl_->run(); + delete impl_; + impl_ = nullptr; is_done_ = true; } @@ -293,7 +295,7 @@ struct RunnableMaker { } private: - std::unique_ptr impl_ = nullptr; + RunnableNew* impl_ = nullptr; MsgSharedPtr msg_ = nullptr; HandlerType handler_ = uninitialized_handler; bool set_handler_ = false; @@ -318,7 +320,7 @@ template RunnableMaker makeRunnable( MsgSharedPtr const& msg, bool is_threaded, HandlerType handler, NodeType from ) { - auto r = std::make_unique(msg, is_threaded); + auto r = new RunnableNew(msg, is_threaded); #if vt_check_enabled(trace_enabled) auto const han_type = HandlerManager::getHandlerRegistryType(handler); if (han_type == auto_registry::RegistryTypeEnum::RegVrt or @@ -327,8 +329,8 @@ RunnableMaker makeRunnable( r->addContextTrace(msg, handler, from); } #endif - r->addContextSetContext(r.get(), from); - return RunnableMaker{std::move(r), msg, handler, from}; + r->addContextSetContext(r, from); + return RunnableMaker{r, msg, handler, from}; } /** @@ -344,10 +346,10 @@ inline RunnableMaker makeRunnableVoid( bool is_threaded, HandlerType handler, NodeType from ) { // These are currently only types of registry entries that can be void - auto r = std::make_unique(is_threaded); + auto r = new RunnableNew(is_threaded); // @todo: figure out how to trace this? - r->addContextSetContext(r.get(), from); - return RunnableMaker{std::move(r), nullptr, handler, from}; + r->addContextSetContext(r, from); + return RunnableMaker{r, nullptr, handler, from}; } }} /* end namespace vt::runnable */ diff --git a/src/vt/runnable/make_runnable.impl.h b/src/vt/runnable/make_runnable.impl.h index a1adcb034c..070aea60fa 100644 --- a/src/vt/runnable/make_runnable.impl.h +++ b/src/vt/runnable/make_runnable.impl.h @@ -53,9 +53,9 @@ template void RunnableMaker::enqueue() { setup(); if (msg_ != nullptr) { - theSched()->enqueue(msg_, std::move(impl_)); + theSched()->enqueue(msg_, impl_); } else { - theSched()->enqueue(std::move(impl_)); + theSched()->enqueue(impl_); } is_done_ = true; } diff --git a/src/vt/scheduler/base_unit.cc b/src/vt/scheduler/base_unit.cc index 2f7901b149..9c89544d36 100644 --- a/src/vt/scheduler/base_unit.cc +++ b/src/vt/scheduler/base_unit.cc @@ -56,6 +56,7 @@ void BaseUnit::execute() { theSched()->suspend(tid, std::move(r_)); } #endif + delete r_; } else if (work_) { work_(); } diff --git a/src/vt/scheduler/base_unit.h b/src/vt/scheduler/base_unit.h index 86519b0d9d..027485e028 100644 --- a/src/vt/scheduler/base_unit.h +++ b/src/vt/scheduler/base_unit.h @@ -58,7 +58,7 @@ namespace vt { namespace sched { * to a runnable or contains a general lambda to execute. */ struct BaseUnit { - using RunnablePtrType = std::unique_ptr; + using RunnablePtrType = runnable::RunnableNew*; BaseUnit() = default; @@ -69,7 +69,7 @@ struct BaseUnit { * \param[in] in_r the runnable moved in */ BaseUnit(bool in_is_term, RunnablePtrType in_r) - : r_(std::move(in_r)), + : r_(in_r), is_term_(in_is_term) { } From 3d03ee5d81a8455c955b3844b38ef99af6abf489 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 12 Sep 2022 14:56:50 -0700 Subject: [PATCH 08/27] #1899: runnable: fix linking problem --- src/vt/runnable/runnable.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index f6a06244b0..7066df9a8c 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -263,3 +263,5 @@ RunnableNewAlloc::runnable = std::make_unique< >(256); }} /* end namespace vt::runnable */ + +#include "vt/pool/static_sized/memory_pool_equal.cc" From f7dbca2b4290ac31fc3a526dbf9d881a4d36f084 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 12 Sep 2022 14:57:05 -0700 Subject: [PATCH 09/27] #1899: runnable: switch to bare pointer --- src/vt/scheduler/scheduler.h | 2 +- src/vt/scheduler/suspended_units.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vt/scheduler/scheduler.h b/src/vt/scheduler/scheduler.h index 4c48cff718..3ed60fa603 100644 --- a/src/vt/scheduler/scheduler.h +++ b/src/vt/scheduler/scheduler.h @@ -114,7 +114,7 @@ struct Scheduler : runtime::component::Component { using TriggerType = std::function; using TriggerContainerType = std::list; using EventTriggerContType = std::vector; - using RunnablePtrType = std::unique_ptr; + using RunnablePtrType = runnable::RunnableNew*; struct SchedulerLoopGuard { SchedulerLoopGuard(Scheduler* scheduler); diff --git a/src/vt/scheduler/suspended_units.h b/src/vt/scheduler/suspended_units.h index ebb7fb5f27..f61aabeddf 100644 --- a/src/vt/scheduler/suspended_units.h +++ b/src/vt/scheduler/suspended_units.h @@ -62,7 +62,7 @@ namespace detail { * until is ready to resume */ struct SuspendedRunnable { - using RunnablePtrType = std::unique_ptr; + using RunnablePtrType = runnable::RunnableNew*; /** * \brief Construct a new suspended runnable @@ -90,7 +90,7 @@ struct SuspendedRunnable { * calls \c resumeRunnable on it with the appropriate thread ID. */ struct SuspendedUnits { - using RunnablePtrType = std::unique_ptr; + using RunnablePtrType = runnable::RunnableNew*; /** * \brief Add a suspended runnable that is running in a thread From 9f99fe313569aa982c3d27b2b934f435dcccb04f Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 12 Sep 2022 15:40:28 -0700 Subject: [PATCH 10/27] #1899: registry: completely remove old manual registry --- docs/md/registry.md | 4 - src/vt/collective/collective_ops.cc | 5 - src/vt/collective/collective_ops.h | 3 - src/vt/collective/reduce/reduce.impl.h | 1 - src/vt/messaging/active.cc | 153 ++-------------- src/vt/messaging/active.h | 95 +--------- src/vt/registry/auto/auto_registry.cc | 1 - src/vt/registry/auto/auto_registry.h | 1 - src/vt/registry/auto/auto_registry_common.h | 5 +- .../registry/auto/auto_registry_interface.h | 1 - .../collection/auto_registry_collection.h | 1 - .../auto/functor/auto_registry_functor.h | 1 - .../registry/auto/index/auto_registry_index.h | 1 - .../auto/index/auto_registry_index.impl.h | 1 - .../auto/index/auto_registry_index_reg.h | 1 - src/vt/registry/auto/map/auto_registry_map.h | 1 - .../registry/auto/rdma/auto_registry_rdma.h | 1 - src/vt/registry/auto/vc/auto_registry_vc.h | 1 - src/vt/registry/registry.cc | 132 -------------- src/vt/registry/registry.h | 169 ------------------ src/vt/runnable/runnable.cc | 6 +- src/vt/runtime/runtime.cc | 14 +- src/vt/runtime/runtime.h | 1 - src/vt/runtime/runtime_component_fwd.h | 3 - src/vt/runtime/runtime_get.cc | 2 - src/vt/transport.h | 1 - 26 files changed, 23 insertions(+), 582 deletions(-) delete mode 100644 src/vt/registry/registry.cc delete mode 100644 src/vt/registry/registry.h diff --git a/docs/md/registry.md b/docs/md/registry.md index 8ab467020d..6d257faa4d 100644 --- a/docs/md/registry.md +++ b/docs/md/registry.md @@ -1,10 +1,6 @@ \page registry Registry \brief Registered handlers -The registry component `vt::registry::Registry`, accessed via -`vt::theRegistry()` holds type-safe active handlers for execution across a -distributed machine. - - The \ref active-messenger uses the registry to store/dispatch active function and active functor handlers. - The \ref objgroup uses the registry to store/dispatch active member diff --git a/src/vt/collective/collective_ops.cc b/src/vt/collective/collective_ops.cc index 0d38a2a8cd..9f392b93a1 100644 --- a/src/vt/collective/collective_ops.cc +++ b/src/vt/collective/collective_ops.cc @@ -334,11 +334,6 @@ void CollectiveAnyOps::output( } } -template -HandlerType CollectiveAnyOps::registerHandler(ActiveClosureFnType fn) { - return theRegistry()->registerActiveHandler(fn); -} - template struct CollectiveAnyOps; } /* end namespace vt */ diff --git a/src/vt/collective/collective_ops.h b/src/vt/collective/collective_ops.h index 849ac3a6a7..2a9d17dc5f 100644 --- a/src/vt/collective/collective_ops.h +++ b/src/vt/collective/collective_ops.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/context/context.h" #include "vt/runtime/runtime_headers.h" -#include "vt/registry/registry.h" #include @@ -77,8 +76,6 @@ struct CollectiveAnyOps { bool error = false, bool decorate = true, bool formatted = false, bool abort_out = false ); - - static HandlerType registerHandler(ActiveClosureFnType fn); }; using CollectiveOps = CollectiveAnyOps; diff --git a/src/vt/collective/reduce/reduce.impl.h b/src/vt/collective/reduce/reduce.impl.h index ae957bc12c..0a2724d38d 100644 --- a/src/vt/collective/reduce/reduce.impl.h +++ b/src/vt/collective/reduce/reduce.impl.h @@ -46,7 +46,6 @@ #include "vt/config.h" #include "vt/collective/collective_alg.h" -#include "vt/registry/registry.h" #include "vt/registry/auto/auto_registry_interface.h" #include "vt/messaging/active.h" #include "vt/messaging/message.h" diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index b5c7de42dc..dc2186ecbc 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -890,7 +890,7 @@ bool ActiveMessenger::recvDataMsg( ); } -bool ActiveMessenger::processActiveMsg( +void ActiveMessenger::processActiveMsg( MsgSharedPtr const& base, NodeType const& from, bool insert, ActionType cont ) { @@ -913,18 +913,17 @@ bool ActiveMessenger::processActiveMsg( } if (deliver) { - return prepareActiveMsgToRun(base,from,insert,cont); + prepareActiveMsgToRun(base,from,insert,cont); } else { amForwardCounterGauge.incrementUpdate(base.size(), 1); if (cont != nullptr) { cont(); } - return false; } } -bool ActiveMessenger::prepareActiveMsgToRun( +void ActiveMessenger::prepareActiveMsgToRun( MsgSharedPtr const& base, NodeType const& in_from_node, bool insert, ActionType cont ) { @@ -950,11 +949,6 @@ bool ActiveMessenger::prepareActiveMsgToRun( ); } - bool const is_auto = HandlerManagerType::isHandlerAuto(handler); - bool const is_obj = HandlerManagerType::isHandlerObjGroup(handler); - bool has_handler = - (is_obj or is_auto) or theRegistry()->getHandler(handler, tag) != nullptr; - if (!is_term || vt_check_enabled(print_term_msgs)) { vt_debug_print( normal, active, @@ -965,41 +959,22 @@ bool ActiveMessenger::prepareActiveMsgToRun( ); } - if (has_handler) { - runnable::makeRunnable(base, not is_term, handler, from_node) - .withContinuation(cont) - .withTag(tag) - .withTDEpochFromMsg(is_term) - .withLBData(&bare_handler_lb_data_, bare_handler_dummy_elm_id_for_lb_data_) - .enqueue(); - - if (is_term) { - tdRecvCount.increment(1); - } - amHandlerCount.increment(1); + runnable::makeRunnable(base, not is_term, handler, from_node) + .withContinuation(cont) + .withTag(tag) + .withTDEpochFromMsg(is_term) + .withLBData(&bare_handler_lb_data_, bare_handler_dummy_elm_id_for_lb_data_) + .enqueue(); - if (not is_term) { - theTerm()->consume(epoch,1,in_from_node); - theTerm()->hangDetectRecv(); - } - } else { - if (insert) { - auto iter = pending_handler_msgs_.find(handler); - if (iter == pending_handler_msgs_.end()) { - pending_handler_msgs_.emplace( - std::piecewise_construct, - std::forward_as_tuple(handler), - std::forward_as_tuple( - MsgContType{BufferedMsgType{base,from_node,cont}} - ) - ); - } else { - iter->second.push_back(BufferedMsgType{base,from_node,cont}); - } - } + if (is_term) { + tdRecvCount.increment(1); } + amHandlerCount.increment(1); - return has_handler; + if (not is_term) { + theTerm()->consume(epoch,1,in_from_node); + theTerm()->hangDetectRecv(); + } } bool ActiveMessenger::tryProcessIncomingActiveMsg() { @@ -1176,7 +1151,6 @@ bool ActiveMessenger::testPendingAsyncOps() { int ActiveMessenger::progress(TimeType current_time) { bool const started_irecv_active_msg = tryProcessIncomingActiveMsg(); bool const started_irecv_data_msg = tryProcessDataMsgRecv(); - processMaybeReadyHanTag(); bool const received_active_msg = testPendingActiveMsgAsyncRecv(); bool const received_data_msg = testPendingDataMsgAsyncRecv(); bool const general_async = testPendingAsyncOps(); @@ -1185,101 +1159,6 @@ int ActiveMessenger::progress(TimeType current_time) { received_active_msg or received_data_msg or general_async; } -void ActiveMessenger::processMaybeReadyHanTag() { - decltype(maybe_ready_tag_han_) maybe_ready = maybe_ready_tag_han_; - // Clear first so clearing doesn't happen after new entries may be added by an - // active message arriving - maybe_ready_tag_han_.clear(); - for (auto&& x : maybe_ready) { - deliverPendingMsgsHandler(std::get<0>(x), std::get<1>(x)); - } -} - -HandlerType ActiveMessenger::registerNewHandler( - ActiveClosureFnType fn, TagType const& tag -) { - return theRegistry()->registerNewHandler(fn, tag); -} - -HandlerType ActiveMessenger::collectiveRegisterHandler( - ActiveClosureFnType fn, TagType const& tag -) { - return theRegistry()->registerActiveHandler(fn, tag); -} - -void ActiveMessenger::swapHandlerFn( - HandlerType const han, ActiveClosureFnType fn, TagType const& tag -) { - vt_debug_print( - verbose, active, - "swapHandlerFn: han={}, tag={}\n", han, tag - ); - - theRegistry()->swapHandler(han, fn, tag); - - if (fn != nullptr) { - maybe_ready_tag_han_.push_back(ReadyHanTagType{han,tag}); - } -} - -void ActiveMessenger::deliverPendingMsgsHandler( - HandlerType const han, TagType const& tag -) { - vt_debug_print( - normal, active, - "deliverPendingMsgsHandler: han={}, tag={}\n", han, tag - ); - auto iter = pending_handler_msgs_.find(han); - if (iter != pending_handler_msgs_.end()) { - if (iter->second.size() > 0) { - for (auto cur = iter->second.begin(); cur != iter->second.end(); ) { - vt_debug_print( - verbose, active, - "deliverPendingMsgsHandler: msg={}, from={}\n", - print_ptr(cur->buffered_msg.get()), cur->from_node - ); - if ( - prepareActiveMsgToRun( - cur->buffered_msg, cur->from_node, false, cur->cont - ) - ) { - cur = iter->second.erase(cur); - } else { - ++cur; - } - } - } else { - pending_handler_msgs_.erase(iter); - } - } -} - -void ActiveMessenger::registerHandlerFn( - HandlerType const han, ActiveClosureFnType fn, TagType const& tag -) { - vt_debug_print( - verbose, active, - "registerHandlerFn: han={}, tag={}\n", han, tag - ); - - swapHandlerFn(han, fn, tag); - - if (fn != nullptr) { - maybe_ready_tag_han_.push_back(ReadyHanTagType{han,tag}); - } -} - -void ActiveMessenger::unregisterHandlerFn( - HandlerType const han, TagType const& tag -) { - vt_debug_print( - verbose, active, - "unregisterHandlerFn: han={}, tag={}\n", han, tag - ); - - return theRegistry()->unregisterHandlerFn(han, tag); -} - void ActiveMessenger::registerAsyncOp(std::unique_ptr in) { in_progress_ops.emplace(AsyncOpWrapper{std::move(in)}); } diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index 2b44025004..49aa04b43f 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -57,7 +57,6 @@ #include "vt/messaging/send_info.h" #include "vt/messaging/async_op_wrapper.h" #include "vt/event/event.h" -#include "vt/registry/registry.h" #include "vt/registry/auto/auto_registry_interface.h" #include "vt/trace/trace_common.h" #include "vt/utils/static_checks/functor.h" @@ -320,10 +319,7 @@ struct ActiveMessenger : runtime::component::PollableComponent using SendFnType = std::function; using UserSendFnType = std::function; using ContainerPendingType = std::unordered_map; - using MsgContType = std::list; - using ContWaitType = std::unordered_map; using ReadyHanTagType = std::tuple; - using MaybeReadyType = std::vector; using HandlerManagerType = HandlerManager; using PendingSendType = PendingSend; @@ -1354,65 +1350,6 @@ struct ActiveMessenger : runtime::component::PollableComponent */ int progress(TimeType current_time) override; - /** - * \internal - * \brief Register a bare handler - * - * \param[in] fn the function to register - * \param[in] tag the tag this handler will accept (\c vt::no_tag means any) - * - * \return the handler ID - */ - HandlerType registerNewHandler( - ActiveClosureFnType fn, TagType const& tag = no_tag - ); - - /** - * \internal - * \brief Swap the underlying handler function pointer - * - * \param[in] han the handler to swap function pointers - * \param[in] fn the new function pointer - * \param[in] tag the tag this handler will accept (\c vt::no_tag means any) - */ - void swapHandlerFn( - HandlerType const han, ActiveClosureFnType fn, TagType const& tag = no_tag - ); - - /** - * \internal - * \brief Un-register a bare handler - * - * \param[in] han the handler to de-register - * \param[in] tag the tag this handler will accept (\c vt::no_tag means any) - */ - void unregisterHandlerFn(HandlerType const han, TagType const& tag = no_tag); - - /** - * \internal - * \brief Register a handler function for existing handler - * - * \param[in] han the handler to swap function pointers - * \param[in] fn the new function pointer - * \param[in] tag the tag this handler will accept (\c vt::no_tag means any) - */ - void registerHandlerFn( - HandlerType const han, ActiveClosureFnType fn, TagType const& tag = no_tag - ); - - /** - * \internal - * \brief Register an active handler (collective) - * - * \param[in] fn the function pointer for the handler - * \param[in] tag the tag this handler will accept (\c vt::no_tag means any) - * - * \return the handler ID - */ - HandlerType collectiveRegisterHandler( - ActiveClosureFnType fn, TagType const& tag = no_tag - ); - /** * \internal * \brief Process an incoming active message @@ -1425,10 +1362,8 @@ struct ActiveMessenger : runtime::component::PollableComponent * \param[in] sender the sender of the message * \param[in] insert whether to insert the message if handler does not exist * \param[in] cont continuation after message is processed - * - * \return whether it was delivered locally */ - bool processActiveMsg( + void processActiveMsg( MsgSharedPtr const& base, NodeType const& sender, bool insert, ActionType cont = nullptr ); @@ -1441,32 +1376,12 @@ struct ActiveMessenger : runtime::component::PollableComponent * \param[in] from_node the node the message came from * \param[in] insert whether to insert the message if handler does not exist * \param[in] cont continuation after message is processed - * - * \return whether the message was delivered, false when handler does not exist */ - bool prepareActiveMsgToRun( + void prepareActiveMsgToRun( MsgSharedPtr const& base, NodeType const& from_node, bool insert, ActionType cont ); - /** - * \internal - * \brief Deliver pending messaging waiting for a handler to be registered - * - * \param[in] han the handler that will now accept - * \param[in] tag the tag for that handler - */ - void deliverPendingMsgsHandler( - HandlerType const han, TagType const& tag = no_tag - ); - - /** - * \internal - * \brief Process any messages that might be ready now (handler is now - * registered) - */ - void processMaybeReadyHanTag(); - /** * \internal * \brief Send message as low-level bytes after packing put bytes if needed @@ -1622,9 +1537,7 @@ struct ActiveMessenger : runtime::component::PollableComponent template void serialize(SerializerT& s) { - s | maybe_ready_tag_han_ - | pending_handler_msgs_ - | pending_recvs_ + s | pending_recvs_ | cur_direct_buffer_tag_ | in_progress_active_msg_irecv | in_progress_data_irecv @@ -1732,8 +1645,6 @@ struct ActiveMessenger : runtime::component::PollableComponent trace::UserEventIDType trace_asyncop = trace::no_user_event_id; # endif - MaybeReadyType maybe_ready_tag_han_ = {}; - ContWaitType pending_handler_msgs_ = {}; ContainerPendingType pending_recvs_ = {}; TagType cur_direct_buffer_tag_ = starting_direct_buffer_tag; RequestHolder in_progress_active_msg_irecv; diff --git a/src/vt/registry/auto/auto_registry.cc b/src/vt/registry/auto/auto_registry.cc index 9eceda1d16..6cdb9f0176 100644 --- a/src/vt/registry/auto/auto_registry.cc +++ b/src/vt/registry/auto/auto_registry.cc @@ -44,7 +44,6 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" #include "vt/registry/auto/auto_registry_interface.h" -#include "vt/registry/registry.h" #include diff --git a/src/vt/registry/auto/auto_registry.h b/src/vt/registry/auto/auto_registry.h index fef2832a5a..36362d1bb3 100644 --- a/src/vt/registry/auto/auto_registry.h +++ b/src/vt/registry/auto/auto_registry.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" #include "vt/registry/auto/auto_registry_general.h" -#include "vt/registry/registry.h" #include "vt/trace/trace.h" #include "vt/utils/demangle/demangle.h" diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index 52140ee1aa..d8eb56b66b 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -44,11 +44,10 @@ #if !defined INCLUDED_VT_REGISTRY_AUTO_AUTO_REGISTRY_COMMON_H #define INCLUDED_VT_REGISTRY_AUTO_AUTO_REGISTRY_COMMON_H -#include "vt/trace/trace_event.h" - #include "vt/config.h" +#include "vt/handler/handler.h" +#include "vt/trace/trace_event.h" #include "vt/activefn/activefn.h" -#include "vt/registry/registry.h" #include "vt/trace/trace.h" #include "vt/vrt/context/context_vrt_funcs.h" #include "vt/vrt/collection/active/active_funcs.h" diff --git a/src/vt/registry/auto/auto_registry_interface.h b/src/vt/registry/auto/auto_registry_interface.h index 11ef7d538c..5b1fb6dc70 100644 --- a/src/vt/registry/auto/auto_registry_interface.h +++ b/src/vt/registry/auto/auto_registry_interface.h @@ -46,7 +46,6 @@ #include "vt/registry/auto/auto_registry_common.h" #include "vt/config.h" -#include "vt/registry/registry.h" namespace vt { namespace auto_registry { diff --git a/src/vt/registry/auto/collection/auto_registry_collection.h b/src/vt/registry/auto/collection/auto_registry_collection.h index 742b46e1db..d025a07646 100644 --- a/src/vt/registry/auto/collection/auto_registry_collection.h +++ b/src/vt/registry/auto/collection/auto_registry_collection.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" #include "vt/registry/auto/auto_registry_general.h" -#include "vt/registry/registry.h" #include "vt/activefn/activefn.h" #include "vt/vrt/collection/active/active_funcs.h" diff --git a/src/vt/registry/auto/functor/auto_registry_functor.h b/src/vt/registry/auto/functor/auto_registry_functor.h index a69d2ae43c..79c1221afe 100644 --- a/src/vt/registry/auto/functor/auto_registry_functor.h +++ b/src/vt/registry/auto/functor/auto_registry_functor.h @@ -46,7 +46,6 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" -#include "vt/registry/registry.h" #include #include diff --git a/src/vt/registry/auto/index/auto_registry_index.h b/src/vt/registry/auto/index/auto_registry_index.h index d5d1029fbf..13a5415ec4 100644 --- a/src/vt/registry/auto/index/auto_registry_index.h +++ b/src/vt/registry/auto/index/auto_registry_index.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" #include "vt/registry/auto/auto_registry_general.h" -#include "vt/registry/registry.h" namespace vt { namespace auto_registry { diff --git a/src/vt/registry/auto/index/auto_registry_index.impl.h b/src/vt/registry/auto/index/auto_registry_index.impl.h index 79289b124b..1ca22c5a14 100644 --- a/src/vt/registry/auto/index/auto_registry_index.impl.h +++ b/src/vt/registry/auto/index/auto_registry_index.impl.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" #include "vt/registry/auto/auto_registry_general.h" -#include "vt/registry/registry.h" #include "vt/registry/auto/index/auto_registry_index.h" #include "vt/registry/auto/index/auto_registry_index_reg.h" diff --git a/src/vt/registry/auto/index/auto_registry_index_reg.h b/src/vt/registry/auto/index/auto_registry_index_reg.h index 19220b8a7a..36fbe6833d 100644 --- a/src/vt/registry/auto/index/auto_registry_index_reg.h +++ b/src/vt/registry/auto/index/auto_registry_index_reg.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" #include "vt/registry/auto/auto_registry_general.h" -#include "vt/registry/registry.h" namespace vt { namespace auto_registry { diff --git a/src/vt/registry/auto/map/auto_registry_map.h b/src/vt/registry/auto/map/auto_registry_map.h index 4585f0995c..c81213f476 100644 --- a/src/vt/registry/auto/map/auto_registry_map.h +++ b/src/vt/registry/auto/map/auto_registry_map.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" #include "vt/registry/auto/auto_registry_general.h" -#include "vt/registry/registry.h" #include "vt/topos/mapping/mapping_function.h" diff --git a/src/vt/registry/auto/rdma/auto_registry_rdma.h b/src/vt/registry/auto/rdma/auto_registry_rdma.h index 04ed7a0ee6..162d19a8a5 100644 --- a/src/vt/registry/auto/rdma/auto_registry_rdma.h +++ b/src/vt/registry/auto/rdma/auto_registry_rdma.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" #include "vt/registry/auto/auto_registry_general.h" -#include "vt/registry/registry.h" #include "vt/activefn/activefn.h" #include "vt/vrt/collection/active/active_funcs.h" diff --git a/src/vt/registry/auto/vc/auto_registry_vc.h b/src/vt/registry/auto/vc/auto_registry_vc.h index a5850eb8dd..05c5d1d70a 100644 --- a/src/vt/registry/auto/vc/auto_registry_vc.h +++ b/src/vt/registry/auto/vc/auto_registry_vc.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" #include "vt/registry/auto/auto_registry_general.h" -#include "vt/registry/registry.h" #include "vt/activefn/activefn.h" #include "vt/vrt/context/context_vrt_funcs.h" diff --git a/src/vt/registry/registry.cc b/src/vt/registry/registry.cc deleted file mode 100644 index ddf67052ed..0000000000 --- a/src/vt/registry/registry.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// registry.cc -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#include "vt/config.h" -#include "vt/registry/registry.h" - -namespace vt { namespace registry { - -HandlerType Registry::registerNewHandler( - ActiveClosureFnType fn, TagType const& tag, bool const& is_collective -) { - HandlerType new_handle = 0; - HandlerIdentifierType const& new_identifier = - is_collective ? cur_ident_collective_++ : cur_ident_++; - - HandlerManagerType::setHandlerIdentifier(new_handle, new_identifier); - - if (tag == no_tag) { - registered_[new_handle] = fn; - } else { - tagged_registered_[new_handle][tag] = fn; - } - - return new_handle; -} - -void Registry::swapHandler( - HandlerType const han, ActiveClosureFnType fn, TagType const& tag -) { - if (tag == no_tag) { - auto iter = registered_.find(han); - vtAssert( - iter != registered_.end(), "Handler must be registered" - ); - iter->second = fn; - } else { - if (fn == nullptr) { - auto tag_iter = tagged_registered_[han].find(tag); - if (tag_iter != tagged_registered_[han].end()) { - tagged_registered_[han].erase(tag_iter); - if (tagged_registered_[han].size() == 0) { - tagged_registered_.erase(tagged_registered_.find(han)); - } - } - } else { - tagged_registered_[han][tag] = fn; - } - } -} - -void Registry::unregisterHandlerFn( - HandlerType const han, TagType const& tag -) { - swapHandler(han, nullptr, tag); -} - -HandlerType Registry::registerActiveHandler( - ActiveClosureFnType fn, TagType const& tag -) { - return registerNewHandler(fn, tag, true); -} - -ActiveClosureFnType Registry::getHandlerNoTag(HandlerType const han) { - auto iter = registered_.find(han); - if (iter != registered_.end()) { - return iter->second; - } else { - return nullptr; - } -} - -ActiveClosureFnType Registry::getHandler( - HandlerType const han, TagType const& tag -) { - if (tag == no_tag) { - return getHandlerNoTag(han); - } else { - auto tag_iter = tagged_registered_.find(han); - if (tag_iter == tagged_registered_.end()) { - return getHandlerNoTag(han); - } else { - auto iter = tag_iter->second.find(tag); - if (iter != tag_iter->second.end()) { - return iter->second; - } else { - return getHandlerNoTag(han); - } - } - } -} - -}} //end namespace vt::registry diff --git a/src/vt/registry/registry.h b/src/vt/registry/registry.h deleted file mode 100644 index bcd79f0670..0000000000 --- a/src/vt/registry/registry.h +++ /dev/null @@ -1,169 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// registry.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_REGISTRY_REGISTRY_H -#define INCLUDED_VT_REGISTRY_REGISTRY_H - -#include -#include -#include - -#include "vt/config.h" -#include "vt/activefn/activefn.h" -#include "vt/handler/handler.h" -#include "vt/runtime/component/component.h" - -namespace vt { namespace registry { - -/** - * \struct Registry - * - * \brief A VT component that manages registered active handlers. - */ -struct Registry : runtime::component::Component { - using HandlerManagerType = HandlerManager; - using HandlerBitsType = eHandlerBits; - using TaggerHandlerType = std::tuple; - using ContainerType = std::unordered_map; - using TagContainerType = std::unordered_map; - using HanTagContainerType = std::unordered_map; - - /** - * \internal \brief System call to construct a registry - */ - Registry() = default; - - std::string name() override { return "Registry"; } - - /** - * \brief Register a new handler - * - * \param[in] fn the active function pointer - * \param[in] tag relevant message tag for delivery - * \param[in] is_collective whether it's a collective registration - * - * \return the handler ID - */ - HandlerType registerNewHandler( - ActiveClosureFnType fn, TagType const& tag = no_tag, - bool const& is_collective = false - ); - - /** - * \brief Unregister a handler - * - * \param[in] han the handler ID - * \param[in] tag relevant message tag for delivery - */ - void unregisterHandlerFn( - HandlerType const han, TagType const& tag = no_tag - ); - - /** - * \brief Swap underlying handler out for registered handler ID - * - * \param[in] han the handler ID - * \param[in] fn the active function to attach - * \param[in] tag tag to associate - */ - void swapHandler( - HandlerType const han, ActiveClosureFnType fn, TagType const& tag = no_tag - ); - - /** - * \brief Registry an active handler - * - * \param[in] fn the active handler - * \param[in] tag relevant message tag - * - * \return the handler ID - */ - HandlerType registerActiveHandler( - ActiveClosureFnType fn, TagType const& tag = no_tag - ); - - /** - * \brief Get active function for handler - * - * \param[in] han the handler ID - * \param[in] tag the relevant tag - * - * \return the active function - */ - ActiveClosureFnType getHandler( - HandlerType const han, TagType const& tag = no_tag - ); - - /** - * \brief Get active function for handler - * - * \param[in] han the handler ID - * - * \return the active function - */ - ActiveClosureFnType getHandlerNoTag(HandlerType const han); - - template - void serialize(SerializerT& s) { - s | registered_ - | tagged_registered_ - | cur_ident_collective_ - | cur_ident_; - } - -private: - ContainerType registered_; - HanTagContainerType tagged_registered_; - HandlerIdentifierType cur_ident_collective_ = first_handle_identifier; - HandlerIdentifierType cur_ident_ = first_handle_identifier; -}; - -}} //end namespace vt::registry - -namespace vt { - -extern registry::Registry* theRegistry(); - -} // end namespace vt - -#endif /*INCLUDED_VT_REGISTRY_REGISTRY_H*/ diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index 7066df9a8c..4f54bbd4c1 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -75,7 +75,7 @@ void RunnableNew::setupHandler(HandlerType handler, bool is_void, TagType tag) { } return; - } else if (is_auto) { + } else { bool const is_base_msg_derived = HandlerManagerType::isHandlerBaseMsgDerived(handler); if (is_base_msg_derived) { @@ -87,10 +87,6 @@ void RunnableNew::setupHandler(HandlerType handler, bool is_void, TagType tag) { auto const& func = auto_registry::getScatterAutoHandler(handler); task_ = [=, &func] { func->dispatch(msg_.get(), nullptr); }; return; - } else { - auto typed_func = theRegistry()->getHandler(handler, tag); - task_ = [=] { typed_func(msg_.get()); }; - return; } } } else { diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index fcaa3812c9..48a23db6a0 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -45,7 +45,6 @@ #include "vt/runtime/runtime.h" #include "vt/context/context.h" #include "vt/context/context_attorney.h" -#include "vt/registry/registry.h" #include "vt/messaging/active.h" #include "vt/event/event.h" #include "vt/termination/termination.h" @@ -680,10 +679,6 @@ void Runtime::initializeComponents() { phase::PhaseManager // For outputting memory at phase boundaries >{}); - p_->registerComponent(&theRegistry, Deps< - ctx::Context // Everything depends on theContext - >{}); - p_->registerComponent(&thePool, Deps< ctx::Context // Everything depends on theContext >{}); @@ -730,8 +725,7 @@ void Runtime::initializeComponents() { # endif ctx::Context, // Everything depends on theContext event::AsyncEvent, // Depends on event to send messages - pool::Pool, // Depends on pool for message allocation - registry::Registry // Depends on registry for handlers + pool::Pool // Depends on pool for message allocation >{} ); @@ -887,7 +881,6 @@ void Runtime::initializeComponents() { p_->add(); p_->add(); p_->add(); - p_->add(); p_->add(); p_->add(); # if vt_check_enabled(trace_enabled) @@ -909,7 +902,6 @@ void Runtime::initializeComponents() { p_->add(); p_->add(); p_->add(); - p_->add(); p_->add(); p_->add(); p_->add(); @@ -1112,10 +1104,6 @@ void Runtime::printMemoryFootprint() const { printComponentFootprint( static_cast(base) ); - } else if (name == "Registry") { - printComponentFootprint( - static_cast(base) - ); } else if (name == "Scheduler") { printComponentFootprint( static_cast(base) diff --git a/src/vt/runtime/runtime.h b/src/vt/runtime/runtime.h index 00f2a9162f..b2a4c8d2c5 100644 --- a/src/vt/runtime/runtime.h +++ b/src/vt/runtime/runtime.h @@ -395,7 +395,6 @@ struct Runtime { public: ComponentPtrType theArgConfig = nullptr; - ComponentPtrType theRegistry = nullptr; ComponentPtrType theMsg = nullptr; ComponentPtrType theContext = nullptr; ComponentPtrType theEvent = nullptr; diff --git a/src/vt/runtime/runtime_component_fwd.h b/src/vt/runtime/runtime_component_fwd.h index 93cf5153ed..b54bc264b0 100644 --- a/src/vt/runtime/runtime_component_fwd.h +++ b/src/vt/runtime/runtime_component_fwd.h @@ -52,9 +52,6 @@ namespace vt { namespace arguments { struct ArgConfig; } -namespace registry { -struct Registry; -} namespace messaging { struct ActiveMessenger; } diff --git a/src/vt/runtime/runtime_get.cc b/src/vt/runtime/runtime_get.cc index 670f4f3e45..8aa6dab0c2 100644 --- a/src/vt/runtime/runtime_get.cc +++ b/src/vt/runtime/runtime_get.cc @@ -49,7 +49,6 @@ #include "vt/utils/tls/tls.h" #include "vt/vrt/context/context_vrtmanager.h" #include "vt/context/context.h" -#include "vt/registry/registry.h" #include "vt/messaging/active.h" #include "vt/event/event.h" #include "vt/termination/term_headers.h" @@ -119,7 +118,6 @@ event::AsyncEvent* theEvent() { return CUR_RT->theEvent; messaging::ActiveMessenger* theMsg() { return CUR_RT->theMsg; } param::Param* theParam() { return CUR_RT->theParam; } rdma::RDMAManager* theRDMA() { return CUR_RT->theRDMA; } -registry::Registry* theRegistry() { return CUR_RT->theRegistry; } sched::Scheduler* theSched() { return CUR_RT->theSched; } term::TerminationDetector* theTerm() { return CUR_RT->theTerm; } location::LocationManager* theLocMan() { return CUR_RT->theLocMan; } diff --git a/src/vt/transport.h b/src/vt/transport.h index f69f54213b..d035867f7a 100644 --- a/src/vt/transport.h +++ b/src/vt/transport.h @@ -55,7 +55,6 @@ #include "vt/collective/collective_alg.h" #include "vt/collective/collective.h" #include "vt/event/event.h" -#include "vt/registry/registry.h" #include "vt/messaging/active.h" #include "vt/parameterization/parameterization.h" #include "vt/event/event_msgs.h" From a2812e00beaa5e9fa8035de62361970470eda5a3 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 12 Sep 2022 15:44:40 -0700 Subject: [PATCH 11/27] #1899: runnable: remove tag as a runnable parameter --- src/vt/messaging/active.cc | 7 ++----- src/vt/runnable/make_runnable.h | 13 +------------ src/vt/runnable/runnable.cc | 2 +- src/vt/runnable/runnable.h | 5 +---- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index dc2186ecbc..8ff4c5a149 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -936,8 +936,6 @@ void ActiveMessenger::prepareActiveMsgToRun( auto const handler = envelopeGetHandler(msg->env); auto const epoch = envelopeIsEpochType(msg->env) ? envelopeGetEpoch(msg->env) : term::any_epoch_sentinel; - auto const is_tag = envelopeIsTagType(msg->env); - auto const tag = is_tag ? envelopeGetTag(msg->env) : no_tag; auto const from_node = is_bcast ? dest : in_from_node; if (!is_term || vt_check_enabled(print_term_msgs)) { @@ -952,16 +950,15 @@ void ActiveMessenger::prepareActiveMsgToRun( if (!is_term || vt_check_enabled(print_term_msgs)) { vt_debug_print( normal, active, - "prepareActiveMsgToRun: msg={}, handler={:x}, tag={}, is_auto={}, " + "prepareActiveMsgToRun: msg={}, handler={:x}" "is_obj_group={}, has_handler={}, insert={}\n", - print_ptr(msg), handler, tag, is_auto, is_obj, + print_ptr(msg), handler, is_obj, has_handler, insert ); } runnable::makeRunnable(base, not is_term, handler, from_node) .withContinuation(cont) - .withTag(tag) .withTDEpochFromMsg(is_term) .withLBData(&bare_handler_lb_data_, bare_handler_dummy_elm_id_for_lb_data_) .enqueue(); diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index fbe4130bf5..70739c49e7 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -232,16 +232,6 @@ struct RunnableMaker { } #endif - /** - * \brief Add a tag to the handler - * - * \param[in] tag the tag - */ - RunnableMaker&& withTag(TagType tag) { - tag_ = tag; - return std::move(*this); - } - /** * \brief Run or enqueue the runnable depending on argument * @@ -289,7 +279,7 @@ struct RunnableMaker { */ void setup() { if (not set_handler_) { - impl_->setupHandler(handler_, is_void_, tag_); + impl_->setupHandler(handler_, is_void_); set_handler_ = true; } } @@ -299,7 +289,6 @@ struct RunnableMaker { MsgSharedPtr msg_ = nullptr; HandlerType handler_ = uninitialized_handler; bool set_handler_ = false; - TagType tag_ = no_tag; bool is_void_ = false; NodeType from_node_ = uninitialized_destination; bool is_done_ = false; diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index 4f54bbd4c1..70d730a5cc 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -53,7 +53,7 @@ namespace vt { namespace runnable { -void RunnableNew::setupHandler(HandlerType handler, bool is_void, TagType tag) { +void RunnableNew::setupHandler(HandlerType handler, bool is_void) { using HandlerManagerType = HandlerManager; bool const is_obj = HandlerManagerType::isHandlerObjGroup(handler); diff --git a/src/vt/runnable/runnable.h b/src/vt/runnable/runnable.h index a7332e1269..d62755b858 100644 --- a/src/vt/runnable/runnable.h +++ b/src/vt/runnable/runnable.h @@ -203,11 +203,8 @@ struct RunnableNew { * * \param[in] handler the handler ID bits * \param[in] is_void whether it's a void handler w/o an associated message - * \param[in] tag an optional tag */ - void setupHandler( - HandlerType handler, bool is_void = false, TagType tag = no_tag - ); + void setupHandler(HandlerType handler, bool is_void = false); /** * \brief Run the task! From ca3c4b5784c1b232617533943ab88eaaedcd62bc Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 12 Sep 2022 16:02:25 -0700 Subject: [PATCH 12/27] #1899: active: fix debug print --- src/vt/messaging/active.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 8ff4c5a149..aeafcddbcb 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -950,10 +950,8 @@ void ActiveMessenger::prepareActiveMsgToRun( if (!is_term || vt_check_enabled(print_term_msgs)) { vt_debug_print( normal, active, - "prepareActiveMsgToRun: msg={}, handler={:x}" - "is_obj_group={}, has_handler={}, insert={}\n", - print_ptr(msg), handler, is_obj, - has_handler, insert + "prepareActiveMsgToRun: msg={}, handler={:x}, insert={}\n", + print_ptr(msg), handler, insert ); } From bc52656f863b93a6c20f4b4646e42ad4fc64005d Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 14 Sep 2022 09:23:12 -0700 Subject: [PATCH 13/27] #1899: runnable: make message const& in builder --- src/vt/runnable/make_runnable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index 70739c49e7..4f566d1f0f 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -286,7 +286,7 @@ struct RunnableMaker { private: RunnableNew* impl_ = nullptr; - MsgSharedPtr msg_ = nullptr; + MsgSharedPtr const& msg_; HandlerType handler_ = uninitialized_handler; bool set_handler_ = false; bool is_void_ = false; From 1866bba69bf270907aa3556bc5104e158cecfe2b Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 14 Sep 2022 09:36:54 -0700 Subject: [PATCH 14/27] #1899: runnable: disable more fcontext code when compile-time disabled --- src/vt/runnable/runnable.cc | 18 ++++++++++++++++++ src/vt/runnable/runnable.h | 16 +++++++++++++--- src/vt/scheduler/suspended_units.cc | 1 + 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index 70d730a5cc..ec4b18eaa8 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -133,6 +133,7 @@ void RunnableNew::setupHandlerElement( } void RunnableNew::run() { +#if vt_check_enabled(fcontext) vtAbortIf( done_ and not suspended_, "Runnable task must either be not done (finished execution) or suspended" @@ -143,12 +144,17 @@ void RunnableNew::run() { "start running task={}, done={}, suspended={}\n", print_ptr(this), done_, suspended_ ); +#endif +#if vt_check_enabled(fcontext) if (suspended_) { resume(); } else { begin(); } +#else + begin(); +#endif vtAssert(task_ != nullptr, "Must have a valid task to run"); @@ -174,24 +180,36 @@ void RunnableNew::run() { } else #endif { +#if vt_check_enabled(fcontext) // force use this for when fcontext is disabled to avoid compiler warning vt_force_use(is_threaded_, tid_) +#endif + task_(); + +#if vt_check_enabled(fcontext) done_ = true; +#endif } +#if vt_check_enabled(fcontext) if (done_) { end(); } else { suspended_ = true; suspend(); } +#else + end(); +#endif +#if vt_check_enabled(fcontext) vt_debug_print( terse, context, "done running task={}, done={}, suspended={}\n", print_ptr(this), done_, suspended_ ); +#endif } void RunnableNew::begin() { diff --git a/src/vt/runnable/runnable.h b/src/vt/runnable/runnable.h index d62755b858..f41f916298 100644 --- a/src/vt/runnable/runnable.h +++ b/src/vt/runnable/runnable.h @@ -105,8 +105,10 @@ struct RunnableNew { */ template RunnableNew(MsgSharedPtr const& in_msg, bool in_is_threaded) - : msg_(in_msg.template to()), - is_threaded_(in_is_threaded) + : msg_(in_msg.template to()) +#if vt_check_enabled(fcontext) + , is_threaded_(in_is_threaded) +#endif { } /** @@ -115,7 +117,9 @@ struct RunnableNew { * \param[in] in_is_threaded whether the handler can be run with a thread */ explicit RunnableNew(bool in_is_threaded) +#if vt_check_enabled(fcontext) : is_threaded_(in_is_threaded) +#endif { } RunnableNew(RunnableNew&&) = default; @@ -215,6 +219,7 @@ struct RunnableNew { */ void run(); +#if vt_check_enabled(fcontext) /** * \brief Get the thread ID associated with the runnable. * @@ -224,6 +229,7 @@ struct RunnableNew { * \return the thread ID */ ThreadIDType getThreadID() const { return tid_; } +#endif private: /** @@ -279,6 +285,7 @@ struct RunnableNew { */ BaseMsgType* getMsg() const { return msg_.get(); } +#if vt_check_enabled(fcontext) /** * \brief Check if this runnable is complete or not * @@ -297,6 +304,7 @@ struct RunnableNew { * \return return if it is suspended */ bool isSuspended() const { return suspended_; } +#endif /** * \brief Set an explicit task for the runnable bypassing the handler @@ -326,11 +334,13 @@ struct RunnableNew { private: detail::Contexts contexts_; /**< The contexts */ MsgSharedPtr msg_ = nullptr; /**< The associated message */ - bool is_threaded_ = false; /**< Whether ULTs are supported */ ActionType task_ = nullptr; /**< The runnable's task */ +#if vt_check_enabled(fcontext) + bool is_threaded_ = false; /**< Whether ULTs are supported */ bool done_ = false; /**< Whether task is complete */ bool suspended_ = false; /**< Whether task is suspended */ ThreadIDType tid_ = no_thread_id; /**< The thread ID for the task */ +#endif }; struct RunnableNewAlloc { diff --git a/src/vt/scheduler/suspended_units.cc b/src/vt/scheduler/suspended_units.cc index 1e24820253..6ac57a874d 100644 --- a/src/vt/scheduler/suspended_units.cc +++ b/src/vt/scheduler/suspended_units.cc @@ -52,6 +52,7 @@ void SuspendedUnits::addSuspended( ) { #if vt_check_enabled(fcontext) vtAssert(runnable->isSuspended(), "Runnable must be suspended to add"); +#endif units_.emplace( std::piecewise_construct, From 53e65127f202ff49c82fab89cd9053814d905468 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 14 Sep 2022 09:57:16 -0700 Subject: [PATCH 15/27] #1899: runnable: do not reference message to enqueue --- src/vt/runnable/make_runnable.h | 3 +++ src/vt/runnable/make_runnable.impl.h | 4 ++++ src/vt/scheduler/scheduler.h | 11 ++++++++++- src/vt/scheduler/scheduler.impl.h | 15 ++++++++++++++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index 4f566d1f0f..386b5efe76 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -107,6 +107,7 @@ struct RunnableMaker { * \param[in] is_term whether it's a termination message */ RunnableMaker&& withTDEpoch(EpochType ep, bool is_term = false) { + is_term_ = is_term; if (not is_term) { impl_->addContextTD(ep); } @@ -119,6 +120,7 @@ struct RunnableMaker { * \param[in] is_term whether it's a termination message */ RunnableMaker&& withTDEpochFromMsg(bool is_term = false) { + is_term_ = is_term; if (not is_term) { impl_->addContextTD(msg_); } @@ -292,6 +294,7 @@ struct RunnableMaker { bool is_void_ = false; NodeType from_node_ = uninitialized_destination; bool is_done_ = false; + bool is_term_ = false; }; /** diff --git a/src/vt/runnable/make_runnable.impl.h b/src/vt/runnable/make_runnable.impl.h index 070aea60fa..1ad9db1885 100644 --- a/src/vt/runnable/make_runnable.impl.h +++ b/src/vt/runnable/make_runnable.impl.h @@ -53,7 +53,11 @@ template void RunnableMaker::enqueue() { setup(); if (msg_ != nullptr) { +#if vt_check_enabled(priorities) theSched()->enqueue(msg_, impl_); +#else + theSched()->enqueue(is_term_, impl_); +#endif } else { theSched()->enqueue(impl_); } diff --git a/src/vt/scheduler/scheduler.h b/src/vt/scheduler/scheduler.h index 3ed60fa603..45e4fde9c8 100644 --- a/src/vt/scheduler/scheduler.h +++ b/src/vt/scheduler/scheduler.h @@ -247,6 +247,15 @@ struct Scheduler : runtime::component::Component { */ void printMemoryUsage(); + /** + * \brief Enqueue an action without a message. + * + * \param[in] is_term whether it is a termination message or not + * \param[in] r the runnable + */ + template + void enqueue(bool is_term, RunT r); + /** * \brief Enqueue an action associated with a prioritized message. The action * will be enqueued with the priority found on the message. @@ -265,7 +274,7 @@ struct Scheduler : runtime::component::Component { * \param[in] r the runnable to execute later */ template - void enqueue(messaging::MsgSharedPtr msg, RunT r); + void enqueue(messaging::MsgSharedPtr const& msg, RunT r); /** * \brief Get the work queue size diff --git a/src/vt/scheduler/scheduler.impl.h b/src/vt/scheduler/scheduler.impl.h index 1e0c9b7520..c7834bbd4e 100644 --- a/src/vt/scheduler/scheduler.impl.h +++ b/src/vt/scheduler/scheduler.impl.h @@ -87,6 +87,14 @@ void runInEpochRooted(std::string const& label, Callable&& fn) { namespace vt { namespace sched { +template +void Scheduler::enqueue(bool is_term, RunT r) { + if (is_term) { + num_term_msgs_++; + } + work_queue_.emplace(UnitType(is_term, r)); +} + template void Scheduler::enqueue(MsgT* msg, RunT r) { bool const is_term = envelopeIsTerm(msg->env); @@ -104,7 +112,8 @@ void Scheduler::enqueue(MsgT* msg, RunT r) { } template -void Scheduler::enqueue(MsgSharedPtr msg, RunT r) { +void Scheduler::enqueue(MsgSharedPtr const& msg, RunT r) { +# if vt_check_enabled(priorities) // // Assume that MsgSharedPtr is already captured in the action. // @@ -112,6 +121,10 @@ void Scheduler::enqueue(MsgSharedPtr msg, RunT r) { // could be dispatched directly based on type/state-bits // enqueue(msg.get(), std::move(r)); +#else + bool const is_term = envelopeIsTerm(msg->env); + enqueue(is_term, r); +#endif } template From 447330951ce631f1568b101130b53f2e6f018cb5 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 14 Sep 2022 11:20:48 -0700 Subject: [PATCH 16/27] #1899: td: disable suspended epochs when fcontext is disabled --- src/vt/context/runnable_context/td.cc | 11 +++++++---- src/vt/context/runnable_context/td.h | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/vt/context/runnable_context/td.cc b/src/vt/context/runnable_context/td.cc index a989c0d460..02e2b13bc2 100644 --- a/src/vt/context/runnable_context/td.cc +++ b/src/vt/context/runnable_context/td.cc @@ -56,16 +56,17 @@ TD::TD(EpochType in_ep) void TD::begin() { theTerm()->pushEpoch(ep_); +#if vt_check_enabled(fcontext) auto& epoch_stack = theTerm()->getEpochStack(); - base_epoch_stack_size_ = epoch_stack.size(); +#endif } void TD::end() { +#if vt_check_enabled(fcontext) auto& epoch_stack = theTerm()->getEpochStack(); - vtAssert( base_epoch_stack_size_ <= epoch_stack.size(), "Epoch stack popped below preceding push size in handler" @@ -74,15 +75,16 @@ void TD::end() { while (epoch_stack.size() > base_epoch_stack_size_) { theTerm()->popEpoch(); } +#endif theTerm()->popEpoch(ep_); theTerm()->consume(ep_); } void TD::suspend() { +#if vt_check_enabled(fcontext) auto& epoch_stack = theTerm()->getEpochStack(); - while (epoch_stack.size() > base_epoch_stack_size_) { suspended_epochs_.push_back(theTerm()->getEpoch()); theTerm()->popEpoch(); @@ -92,12 +94,12 @@ void TD::suspend() { } void TD::resume() { +#if vt_check_enabled(fcontext) theTerm()->pushEpoch(ep_); auto& epoch_stack = theTerm()->getEpochStack(); base_epoch_stack_size_ = epoch_stack.size(); - for (auto it = suspended_epochs_.rbegin(); it != suspended_epochs_.rend(); ++it) { @@ -105,6 +107,7 @@ void TD::resume() { } suspended_epochs_.clear(); +#endif } }} /* end namespace vt::ctx */ diff --git a/src/vt/context/runnable_context/td.h b/src/vt/context/runnable_context/td.h index 53b99770c5..bd3c4ab494 100644 --- a/src/vt/context/runnable_context/td.h +++ b/src/vt/context/runnable_context/td.h @@ -44,6 +44,7 @@ #if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_TD_H #define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_TD_H +#include "vt/config.h" #include "vt/configs/types/types_type.h" #include "vt/configs/types/types_sentinels.h" #include "vt/epoch/epoch_type.h" @@ -105,8 +106,10 @@ struct TD { private: EpochType ep_ = no_epoch; /**< The epoch for the task */ +#if vt_check_enabled(fcontext) std::size_t base_epoch_stack_size_ = 0; /**< Epoch stack size at start */ std::vector suspended_epochs_; /**< Suspended epoch stack */ +#endif }; }} /* end namespace vt::ctx */ From 77b053b0c31fc535212d5802084267cb411d2a15 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 14 Sep 2022 11:22:04 -0700 Subject: [PATCH 17/27] #1899: td: take message by const& --- src/vt/context/runnable_context/td.h | 2 +- src/vt/context/runnable_context/td.impl.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vt/context/runnable_context/td.h b/src/vt/context/runnable_context/td.h index bd3c4ab494..8a0cf0f913 100644 --- a/src/vt/context/runnable_context/td.h +++ b/src/vt/context/runnable_context/td.h @@ -78,7 +78,7 @@ struct TD { * \param[in] msg the message to extract the epoch from */ template - explicit TD(MsgPtrT msg); + explicit TD(MsgPtrT const& msg); /** * \brief During begin \c TD will capture the epoch stack size and push \c ep_ diff --git a/src/vt/context/runnable_context/td.impl.h b/src/vt/context/runnable_context/td.impl.h index e456ffd713..0992a18b54 100644 --- a/src/vt/context/runnable_context/td.impl.h +++ b/src/vt/context/runnable_context/td.impl.h @@ -60,7 +60,7 @@ namespace { * \return the associated epoch */ template -static EpochType extractEpochMsg(MsgPtrT msg) { +static EpochType extractEpochMsg(MsgPtrT const& msg) { auto const is_term = envelopeIsTerm(msg->env); if (not is_term) { auto ep_ = envelopeIsEpochType(msg->env) ? @@ -77,7 +77,7 @@ static EpochType extractEpochMsg(MsgPtrT msg) { } /* end anon namespace */ template -/*explicit*/ TD::TD(MsgPtrT msg) +/*explicit*/ TD::TD(MsgPtrT const& msg) : TD(extractEpochMsg(msg)) { } From 892c29addaf6fdaba6c6e9d2cc077bf65d49fb71 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 14 Sep 2022 12:28:51 -0700 Subject: [PATCH 18/27] #1899: scheduler: don't transition to idle right away --- src/vt/scheduler/scheduler.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/scheduler/scheduler.cc b/src/vt/scheduler/scheduler.cc index fe574166c2..ced76058a2 100644 --- a/src/vt/scheduler/scheduler.cc +++ b/src/vt/scheduler/scheduler.cc @@ -275,7 +275,7 @@ void Scheduler::runSchedulerOnceImpl(bool msg_only) { */ UnitType work = work_queue_.pop(); runWorkUnit(work); - + } else { // Enter idle state immediately after processing if relevant. if (not is_idle_minus_term and num_term_msgs_ == work_queue_.size()) { is_idle_minus_term = true; From 087d68eb0475cf9e6f3192deaa144210d1be1f9c Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 20 Sep 2022 11:33:28 -0700 Subject: [PATCH 19/27] #1899: scheduler: fix bad rebase with endif --- src/vt/scheduler/suspended_units.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vt/scheduler/suspended_units.cc b/src/vt/scheduler/suspended_units.cc index 6ac57a874d..1e24820253 100644 --- a/src/vt/scheduler/suspended_units.cc +++ b/src/vt/scheduler/suspended_units.cc @@ -52,7 +52,6 @@ void SuspendedUnits::addSuspended( ) { #if vt_check_enabled(fcontext) vtAssert(runnable->isSuspended(), "Runnable must be suspended to add"); -#endif units_.emplace( std::piecewise_construct, From 3b3d77d8e239afeb99924409fd404c6840e72ab3 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 20 Sep 2022 12:21:52 -0700 Subject: [PATCH 20/27] #1899: runnable: add missing getter for trace context --- src/vt/runnable/runnable.impl.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/vt/runnable/runnable.impl.h b/src/vt/runnable/runnable.impl.h index d4b3015a6f..3fb93ac5f0 100644 --- a/src/vt/runnable/runnable.impl.h +++ b/src/vt/runnable/runnable.impl.h @@ -63,6 +63,17 @@ inline ctx::LBData* RunnableNew::get() { return nullptr; } +#if vt_check_enabled(trace_enabled) +template <> +inline ctx::Trace* RunnableNew::get() { + if (contexts_.has_trace) + return &contexts_.trace; + else + return nullptr; +} +#endif + + template void RunnableNew::addContextSetContext(Args&&... args) { contexts_.setcontext = ctx::SetContext{std::forward(args)...}; From 7fbf2d2a6dcae7b58e902dcbf2fb4c98aac63af9 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 22 Sep 2022 10:41:54 -0700 Subject: [PATCH 21/27] #1899: runnable: fix missing endif from merge --- src/vt/context/runnable_context/td.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vt/context/runnable_context/td.cc b/src/vt/context/runnable_context/td.cc index 02e2b13bc2..db8f1b76cb 100644 --- a/src/vt/context/runnable_context/td.cc +++ b/src/vt/context/runnable_context/td.cc @@ -91,6 +91,7 @@ void TD::suspend() { } theTerm()->popEpoch(ep_); +#endif } void TD::resume() { From b54d08e73c8b0463de013b9b9b10ba8d8a15d6c8 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 26 Sep 2022 08:29:25 -0700 Subject: [PATCH 22/27] #1899: runnable: fix double free --- src/vt/scheduler/base_unit.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vt/scheduler/base_unit.cc b/src/vt/scheduler/base_unit.cc index 9c89544d36..3a4292d289 100644 --- a/src/vt/scheduler/base_unit.cc +++ b/src/vt/scheduler/base_unit.cc @@ -54,9 +54,12 @@ void BaseUnit::execute() { if (not r_->isDone()) { auto tid = r_->getThreadID(); theSched()->suspend(tid, std::move(r_)); + } else { + delete r_; } + #else + delete r_; #endif - delete r_; } else if (work_) { work_(); } From cdd8cf07711aa796cac6d94aa7ec5f0ce294e799 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 26 Sep 2022 09:23:19 -0700 Subject: [PATCH 23/27] #1899: runnable: stop accessing msg_ if const& is invalid --- src/vt/runnable/make_runnable.h | 4 +++- src/vt/runnable/make_runnable.impl.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index 386b5efe76..d019ad45b9 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -79,7 +79,8 @@ struct RunnableMaker { msg_(in_msg), handler_(in_handler), is_void_(in_msg == nullptr), - from_node_(in_from_node) + from_node_(in_from_node), + has_msg_(in_msg != nullptr) { } RunnableMaker(RunnableMaker const&) = delete; RunnableMaker(RunnableMaker&&) = default; @@ -295,6 +296,7 @@ struct RunnableMaker { NodeType from_node_ = uninitialized_destination; bool is_done_ = false; bool is_term_ = false; + bool has_msg_ = true; }; /** diff --git a/src/vt/runnable/make_runnable.impl.h b/src/vt/runnable/make_runnable.impl.h index 1ad9db1885..bb6ec61930 100644 --- a/src/vt/runnable/make_runnable.impl.h +++ b/src/vt/runnable/make_runnable.impl.h @@ -52,7 +52,7 @@ namespace vt { namespace runnable { template void RunnableMaker::enqueue() { setup(); - if (msg_ != nullptr) { + if (has_msg_) { #if vt_check_enabled(priorities) theSched()->enqueue(msg_, impl_); #else From 69fb406dcc169d407471fe4e463c1e02807ea943 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 26 Sep 2022 09:50:05 -0700 Subject: [PATCH 24/27] #1899: runnable: add missing end for continuation causing leak --- src/vt/runnable/runnable.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vt/runnable/runnable.cc b/src/vt/runnable/runnable.cc index ec4b18eaa8..15ba22af36 100644 --- a/src/vt/runnable/runnable.cc +++ b/src/vt/runnable/runnable.cc @@ -226,6 +226,7 @@ void RunnableNew::end() { contexts_.setcontext.end(); if (contexts_.has_td) contexts_.td.end(); if (contexts_.has_col) contexts_.col.end(); + if (contexts_.has_cont) contexts_.cont.end(); if (contexts_.has_lb) contexts_.lb.end(); #if vt_check_enabled(trace_enabled) if (contexts_.has_trace) contexts_.trace.end(); From aba1bbc0f9b0bcb92c3a16100f4863e63440c7a1 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 26 Sep 2022 12:29:53 -0700 Subject: [PATCH 25/27] #1899: envelope: fix bug with lack of epoch propagation on put messages This is a long-standing bug that started showing up with the changes in #1899, making the runnable more efficient. TestGroup.test_group_range_construct_2 was consistently breaking on the gcc-8 build with address sanitizer. With extensive debugging, I tracked this bug down to the lack of propagation of an epoch on the remote group construction message when a rooted group is constructed where the constructing node is not included. Additionally, the group must be specified by a list (not a range). When these conditions occur, the group manager sends the information about the group to a remote node using a packed put, which uses the `PayloadMessage`: namely, ` struct GroupListMsg : GroupInfoMsg>`. The `PayloadMessage`, using a default template parameter, uses a basic envelope which is not large enough to store the epoch. Thus, it gets dropped. Therefore, the test sometimes breaks because the group construction and following broadcast escape the `runInEpochCollective` and the test condition will fail sometimes as it races with the delivery of the group message being broadcast to the group spanning tree. --- src/vt/messaging/envelope/payload_envelope.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/vt/messaging/envelope/payload_envelope.h b/src/vt/messaging/envelope/payload_envelope.h index 6bcfebf6d8..09ec6e47a8 100644 --- a/src/vt/messaging/envelope/payload_envelope.h +++ b/src/vt/messaging/envelope/payload_envelope.h @@ -53,7 +53,7 @@ namespace vt { using PutPtrType = void*; using PutPtrConstType = void const*; using PutEnvSizeType = size_t; -using PutUnderEnvelopeT = Envelope; +using PutUnderEnvelopeT = EpochTagEnvelope; /** * \struct PutEnvelope @@ -75,8 +75,7 @@ struct PutEnvelope { TagType put_data_tag_; /**< The put tag */ }; -//using PutBasicEnvelope = PutEnvelope; -using PutShortEnvelope = PutEnvelope; +using PutShortEnvelope = PutEnvelope; using eEnvType = messaging::eEnvelopeType; /** From ba19badd2dfcf4f0de91861dd26ba70bf5022f55 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 26 Sep 2022 12:42:25 -0700 Subject: [PATCH 26/27] #1899: TD: make testEpochTerminated print verbose (mis-marked) --- src/vt/termination/termination.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/termination/termination.cc b/src/vt/termination/termination.cc index bcd1dd6912..a413df460c 100644 --- a/src/vt/termination/termination.cc +++ b/src/vt/termination/termination.cc @@ -791,7 +791,7 @@ TermStatusEnum TerminationDetector::testEpochTerminated(EpochType epoch) { } vt_debug_print( - normal, term, + verbose, term, "testEpochTerminated: epoch={:x}, pending={}, terminated={}, remote={}\n", epoch, status == TermStatusEnum::Pending, status == TermStatusEnum::Terminated, status == TermStatusEnum::Remote From 8568fb7dbc9b665f7c049a601e04d666de21b48b Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 27 Sep 2022 12:06:21 -0700 Subject: [PATCH 27/27] #1899: runnable: try moving trace context section up to fix Mac bug --- src/vt/runnable/runnable.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vt/runnable/runnable.h b/src/vt/runnable/runnable.h index f41f916298..8691457262 100644 --- a/src/vt/runnable/runnable.h +++ b/src/vt/runnable/runnable.h @@ -70,6 +70,10 @@ namespace vt { namespace runnable { namespace detail { struct Contexts { +#if vt_check_enabled(trace_enabled) + bool has_trace = false; + ctx::Trace trace; +#endif ctx::SetContext setcontext; bool has_td = false; ctx::TD td; @@ -79,10 +83,6 @@ struct Contexts { ctx::Collection col; bool has_lb = false; ctx::LBData lb; -#if vt_check_enabled(trace_enabled) - bool has_trace = false; - ctx::Trace trace; -#endif }; } /* end namespace detail */