From 103c6c195d77934fb669bbd201888f002340b3fb Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 12 Jan 2023 18:00:31 -0800 Subject: [PATCH 01/32] #276: active: add interface with only handler required --- src/vt/messaging/active.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index 49aa04b43f..e7e6f727ec 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -704,6 +704,15 @@ struct ActiveMessenger : runtime::component::PollableComponent TagType tag = no_tag ); + template + PendingSendType sendMsg( + NodeType dest, + MsgPtrThief msg, + TagType tag = no_tag + ) { + return sendMsg(dest, msg, tag); + } + /** * \brief Send a message with explicit size. * From 3c6300444eafe56c0678ab8e2dc3f76c5a411230 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 12 Jan 2023 20:46:25 -0800 Subject: [PATCH 02/32] #276: active: finish up interface with extractor and modify example --- examples/hello_world/hello_world.cc | 2 +- src/vt/messaging/active.h | 47 +++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/examples/hello_world/hello_world.cc b/examples/hello_world/hello_world.cc index 659dc86bda..b8308ee1ea 100644 --- a/examples/hello_world/hello_world.cc +++ b/examples/hello_world/hello_world.cc @@ -66,7 +66,7 @@ int main(int argc, char** argv) { if (this_node == 0) { auto msg = vt::makeMessage(this_node); - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->broadcastMsg(msg); } vt::finalize(); diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index e7e6f727ec..10bdc4a7e0 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -686,6 +686,37 @@ struct ActiveMessenger : runtime::component::PollableComponent TagType tag = no_tag ); + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = T; + using ReturnType = ReturnT; + }; + + + /** + * \brief Broadcast a message (message type not required). + * + * \note Takes ownership of the supplied message. + * + * \param[in] msg the message to broadcast + * \param[in] deliver_to_sender whether msg should be delivered to sender + * \param[in] tag the tag to put on the message + * + * \return the \c PendingSend for the sent message + */ + template + PendingSendType broadcastMsg( + MsgPtrThief::MsgT> msg, + bool deliver_to_sender = true, + TagType tag = no_tag + ) { + using MsgT = typename FunctionTraits::MsgT; + return broadcastMsg(msg, deliver_to_sender, tag); + } + /** * \brief Send a message. * @@ -704,12 +735,24 @@ struct ActiveMessenger : runtime::component::PollableComponent TagType tag = no_tag ); - template + /** + * \brief Send a message (message type not required). + * + * \note Takes ownership of the supplied message. + * + * \param[in] dest the destination node to send the message to + * \param[in] msg the message to send + * \param[in] tag the tag to put on the message + * + * \return the \c PendingSend for the sent message + */ + template PendingSendType sendMsg( NodeType dest, - MsgPtrThief msg, + MsgPtrThief::MsgT> msg, TagType tag = no_tag ) { + using MsgT = typename FunctionTraits::MsgT; return sendMsg(dest, msg, tag); } From 8a2fe392280efdffc96536dc7095c94cc4c565ca Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 17 Jan 2023 15:40:59 -0800 Subject: [PATCH 03/32] #276: active: implement parameterization --- examples/hello_world/hello_world.cc | 9 +-- src/vt/messaging/active.h | 18 +++++ src/vt/messaging/param_msg.h | 72 ++++++++++++++++++++ src/vt/registry/auto/auto_registry_common.h | 15 ++++ src/vt/registry/auto/auto_registry_general.h | 6 +- src/vt/registry/auto/auto_registry_impl.h | 4 +- 6 files changed, 114 insertions(+), 10 deletions(-) create mode 100644 src/vt/messaging/param_msg.h diff --git a/examples/hello_world/hello_world.cc b/examples/hello_world/hello_world.cc index b8308ee1ea..8345f95410 100644 --- a/examples/hello_world/hello_world.cc +++ b/examples/hello_world/hello_world.cc @@ -49,24 +49,21 @@ struct HelloMsg : vt::Message { vt::NodeType from = 0; }; -static void hello_world(HelloMsg* msg) { +void helloWorld(int a, int b, float c) { vt::NodeType this_node = vt::theContext()->getNode(); - fmt::print("{}: Hello from node {}\n", this_node, msg->from); + fmt::print("{}: Hello from node vals = {} {} {}\n", this_node, a, b, c); } int main(int argc, char** argv) { vt::initialize(argc, argv); - vt::NodeType this_node = vt::theContext()->getNode(); vt::NodeType num_nodes = vt::theContext()->getNumNodes(); - if (num_nodes == 1) { return vt::rerror("requires at least 2 nodes"); } if (this_node == 0) { - auto msg = vt::makeMessage(this_node); - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->send(1, 10, 20, 11.3f); } vt::finalize(); diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index 10bdc4a7e0..3d9db3504a 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -56,6 +56,7 @@ #include "vt/messaging/request_holder.h" #include "vt/messaging/send_info.h" #include "vt/messaging/async_op_wrapper.h" +#include "vt/messaging/param_msg.h" #include "vt/event/event.h" #include "vt/registry/auto/auto_registry_interface.h" #include "vt/trace/trace_common.h" @@ -756,6 +757,23 @@ struct ActiveMessenger : runtime::component::PollableComponent return sendMsg(dest, msg, tag); } + /** + * \brief Send parameters to a handler in a message + * + * \param[in] dest the destination node to send the message to + * \param[in] params the parameters + * + * \return the \c PendingSend for the sent message + */ + template + PendingSendType send(NodeType dest, Params&&... params) { + using Tuple = typename std::decay>::type; + using MsgT = ParamMsg; + auto msg = vt::makeMessage(std::forward(params)...); + auto han = auto_registry::makeAutoHandlerParam(); + return sendMsg(dest, han, msg, no_tag); + } + /** * \brief Send a message with explicit size. * diff --git a/src/vt/messaging/param_msg.h b/src/vt/messaging/param_msg.h new file mode 100644 index 0000000000..db35ec0c5d --- /dev/null +++ b/src/vt/messaging/param_msg.h @@ -0,0 +1,72 @@ +/* +//@HEADER +// ***************************************************************************** +// +// param_msg.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_MESSAGING_PARAM_MSG_H +#define INCLUDED_VT_MESSAGING_PARAM_MSG_H + +#include "vt/messaging/message/message_serialize.h" + +namespace vt { namespace messaging { + +template +struct ParamMsg : vt::Message { + using MessageParentType = vt::Message; + vt_msg_serialize_if_needed_by_parent_or_type1(Tuple); // by tup + + template + explicit ParamMsg(Params&&... in_params) + : params(std::forward(in_params)...) + { } + + Tuple params; + + template + void serialize(SerializerT& s) { + MessageParentType::serialize(s); + s | params; + } +}; + +}} /* end namespace vt::messaging */ + +#endif /*INCLUDED_VT_MESSAGING_PARAM_MSG_H*/ diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index 93bca42d1e..a8ec985371 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -133,6 +133,21 @@ struct HandlersDispatcher final : BaseHandlersDispatcher { } }; + template + struct DispatchImpl< + T, + std::enable_if_t< + std::is_same::value and + not std::is_same::value and + not std::is_same*>::value + > + > { + static void run(MsgT* msg, void*, HandlerT han) { + std::apply(han, msg->params); + } + }; + + public: void dispatch(messaging::BaseMsg* msg, void* object) const override { DispatchImpl::run(static_cast(msg), object, fn_ptr_); diff --git a/src/vt/registry/auto/auto_registry_general.h b/src/vt/registry/auto/auto_registry_general.h index 01d045f266..1cb9d9abf6 100644 --- a/src/vt/registry/auto/auto_registry_general.h +++ b/src/vt/registry/auto/auto_registry_general.h @@ -45,6 +45,7 @@ #include "vt/config.h" #include "vt/registry/auto/auto_registry_common.h" +#include "vt/messaging/param_msg.h" #include "vt/utils/demangle/demangle.h" @@ -154,10 +155,11 @@ struct FunctorAdapterArgs { // Need to provide a non-pointer overload for parameterization auto-registered // functions for GCC -template +template struct FunctorAdapterParam { using FunctionPtrType = F; - using ObjType = void; + using ObjType = SentinelObject; + using MsgType = messaging::ParamMsg>; static constexpr FunctionPtrType getFunction() { return f; } diff --git a/src/vt/registry/auto/auto_registry_impl.h b/src/vt/registry/auto/auto_registry_impl.h index fb98dd8a0b..ebc2dbd5ff 100644 --- a/src/vt/registry/auto/auto_registry_impl.h +++ b/src/vt/registry/auto/auto_registry_impl.h @@ -144,9 +144,9 @@ inline BaseScatterDispatcherPtr const& getScatterAutoHandler(HandlerType const h return getAutoRegistryGen().at(han_id).getFun(); } -template +template inline HandlerType makeAutoHandlerParam() { - using AdapterT = FunctorAdapterParam; + using AdapterT = FunctorAdapterParam; using ContainerType = AutoActiveContainerType; using RegInfoType = AutoRegInfoType; using FuncType = ActiveFnPtrType; From ef3ec8a7e5e66107c7885c58ef5c5f428d9e2f7e Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 17 Jan 2023 15:58:18 -0800 Subject: [PATCH 04/32] #276: example: fix --- examples/hello_world/hello_world.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/hello_world/hello_world.cc b/examples/hello_world/hello_world.cc index 8345f95410..b9127da1d0 100644 --- a/examples/hello_world/hello_world.cc +++ b/examples/hello_world/hello_world.cc @@ -57,7 +57,9 @@ void helloWorld(int a, int b, float c) { int main(int argc, char** argv) { vt::initialize(argc, argv); + vt::NodeType this_node = vt::theContext()->getNode(); vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + if (num_nodes == 1) { return vt::rerror("requires at least 2 nodes"); } From afe6f237cb4014c1b57394aecddebc66d7dea701 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 17 Jan 2023 15:58:33 -0800 Subject: [PATCH 05/32] #276: active: decay tuple elements properly --- src/vt/messaging/active.h | 2 +- src/vt/messaging/param_msg.h | 8 ++++++++ src/vt/registry/auto/auto_registry_general.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index 3d9db3504a..ffd42ca3b9 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -767,7 +767,7 @@ struct ActiveMessenger : runtime::component::PollableComponent */ template PendingSendType send(NodeType dest, Params&&... params) { - using Tuple = typename std::decay>::type; + using Tuple = DecayTuple>; using MsgT = ParamMsg; auto msg = vt::makeMessage(std::forward(params)...); auto han = auto_registry::makeAutoHandlerParam(); diff --git a/src/vt/messaging/param_msg.h b/src/vt/messaging/param_msg.h index db35ec0c5d..37082f0990 100644 --- a/src/vt/messaging/param_msg.h +++ b/src/vt/messaging/param_msg.h @@ -67,6 +67,14 @@ struct ParamMsg : vt::Message { } }; + +template +constexpr auto decayTypes(std::tuple const&) + -> std::tuple>...>; + +template +using DecayTuple = decltype(decayTypes(std::declval())); + }} /* end namespace vt::messaging */ #endif /*INCLUDED_VT_MESSAGING_PARAM_MSG_H*/ diff --git a/src/vt/registry/auto/auto_registry_general.h b/src/vt/registry/auto/auto_registry_general.h index 1cb9d9abf6..3fac996864 100644 --- a/src/vt/registry/auto/auto_registry_general.h +++ b/src/vt/registry/auto/auto_registry_general.h @@ -159,7 +159,7 @@ template struct FunctorAdapterParam { using FunctionPtrType = F; using ObjType = SentinelObject; - using MsgType = messaging::ParamMsg>; + using MsgType = messaging::ParamMsg>>; static constexpr FunctionPtrType getFunction() { return f; } From 1c9846bdbad3cebe75d8820663e73f7c451dc02b Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 19 Jan 2023 10:05:00 -0800 Subject: [PATCH 06/32] #276: active: fix serialization for parameterized handlers --- src/vt/messaging/active.h | 30 +++++++++++++-- src/vt/messaging/param_msg.h | 40 ++++++++++++++------ src/vt/registry/auto/auto_registry_common.h | 2 +- src/vt/registry/auto/auto_registry_general.h | 4 +- src/vt/registry/auto/auto_registry_impl.h | 4 +- 5 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index ffd42ca3b9..159eb19c24 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -696,7 +696,6 @@ struct ActiveMessenger : runtime::component::PollableComponent using ReturnType = ReturnT; }; - /** * \brief Broadcast a message (message type not required). * @@ -757,6 +756,15 @@ struct ActiveMessenger : runtime::component::PollableComponent return sendMsg(dest, msg, tag); } + template + struct FunctionTraitsArgs; + + template + struct FunctionTraitsArgs { + using TupleType = std::tuple...>; + using ReturnType = ReturnT; + }; + /** * \brief Send parameters to a handler in a message * @@ -767,13 +775,29 @@ struct ActiveMessenger : runtime::component::PollableComponent */ template PendingSendType send(NodeType dest, Params&&... params) { - using Tuple = DecayTuple>; + using Tuple = typename FunctionTraitsArgs::TupleType; using MsgT = ParamMsg; auto msg = vt::makeMessage(std::forward(params)...); - auto han = auto_registry::makeAutoHandlerParam(); + auto han = auto_registry::makeAutoHandlerParam(); return sendMsg(dest, han, msg, no_tag); } + /** + * \brief Broadcast parameters to a handler in a message + * + * \param[in] params the parameters + * + * \return the \c PendingSend for the sent message + */ + template + PendingSendType broadcast(Params&&... params) { + using Tuple = typename FunctionTraitsArgs::TupleType; + using MsgT = ParamMsg; + auto msg = vt::makeMessage(std::forward(params)...); + auto han = auto_registry::makeAutoHandlerParam(); + return broadcastMsg(han, msg, true, no_tag); + } + /** * \brief Send a message with explicit size. * diff --git a/src/vt/messaging/param_msg.h b/src/vt/messaging/param_msg.h index 37082f0990..d3e7c25087 100644 --- a/src/vt/messaging/param_msg.h +++ b/src/vt/messaging/param_msg.h @@ -48,10 +48,15 @@ namespace vt { namespace messaging { +template +struct ParamMsg; + template -struct ParamMsg : vt::Message { - using MessageParentType = vt::Message; - vt_msg_serialize_if_needed_by_parent_or_type1(Tuple); // by tup +struct ParamMsg< + Tuple, std::enable_if_t::value> +> : vt::Message +{ + ParamMsg() = default; template explicit ParamMsg(Params&&... in_params) @@ -59,6 +64,27 @@ struct ParamMsg : vt::Message { { } Tuple params; + Tuple& getTuple() { return params; } +}; + +template +struct ParamMsg< + Tuple, std::enable_if_t::value> +> : vt::Message +{ + using MessageParentType = vt::Message; + vt_msg_serialize_if_needed_by_parent_or_type1(Tuple); // by tup + + ParamMsg() = default; + + template + explicit ParamMsg(Params&&... in_params) + : params(std::make_unique(std::forward(in_params)...)) + { } + + std::unique_ptr params; + + Tuple& getTuple() { return *params.get(); } template void serialize(SerializerT& s) { @@ -67,14 +93,6 @@ struct ParamMsg : vt::Message { } }; - -template -constexpr auto decayTypes(std::tuple const&) - -> std::tuple>...>; - -template -using DecayTuple = decltype(decayTypes(std::declval())); - }} /* end namespace vt::messaging */ #endif /*INCLUDED_VT_MESSAGING_PARAM_MSG_H*/ diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index a8ec985371..5269a1cfba 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -143,7 +143,7 @@ struct HandlersDispatcher final : BaseHandlersDispatcher { > > { static void run(MsgT* msg, void*, HandlerT han) { - std::apply(han, msg->params); + std::apply(han, msg->getTuple()); } }; diff --git a/src/vt/registry/auto/auto_registry_general.h b/src/vt/registry/auto/auto_registry_general.h index 3fac996864..aec46e5f4a 100644 --- a/src/vt/registry/auto/auto_registry_general.h +++ b/src/vt/registry/auto/auto_registry_general.h @@ -155,11 +155,11 @@ struct FunctorAdapterArgs { // Need to provide a non-pointer overload for parameterization auto-registered // functions for GCC -template +template struct FunctorAdapterParam { using FunctionPtrType = F; using ObjType = SentinelObject; - using MsgType = messaging::ParamMsg>>; + using MsgType = MsgT; static constexpr FunctionPtrType getFunction() { return f; } diff --git a/src/vt/registry/auto/auto_registry_impl.h b/src/vt/registry/auto/auto_registry_impl.h index ebc2dbd5ff..1ca2a679e0 100644 --- a/src/vt/registry/auto/auto_registry_impl.h +++ b/src/vt/registry/auto/auto_registry_impl.h @@ -144,9 +144,9 @@ inline BaseScatterDispatcherPtr const& getScatterAutoHandler(HandlerType const h return getAutoRegistryGen().at(han_id).getFun(); } -template +template inline HandlerType makeAutoHandlerParam() { - using AdapterT = FunctorAdapterParam; + using AdapterT = FunctorAdapterParam; using ContainerType = AutoActiveContainerType; using RegInfoType = AutoRegInfoType; using FuncType = ActiveFnPtrType; From b1441fe7adbcc360206f70d1d4b5897766adf7c7 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 25 Jan 2023 15:45:24 -0800 Subject: [PATCH 07/32] #276: active: make Node parameter a strong type --- examples/hello_world/hello_world.cc | 2 +- src/vt/messaging/active.h | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/hello_world/hello_world.cc b/examples/hello_world/hello_world.cc index b9127da1d0..cc3ca80b25 100644 --- a/examples/hello_world/hello_world.cc +++ b/examples/hello_world/hello_world.cc @@ -65,7 +65,7 @@ int main(int argc, char** argv) { } if (this_node == 0) { - vt::theMsg()->send(1, 10, 20, 11.3f); + vt::theMsg()->send(vt::Node{1}, 10, 20, 11.3f); } vt::finalize(); diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index 159eb19c24..9fbc95ded8 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -64,6 +64,7 @@ #include "vt/runtime/component/component_pack.h" #include "vt/elm/elm_id.h" #include "vt/elm/elm_lb_data.h" +#include "vt/utils/strong/strong_type.h" #if vt_check_enabled(trace_enabled) #include "vt/trace/trace_headers.h" @@ -87,7 +88,12 @@ using ContinuationDeleterType = } /* end namespace vt */ -namespace vt { namespace messaging { +namespace vt { + +struct StrongNodeType { }; +using Node = Strong; + +namespace messaging { /** \file */ @@ -774,7 +780,7 @@ struct ActiveMessenger : runtime::component::PollableComponent * \return the \c PendingSend for the sent message */ template - PendingSendType send(NodeType dest, Params&&... params) { + PendingSendType send(Node dest, Params&&... params) { using Tuple = typename FunctionTraitsArgs::TupleType; using MsgT = ParamMsg; auto msg = vt::makeMessage(std::forward(params)...); From e676f2d70fe4fd9be586ff006af928b04707a910 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 25 Jan 2023 15:59:58 -0800 Subject: [PATCH 08/32] #276: active: add get --- src/vt/messaging/active.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index 9fbc95ded8..d521fe65a4 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -785,7 +785,7 @@ struct ActiveMessenger : runtime::component::PollableComponent using MsgT = ParamMsg; auto msg = vt::makeMessage(std::forward(params)...); auto han = auto_registry::makeAutoHandlerParam(); - return sendMsg(dest, han, msg, no_tag); + return sendMsg(dest.get(), han, msg, no_tag); } /** From 0e7d5d3afd83e3834769d87655019983b1328b1f Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Wed, 8 Feb 2023 15:32:35 +0100 Subject: [PATCH 09/32] #276: Automatically synthesize message type in vt/collective --- src/vt/collective/reduce/reduce.h | 147 ++++++++++++++++++ src/vt/collective/reduce/reduce.impl.h | 2 +- src/vt/collective/scatter/scatter.h | 29 ++++ src/vt/vrt/collection/manager.impl.h | 2 +- .../collectives/test_collectives_reduce.cc | 2 +- .../test_collectives_scatter.extended.cc | 2 +- 6 files changed, 180 insertions(+), 4 deletions(-) diff --git a/src/vt/collective/reduce/reduce.h b/src/vt/collective/reduce/reduce.h index 55b5d30083..75bf0120dd 100644 --- a/src/vt/collective/reduce/reduce.h +++ b/src/vt/collective/reduce/reduce.h @@ -146,6 +146,36 @@ struct Reduce : virtual collective::tree::Tree { ReduceNumType num_contrib = 1 ); + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = T; + using ReturnType = ReturnT; + }; + + /** + * \brief Reduce a message up the tree, possibly delayed through a pending send + * + * \param[in] root the root node where the final handler provides the result + * \param[in] msg the message to reduce on this node + * \param[in] id the reduction stamp (optional), provided if out-of-order + * \param[in] num_contrib number of expected contributions from this node + * + * \return the pending send corresponding to the reduce + */ + template + PendingSendType reduce( + NodeType root, + typename FunctionTraits::MsgT* const msg, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType num_contrib = 1 + ) { + using MsgT = typename FunctionTraits::MsgT; + return reduce(root, msg, id, num_contrib); + } + /** * \brief Reduce a message up the tree * @@ -163,6 +193,27 @@ struct Reduce : virtual collective::tree::Tree { ReduceNumType num_contrib = 1 ); + /** + * \brief Reduce a message up the tree + * + * \param[in] root the root node where the final handler provides the result + * \param[in] msg the message to reduce on this node + * \param[in] id the reduction stamp (optional), provided if out-of-order + * \param[in] num_contrib number of expected contributions from this node + * + * \return the next reduction stamp + */ + template + detail::ReduceStamp reduceImmediate( + NodeType root, + typename FunctionTraits::MsgT* const msg, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType num_contrib = 1 + ) { + using MsgT = typename FunctionTraits::MsgT; + return reduceImmediate(root, msg, id, num_contrib); + } + /** * \brief Reduce a message up the tree * @@ -205,6 +256,29 @@ struct Reduce : virtual collective::tree::Tree { >(root, msg, cb, id, num_contrib); } + /** + * \brief Reduce a message up the tree + * + * \param[in] root the root node where the final handler provides the result + * \param[in] msg the message to reduce on this node + * \param[in] cb the callback to trigger on the root node + * \param[in] id the reduction stamp (optional), provided if out-of-order + * \param[in] num_contrib number of expected contributions from this node + * + * \return the next reduction stamp + */ + template + PendingSendType reduce( + NodeType const& root, + typename FunctionTraits::MsgT* msg, + Callback::MsgT> cb, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType const& num_contrib = 1 + ) { + using MsgT = typename FunctionTraits::MsgT; + return reduce(root, msg, cb, id, num_contrib); + } + /** * \brief Reduce a message up the tree * @@ -247,6 +321,29 @@ struct Reduce : virtual collective::tree::Tree { >(root, msg, cb, id, num_contrib); } + /** + * \brief Reduce a message up the tree + * + * \param[in] root the root node where the final handler provides the result + * \param[in] msg the message to reduce on this node + * \param[in] cb the callback to trigger on the root node + * \param[in] id the reduction stamp (optional), provided if out-of-order + * \param[in] num_contrib number of expected contributions from this node + * + * \return the next reduction stamp + */ + template + detail::ReduceStamp reduceImmediate( + NodeType const& root, + typename FunctionTraits::MsgT* msg, + Callback::MsgT> cb, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType const& num_contrib = 1 + ) { + using MsgT = typename FunctionTraits::MsgT; + return reduceImmediate(root, msg, cb, id, num_contrib); + } + /** * \brief Reduce a message up the tree with a target function on the root node * @@ -287,6 +384,31 @@ struct Reduce : virtual collective::tree::Tree { >(root, msg, id, num_contrib); } + /** + * \brief Reduce a message up the tree with a target function on the root node + * + * \param[in] root the root node where the final handler provides the result + * \param[in] msg the message to reduce on this node + * \param[in] id the reduction stamp (optional), provided if out-of-order + * \param[in] num_contrib number of expected contributions from this node + * + * \return the next reduction stamp + */ + template < + typename OpT, + typename FunctorT, + auto f + > + PendingSendType reduce( + NodeType const& root, + typename FunctionTraits::MsgT* msg, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType const& num_contrib = 1 + ) { + using MsgT = typename FunctionTraits::MsgT; + return reduce(root, msg, id, num_contrib); + } + /** * \brief Reduce a message up the tree with a target function on the root node * @@ -327,6 +449,31 @@ struct Reduce : virtual collective::tree::Tree { >(root, msg, id, num_contrib); } + /** + * \brief Reduce a message up the tree with a target function on the root node + * + * \param[in] root the root node where the final handler provides the result + * \param[in] msg the message to reduce on this node + * \param[in] id the reduction stamp (optional), provided if out-of-order + * \param[in] num_contrib number of expected contributions from this node + * + * \return the next reduction stamp + */ + template < + typename OpT, + typename FunctorT, + auto f + > + detail::ReduceStamp reduceImmediate( + NodeType const& root, + typename FunctionTraits::MsgT* msg, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType const& num_contrib = 1 + ) { + using MsgT = typename FunctionTraits::MsgT; + return reduceImmediate(root, msg, id, num_contrib); + } + /** * \internal \brief Combine in a new message for a given reduction * diff --git a/src/vt/collective/reduce/reduce.impl.h b/src/vt/collective/reduce/reduce.impl.h index 0a2724d38d..f9a6d4d4bf 100644 --- a/src/vt/collective/reduce/reduce.impl.h +++ b/src/vt/collective/reduce/reduce.impl.h @@ -128,7 +128,7 @@ Reduce::PendingSendType Reduce::reduce( ) { auto msg_ptr = promoteMsg(msg); return PendingSendType{theMsg()->getEpochContextMsg(msg_ptr), [=](){ - reduceImmediate(root, msg_ptr.get(), id, num_contrib); + reduceImmediate(root, msg_ptr.get(), id, num_contrib); } }; } diff --git a/src/vt/collective/scatter/scatter.h b/src/vt/collective/scatter/scatter.h index a15d59c3ca..e1a3464b94 100644 --- a/src/vt/collective/scatter/scatter.h +++ b/src/vt/collective/scatter/scatter.h @@ -89,6 +89,35 @@ struct Scatter : virtual collective::tree::Tree { FuncSizeType size_fn, FuncDataType data_fn ); + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MessageT = T; + using ReturnType = ReturnT; + }; + + /** + * \brief Scatter data to all nodes + * + * The functions passed to scatter through the arguments \c size_fn and + * \c data_fn will not be retained after this call returns. + * + * \param[in] total_size total size of data to scatter + * \param[in] max_proc_size max data to be scattered to any node + * \param[in] size_fn callback to get size for each node + * \param[in] data_fn callback to get data for each node + */ + template + void scatter( + std::size_t const& total_size, std::size_t const& max_proc_size, + FuncSizeType size_fn, FuncDataType data_fn + ) { + using MessageT = typename FunctionTraits::MessageT; + return scatter(total_size, max_proc_size, size_fn, data_fn); + } + protected: /** * \internal \brief Receive scattered data down the spanning tree diff --git a/src/vt/vrt/collection/manager.impl.h b/src/vt/vrt/collection/manager.impl.h index c9a75f56ee..5915ea91e0 100644 --- a/src/vt/vrt/collection/manager.impl.h +++ b/src/vt/vrt/collection/manager.impl.h @@ -959,7 +959,7 @@ messaging::PendingSend CollectionManager::reduceMsgExpr( r = theCollective()->getReducerVrtProxy(col_proxy); } - r->reduceImmediate(root_node, msg.get(), cur_stamp, num_elms); + r->reduceImmediate(root_node, msg.get(), cur_stamp, num_elms); vt_debug_print( normal, vrt_coll, diff --git a/tests/unit/collectives/test_collectives_reduce.cc b/tests/unit/collectives/test_collectives_reduce.cc index 910125e349..070c3e8695 100644 --- a/tests/unit/collectives/test_collectives_reduce.cc +++ b/tests/unit/collectives/test_collectives_reduce.cc @@ -58,7 +58,7 @@ TEST_F(TestReduce, test_reduce_op) { auto msg = makeMessage(my_node); vt_debug_print(normal, reduce, "msg->num={}\n", msg->num); - theCollective()->global()->reduce(root, msg.get()); + theCollective()->global()->reduce(root, msg.get()); } using ReduceMsg = vt::collective::ReduceTMsg; diff --git a/tests/unit/collectives/test_collectives_scatter.extended.cc b/tests/unit/collectives/test_collectives_scatter.extended.cc index 5d11dd6a1d..4350a7aa14 100644 --- a/tests/unit/collectives/test_collectives_scatter.extended.cc +++ b/tests/unit/collectives/test_collectives_scatter.extended.cc @@ -86,7 +86,7 @@ TEST_F(TestScatter, test_scatter_1) { if (this_node == 0) { auto const& elm_size = sizeof(int) * num_elms; auto const& total_size = elm_size * num_nodes; - theCollective()->scatter( + theCollective()->scatter( total_size,elm_size,nullptr,[](NodeType node, void* ptr){ auto ptr_out = reinterpret_cast(ptr); for (std::size_t i = 0; i < num_elms; i++) { From 1a286a87dd3a235c602830cca12feb086a197918 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Wed, 8 Feb 2023 15:46:41 +0100 Subject: [PATCH 10/32] #276: Automatically synthesize message type in vt/group --- src/vt/group/group_manager.h | 18 ++++++++++++++ src/vt/objgroup/manager.h | 28 ++++++++++++++++++++++ src/vt/objgroup/manager.impl.h | 2 +- src/vt/objgroup/proxy/proxy_objgroup_elm.h | 21 ++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) diff --git a/src/vt/group/group_manager.h b/src/vt/group/group_manager.h index 24f9a6c101..d091877d2e 100644 --- a/src/vt/group/group_manager.h +++ b/src/vt/group/group_manager.h @@ -193,6 +193,24 @@ struct GroupManager : runtime::component::Component { template *f> void sendMsg(GroupType const group, MsgT* msg); + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = T; + using ReturnType = ReturnT; + }; + + template + void sendMsg( + GroupType const group, + typename FunctionTraits::MsgT* msg + ) { + using MsgT = typename FunctionTraits::MsgT; + return sendMsg(group, msg); + } + friend struct Info; friend struct InfoColl; friend struct FinishedWork; diff --git a/src/vt/objgroup/manager.h b/src/vt/objgroup/manager.h index 937b615fc3..8fd804b386 100644 --- a/src/vt/objgroup/manager.h +++ b/src/vt/objgroup/manager.h @@ -273,6 +273,34 @@ struct ObjGroupManager : runtime::component::Component { collective::reduce::ReduceStamp const& stamp ); + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = T; + using ReturnType = ReturnT; + }; + + /** + * \brief Perform a reduction over an objgroup + * + * \param[in] proxy proxy to the object group + * \param[in] msg reduction message + * \param[in] stamp stamp to identify reduction across nodes + * + * \return the PendingSend corresponding to the reduce + */ + template + PendingSendType reduce( + ProxyType proxy, + messaging::MsgPtrThief::MsgT> msg, + collective::reduce::ReduceStamp const& stamp + ) { + using MsgT = typename FunctionTraits::MsgT; + return reduce(proxy, msg, stamp); + } + /** * \brief Get a pointer to the local objgroup instance. Returns null if the * object doesn't exist. diff --git a/src/vt/objgroup/manager.impl.h b/src/vt/objgroup/manager.impl.h index 0f2a6ec223..898057609a 100644 --- a/src/vt/objgroup/manager.impl.h +++ b/src/vt/objgroup/manager.impl.h @@ -271,7 +271,7 @@ ObjGroupManager::PendingSendType ObjGroupManager::reduce( auto const objgroup = proxy.getProxy(); auto r = theCollective()->getReducerObjGroup(objgroup); - return r->template reduce(root, msg.get(), stamp); + return r->template reduce(root, msg.get(), stamp); } template diff --git a/src/vt/objgroup/proxy/proxy_objgroup_elm.h b/src/vt/objgroup/proxy/proxy_objgroup_elm.h index 58eca136b7..e5eebae2c2 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup_elm.h +++ b/src/vt/objgroup/proxy/proxy_objgroup_elm.h @@ -213,6 +213,27 @@ struct ProxyElm { template * f, typename... Args> void send(Args&&... args) const; + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = T; + using ReturnType = ReturnT; + }; + + /** + * \brief Send a message to the node indexed by this proxy to be + * delivered to the local object instance + * + * \param[in] args args to pass to the message constructor + */ + template + void send(Args&&... args) const { + using MsgT = typename FunctionTraits::MsgT; + send(std::forward(args)...); + } + private: NodeType node_ = uninitialized_destination; /**< The indexed node */ }; From 866483105374ac4ae9577cb28782130e50002871 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Wed, 8 Feb 2023 15:59:54 +0100 Subject: [PATCH 11/32] #276: Update calls to sendMsg and broadcastMsg --- examples/callback/callback.cc | 2 +- examples/collection/transpose.cc | 4 +-- examples/group/group_collective.cc | 2 +- examples/group/group_rooted.cc | 4 +-- .../hello_world_virtual_context.cc | 2 +- examples/hello_world/ring.cc | 2 +- examples/rdma/rdma_simple_get.cc | 2 +- examples/rdma/rdma_simple_get_direct.cc | 2 +- examples/rdma/rdma_simple_put.cc | 4 +-- examples/rdma/rdma_simple_put_direct.cc | 6 ++-- .../termination/termination_collective.cc | 4 +-- examples/termination/termination_rooted.cc | 4 +-- src/vt/collective/reduce/reduce.impl.h | 4 +-- src/vt/collective/scatter/scatter.cc | 2 +- src/vt/collective/scatter/scatter.impl.h | 2 +- src/vt/event/event.cc | 4 +-- .../collective/group_collective_finished.cc | 2 +- .../group/collective/group_info_collective.cc | 30 +++++++++---------- src/vt/group/global/group_default.impl.h | 2 +- src/vt/group/group_info.impl.h | 4 +-- src/vt/objgroup/proxy/proxy_objgroup.impl.h | 2 +- .../objgroup/proxy/proxy_objgroup_elm.impl.h | 2 +- src/vt/parameterization/parameterization.h | 4 +-- .../pipe/callback/anon/callback_anon.impl.h | 4 +-- src/vt/pipe/callback/anon/callback_anon_tl.cc | 2 +- src/vt/pipe/callback/callback_handler_bcast.h | 2 +- src/vt/rdma/collection/rdma_collection.cc | 2 +- src/vt/rdma/rdma.cc | 18 +++++------ src/vt/termination/dijkstra-scholten/comm.cc | 4 +-- src/vt/termination/termination.cc | 16 +++++----- src/vt/topos/location/location.impl.h | 8 ++--- src/vt/trace/trace_user_event.cc | 6 ++-- src/vt/vrt/context/context_vrtmanager.impl.h | 4 +-- tests/perf/comm_cost_curve.cc | 4 +-- tests/perf/ping_pong_am.cc | 6 ++-- tests/unit/active/test_active_bcast_put.cc | 2 +- tests/unit/active/test_active_broadcast.cc | 2 +- tests/unit/active/test_active_send.cc | 8 ++--- tests/unit/active/test_active_send_large.cc | 2 +- tests/unit/active/test_active_send_put.cc | 2 +- tests/unit/active/test_pending_send.cc | 6 ++-- tests/unit/collectives/test_mpi_collective.cc | 2 +- tests/unit/group/test_group.cc | 6 ++-- tests/unit/group/test_group.extended.cc | 2 +- tests/unit/lb/test_lb_data_comm.cc | 12 ++++---- tests/unit/location/test_location.cc | 2 +- tests/unit/mapping/test_mapping_registry.cc | 4 +-- tests/unit/memory/test_memory_active.cc | 4 +-- tests/unit/memory/test_memory_lifetime.cc | 8 ++--- tests/unit/pipe/test_callback_bcast.cc | 6 ++-- ...test_callback_bcast_collection.extended.cc | 4 +-- tests/unit/pipe/test_callback_func.cc | 2 +- tests/unit/pipe/test_callback_func_ctx.cc | 2 +- tests/unit/pipe/test_callback_send.cc | 6 ++-- .../test_callback_send_collection.extended.cc | 4 +-- tests/unit/pipe/test_signal_cleanup.cc | 4 +-- tests/unit/runtime/test_mpi_access_guards.cc | 2 +- tests/unit/scheduler/test_scheduler_loop.cc | 4 +-- tests/unit/termination/test_epoch_guard.cc | 4 +-- tests/unit/termination/test_term_chaining.cc | 12 ++++---- tests/unit/termination/test_term_cleanup.cc | 8 ++--- .../test_termination_action_common.impl.h | 2 +- .../test_termination_channel_counting.impl.h | 4 +-- .../termination/test_termination_reset.cc | 4 +-- tutorial/tutorial_1b.h | 2 +- tutorial/tutorial_1c.h | 2 +- tutorial/tutorial_1e.h | 2 +- tutorial/tutorial_1f.h | 2 +- tutorial/tutorial_1g.h | 8 ++--- tutorial/tutorial_3a.h | 4 +-- 70 files changed, 161 insertions(+), 161 deletions(-) diff --git a/examples/callback/callback.cc b/examples/callback/callback.cc index df734afcaf..c262118616 100644 --- a/examples/callback/callback.cc +++ b/examples/callback/callback.cc @@ -116,7 +116,7 @@ void colHan(TestMsg* msg, MyCol* col) { void bounceCallback(vt::Callback cb) { auto msg = vt::makeMessage(cb); - vt::theMsg()->sendMsg(1, msg); + vt::theMsg()->sendMsg(1, msg); } int main(int argc, char** argv) { diff --git a/examples/collection/transpose.cc b/examples/collection/transpose.cc index 32b1074880..0a4c1ad965 100644 --- a/examples/collection/transpose.cc +++ b/examples/collection/transpose.cc @@ -165,7 +165,7 @@ struct Block : vt::Collection { ); auto const from_idx = getIndex().x(); auto data_msg = vt::makeMessage(data_,from_idx); - vt::theMsg()->sendMsg( + vt::theMsg()->sendMsg( requesting_node, data_msg ); } @@ -313,7 +313,7 @@ static void solveGroupSetup(vt::NodeType this_node, vt::VirtualProxyType coll_pr if (this_node == 1) { auto msg = vt::makeMessage(coll_proxy); vt::envelopeSetGroup(msg->env, group_id); - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->broadcastMsg(msg); } }, true ); diff --git a/examples/group/group_collective.cc b/examples/group/group_collective.cc index f75ea2664a..e43a4b0e5e 100644 --- a/examples/group/group_collective.cc +++ b/examples/group/group_collective.cc @@ -91,7 +91,7 @@ int main(int argc, char** argv) { if (this_node == 1) { auto msg = vt::makeMessage(); vt::envelopeSetGroup(msg->env, group); - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->broadcastMsg(msg); } } ); diff --git a/examples/group/group_rooted.cc b/examples/group/group_rooted.cc index bd3f3777ef..094da60fe9 100644 --- a/examples/group/group_rooted.cc +++ b/examples/group/group_rooted.cc @@ -71,7 +71,7 @@ int main(int argc, char** argv) { if (this_node == 0) { auto msg = vt::makeMessage(this_node); - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->broadcastMsg(msg); using RangeType = vt::group::region::Range; auto list = std::make_unique(num_nodes / 2, num_nodes); @@ -79,7 +79,7 @@ int main(int argc, char** argv) { vt::theGroup()->newGroup(std::move(list), [=](vt::GroupType group){ auto gmsg = vt::makeMessage(this_node); vt::envelopeSetGroup(gmsg->env, group); - vt::theMsg()->broadcastMsg(gmsg); + vt::theMsg()->broadcastMsg(gmsg); }); } diff --git a/examples/hello_world/hello_world_virtual_context.cc b/examples/hello_world/hello_world_virtual_context.cc index 0153a5097e..8058287785 100644 --- a/examples/hello_world/hello_world_virtual_context.cc +++ b/examples/hello_world/hello_world_virtual_context.cc @@ -105,7 +105,7 @@ int main(int argc, char** argv) { // send out the proxy to all the nodes auto msg = vt::makeMessage(proxy); - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->broadcastMsg(msg); } vt::finalize(); diff --git a/examples/hello_world/ring.cc b/examples/hello_world/ring.cc index b955c930f6..2488dbf24f 100644 --- a/examples/hello_world/ring.cc +++ b/examples/hello_world/ring.cc @@ -75,7 +75,7 @@ static void sendToNext() { vt::NodeType next_node = this_node + 1 >= num_nodes ? 0 : this_node + 1; auto msg = vt::makeMessage(this_node); - vt::theMsg()->sendMsg(next_node, msg); + vt::theMsg()->sendMsg(next_node, msg); } int main(int argc, char** argv) { diff --git a/examples/rdma/rdma_simple_get.cc b/examples/rdma/rdma_simple_get.cc index 6ae5587d49..79d92ceb07 100644 --- a/examples/rdma/rdma_simple_get.cc +++ b/examples/rdma/rdma_simple_get.cc @@ -112,7 +112,7 @@ int main(int argc, char** argv) { auto msg = vt::makeMessage(this_node); msg->han = my_handle; - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->broadcastMsg(msg); } vt::finalize(); diff --git a/examples/rdma/rdma_simple_get_direct.cc b/examples/rdma/rdma_simple_get_direct.cc index ae4a9e00e7..5a720caab6 100644 --- a/examples/rdma/rdma_simple_get_direct.cc +++ b/examples/rdma/rdma_simple_get_direct.cc @@ -87,7 +87,7 @@ int main(int argc, char** argv) { auto msg = vt::makeMessage(this_node); msg->han = my_handle; - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->broadcastMsg(msg); } vt::finalize(); diff --git a/examples/rdma/rdma_simple_put.cc b/examples/rdma/rdma_simple_put.cc index 854e3d11e5..b9f24bb036 100644 --- a/examples/rdma/rdma_simple_put.cc +++ b/examples/rdma/rdma_simple_put.cc @@ -88,7 +88,7 @@ static void put_data_fn(HandleMsg* msg) { fmt::print("{}: after put: sending msg back to 0\n", this_node); auto msg2 = vt::makeMessage(this_node); msg2->han = handle; - vt::theMsg()->sendMsg(0, msg2); + vt::theMsg()->sendMsg(0, msg2); } ); } @@ -144,7 +144,7 @@ int main(int argc, char** argv) { auto msg = vt::makeMessage(this_node); msg->han = my_handle; - vt::theMsg()->broadcastMsg(msg, false); + vt::theMsg()->broadcastMsg(msg, false); } vt::finalize(); diff --git a/examples/rdma/rdma_simple_put_direct.cc b/examples/rdma/rdma_simple_put_direct.cc index 7463b0a959..eba91a7c25 100644 --- a/examples/rdma/rdma_simple_put_direct.cc +++ b/examples/rdma/rdma_simple_put_direct.cc @@ -84,7 +84,7 @@ static void putDataFn(HandleMsg* msg) { ); auto back = vt::makeMessage(han); - vt::theMsg()->sendMsg(0, back); + vt::theMsg()->sendMsg(0, back); }); } } @@ -117,8 +117,8 @@ int main(int argc, char** argv) { auto msg1 = vt::makeMessage(my_handle); auto msg2 = vt::makeMessage(my_handle); - vt::theMsg()->sendMsg(1, msg1); - vt::theMsg()->sendMsg(2, msg2); + vt::theMsg()->sendMsg(1, msg1); + vt::theMsg()->sendMsg(2, msg2); } vt::finalize(); diff --git a/examples/termination/termination_collective.cc b/examples/termination/termination_collective.cc index 09ecfa6a4a..90f4ef68f1 100644 --- a/examples/termination/termination_collective.cc +++ b/examples/termination/termination_collective.cc @@ -63,7 +63,7 @@ static void test_handler(TestMsg* msg) { num--; if (num > 0) { auto msg_send = vt::makeMessage(); - vt::theMsg()->sendMsg(nextNode(), msg_send); + vt::theMsg()->sendMsg(nextNode(), msg_send); } } @@ -89,7 +89,7 @@ int main(int argc, char** argv) { { auto msg = vt::makeMessage(); vt::envelopeSetEpoch(msg->env, epoch); - vt::theMsg()->sendMsg(nextNode(), msg); + vt::theMsg()->sendMsg(nextNode(), msg); } vt::theTerm()->finishedEpoch(epoch); diff --git a/examples/termination/termination_rooted.cc b/examples/termination/termination_rooted.cc index 08c3977b2f..3eb2c752d0 100644 --- a/examples/termination/termination_rooted.cc +++ b/examples/termination/termination_rooted.cc @@ -63,7 +63,7 @@ static void test_handler(TestMsg* msg) { num--; if (num > 0) { auto msg_send = vt::makeMessage(); - vt::theMsg()->sendMsg(nextNode(), msg_send); + vt::theMsg()->sendMsg(nextNode(), msg_send); } } @@ -88,7 +88,7 @@ int main(int argc, char** argv) { auto msg = vt::makeMessage(); vt::envelopeSetEpoch(msg->env, epoch); - vt::theMsg()->sendMsg(nextNode(), msg); + vt::theMsg()->sendMsg(nextNode(), msg); vt::theTerm()->finishedEpoch(epoch); } diff --git a/src/vt/collective/reduce/reduce.impl.h b/src/vt/collective/reduce/reduce.impl.h index f9a6d4d4bf..ccd37b57c4 100644 --- a/src/vt/collective/reduce/reduce.impl.h +++ b/src/vt/collective/reduce/reduce.impl.h @@ -282,7 +282,7 @@ void Reduce::startReduce(detail::ReduceStamp id, bool use_num_contrib) { scope_.str(), detail::stringizeStamp(id), root, this_node ); - theMsg()->sendMsg>(root, typed_msg); + theMsg()->sendMsg>(root, typed_msg); } else { vt_debug_print( normal, reduce, @@ -300,7 +300,7 @@ void Reduce::startReduce(detail::ReduceStamp id, bool use_num_contrib) { scope_.str(), detail::stringizeStamp(id), parent ); - theMsg()->sendMsg>(parent, typed_msg); + theMsg()->sendMsg>(parent, typed_msg); } } } diff --git a/src/vt/collective/scatter/scatter.cc b/src/vt/collective/scatter/scatter.cc index 370672f88a..1d9ee9dde0 100644 --- a/src/vt/collective/scatter/scatter.cc +++ b/src/vt/collective/scatter/scatter.cc @@ -112,7 +112,7 @@ void Scatter::scatterIn(ScatterMsg* msg) { ); std::memcpy(ptr, in_ptr, child_bytes_size); in_ptr += child_bytes_size; - theMsg()->sendMsg( + theMsg()->sendMsg( child, child_msg ); }); diff --git a/src/vt/collective/scatter/scatter.impl.h b/src/vt/collective/scatter/scatter.impl.h index 0e757b67fb..8423d08177 100644 --- a/src/vt/collective/scatter/scatter.impl.h +++ b/src/vt/collective/scatter/scatter.impl.h @@ -93,7 +93,7 @@ void Scatter::scatter( auto const& this_node = theContext()->getNode(); scatter_msg->user_han = handler; if (this_node != root_node) { - theMsg()->sendMsg( + theMsg()->sendMsg( root_node, scatter_msg ); } else { diff --git a/src/vt/event/event.cc b/src/vt/event/event.cc index f9b8dd7653..59737386cc 100644 --- a/src/vt/event/event.cc +++ b/src/vt/event/event.cc @@ -123,7 +123,7 @@ EventType AsyncEvent::attachAction(EventType const& event, ActionType callable) event, event_id, static_cast(event_state), this_node ); - theMsg()->sendMsg( + theMsg()->sendMsg( owning_node, msg ); @@ -162,7 +162,7 @@ EventType AsyncEvent::attachAction(EventType const& event, ActionType callable) vtAssertExpr(send_back == msg->sent_from_node_); auto msg_send = makeMessage(event, msg->event_back_); - theMsg()->sendMsg( + theMsg()->sendMsg( send_back, msg_send ); }; diff --git a/src/vt/group/collective/group_collective_finished.cc b/src/vt/group/collective/group_collective_finished.cc index 2b7b1864e6..a327676f17 100644 --- a/src/vt/group/collective/group_collective_finished.cc +++ b/src/vt/group/collective/group_collective_finished.cc @@ -68,7 +68,7 @@ void InfoColl::CollSetupFinished::operator()(FinishedReduceMsg* msg) { auto nmsg = makeMessage( msg->getGroup(),info->new_tree_cont_ ); - theMsg()->sendMsg( + theMsg()->sendMsg( info->known_root_node_, nmsg ); } else { diff --git a/src/vt/group/collective/group_info_collective.cc b/src/vt/group/collective/group_info_collective.cc index 248c02deda..7c7075eb67 100644 --- a/src/vt/group/collective/group_info_collective.cc +++ b/src/vt/group/collective/group_info_collective.cc @@ -227,7 +227,7 @@ void InfoColl::setupCollective() { auto msg = makeMessage( group_, up_tree_cont_, in_group, size, child ); - theMsg()->sendMsg(parent, msg); + theMsg()->sendMsg(parent, msg); } } @@ -336,7 +336,7 @@ void InfoColl::upTree() { auto msg = makeMessage( group,new_root_cont_,true,subtree_zero,root_node,0,extra ); - theMsg()->sendMsg(root_node, msg); + theMsg()->sendMsg(root_node, msg); for (std::size_t i = 1; i < msg_list.size(); i++) { vt_debug_print( @@ -347,7 +347,7 @@ void InfoColl::upTree() { msg_list[i]->setOpID(down_tree_cont_); auto pmsg = promoteMsg(msg_list[i]); - theMsg()->sendMsg(root_node, pmsg); + theMsg()->sendMsg(root_node, pmsg); ++send_down_; } in_phase_two_ = true; @@ -377,7 +377,7 @@ void InfoColl::upTree() { auto cmsg = makeMessage( group,op,is_in_group,total_subtree,child,level ); - theMsg()->sendMsg(p, cmsg); + theMsg()->sendMsg(p, cmsg); for (auto&& msg : msg_in_group) { span_children_.push_back(msg->getChild()); @@ -406,14 +406,14 @@ void InfoColl::upTree() { auto msg = makeMessage( group,op,is_in_group,static_cast(subtree_),child,0,extra ); - theMsg()->sendMsg(p, msg); + theMsg()->sendMsg(p, msg); /* * Forward all the children messages up the tree (up to 2 of them) */ for (std::size_t i = 0; i < msg_in_group.size(); i++) { // new MsgPtr to avoid thief of original in collection auto msg_out = promoteMsg(msg_in_group[i].get()); - theMsg()->sendMsg(p, msg_out); + theMsg()->sendMsg(p, msg_out); } } else if (is_in_group && msg_in_group.size() == 1) { /* @@ -438,10 +438,10 @@ void InfoColl::upTree() { auto msg = makeMessage( group,op,is_in_group,total_subtree,child,0,extra ); - theMsg()->sendMsg(p, msg); + theMsg()->sendMsg(p, msg); // new MsgPtr to avoid thief of original in collection auto msg_out = promoteMsg(msg_in_group[0].get()); - theMsg()->sendMsg(p, msg_out); + theMsg()->sendMsg(p, msg_out); } else { vtAssertExpr(msg_in_group.size() > 2); @@ -478,7 +478,7 @@ void InfoColl::upTree() { auto msg = makeMessage( group,op,is_in_group,total_subtree,child,0,extra ); - theMsg()->sendMsg(p, msg); + theMsg()->sendMsg(p, msg); vt_debug_print( verbose, group, @@ -494,7 +494,7 @@ void InfoColl::upTree() { GroupCollectiveMsg* tmsg = *iter; c[i] = tmsg->getChild(); auto pmsg = promoteMsg(tmsg); - theMsg()->sendMsg(p, pmsg); + theMsg()->sendMsg(p, pmsg); iter++; } @@ -503,7 +503,7 @@ void InfoColl::upTree() { GroupCollectiveMsg* tmsg = *iter; tmsg->setOpID(down_tree_cont_); auto pmsg = promoteMsg(tmsg); - theMsg()->sendMsg(c[i % extra], pmsg); + theMsg()->sendMsg(c[i % extra], pmsg); ++send_down_; ++iter; } @@ -639,13 +639,13 @@ void InfoColl::downTree(GroupCollectiveMsg* msg) { auto const& num = collective_->span_children_.size(); auto const& child = collective_->span_children_[msg->getChild() % num]; auto nmsg = makeMessage(*msg); - theMsg()->sendMsg(child, nmsg); + theMsg()->sendMsg(child, nmsg); ++send_down_; } auto const& group_ = getGroupID(); auto nmsg = makeMessage(group_,down_tree_fin_cont_); - theMsg()->sendMsg(from, nmsg); + theMsg()->sendMsg(from, nmsg); } void InfoColl::newTree(NodeType const& parent) { @@ -686,7 +686,7 @@ void InfoColl::sendDownNewTree() { group_, c ); auto msg = makeMessage(group_,new_tree_cont_); - theMsg()->sendMsg(c, msg); + theMsg()->sendMsg(c, msg); } } @@ -727,7 +727,7 @@ void InfoColl::finalize() { auto msg = makeMessage( group_,finalize_cont_,known_root_node_,is_default_group_ ); - theMsg()->sendMsg(c, msg); + theMsg()->sendMsg(c, msg); } if (!is_in_group) { diff --git a/src/vt/group/global/group_default.impl.h b/src/vt/group/global/group_default.impl.h index 57ec37eca8..8d50239776 100644 --- a/src/vt/group/global/group_default.impl.h +++ b/src/vt/group/global/group_default.impl.h @@ -65,7 +65,7 @@ template * handler> } else { auto msg = makeMessage(); envelopeSetTag(msg->env, phase); - theMsg()->sendMsg(node, msg); + theMsg()->sendMsg(node, msg); } } diff --git a/src/vt/group/group_info.impl.h b/src/vt/group/group_info.impl.h index ba8ca3113b..10fdfd5794 100644 --- a/src/vt/group/group_info.impl.h +++ b/src/vt/group/group_info.impl.h @@ -115,7 +115,7 @@ template if (op_id != no_op_id) { // Send back message auto retmsg = makeMessage(group, op_id); - theMsg()->sendMsg( + theMsg()->sendMsg( parent, retmsg ); } @@ -151,7 +151,7 @@ template auto contmsg = makeMessage(group, op_id); if (parent != this_node) { - theMsg()->sendMsg( + theMsg()->sendMsg( parent, contmsg ); } else { diff --git a/src/vt/objgroup/proxy/proxy_objgroup.impl.h b/src/vt/objgroup/proxy/proxy_objgroup.impl.h index 78a9b30ece..078e65231c 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup.impl.h +++ b/src/vt/objgroup/proxy/proxy_objgroup.impl.h @@ -217,7 +217,7 @@ messaging::PendingSend Proxy::broadcast(Args&&... args) const { template * f> messaging::PendingSend Proxy::broadcastMsg(messaging::MsgPtrThief msg, TagType tag) const { - return theMsg()->broadcastMsg(msg, true, tag); + return theMsg()->broadcastMsg(msg, true, tag); } template diff --git a/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h b/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h index 9570f60dc7..4641f718bc 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h +++ b/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h @@ -116,7 +116,7 @@ inline ProxyElm::ProxyElm(NodeType in_node) : node_{in_node} {} template * f, typename... Args> void ProxyElm::send(Args&&... args) const { - vt::theMsg()->sendMsg( + vt::theMsg()->sendMsg( node_, vt::makeMessage(std::forward(args)...)); } diff --git a/src/vt/parameterization/parameterization.h b/src/vt/parameterization/parameterization.h index 5f9c15e8c9..9c427ac33a 100644 --- a/src/vt/parameterization/parameterization.h +++ b/src/vt/parameterization/parameterization.h @@ -150,7 +150,7 @@ struct Param : runtime::component::Component { auto m = makeMessage>( han, std::forward>(tup) ); - theMsg()->sendMsg, dataMessageHandler>(dest, m); + theMsg()->sendMsg(dest, m); } template @@ -169,7 +169,7 @@ struct Param : runtime::component::Component { MsgSharedPtr m ) { auto pmsg = promoteMsg(m.get()); - theMsg()->sendMsg(dest, pmsg); + theMsg()->sendMsg(dest, pmsg); } template diff --git a/src/vt/pipe/callback/anon/callback_anon.impl.h b/src/vt/pipe/callback/anon/callback_anon.impl.h index 83a84f7dd1..04378a0a29 100644 --- a/src/vt/pipe/callback/anon/callback_anon.impl.h +++ b/src/vt/pipe/callback/anon/callback_anon.impl.h @@ -80,7 +80,7 @@ CallbackAnon::triggerDispatch(SignalDataType* data, PipeType const& pid) { triggerPipe(pid); } else { auto msg = makeMessage(pid); - theMsg()->sendMsg(pipe_node, msg); + theMsg()->sendMsg(pipe_node, msg); } } @@ -105,7 +105,7 @@ CallbackAnon::triggerDispatch(SignalDataType* data, PipeType const& pid) { */ setPipeType(data->env); envelopeSetGroup(data->env,pid); - theMsg()->sendMsg(pipe_node, data); + theMsg()->sendMsg(pipe_node, data); } } diff --git a/src/vt/pipe/callback/anon/callback_anon_tl.cc b/src/vt/pipe/callback/anon/callback_anon_tl.cc index dc2b2aab8a..02f76bb1c0 100644 --- a/src/vt/pipe/callback/anon/callback_anon_tl.cc +++ b/src/vt/pipe/callback/anon/callback_anon_tl.cc @@ -65,7 +65,7 @@ void CallbackAnonTypeless::triggerVoid(PipeType const& pipe) { theCB()->triggerPipe(pipe); } else { auto msg = makeMessage(pipe,true); - theMsg()->sendMsg(pipe_node, msg); + theMsg()->sendMsg(pipe_node, msg); } } diff --git a/src/vt/pipe/callback/callback_handler_bcast.h b/src/vt/pipe/callback/callback_handler_bcast.h index 411042b205..b53e5cdf03 100644 --- a/src/vt/pipe/callback/callback_handler_bcast.h +++ b/src/vt/pipe/callback/callback_handler_bcast.h @@ -62,7 +62,7 @@ struct CallbackBcast : CallbackBase> { private: void trigger_(SignalDataType* data) override { - theMsg()->broadcastMsg(data); + theMsg()->broadcastMsg(data); } }; diff --git a/src/vt/rdma/collection/rdma_collection.cc b/src/vt/rdma/collection/rdma_collection.cc index 04085d3c83..c8565a1b9a 100644 --- a/src/vt/rdma/collection/rdma_collection.cc +++ b/src/vt/rdma/collection/rdma_collection.cc @@ -125,7 +125,7 @@ namespace vt { namespace rdma { if (tag != no_tag) { envelopeSetTag(msg->env, tag); } - theMsg()->sendMsg( + theMsg()->sendMsg( default_node, msg ); diff --git a/src/vt/rdma/rdma.cc b/src/vt/rdma/rdma.cc index d451bc8eda..522bec52f3 100644 --- a/src/vt/rdma/rdma.cc +++ b/src/vt/rdma/rdma.cc @@ -187,7 +187,7 @@ RDMAManager::RDMAManager() ); if (send_back != uninitialized_destination) { auto new_msg = makeMessage(op_id); - theMsg()->sendMsg(send_back, new_msg); + theMsg()->sendMsg(send_back, new_msg); } }, false, recv_node ); @@ -228,7 +228,7 @@ RDMAManager::RDMAManager() ); if (send_back != uninitialized_destination) { auto new_msg = makeMessage(op_id); - theMsg()->sendMsg( + theMsg()->sendMsg( send_back, new_msg ); } @@ -250,7 +250,7 @@ RDMAManager::RDMAManager() ); if (send_back) { auto new_msg = makeMessage(op_id); - theMsg()->sendMsg( + theMsg()->sendMsg( send_back, new_msg ); } @@ -669,7 +669,7 @@ void RDMAManager::putData( envelopeSetTag(msg->env, tag); } - theMsg()->sendMsg( + theMsg()->sendMsg( put_node, msg, no_tag ); @@ -965,7 +965,7 @@ void RDMAManager::getDataIntoBuf( if (tag != no_tag) { envelopeSetTag(msg->env, tag); } - theMsg()->sendMsg(getNode, msg); + theMsg()->sendMsg(getNode, msg); pending_ops_.emplace( std::piecewise_construct, @@ -1002,7 +1002,7 @@ void RDMAManager::getData( if (tag != no_tag) { envelopeSetTag(msg->env, tag); } - theMsg()->sendMsg(getNode, msg); + theMsg()->sendMsg(getNode, msg); pending_ops_.emplace( std::piecewise_construct, @@ -1095,7 +1095,7 @@ void RDMAManager::setupChannelWithRemote( auto msg = makeMessage( type, han, num_bytes, tag, cb, dest, override_target ); - theMsg()->sendMsg(other_node, msg); + theMsg()->sendMsg(other_node, msg); return createDirectChannelInternal( type, han, dest, nullptr, target, tag, num_bytes @@ -1295,7 +1295,7 @@ void RDMAManager::createDirectChannelInternal( auto msg = makeMessage( type, han, unique_channel_tag, target, this_node, cb ); - theMsg()->sendMsg(target, msg); + theMsg()->sendMsg(target, msg); } else { return createDirectChannelFinish( type, han, non_target, action, channel_tag, is_target, num_bytes, @@ -1337,7 +1337,7 @@ void RDMAManager::removeDirectChannel( auto msg = makeMessage( RDMA_TypeType::Get, han, no_byte, no_tag, cb ); - theMsg()->sendMsg(target, msg); + theMsg()->sendMsg(target, msg); } else { auto iter = channels_.find( makeChannelLookup(han,RDMA_TypeType::Get,target,this_node) diff --git a/src/vt/termination/dijkstra-scholten/comm.cc b/src/vt/termination/dijkstra-scholten/comm.cc index 998429afdb..3788348429 100644 --- a/src/vt/termination/dijkstra-scholten/comm.cc +++ b/src/vt/termination/dijkstra-scholten/comm.cc @@ -66,7 +66,7 @@ namespace vt { namespace term { namespace ds { vtAssertExpr(successor != node); auto msg = makeMessage(epoch,node,successor,count); theMsg()->markAsTermMessage(msg); - theMsg()->sendMsg(successor, msg); + theMsg()->sendMsg(successor, msg); } /*static*/ void StateDS::acknowledge( @@ -81,7 +81,7 @@ namespace vt { namespace term { namespace ds { vtAssertExpr(predecessor != node); auto msg = makeMessage(epoch,node,predecessor,count); theMsg()->markAsTermMessage(msg); - theMsg()->sendMsg(predecessor, msg); + theMsg()->sendMsg(predecessor, msg); } /*static*/ void StateDS::rootTerminated(EpochType epoch) { diff --git a/src/vt/termination/termination.cc b/src/vt/termination/termination.cc index d0af8168c4..a8a5db7dd7 100644 --- a/src/vt/termination/termination.cc +++ b/src/vt/termination/termination.cc @@ -365,7 +365,7 @@ bool TerminationDetector::propagateEpoch(TermStateType& state) { parent, print_ptr(msg.get()), state.getEpoch(), state.getCurWave() ); - theMsg()->sendMsg(parent, msg); + theMsg()->sendMsg(parent, msg); } else /*if (is_root) */ { is_term = state.g_prod1 == state.g_cons1 and @@ -404,7 +404,7 @@ bool TerminationDetector::propagateEpoch(TermStateType& state) { if (is_term) { auto msg = makeMessage(state.getEpoch()); theMsg()->markAsTermMessage(msg); - theMsg()->broadcastMsg(msg, false); + theMsg()->broadcastMsg(msg, false); vt_debug_print( terse, term, @@ -441,7 +441,7 @@ bool TerminationDetector::propagateEpoch(TermStateType& state) { auto msg = makeMessage(state.getEpoch(), state.getCurWave()); theMsg()->markAsTermMessage(msg); - theMsg()->broadcastMsg(msg, false); + theMsg()->broadcastMsg(msg, false); } } @@ -520,7 +520,7 @@ void TerminationDetector::countsConstant(TermStateType& state) { if (not theConfig()->vt_no_detect_hang) { auto msg = makeMessage(); theMsg()->markAsTermMessage(msg.get()); - theMsg()->broadcastMsg(msg, false); + theMsg()->broadcastMsg(msg, false); hangCheckHandler(nullptr); } } @@ -537,7 +537,7 @@ void TerminationDetector::startEpochGraphBuild() { if (theConfig()->vt_epoch_graph_on_hang) { auto msg = makeMessage(); theMsg()->markAsTermMessage(msg.get()); - theMsg()->broadcastMsg(msg, false); + theMsg()->broadcastMsg(msg, false); buildLocalGraphHandler(nullptr); } } @@ -705,7 +705,7 @@ void TerminationDetector::inquireTerminated( bool const is_ready = true; auto msg = makeMessage(epoch,is_ready); - theMsg()->sendMsg(from, msg); + theMsg()->sendMsg(from, msg); }); } @@ -773,7 +773,7 @@ TermStatusEnum TerminationDetector::testEpochTerminated(EpochType epoch) { * terminated or not */ auto msg = makeMessage(epoch,this_node_); - theMsg()->sendMsg(root, msg); + theMsg()->sendMsg(root, msg); epoch_wait_status_.insert(epoch); } status = TermStatusEnum::Remote; @@ -957,7 +957,7 @@ void TerminationDetector::initializeRootedWaveEpoch( */ auto msg = makeMessage(epoch); theMsg()->markAsTermMessage(msg); - theMsg()->broadcastMsg(msg, false); + theMsg()->broadcastMsg(msg, false); /* * Setup the new rooted epoch locally on the root node (this node) diff --git a/src/vt/topos/location/location.impl.h b/src/vt/topos/location/location.impl.h index 7ffeaa7efa..b0f065f3ad 100644 --- a/src/vt/topos/location/location.impl.h +++ b/src/vt/topos/location/location.impl.h @@ -174,7 +174,7 @@ void EntityLocationCoord::registerEntity( ); msg->setResolvedNode(this_node); theMsg()->markAsLocationMessage(msg); - theMsg()->sendMsg::updateLocation>(home, msg); + theMsg()->sendMsg<&EntityLocationCoord::updateLocation>(home, msg); } } } @@ -424,7 +424,7 @@ void EntityLocationCoord::getLocation( this_inst, id, event_id, this_node, home_node ); theMsg()->markAsLocationMessage(msg); - theMsg()->sendMsg::getLocationHandler>(home_node, msg); + theMsg()->sendMsg<&EntityLocationCoord::getLocationHandler>(home_node, msg); // save a pending action when information about location arrives pending_actions_.emplace( std::piecewise_construct, @@ -497,7 +497,7 @@ void EntityLocationCoord::sendEagerUpdate( auto msg = makeMessage( this_inst, id, ask_node, home_node, deliver_node ); - theMsg()->sendMsg::recvEagerUpdate>(ask_node, msg); + theMsg()->sendMsg<&EntityLocationCoord::recvEagerUpdate>(ask_node, msg); } } @@ -892,7 +892,7 @@ template ); msg2->setResolvedNode(node); theMsg()->markAsLocationMessage(msg2); - theMsg()->sendMsg::updateLocation>(ask_node, msg2); + theMsg()->sendMsg<&EntityLocationCoord::updateLocation>(ask_node, msg2); }); theMsg()->popEpoch(epoch); theTerm()->consume(epoch); diff --git a/src/vt/trace/trace_user_event.cc b/src/vt/trace/trace_user_event.cc index 3d7e74a9bd..483f0dec80 100644 --- a/src/vt/trace/trace_user_event.cc +++ b/src/vt/trace/trace_user_event.cc @@ -87,7 +87,7 @@ UserEventIDType UserEventRegistry::hash(std::string const& in_event_name) { auto const node = theContext()->getNode(); if (node != 0) { auto msg = makeMessage(false, id, in_event_name); - theMsg()->sendMsg(0, msg); + theMsg()->sendMsg(0, msg); } } return id; @@ -99,7 +99,7 @@ UserEventIDType UserEventRegistry::rooted(std::string const& in_event_name) { auto const node = theContext()->getNode(); if (node != 0) { auto msg = makeMessage(false, id, in_event_name); - theMsg()->sendMsg(0, msg); + theMsg()->sendMsg(0, msg); } return id; } @@ -112,7 +112,7 @@ UserEventIDType UserEventRegistry::user( auto const node = theContext()->getNode(); if (node != 0) { auto msg = makeMessage(true, id, in_event_name); - theMsg()->sendMsg(0, msg); + theMsg()->sendMsg(0, msg); } return id; } diff --git a/src/vt/vrt/context/context_vrtmanager.impl.h b/src/vt/vrt/context/context_vrtmanager.impl.h index 5f75805da7..39d3bad273 100644 --- a/src/vt/vrt/context/context_vrtmanager.impl.h +++ b/src/vt/vrt/context/context_vrtmanager.impl.h @@ -105,7 +105,7 @@ template auto send_msg = makeMessage( cons_node, req_node, request_id, new_proxy ); - theMsg()->sendMsg( + theMsg()->sendMsg( req_node, send_msg ); } @@ -218,7 +218,7 @@ VirtualProxyType VirtualContextManager::makeVirtualRemote( sys_msg->info = *info.get(); - theMsg()->sendMsg>(dest, sys_msg); + theMsg()->sendMsg>(dest, sys_msg); return return_proxy; } diff --git a/tests/perf/comm_cost_curve.cc b/tests/perf/comm_cost_curve.cc index d7cca1e673..c5366e4478 100644 --- a/tests/perf/comm_cost_curve.cc +++ b/tests/perf/comm_cost_curve.cc @@ -78,7 +78,7 @@ static void handler(PingMsg*) { count++; if (count == pings) { auto msg = vt::makeMessage(1); - vt::theMsg()->sendMsg(0, msg); + vt::theMsg()->sendMsg(0, msg); count = 0; } } @@ -88,7 +88,7 @@ void sender() { auto start = vt::timing::getCurrentTime(); for (int i = 0; i < pings; i++) { auto msg = vt::makeMessage(bytes); - vt::theMsg()->sendMsg(1, msg); + vt::theMsg()->sendMsg(1, msg); } vt::theSched()->runSchedulerWhile([]{return !is_done; }); diff --git a/tests/perf/ping_pong_am.cc b/tests/perf/ping_pong_am.cc index 182685840f..cecb2445ab 100644 --- a/tests/perf/ping_pong_am.cc +++ b/tests/perf/ping_pong_am.cc @@ -66,7 +66,7 @@ void handlerFinished(MyMsg* msg); void handler(MyMsg* in_msg) { auto msg = makeMessage(); - theMsg()->sendMsg(0, msg); + theMsg()->sendMsg<&handlerFinished>(0, msg); } struct NodeObj { @@ -88,7 +88,7 @@ struct NodeObj { void perfPingPong(MyMsg* in_msg) { test_obj_->StartTimer(fmt::format("{} ping-pong", i)); auto msg = makeMessage(); - theMsg()->sendMsg(1, msg); + theMsg()->sendMsg<&handler>(1, msg); } private: @@ -104,7 +104,7 @@ void handlerFinished(MyMsg* msg) { } else { i++; auto msg = makeMessage(); - theMsg()->sendMsg(1, msg); + theMsg()->sendMsg<&handler>(1, msg); } } diff --git a/tests/unit/active/test_active_bcast_put.cc b/tests/unit/active/test_active_bcast_put.cc index 78a6ba4e21..046eb1f0cf 100644 --- a/tests/unit/active/test_active_bcast_put.cc +++ b/tests/unit/active/test_active_bcast_put.cc @@ -127,7 +127,7 @@ TEST_P(TestActiveBroadcastPut, test_type_safe_active_fn_bcast2) { for (int i = 0; i < num_msg_sent; i++) { auto msg = makeMessage(); msg->setPut(put_payload.data(), put_size * sizeof(int)); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); } } }); diff --git a/tests/unit/active/test_active_broadcast.cc b/tests/unit/active/test_active_broadcast.cc index 8eeeecc7ab..274ba5846a 100644 --- a/tests/unit/active/test_active_broadcast.cc +++ b/tests/unit/active/test_active_broadcast.cc @@ -104,7 +104,7 @@ TEST_P(TestActiveBroadcast, test_type_safe_active_fn_bcast2) { auto msg = makeMessage(); auto msg_hold = promoteMsg(msg.get()); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); EXPECT_TRUE(envelopeIsLocked(msg_hold->env)) << "Should be locked on send"; } } diff --git a/tests/unit/active/test_active_send.cc b/tests/unit/active/test_active_send.cc index f996b6b33f..8313daf0fe 100644 --- a/tests/unit/active/test_active_send.cc +++ b/tests/unit/active/test_active_send.cc @@ -163,7 +163,7 @@ TEST_F(TestActiveSend, test_type_safe_active_fn_send) { auto msg = makeMessage(); auto msg_hold = promoteMsg(msg.get()); - theMsg()->sendMsg(to_node, msg); + theMsg()->sendMsg(to_node, msg); EXPECT_TRUE(envelopeIsLocked(msg_hold->env)) << "Should be locked on send"; } } @@ -194,7 +194,7 @@ TEST_F(TestActiveSend, test_type_safe_active_fn_send_small_put) { #if DEBUG_TEST_HARNESS_PRINT fmt::print("{}: sendMsg: (put) i={}\n", my_node, i); #endif - theMsg()->sendMsg(to_node, msg); + theMsg()->sendMsg(to_node, msg); } } @@ -219,7 +219,7 @@ TEST_F(TestActiveSend, test_type_safe_active_fn_send_large_put) { #if DEBUG_TEST_HARNESS_PRINT fmt::print("{}: sendMsg: (put) i={}\n", my_node, i); #endif - theMsg()->sendMsg(to_node, msg); + theMsg()->sendMsg(to_node, msg); } } @@ -235,7 +235,7 @@ TEST_F(TestActiveSend, test_active_message_serialization) { auto msg = vt::makeMessage(); msg->data.resize(serialization::serialized_msg_eager_size); - theMsg()->sendMsg(this_node, msg); + theMsg()->sendMsg(this_node, msg); } }); diff --git a/tests/unit/active/test_active_send_large.cc b/tests/unit/active/test_active_send_large.cc index 16a70822b8..7833fd87a5 100644 --- a/tests/unit/active/test_active_send_large.cc +++ b/tests/unit/active/test_active_send_large.cc @@ -140,7 +140,7 @@ TYPED_TEST_P(TestActiveSendLarge, test_large_bytes_msg) { auto msg = makeMessage(); fillMsg(msg); msg->cb_ = cb; - theMsg()->sendMsg>(next_node, msg); + theMsg()->sendMsg>(next_node, msg); }); EXPECT_EQ(counter, 1); diff --git a/tests/unit/active/test_active_send_put.cc b/tests/unit/active/test_active_send_put.cc index 8cf89320f7..ba2c52551f 100644 --- a/tests/unit/active/test_active_send_put.cc +++ b/tests/unit/active/test_active_send_put.cc @@ -113,7 +113,7 @@ TEST_P(TestActiveSendPut, test_active_fn_send_put_param) { #if DEBUG_TEST_HARNESS_PRINT fmt::print("{}: sendMsg: (put) i={}\n", my_node, i); #endif - theMsg()->sendMsg(1, msg); + theMsg()->sendMsg(1, msg); } // Spin here so test_vec does not go out of scope before the send completes diff --git a/tests/unit/active/test_pending_send.cc b/tests/unit/active/test_pending_send.cc index ccb55513cc..9f320ddd5c 100644 --- a/tests/unit/active/test_pending_send.cc +++ b/tests/unit/active/test_pending_send.cc @@ -65,7 +65,7 @@ struct TestPendingSend : TestParallelHarness { auto const num_nodes = theContext()->getNumNodes(); auto prev = this_node - 1 >= 0 ? this_node - 1 : num_nodes - 1; auto msg = vt::makeMessage(); - theMsg()->sendMsg(prev, msg); + theMsg()->sendMsg(prev, msg); } static void handlerLocal(TestMsg* msg) { auto const this_node = theContext()->getNode(); @@ -93,7 +93,7 @@ TEST_F(TestPendingSend, test_pending_send_hold) { auto msg = vt::makeMessage(); auto msg_hold = promoteMsg(msg.get()); pending.emplace_back( - theMsg()->sendMsg(next, msg) + theMsg()->sendMsg(next, msg) ); // Must be stamped with the current epoch @@ -134,7 +134,7 @@ TEST_F(TestPendingSend, test_pending_broadcast_hold) { auto msg = vt::makeMessage(theContext()->getNode()); auto msg_hold = promoteMsg(msg.get()); - pending.emplace_back(theMsg()->broadcastMsg(msg)); + pending.emplace_back(theMsg()->broadcastMsg(msg)); // Must be stamped with the current epoch EXPECT_EQ(envelopeGetEpoch(msg_hold->env), ep); diff --git a/tests/unit/collectives/test_mpi_collective.cc b/tests/unit/collectives/test_mpi_collective.cc index 6b6cdbcf42..f137195344 100644 --- a/tests/unit/collectives/test_mpi_collective.cc +++ b/tests/unit/collectives/test_mpi_collective.cc @@ -257,7 +257,7 @@ TEST_F(TestMPICollective, test_mpi_collective_4) { // Broadcast out node 0's order to confirm with all other nodes if (this_node == 0) { auto msg = makeMessage(run_order); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); } } diff --git a/tests/unit/group/test_group.cc b/tests/unit/group/test_group.cc index 17056a224e..d3c425ae03 100644 --- a/tests/unit/group/test_group.cc +++ b/tests/unit/group/test_group.cc @@ -88,7 +88,7 @@ TEST_F(TestGroup, test_group_range_construct_1) { fmt::print("Group is created: group={:x}\n", group); auto msg = makeMessage(); envelopeSetGroup(msg->env, group); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); } ); } @@ -118,7 +118,7 @@ TEST_F(TestGroup, test_group_range_construct_2) { fmt::print("Group is created: group={:x}\n", group); auto msg = makeMessage(); envelopeSetGroup(msg->env, group); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); } ); } @@ -146,7 +146,7 @@ TEST_F(TestGroup, test_group_collective_construct_1) { EXPECT_EQ(is_default_group, false); auto msg = makeMessage(); envelopeSetGroup(msg->env, group); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); } ); }); diff --git a/tests/unit/group/test_group.extended.cc b/tests/unit/group/test_group.extended.cc index d28897bb50..a222164da0 100644 --- a/tests/unit/group/test_group.extended.cc +++ b/tests/unit/group/test_group.extended.cc @@ -83,7 +83,7 @@ static inline void activeMessageGroupCollective() { if (my_node == 1) { auto msg = makeMessage(); envelopeSetGroup(msg->env, group_id); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); } } ); diff --git a/tests/unit/lb/test_lb_data_comm.cc b/tests/unit/lb/test_lb_data_comm.cc index 42c17f35e0..6bd5808821 100644 --- a/tests/unit/lb/test_lb_data_comm.cc +++ b/tests/unit/lb/test_lb_data_comm.cc @@ -205,7 +205,7 @@ void simulateColTHandlerSends(MyMsg* msg, MyCol* col) { auto next = (this_node + 1) % num_nodes; for (int i = 0; i < num_sends; i++) { auto msg2 = makeMessage(); - vt::theMsg()->sendMsg(next, msg2); + vt::theMsg()->sendMsg(next, msg2); } } @@ -215,7 +215,7 @@ void MyObj::simulateObjGroupHandlerSends(MyMsg* msg) { auto next = (this_node + 1) % num_nodes; for (int i = 0; i < num_sends; i++) { auto msg2 = makeMessage(); - vt::theMsg()->sendMsg(next, msg2); + vt::theMsg()->sendMsg(next, msg2); } } @@ -251,7 +251,7 @@ void simulateHandlerHandlerSends(MyMsg* msg) { auto next = (this_node + 1) % num_nodes; for (int i = 0; i < num_sends; i++) { auto msg2 = makeMessage(); - vt::theMsg()->sendMsg(next, msg2); + vt::theMsg()->sendMsg(next, msg2); } } @@ -520,7 +520,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_handler_to_col_send) { auto num_nodes = theContext()->getNumNodes(); auto next = (this_node + 1) % num_nodes; auto msg = makeMessage(proxy); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); }); vt::thePhase()->nextPhaseCollective(); @@ -683,7 +683,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_handler_to_objgroup_send) { auto num_nodes = theContext()->getNumNodes(); auto next = (this_node + 1) % num_nodes; auto msg = makeMessage(obj_proxy_a); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); }); vt::thePhase()->nextPhaseCollective(); @@ -724,7 +724,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_handler_to_handler_send) { auto num_nodes = theContext()->getNumNodes(); auto next = (this_node + 1) % num_nodes; auto msg = makeMessage(); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); }); vt::thePhase()->nextPhaseCollective(); diff --git a/tests/unit/location/test_location.cc b/tests/unit/location/test_location.cc index 8be5b21aff..190cd2e50d 100644 --- a/tests/unit/location/test_location.cc +++ b/tests/unit/location/test_location.cc @@ -341,7 +341,7 @@ TYPED_TEST_P(TestLocationRoute, test_route_entity) { using MsgType = location::EntityMsg; bool is_long = std::is_same::value; auto msg = vt::makeMessage(entity, my_node, is_long); - vt::theMsg()->broadcastMsg>(msg); + vt::theMsg()->broadcastMsg>(msg); vt::theSched()->runSchedulerWhile([&msg_count, nb_nodes]{ return msg_count < nb_nodes; }); diff --git a/tests/unit/mapping/test_mapping_registry.cc b/tests/unit/mapping/test_mapping_registry.cc index 7606188a0a..2d998ac7c6 100644 --- a/tests/unit/mapping/test_mapping_registry.cc +++ b/tests/unit/mapping/test_mapping_registry.cc @@ -108,11 +108,11 @@ TEST_F(TestMappingRegistry, test_mapping_block_1d_registry) { auto map_han = auto_registry::makeAutoHandlerMap(); auto msg = makeMessage(map_han); msg->is_block = true; - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); auto map_han2 = auto_registry::makeAutoHandlerMap(); auto msg2 = makeMessage(map_han2); - theMsg()->broadcastMsg(msg2); + theMsg()->broadcastMsg(msg2); } } diff --git a/tests/unit/memory/test_memory_active.cc b/tests/unit/memory/test_memory_active.cc index 7ef27df03f..53ce419e4a 100644 --- a/tests/unit/memory/test_memory_active.cc +++ b/tests/unit/memory/test_memory_active.cc @@ -85,7 +85,7 @@ TYPED_TEST_P(TestMemoryActive, test_memory_remote_send) { for (int i = 0; i < num_msg_sent; i++) { auto msg = makeMessage(); msgs.push_back(msg); - theMsg()->sendMsg::test_handler>( + theMsg()->sendMsg::test_handler>( to_node, msg.get() ); } @@ -116,7 +116,7 @@ TYPED_TEST_P(TestMemoryActive, test_memory_remote_broadcast) { for (int i = 0; i < num_msg_sent; i++) { auto msg = makeMessage(); msgs.push_back(msg); - theMsg()->broadcastMsg::test_handler>( + theMsg()->broadcastMsg::test_handler>( msg.get() ); } diff --git a/tests/unit/memory/test_memory_lifetime.cc b/tests/unit/memory/test_memory_lifetime.cc index 90596e984c..8ab52b14c4 100644 --- a/tests/unit/memory/test_memory_lifetime.cc +++ b/tests/unit/memory/test_memory_lifetime.cc @@ -143,7 +143,7 @@ TEST_F(TestMemoryLifetime, test_active_bcast_serial_lifetime) { runInEpochCollective([&]{ for (int i = 0; i < num_msgs_sent; i++) { auto msg = makeMessage(); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); } }); @@ -165,7 +165,7 @@ TEST_F(TestMemoryLifetime, test_active_send_normal_lifetime_msgptr) { EXPECT_EQ(envelopeGetRef(msg->env), 1); auto msg_hold = promoteMsg(msg.get()); EXPECT_EQ(envelopeGetRef(msg_hold->env), 2); - theMsg()->sendMsg(next_node, msg); + theMsg()->sendMsg(next_node, msg); theTerm()->addAction([msg_hold]{ // Call event cleanup all pending MPI requests to clear theEvent()->finalize(); @@ -190,7 +190,7 @@ TEST_F(TestMemoryLifetime, test_active_bcast_normal_lifetime_msgptr) { EXPECT_EQ(envelopeGetRef(msg->env), 1); auto msg_hold = promoteMsg(msg.get()); EXPECT_EQ(envelopeGetRef(msg_hold->env), 2); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); theTerm()->addAction([msg_hold]{ // Call event cleanup all pending MPI requests to clear theEvent()->finalize(); @@ -227,7 +227,7 @@ TEST_F(TestMemoryLifetime, test_active_send_callback_lifetime_1) { for (int i = 0; i < num_msgs_sent; i++) { auto msg = makeMessage>(cb); auto msg_hold = promoteMsg(msg.get()); - theMsg()->broadcastMsg, callbackHan>(msg); + theMsg()->broadcastMsg(msg); theTerm()->addAction([msg_hold]{ // Call event cleanup all pending MPI requests to clear theEvent()->finalize(); diff --git a/tests/unit/pipe/test_callback_bcast.cc b/tests/unit/pipe/test_callback_bcast.cc index 27043b7069..3ebf52983d 100644 --- a/tests/unit/pipe/test_callback_bcast.cc +++ b/tests/unit/pipe/test_callback_bcast.cc @@ -160,7 +160,7 @@ TEST_F(TestCallbackBcast, test_callback_bcast_remote_1) { auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeBcast(); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); }); EXPECT_EQ(called, 100 * theContext()->getNumNodes()); @@ -178,7 +178,7 @@ TEST_F(TestCallbackBcast, test_callback_bcast_remote_2) { auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeBcast(); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); }); EXPECT_EQ(called, 200 * theContext()->getNumNodes()); @@ -196,7 +196,7 @@ TEST_F(TestCallbackBcast, test_callback_bcast_remote_3) { auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeBcast(); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); }); EXPECT_EQ(called, 300 * theContext()->getNumNodes()); diff --git a/tests/unit/pipe/test_callback_bcast_collection.extended.cc b/tests/unit/pipe/test_callback_bcast_collection.extended.cc index 8987da8a5b..0cd621c788 100644 --- a/tests/unit/pipe/test_callback_bcast_collection.extended.cc +++ b/tests/unit/pipe/test_callback_bcast_collection.extended.cc @@ -177,7 +177,7 @@ TEST_F(TestCallbackBcastCollection, test_callback_bcast_collection_2) { auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeBcast(proxy); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); } }); @@ -211,7 +211,7 @@ TEST_F(TestCallbackBcastCollection, test_callback_bcast_collection_3) { auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeBcast(proxy); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); } }); diff --git a/tests/unit/pipe/test_callback_func.cc b/tests/unit/pipe/test_callback_func.cc index 83c7078f92..a9603faa1c 100644 --- a/tests/unit/pipe/test_callback_func.cc +++ b/tests/unit/pipe/test_callback_func.cc @@ -93,7 +93,7 @@ TEST_F(TestCallbackFunc, test_callback_func_2) { vt::pipe::LifetimeEnum::Once, []{ called = 400; } ); auto msg = makeMessage(cb); - theMsg()->sendMsg(1, msg); + theMsg()->sendMsg(1, msg); } }); diff --git a/tests/unit/pipe/test_callback_func_ctx.cc b/tests/unit/pipe/test_callback_func_ctx.cc index d067146e66..09054798b6 100644 --- a/tests/unit/pipe/test_callback_func_ctx.cc +++ b/tests/unit/pipe/test_callback_func_ctx.cc @@ -131,7 +131,7 @@ TEST_F(TestCallbackFuncCtx, test_callback_func_ctx_2) { }); // fmt::print("{}: next={}\n", this_node, next); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); }); // fmt::print("{}: called={}\n", this_node, called); diff --git a/tests/unit/pipe/test_callback_send.cc b/tests/unit/pipe/test_callback_send.cc index 5e8f37a2f8..be1a577957 100644 --- a/tests/unit/pipe/test_callback_send.cc +++ b/tests/unit/pipe/test_callback_send.cc @@ -155,7 +155,7 @@ TEST_F(TestCallbackSend, test_callback_send_remote_1) { auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeSend(this_node); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); }); EXPECT_EQ(called, 100); @@ -171,7 +171,7 @@ TEST_F(TestCallbackSend, test_callback_send_remote_2) { auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeSend(this_node); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); }); EXPECT_EQ(called, 200); @@ -187,7 +187,7 @@ TEST_F(TestCallbackSend, test_callback_send_remote_3) { auto next = this_node + 1 < num_nodes ? this_node + 1 : 0; auto cb = theCB()->makeSend(this_node); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); }); EXPECT_EQ(called, 300); diff --git a/tests/unit/pipe/test_callback_send_collection.extended.cc b/tests/unit/pipe/test_callback_send_collection.extended.cc index 473ebc9149..d58edd4f4c 100644 --- a/tests/unit/pipe/test_callback_send_collection.extended.cc +++ b/tests/unit/pipe/test_callback_send_collection.extended.cc @@ -186,12 +186,12 @@ TEST_F(TestCallbackSendCollection, test_callback_send_collection_2) { auto cb = theCB()->makeSend(proxy(i)); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); } else { auto cb = theCB()->makeSend(proxy(i)); auto msg = makeMessage(cb); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); } } } diff --git a/tests/unit/pipe/test_signal_cleanup.cc b/tests/unit/pipe/test_signal_cleanup.cc index d650b8bb96..01bf454ac6 100644 --- a/tests/unit/pipe/test_signal_cleanup.cc +++ b/tests/unit/pipe/test_signal_cleanup.cc @@ -86,7 +86,7 @@ TEST_F(TestSignalCleanup, test_signal_cleanup_3) { } ); auto msg = makeMessage(cb); - theMsg()->sendMsg(1, msg); + theMsg()->sendMsg(1, msg); } // run until termination @@ -113,7 +113,7 @@ TEST_F(TestSignalCleanup, test_signal_cleanup_3) { } ); auto msg = makeMessage(cb); - theMsg()->sendMsg(1, msg); + theMsg()->sendMsg(1, msg); } // run until termination diff --git a/tests/unit/runtime/test_mpi_access_guards.cc b/tests/unit/runtime/test_mpi_access_guards.cc index d1e6e17535..4f63a80427 100644 --- a/tests/unit/runtime/test_mpi_access_guards.cc +++ b/tests/unit/runtime/test_mpi_access_guards.cc @@ -90,7 +90,7 @@ void testMpiAccess(bool access_allowed, bool grant_access) { // Sending message for common-case of attempting MPI access within // a message handler; it applies to all cases through the scheduler. auto msg = vt::makeMessage(); - theMsg()->sendMsg(1, msg); + theMsg()->sendMsg(1, msg); } } diff --git a/tests/unit/scheduler/test_scheduler_loop.cc b/tests/unit/scheduler/test_scheduler_loop.cc index fee8f98c7f..c39304ec6b 100644 --- a/tests/unit/scheduler/test_scheduler_loop.cc +++ b/tests/unit/scheduler/test_scheduler_loop.cc @@ -88,7 +88,7 @@ static void message_handler_with_nested_loop(TestMsg* msg) { auto next_msg = vt::makeMessage(); next_msg->action_ = next_depth; - theMsg()->sendMsg(target_node, next_msg); + theMsg()->sendMsg(target_node, next_msg); // ..run scheduler until someone also passed us the message. if ("nested" == action) { @@ -117,7 +117,7 @@ TEST_F(TestSchedulerLoop, test_scheduler_loop_nesting_1) { auto msg = vt::makeMessage(); msg->action_ = 1; - theMsg()->sendMsg(target_node, msg); + theMsg()->sendMsg(target_node, msg); done = false; theSched()->runSchedulerWhile([]{ return not done; }); diff --git a/tests/unit/termination/test_epoch_guard.cc b/tests/unit/termination/test_epoch_guard.cc index b828127475..e58360898e 100644 --- a/tests/unit/termination/test_epoch_guard.cc +++ b/tests/unit/termination/test_epoch_guard.cc @@ -74,7 +74,7 @@ struct TestEpochGuard : TestParallelHarness { EXPECT_EQ(theMsg()->getEpoch(), ep); auto node = theContext()->getNode(); if (0 == node) { - theMsg()->sendMsg(1, msg); + theMsg()->sendMsg(1, msg); } } @@ -91,7 +91,7 @@ struct TestEpochGuard : TestParallelHarness { EXPECT_EQ(theMsg()->getEpoch(), ep); auto node = theContext()->getNode(); if (0 == node) { - theMsg()->sendMsg(1, msg); + theMsg()->sendMsg(1, msg); } guard.pop(); diff --git a/tests/unit/termination/test_term_chaining.cc b/tests/unit/termination/test_term_chaining.cc index 42d1a6f760..4627e3e96a 100644 --- a/tests/unit/termination/test_term_chaining.cc +++ b/tests/unit/termination/test_term_chaining.cc @@ -79,7 +79,7 @@ struct TestTermChaining : TestParallelHarness { EXPECT_EQ(theContext()->getNode(), 1); auto msg2 = makeMessage(); - theMsg()->sendMsg(0, msg2); + theMsg()->sendMsg(0, msg2); } static void test_handler_response(TestMsg* msg) { @@ -96,7 +96,7 @@ struct TestTermChaining : TestParallelHarness { EXPECT_EQ(handler_count, 12); handler_count++; auto msg2 = makeMessage(); - theMsg()->sendMsg(0, msg2); + theMsg()->sendMsg(0, msg2); } static void test_handler_chained(TestMsg* msg) { @@ -140,7 +140,7 @@ struct TestTermChaining : TestParallelHarness { vt::theMsg()->pushEpoch(epoch1); auto msg = makeMessage(); chain.add( - epoch1, theMsg()->sendMsg(1, msg) + epoch1, theMsg()->sendMsg(1, msg) ); vt::theMsg()->popEpoch(epoch1); vt::theTerm()->finishedEpoch(epoch1); @@ -149,7 +149,7 @@ struct TestTermChaining : TestParallelHarness { vt::theMsg()->pushEpoch(epoch2); auto msg2 = makeMessage(); chain.add( - epoch2, theMsg()->sendMsg(1, msg2) + epoch2, theMsg()->sendMsg(1, msg2) ); vt::theMsg()->popEpoch(epoch2); vt::theTerm()->finishedEpoch(epoch2); @@ -165,7 +165,7 @@ struct TestTermChaining : TestParallelHarness { vt::theMsg()->pushEpoch(epoch1); auto msg = makeMessage(); chain.add( - epoch1, theMsg()->sendMsg(1, msg.get())); + epoch1, theMsg()->sendMsg(1, msg.get())); vt::theMsg()->popEpoch(epoch1); vt::theTerm()->finishedEpoch(epoch1); } @@ -182,7 +182,7 @@ struct TestTermChaining : TestParallelHarness { vt::theMsg()->pushEpoch(epoch3); auto msg3 = makeMessage(); chain.add( - epoch3, theMsg()->broadcastMsg(msg3.get())); + epoch3, theMsg()->broadcastMsg(msg3.get())); vt::theMsg()->popEpoch(epoch3); vt::theTerm()->finishedEpoch(epoch3); diff --git a/tests/unit/termination/test_term_cleanup.cc b/tests/unit/termination/test_term_cleanup.cc index a67e27c5b6..57f779f8a5 100644 --- a/tests/unit/termination/test_term_cleanup.cc +++ b/tests/unit/termination/test_term_cleanup.cc @@ -79,7 +79,7 @@ TEST_F(TestTermCleanup, test_termination_cleanup_1) { auto msg = makeMessage(); envelopeSetEpoch(msg->env, epoch); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); theTerm()->finishedEpoch(epoch); vt::runSchedulerThrough(epoch); @@ -123,17 +123,17 @@ TEST_F(TestTermCleanup, test_termination_cleanup_2) { for (int j = 0; j < 5; j++) { auto msg = makeMessage(); envelopeSetEpoch(msg->env, coll_epoch); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); } for (int j = 0; j < 5; j++) { auto msg = makeMessage(); envelopeSetEpoch(msg->env, root_epoch); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); } for (int j = 0; j < 5; j++) { auto msg = makeMessage(); envelopeSetEpoch(msg->env, wave_epoch); - theMsg()->sendMsg(next, msg); + theMsg()->sendMsg(next, msg); } theTerm()->finishedEpoch(coll_epoch); diff --git a/tests/unit/termination/test_termination_action_common.impl.h b/tests/unit/termination/test_termination_action_common.impl.h index 5dd8e61beb..ddd38219af 100644 --- a/tests/unit/termination/test_termination_action_common.impl.h +++ b/tests/unit/termination/test_termination_action_common.impl.h @@ -170,7 +170,7 @@ inline void add(vt::EpochType const& epoch, int order){ EXPECT_TRUE(channel::hasEnded(epoch)); channel::ok = true; auto msg = vt::makeMessage(); - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->broadcastMsg<&setOk>(msg); }); } } diff --git a/tests/unit/termination/test_termination_channel_counting.impl.h b/tests/unit/termination/test_termination_channel_counting.impl.h index b089b6b989..0991ee9ffd 100644 --- a/tests/unit/termination/test_termination_channel_counting.impl.h +++ b/tests/unit/termination/test_termination_channel_counting.impl.h @@ -55,7 +55,7 @@ void sendMsg(vt::NodeType dst, int count, vt::EpochType ep) { if (ep != vt::no_epoch) { vt::envelopeSetEpoch(msg->env,ep); } - vt::theMsg()->sendMsg(dst, msg); + vt::theMsg()->sendMsg(dst, msg); } // note: only for basic messages, @@ -68,7 +68,7 @@ void broadcast(int count, vt::EpochType ep) { if (ep != vt::no_epoch) { vt::envelopeSetEpoch(msg->env,ep); } - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->broadcastMsg(msg); for (auto&& active : data[ep].count_) { auto const& dst = active.first; diff --git a/tests/unit/termination/test_termination_reset.cc b/tests/unit/termination/test_termination_reset.cc index af7e42868e..2300e7b491 100644 --- a/tests/unit/termination/test_termination_reset.cc +++ b/tests/unit/termination/test_termination_reset.cc @@ -73,7 +73,7 @@ TEST_F(TestTermReset, test_termination_reset_1) { if (this_node == 0) { auto msg = makeMessage(); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); } else if (this_node == 1) { theTerm()->addAction([=]{ EXPECT_EQ(handler_count, 10); @@ -89,7 +89,7 @@ TEST_F(TestTermReset, test_termination_reset_1) { if (this_node == 1) { auto msg = makeMessage(); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); } else if (this_node == 0) { theTerm()->addAction([=]{ EXPECT_EQ(handler_count, 10); diff --git a/tutorial/tutorial_1b.h b/tutorial/tutorial_1b.h index b8b3ed1cba..94c4a959fc 100644 --- a/tutorial/tutorial_1b.h +++ b/tutorial/tutorial_1b.h @@ -117,7 +117,7 @@ static inline void activeMessageNode() { if (this_node == 0) { NodeType const to_node = 1; auto msg = ::vt::makeMessage(29,32); - ::vt::theMsg()->sendMsg(to_node, msg); + ::vt::theMsg()->sendMsg(to_node, msg); } } diff --git a/tutorial/tutorial_1c.h b/tutorial/tutorial_1c.h index 9aade203ba..f7e9946974 100644 --- a/tutorial/tutorial_1c.h +++ b/tutorial/tutorial_1c.h @@ -137,7 +137,7 @@ static inline void activeMessageSerialization() { auto msg = ::vt::makeMessage(1,2,3); msg->particles.push_back(Particle{10,11,12}); msg->particles.push_back(Particle{13,14,15}); - ::vt::theMsg()->sendMsg(to_node, msg); + ::vt::theMsg()->sendMsg(to_node, msg); } } diff --git a/tutorial/tutorial_1e.h b/tutorial/tutorial_1e.h index 839af157c7..bd21eacbf8 100644 --- a/tutorial/tutorial_1e.h +++ b/tutorial/tutorial_1e.h @@ -78,7 +78,7 @@ static inline void activeMessageGroupRoot() { fmt::print("Group is created: id={:x}\n", group_id); auto msg = makeMessage(); envelopeSetGroup(msg->env, group_id); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); }); // The `id' that is returned from the newGroup invocation, can be used // anywhere in the system to broadcast (multicast) to this group. diff --git a/tutorial/tutorial_1f.h b/tutorial/tutorial_1f.h index 0924fe1b78..fc6a79742c 100644 --- a/tutorial/tutorial_1f.h +++ b/tutorial/tutorial_1f.h @@ -84,7 +84,7 @@ static inline void activeMessageGroupCollective() { if (my_node == 1) { auto msg = makeMessage(); envelopeSetGroup(msg->env, group_id); - theMsg()->broadcastMsg(msg); + theMsg()->broadcastMsg(msg); } } ); diff --git a/tutorial/tutorial_1g.h b/tutorial/tutorial_1g.h index 4ba5ddc263..7379d165cf 100644 --- a/tutorial/tutorial_1g.h +++ b/tutorial/tutorial_1g.h @@ -113,21 +113,21 @@ static inline void activeMessageCallback() { { auto cb = ::vt::theCB()->makeFunc(vt::pipe::LifetimeEnum::Once, void_fn); auto msg = ::vt::makeMessage(cb); - ::vt::theMsg()->sendMsg(to_node, msg); + ::vt::theMsg()->sendMsg(to_node, msg); } // Example of active message handler callback with send node { auto cb = ::vt::theCB()->makeSend(cb_node); auto msg = ::vt::makeMessage(cb); - ::vt::theMsg()->sendMsg(to_node, msg); + ::vt::theMsg()->sendMsg(to_node, msg); } // Example of active message handler callback with broadcast { auto cb = ::vt::theCB()->makeBcast(); auto msg = ::vt::makeMessage(cb); - ::vt::theMsg()->sendMsg(to_node, msg); + ::vt::theMsg()->sendMsg(to_node, msg); } // Example of context callback @@ -136,7 +136,7 @@ static inline void activeMessageCallback() { vt::pipe::LifetimeEnum::Once, &ctx, callbackCtx ); auto msg = ::vt::makeMessage(cb); - ::vt::theMsg()->sendMsg(to_node, msg); + ::vt::theMsg()->sendMsg(to_node, msg); } } } diff --git a/tutorial/tutorial_3a.h b/tutorial/tutorial_3a.h index c1b37536f3..346b2e553e 100644 --- a/tutorial/tutorial_3a.h +++ b/tutorial/tutorial_3a.h @@ -78,7 +78,7 @@ static inline void activeMessageTerm() { if (this_node == 0) { auto msg = vt::makeMessage(8); envelopeSetEpoch(msg->env, new_epoch); - vt::theMsg()->sendMsg(this_node+1, msg); + vt::theMsg()->sendMsg(this_node+1, msg); } // Any node that wishes to have a notification on termination for a given @@ -116,7 +116,7 @@ static void recurHandler(ExampleMsg* msg) { ); auto msg_send = vt::makeMessage(msg->ttl); - vt::theMsg()->sendMsg(next_node, msg_send); + vt::theMsg()->sendMsg(next_node, msg_send); } } } From b3148701bf7a5ae6cd0743d36da5aeda05152aa5 Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Thu, 9 Feb 2023 20:33:49 +0100 Subject: [PATCH 12/32] #276: Automatically synthesize Msg type in vt/objgroup --- src/vt/objgroup/manager.h | 42 ++++++++++++ src/vt/objgroup/proxy/proxy_objgroup.h | 79 ++++++++++++++++++++++ src/vt/objgroup/proxy/proxy_objgroup_elm.h | 36 ++++++++++ tests/unit/objgroup/test_objgroup.cc | 18 ++--- 4 files changed, 166 insertions(+), 9 deletions(-) diff --git a/src/vt/objgroup/manager.h b/src/vt/objgroup/manager.h index 8fd804b386..cf817b1955 100644 --- a/src/vt/objgroup/manager.h +++ b/src/vt/objgroup/manager.h @@ -217,6 +217,32 @@ struct ObjGroupManager : runtime::component::Component { template fn> PendingSendType send(ProxyElmType proxy, MsgSharedPtr msg); + template + struct FunctionTraits; + + template + struct FunctionTraits { + using ObjT = Obj; + using MsgT = Msg; + using ReturnT = Return; + }; + + /** + * \internal \brief Send a message to an element of the object group + * + * \param[in] proxy proxy to the object group + * \param[in] msg message to send + */ + template + PendingSendType send( + ProxyElmType::ObjT> proxy, + MsgSharedPtr::MsgT> msg + ) { + using ObjType = typename FunctionTraits::ObjT; + using MsgType = typename FunctionTraits::MsgT; + return send(proxy, msg); + } + /** * \internal \brief Invoke message handler on an element of the object group * The message handler will be invoked inline without going through scheduler @@ -246,6 +272,22 @@ struct ObjGroupManager : runtime::component::Component { template fn> PendingSendType broadcast(ProxyType proxy, MsgSharedPtr msg); + /** + * \internal \brief Broadcast a message to all nodes in object group + * + * \param[in] proxy proxy to the object group + * \param[in] msg message to broadcast + */ + template + PendingSendType broadcast( + ProxyType::ObjT> proxy, + MsgSharedPtr::MsgT> msg + ) { + using ObjType = typename FunctionTraits::ObjT; + using MsgType = typename FunctionTraits::MsgT; + return broadcast(proxy, msg); + } + /** * \brief Change the traced name of the object group * diff --git a/src/vt/objgroup/proxy/proxy_objgroup.h b/src/vt/objgroup/proxy/proxy_objgroup.h index 704993db8b..7c9113089f 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup.h +++ b/src/vt/objgroup/proxy/proxy_objgroup.h @@ -126,6 +126,30 @@ struct Proxy { template fn> PendingSendType broadcastMsg(messaging::MsgPtrThief msg) const; + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = Msg; + using ReturnT = Return; + }; + + /** + * \brief Broadcast a message to all nodes to be delivered to the local object + * instance + * \note Takes ownership of the supplied message + * + * \param[in] msg the message + */ + template + PendingSendType broadcastMsg( + messaging::MsgPtrThief::MsgT> msg + ) const { + using MsgType = typename FunctionTraits::MsgT; + return broadcastMsg(msg); + } + /** * \brief Broadcast a message to all nodes to be delivered to the local object * instance @@ -135,6 +159,18 @@ struct Proxy { template fn, typename... Args> PendingSendType broadcast(Args&&... args) const; + /** + * \brief Broadcast a message to all nodes to be delivered to the local object + * instance + * + * \param[in] args args to pass to the message constructor + */ + template + PendingSendType broadcast(Args&&... args) const { + using MsgType = typename FunctionTraits::MsgT; + return broadcast(std::forward(args)...); + } + /** * \brief Reduce over the objgroup instances on each node with a callback * target. @@ -370,6 +406,30 @@ struct Proxy { template * f, typename... Args> messaging::PendingSend broadcast(Args&&... args) const; + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = Msg; + using ReturnT = Return; + }; + + /** + * \brief Broadcast a message. + * + * \note Creates message from given args + * + * \param[in] args the arguments used to make a message + * + * \return the \c PendingSend for the sent message + */ + template + messaging::PendingSend broadcast(Args&&... args) const { + using MsgType = typename FunctionTraits::MsgT; + return broadcast(std::forward(args)...); + } + /** * \brief Broadcast a message. * @@ -384,6 +444,25 @@ struct Proxy { messaging::PendingSend broadcastMsg(messaging::MsgPtrThief msg, TagType tag = no_tag) const; + /** + * \brief Broadcast a message. + * + * \note Takes ownership of the supplied message. + * + * \param[in] msg the message to broadcast + * \param[in] tag the tag to put on the message + * + * \return the \c PendingSend for the sent message + */ + template + messaging::PendingSend broadcastMsg( + messaging::MsgPtrThief::MsgT> msg, + TagType tag = no_tag + ) const { + using MsgType = typename FunctionTraits::MsgT; + return broadcastMsg(msg, tag); + } + /** * \brief Reduce a message up the tree, possibly delayed through a pending * send diff --git a/src/vt/objgroup/proxy/proxy_objgroup_elm.h b/src/vt/objgroup/proxy/proxy_objgroup_elm.h index e5eebae2c2..1f4da7c6c1 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup_elm.h +++ b/src/vt/objgroup/proxy/proxy_objgroup_elm.h @@ -120,6 +120,30 @@ struct ProxyElm { template fn> PendingSendType sendMsg(messaging::MsgPtrThief msg) const; + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = Msg; + using ReturnT = Return; + }; + + /** + * \brief Send a message to the node/element indexed by this proxy to be + * delivered to the local object instance + * \note Takes ownership of the supplied message + * + * \param[in] msg the message + */ + template + decltype(auto) sendMsg( + messaging::MsgPtrThief::MsgT> msg + ) const { + using MsgT = typename FunctionTraits::MsgT; + return sendMsg(msg); + } + /** * \brief Send a message to the node/element indexed by this proxy to be * delivered to the local object instance @@ -129,6 +153,18 @@ struct ProxyElm { template fn, typename... Args> PendingSendType send(Args&&... args) const; + /** + * \brief Send a message to the node/element indexed by this proxy to be + * delivered to the local object instance + * + * \param[in] args args to pass to the message constructor + */ + template + decltype(auto) send(Args&&... args) const { + using MsgT = typename FunctionTraits::MsgT; + return send(std::forward(args)...); + } + /** * \brief Invoke locally a message handler on the node/element indexed by this proxy. * The message handler will be invoked inline without going through scheduler diff --git a/tests/unit/objgroup/test_objgroup.cc b/tests/unit/objgroup/test_objgroup.cc index 9995f8d073..572e6c238c 100644 --- a/tests/unit/objgroup/test_objgroup.cc +++ b/tests/unit/objgroup/test_objgroup.cc @@ -181,8 +181,8 @@ TEST_F(TestObjGroup, test_proxy_schedule) { runInEpochCollective([&]{ // self-send a message and then broadcast - proxy[my_node].send(); - proxy.broadcast(); + proxy[my_node].send<&MyObjA::handler>(); + proxy.broadcast<&MyObjA::handler>(); obj = proxy.get(); vt_debug_print( @@ -212,12 +212,12 @@ TEST_F(TestObjGroup, test_proxy_callbacks) { auto proxy3 = vt::theObjGroup()->makeCollective("test_proxy_callbacks"); if (my_node == 0) { - proxy1[0].send(); - proxy1[0].send(); - proxy1[1].send(); + proxy1[0].send<&MyObjA::handler>(); + proxy1[0].send<&MyObjA::handler>(); + proxy1[1].send<&MyObjA::handler>(); } else if (my_node == 1) { - proxy2.broadcast(); - proxy3[0].send(); + proxy2.broadcast<&MyObjB::handler>(); + proxy3[0].send<&MyObjA::handler>(); } // check received messages for each group @@ -313,14 +313,14 @@ TEST_F(TestObjGroup, test_pending_send) { runInEpochCollective([&]{ // self-send a message and then broadcast - auto pending = proxy[my_node].send(); + auto pending = proxy[my_node].send<&MyObjA::handler>(); EXPECT_EQ(obj->recv_, 0); runInEpochCollective([&]{ pending.release(); } ); EXPECT_EQ(obj->recv_, 1 ); - auto pending2 = proxy.broadcast(); + auto pending2 = proxy.broadcast<&MyObjA::handlerOnlyFromSelf>(); EXPECT_EQ(obj->recv_, 1 ); From 46651bd213ca59228865d7627de9386cd80261af Mon Sep 17 00:00:00 2001 From: Arkadiusz Szczepkowicz Date: Fri, 10 Feb 2023 19:18:34 +0100 Subject: [PATCH 13/32] #276: Synthesize Msg type in vt/collection --- .../vrt/collection/broadcast/broadcastable.h | 88 +++++++++++++++++++ src/vt/vrt/collection/manager.h | 54 ++++++++++++ src/vt/vrt/collection/send/sendable.h | 45 ++++++++++ tests/perf/collection_local_send.cc | 4 +- tests/perf/collection_local_send_prealloc.cc | 2 +- tests/unit/collection/test_broadcast.h | 3 +- tests/unit/collection/test_send.h | 10 +-- 7 files changed, 196 insertions(+), 10 deletions(-) diff --git a/src/vt/vrt/collection/broadcast/broadcastable.h b/src/vt/vrt/collection/broadcast/broadcastable.h index 22c51eee2c..f747e499a6 100644 --- a/src/vt/vrt/collection/broadcast/broadcastable.h +++ b/src/vt/vrt/collection/broadcast/broadcastable.h @@ -195,6 +195,94 @@ struct Broadcastable : BaseProxyT { typename... Args > void invokeCollective(Args&&... args) const; + + + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = Msg; + using ReturnT = Return; + }; + + template + struct FunctionTraits { + using MsgT = Msg; + using ReturnT = Return; + }; + + /** + * \brief Rooted broadcast with action function handler + * \note Takes ownership of the supplied message + * + * \param[in] msg the message + * + * \return a pending send + */ + template + messaging::PendingSend broadcastMsg( + messaging::MsgPtrThief::MsgT> msg + ) const { + using MsgT = typename FunctionTraits::MsgT; + return broadcastMsg(msg); + } + + /** + * \brief Rooted broadcast with action function handler + * + * \param[in] args arguments needed for creteating the message + * + * \return a pending send + */ + template + messaging::PendingSend broadcast(Args&&... args) const { + using MsgT = typename FunctionTraits::MsgT; + return broadcast(std::forward(args)...); + } + + /** + * \brief Collective broadcast with action function handler + * \note Takes ownership of the supplied message + * + * \param[in] msg the message + * + * \return a pending send + */ + template + messaging::PendingSend broadcastCollectiveMsg( + messaging::MsgPtrThief::MsgT> msg + ) const { + using MsgT = typename FunctionTraits::MsgT; + return broadcastCollectiveMsg(msg); + } + + /** + * \brief Create message (with action function handler) and broadcast it in a + * collective manner to the collection + * + * \param[in] args arguments needed for creteating the message + * + * \return a pending send + */ + template + messaging::PendingSend broadcastCollective(Args&&... args) const { + using MsgT = typename FunctionTraits::MsgT; + return broadcastCollectiveMsg(std::forward(args)...); + } + + /** + * \brief Invoke member message handler on all collection elements + * The function will be invoked inline without going through scheduler + * + * \param[in] args arguments for creating the message + */ + template + void invokeCollective(Args&&... args) const { + using MsgT = typename FunctionTraits::MsgT; + return invokeCollective(std::forward(args)...); + } + }; }}} /* end namespace vt::vrt::collection */ diff --git a/src/vt/vrt/collection/manager.h b/src/vt/vrt/collection/manager.h index 8968475a75..fa96a62f49 100644 --- a/src/vt/vrt/collection/manager.h +++ b/src/vt/vrt/collection/manager.h @@ -493,6 +493,40 @@ struct CollectionManager VirtualElmProxyType const& proxy, MsgT *msg ); + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = Msg; + using ColT = Col; + using ReturnT = Return; + }; + + template + struct FunctionTraits { + using ColT = Col; + using MsgT = Msg; + using ReturnT = Return; + }; + + /** + * \brief Send collection element a message from active function handler + * + * \param[in] proxy the collection proxy + * \param[in] msg the message + * + * \return a pending send + */ + template + messaging::PendingSend sendMsg( + VirtualElmProxyType::MsgT::CollectionType> const& proxy, + typename FunctionTraits::MsgT *msg + ) { + using MsgT = typename FunctionTraits::MsgT; + return sendMsg(proxy, msg); + } + /** * \brief Send collection element a message from active member handler * @@ -965,6 +999,26 @@ struct CollectionManager MsgT *msg, bool instrument = true ); + /** + * \brief Broadcast a message with action function handler + * + * \param[in] proxy the collection proxy + * \param[in] msg the message + * \param[in] instrument whether to instrument the broadcast for load + * balancing (some system calls use this to disable instrumentation) + * + * \return a pending send + */ + template < auto f> + messaging::PendingSend broadcastMsg( + CollectionProxyWrapType::MsgT::CollectionType> const& proxy, + typename FunctionTraits::MsgT *msg, + bool instrument = true + ) { + using MsgT = typename FunctionTraits::MsgT; + return broadcastMsg(proxy, msg, instrument); + } + /** * \brief Broadcast a message with action member handler * diff --git a/src/vt/vrt/collection/send/sendable.h b/src/vt/vrt/collection/send/sendable.h index bbfecdeda5..d228e64356 100644 --- a/src/vt/vrt/collection/send/sendable.h +++ b/src/vt/vrt/collection/send/sendable.h @@ -121,6 +121,51 @@ struct Sendable : BaseProxyT { typename MsgT, ActiveColMemberTypedFnType f, typename... Args > messaging::PendingSend send(Args&&... args) const; + + + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = Msg; + using ReturnT = Return; + }; + + template + struct FunctionTraits { + using MsgT = Msg; + using ReturnT = Return; + }; + + /** + * \brief Create message (with action function handler) and send to collection element + * + * \param[in] args arguments needed for creteating the message + * + * \return a pending send + */ + template + messaging::PendingSend sendMsg( + messaging::MsgPtrThief::MsgT> msg + ) const { + using MsgT = typename FunctionTraits::MsgT; + return sendMsg(msg); + } + + /** + * \brief Create message (with action function handler) and send to collection element + * + * \param[in] args arguments needed for creteating the message + * + * \return a pending send + */ + template + messaging::PendingSend send(Args&&... args) const { + using MsgT = typename FunctionTraits::MsgT; + return send(std::forward(args)...); + } + }; }}} /* end namespace vt::vrt::collection */ diff --git a/tests/perf/collection_local_send.cc b/tests/perf/collection_local_send.cc index 48978b18a4..41d1df31da 100644 --- a/tests/perf/collection_local_send.cc +++ b/tests/perf/collection_local_send.cc @@ -94,7 +94,7 @@ struct NodeObj { void perfRunBenchmark() { for (int i = 0; i < num_iters; i++) { auto m = makeMessage(); - col_proxy[0].template sendMsg(m); + col_proxy[0].template sendMsg<&TestCol::han>(m); vt::theSched()->runSchedulerOnceImpl(); } } @@ -117,7 +117,7 @@ VT_PERF_TEST(MyTest, test_collection_local_send) { grp_proxy[my_node_].invoke<&NodeObj::initialize>(); if (theContext()->getNode() == 0) { - grp_proxy[my_node_].send(); + grp_proxy[my_node_].send<&NodeObj::perfMakeRunnable>(); } } diff --git a/tests/perf/collection_local_send_prealloc.cc b/tests/perf/collection_local_send_prealloc.cc index 69c9a8ace6..32337253f8 100644 --- a/tests/perf/collection_local_send_prealloc.cc +++ b/tests/perf/collection_local_send_prealloc.cc @@ -98,7 +98,7 @@ struct NodeObj { void perfRunBenchmark() { for (int i = 0; i < num_iters; i++) { auto m = msgs[i]; - col_proxy[0].template sendMsg(m); + col_proxy[0].template sendMsg<&TestCol::han>(m); vt::theSched()->runSchedulerOnceImpl(); } } diff --git a/tests/unit/collection/test_broadcast.h b/tests/unit/collection/test_broadcast.h index c8f4c3fd4a..0f29e902f7 100644 --- a/tests/unit/collection/test_broadcast.h +++ b/tests/unit/collection/test_broadcast.h @@ -131,13 +131,12 @@ void test_broadcast_1(std::string const& label) { auto proxy = theCollection()->construct(range, label); proxy.template broadcast< - MsgType, BroadcastHandlers::handler >(args); auto msg = makeMessage(args); theCollection()->broadcastMsg< - MsgType,BroadcastHandlers::handler + BroadcastHandlers::handler >(proxy, msg.get()); } } diff --git a/tests/unit/collection/test_send.h b/tests/unit/collection/test_send.h index 4d1551a3f1..9187f08c2b 100644 --- a/tests/unit/collection/test_send.h +++ b/tests/unit/collection/test_send.h @@ -195,9 +195,9 @@ void test_collection_send_1(std::string const& label) { auto msg = makeMessage(args); EXPECT_EQ(msg.size(), sizeof(MsgType)); if (i % 2 == 0) { - proxy[i].template sendMsg::handler>(msg.get()); + proxy[i].template sendMsg::handler>(msg.get()); } else { - theCollection()->sendMsg::handler>( + theCollection()->sendMsg::handler>( proxy[i], msg.get() ); } @@ -222,7 +222,7 @@ void test_collection_send_sz_1() { EXPECT_EQ(msg.size(), sizeof(MsgType) + sizeof(PayloadType)); msg->buff_size = sizeof(PayloadType); std::memcpy(reinterpret_cast(msg->payload()), &args, msg->buff_size); - proxy[i].template sendMsg::handler>(msg); + proxy[i].template sendMsg::handler>(msg); } } } @@ -242,9 +242,9 @@ void test_collection_send_ptm_1(std::string const& label) { auto msg = makeMessage(args); //proxy[i].template send::handler>(msg); if (i % 2 == 0) { - proxy[i].template sendMsg(msg.get()); + proxy[i].template sendMsg<&ColType::handler>(msg.get()); } else { - theCollection()->sendMsg( + theCollection()->sendMsg<&ColType::handler>( proxy[i], msg.get() ); } From 289d0843078279821059477e9c9ddae6d31e7e1f Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 16 Feb 2023 22:23:18 -0800 Subject: [PATCH 14/32] #276: vrt: add synthesis of messages for collections --- src/vt/registry/auto/auto_registry_common.h | 25 ++++- .../auto_registry_collection.impl.h | 14 +++ .../vrt/collection/messages/param_col_msg.h | 101 ++++++++++++++++++ src/vt/vrt/collection/send/sendable.h | 44 ++++++-- src/vt/vrt/collection/send/sendable.impl.h | 20 ++++ 5 files changed, 193 insertions(+), 11 deletions(-) create mode 100644 src/vt/vrt/collection/messages/param_col_msg.h diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index 5269a1cfba..514e211a90 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -126,13 +126,36 @@ struct HandlersDispatcher final : BaseHandlersDispatcher { >; template - struct DispatchImpl> { + struct DispatchImpl< + T, + std::enable_if_t< + not std::is_same::value and + std::is_same>::value + > + > { static void run(MsgT* msg, void* object, HandlerT han) { auto elm = static_cast(object); (elm->*han)(msg); } }; + template + struct DispatchImpl< + T, + std::enable_if_t< + not std::is_same::value and + not std::is_same>::value and + not std::is_same*>::value and + not std::is_same::value and + not std::is_same*>::value + > + > { + static void run(MsgT* msg, void* object, HandlerT han) { + auto elm = static_cast(object); + std::apply(han, std::tuple_cat(std::make_tuple(elm), msg->getTuple())); + } + }; + template struct DispatchImpl< T, diff --git a/src/vt/registry/auto/collection/auto_registry_collection.impl.h b/src/vt/registry/auto/collection/auto_registry_collection.impl.h index 3c10e40ee8..062241c4ee 100644 --- a/src/vt/registry/auto/collection/auto_registry_collection.impl.h +++ b/src/vt/registry/auto/collection/auto_registry_collection.impl.h @@ -97,6 +97,20 @@ inline HandlerType makeAutoHandlerCollectionMem() { return handler; } +template +inline HandlerType makeAutoHandlerCollectionMemParam() { + using FunctorT = FunctorAdapterMember; + using ContainerType = AutoActiveCollectionMemContainerType; + using RegInfoType = AutoRegInfoType; + using FuncType = T; + + auto const id = + RunnableGen::idx; + constexpr auto reg_type = RegistryTypeEnum::RegVrtCollectionMember; + auto handler = HandlerManager::makeHandler(false, false, id, reg_type); + return handler; +} + template * f> void setHandlerTraceNameColl(std::string const& name, std::string const& parent) { #if vt_check_enabled(trace_enabled) diff --git a/src/vt/vrt/collection/messages/param_col_msg.h b/src/vt/vrt/collection/messages/param_col_msg.h new file mode 100644 index 0000000000..7c6cfbdd39 --- /dev/null +++ b/src/vt/vrt/collection/messages/param_col_msg.h @@ -0,0 +1,101 @@ +/* +//@HEADER +// ***************************************************************************** +// +// param_col_msg.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_VRT_COLLECTION_MESSAGES_PARAM_COL_MSG_H +#define INCLUDED_VT_VRT_COLLECTION_MESSAGES_PARAM_COL_MSG_H + +#include "vt/vrt/collection/messages/user.h" +#include "vt/messaging/message/message_serialize.h" + +namespace vt { namespace vrt { namespace collection { + +template +struct ParamColMsg; + +template +struct ParamColMsg< + Tuple, + ColT, + std::enable_if_t::value> +> : CollectionMessage { + ParamColMsg() = default; + + template + explicit ParamColMsg(Params&&... in_params) + : params(std::forward(in_params)...) + { } + + Tuple params; + Tuple& getTuple() { return params; } +}; + +template +struct ParamColMsg< + Tuple, + ColT, + std::enable_if_t::value> +> : CollectionMessage { + using MessageParentType = CollectionMessage; + vt_msg_serialize_if_needed_by_parent_or_type1(Tuple); // by params + + ParamColMsg() = default; + + template + explicit ParamColMsg(Params&&... in_params) + : params(std::make_unique(std::forward(in_params)...)) + { } + + std::unique_ptr params; + + Tuple& getTuple() { return *params.get(); } + + template + void serialize(SerializerT& s) { + MessageParentType::serialize(s); + s | params; + } +}; + +}}} /* end namespace vt::vrt::collection */ + +#endif /*INCLUDED_VT_VRT_COLLECTION_MESSAGES_PARAM_COL_MSG_H*/ diff --git a/src/vt/vrt/collection/send/sendable.h b/src/vt/vrt/collection/send/sendable.h index d228e64356..65f8bf6add 100644 --- a/src/vt/vrt/collection/send/sendable.h +++ b/src/vt/vrt/collection/send/sendable.h @@ -122,22 +122,50 @@ struct Sendable : BaseProxyT { > messaging::PendingSend send(Args&&... args) const; + struct NoMsg {}; - template + template struct FunctionTraits; template - struct FunctionTraits { + struct FunctionTraits< + std::enable_if_t::value>, + Return(*)(Msg*, ColT*) + > { using MsgT = Msg; using ReturnT = Return; }; template - struct FunctionTraits { + struct FunctionTraits< + std::enable_if_t::value>, + Return(ColT::*)(Msg*) + > { using MsgT = Msg; using ReturnT = Return; }; + template + struct FunctionTraits< + std::true_type, + ReturnT(ColT::*)() + > { + using MsgT = NoMsg; + using TupleType = std::tuple<>; + using ReturnType = ReturnT; + }; + + template + struct FunctionTraits< + std::enable_if_t::value>, + ReturnT(ColT::*)(Arg, Args...) + > { + using MsgT = NoMsg; + using TupleType = std::tuple, std::decay_t...>; + using ReturnType = ReturnT; + }; + + /** * \brief Create message (with action function handler) and send to collection element * @@ -147,9 +175,9 @@ struct Sendable : BaseProxyT { */ template messaging::PendingSend sendMsg( - messaging::MsgPtrThief::MsgT> msg + messaging::MsgPtrThief::MsgT> msg ) const { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FunctionTraits::MsgT; return sendMsg(msg); } @@ -161,11 +189,7 @@ struct Sendable : BaseProxyT { * \return a pending send */ template - messaging::PendingSend send(Args&&... args) const { - using MsgT = typename FunctionTraits::MsgT; - return send(std::forward(args)...); - } - + messaging::PendingSend send(Args&&... args) const; }; }}} /* end namespace vt::vrt::collection */ diff --git a/src/vt/vrt/collection/send/sendable.impl.h b/src/vt/vrt/collection/send/sendable.impl.h index 96c7d906e8..8b51272668 100644 --- a/src/vt/vrt/collection/send/sendable.impl.h +++ b/src/vt/vrt/collection/send/sendable.impl.h @@ -47,6 +47,7 @@ #include "vt/config.h" #include "vt/vrt/collection/send/sendable.h" #include "vt/vrt/collection/manager.h" +#include "vt/vrt/collection/messages/param_col_msg.h" namespace vt { namespace vrt { namespace collection { @@ -129,6 +130,25 @@ messaging::PendingSend Sendable::send(Args&&... args) co return sendMsg(makeMessage(std::forward(args)...)); } +template +template +messaging::PendingSend Sendable::send(Params&&... params) const { + using MsgT = typename FunctionTraits::MsgT; + if constexpr (std::is_same_v) { + using Tuple = typename FunctionTraits::TupleType; + using SendMsgT = ParamColMsg; + auto msg = vt::makeMessage(std::forward(params)...); + auto han = auto_registry::makeAutoHandlerCollectionMemParam(); + auto col_proxy = this->getCollectionProxy(); + auto elm_proxy = this->getElementProxy(); + auto proxy = VrtElmProxy(col_proxy, elm_proxy); + return theCollection()->sendMsgUntypedHandler(proxy, msg.get(), han); + } else { + auto msg = makeMessage(std::forward(params)...); + return sendMsg(msg); + } +} + }}} /* end namespace vt::vrt::collection */ From faba28241a2399226ffd2b4c0862464b2c2179de Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Feb 2023 18:46:18 -0800 Subject: [PATCH 15/32] #276: registry: cleanup with if constexpr --- src/vt/registry/auto/auto_registry_common.h | 207 +++++--------------- 1 file changed, 51 insertions(+), 156 deletions(-) diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index 514e211a90..47a1f6d907 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -69,115 +69,44 @@ struct BaseHandlersDispatcher { template struct HandlersDispatcher final : BaseHandlersDispatcher { - explicit HandlersDispatcher(HandlerT in_fn_ptr) : fn_ptr_(in_fn_ptr) { } - -private: - template - struct DispatchImpl; - - template - using isActiveVoidFnType = std::enable_if_t< - std::is_same< - T, - ActiveVoidFnType* - >::value - >; - - template - struct DispatchImpl> { - static void run(MsgT*, void*, HandlerT han) { han(); } - }; - - template - using isActiveTypedFnType = std::enable_if_t< - std::is_same< - T, - ActiveTypedFnType* - >::value - >; - - template - struct DispatchImpl> { - static void run(MsgT* msg, void*, HandlerT han) { han(msg); } - }; - - template - using isActiveColTypedFnType = std::enable_if_t< - std::is_same< - T, - vrt::collection::ActiveColTypedFnType* - >::value - >; - - template - struct DispatchImpl> { - static void run(MsgT* msg, void* object, HandlerT han) { - auto elm = static_cast(object); - han(msg, elm); - } - }; - - template - using isActiveColMemberTypedFnType = std::enable_if_t< - std::is_same< - T, - vrt::collection::ActiveColMemberTypedFnType - >::value - >; - - template - struct DispatchImpl< - T, - std::enable_if_t< - not std::is_same::value and - std::is_same>::value - > - > { - static void run(MsgT* msg, void* object, HandlerT han) { - auto elm = static_cast(object); - (elm->*han)(msg); - } - }; - - template - struct DispatchImpl< - T, - std::enable_if_t< - not std::is_same::value and - not std::is_same>::value and - not std::is_same*>::value and - not std::is_same::value and - not std::is_same*>::value - > - > { - static void run(MsgT* msg, void* object, HandlerT han) { - auto elm = static_cast(object); - std::apply(han, std::tuple_cat(std::make_tuple(elm), msg->getTuple())); - } - }; - - template - struct DispatchImpl< - T, - std::enable_if_t< - std::is_same::value and - not std::is_same::value and - not std::is_same*>::value - > - > { - static void run(MsgT* msg, void*, HandlerT han) { - std::apply(han, msg->getTuple()); - } - }; + using ColTypedFnType = vrt::collection::ActiveColTypedFnType; + using ColMemberTypedFnType = vrt::collection::ActiveColMemberTypedFnType; + explicit HandlersDispatcher(HandlerT in_fn_ptr) : fp(in_fn_ptr) { } public: - void dispatch(messaging::BaseMsg* msg, void* object) const override { - DispatchImpl::run(static_cast(msg), object, fn_ptr_); + void dispatch(messaging::BaseMsg* base_msg, void* object) const override { + using T = HandlerT; + + [[maybe_unused]] auto msg = static_cast(base_msg); + [[maybe_unused]] auto elm = static_cast(object); + + if constexpr (std::is_same_v) { + fp(); + } else if constexpr (std::is_same_v*>) { + fp(msg); + } else if constexpr (std::is_same_v) { + fp(msg, elm); + } else { + if constexpr (std::is_same_v) { + + if constexpr (not std::is_same_v and + not std::is_same_v*>) { + std::apply(fp, msg->getTuple()); + } + + } else { + if constexpr (std::is_same_v) { + (elm->*fp)(msg); + } else { + std::apply(fp, std::tuple_cat(std::make_tuple(elm), msg->getTuple())); + } + } + } } private: - HandlerT fn_ptr_ = nullptr; + HandlerT fp = nullptr; }; struct BaseMapsDispatcher { @@ -191,31 +120,7 @@ struct BaseMapsDispatcher { template struct MapsDispatcher final : BaseMapsDispatcher { - explicit MapsDispatcher(HandlerT in_fn_ptr) : fn_ptr_(in_fn_ptr) { } - -private: - template - struct DispatchImpl; - - template - using isActiveMapFnPtrType = std::enable_if_t< - std::is_same< - T, - vt::mapping::ActiveMapTypedFnType* - >::value - >; - - template - struct DispatchImpl> { - static NodeType run( - IndexT* cur_idx_ptr, - IndexT* range_ptr, - NodeType num_nodes, - HandlerT han - ) { - return han(cur_idx_ptr, range_ptr, num_nodes); - } - }; + explicit MapsDispatcher(HandlerT in_fn_ptr) : fp(in_fn_ptr) { } public: NodeType dispatch( @@ -223,16 +128,19 @@ struct MapsDispatcher final : BaseMapsDispatcher { index::BaseIndex* range_ptr, NodeType num_nodes ) const override { - return DispatchImpl::run( - static_cast(cur_idx_ptr), - static_cast(range_ptr), - num_nodes, - fn_ptr_ - ); + using T = HandlerT; + + if constexpr (std::is_same_v*>) { + return fp( + static_cast(cur_idx_ptr), + static_cast(range_ptr), + num_nodes + ); + } } private: - HandlerT fn_ptr_ = nullptr; + HandlerT fp = nullptr; }; struct BaseScatterDispatcher { @@ -242,32 +150,19 @@ struct BaseScatterDispatcher { template struct ScatterDispatcher final : BaseScatterDispatcher { - explicit ScatterDispatcher(HandlerT in_fn_ptr) : fn_ptr_(in_fn_ptr) {} - -private: - template - struct DispatchImpl; - - template - using isActiveTypedFnType = std::enable_if_t< - std::is_same< - T, - ActiveTypedFnType* - >::value - >; - - template - struct DispatchImpl> { - static void run(MsgT* msg, void*, HandlerT han) { han(msg); } - }; + explicit ScatterDispatcher(HandlerT in_fn_ptr) : fp(in_fn_ptr) {} public: - void dispatch(void* msg, void* object) const override { - DispatchImpl::run(static_cast(msg), object, fn_ptr_); + void dispatch(void* msg, void*) const override { + using T = HandlerT; + + if constexpr (std::is_same_v*>) { + fp(static_cast(msg)); + } } private: - HandlerT fn_ptr_ = nullptr; + HandlerT fp = nullptr; }; using BaseHandlersDispatcherPtr = std::unique_ptr; From d7869768165e6e01265c37f6042e3f1dab24e659 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Feb 2023 23:01:13 -0800 Subject: [PATCH 16/32] #276: registry: simplify code --- src/vt/registry/auto/auto_registry_common.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index 47a1f6d907..7c326bbfc6 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -89,12 +89,7 @@ struct HandlersDispatcher final : BaseHandlersDispatcher { fp(msg, elm); } else { if constexpr (std::is_same_v) { - - if constexpr (not std::is_same_v and - not std::is_same_v*>) { - std::apply(fp, msg->getTuple()); - } - + std::apply(fp, msg->getTuple()); } else { if constexpr (std::is_same_v) { (elm->*fp)(msg); From 174c1b703c1abfa2dbaf2f6bf76b318d22ba3b4a Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 28 Feb 2023 11:16:05 -0800 Subject: [PATCH 17/32] #276: vrt: move function traits to utils --- src/vt/utils/fntraits/fntraits.h | 98 ++++++++++++++++++++++ src/vt/vrt/collection/send/sendable.h | 49 +---------- src/vt/vrt/collection/send/sendable.impl.h | 4 +- 3 files changed, 103 insertions(+), 48 deletions(-) create mode 100644 src/vt/utils/fntraits/fntraits.h diff --git a/src/vt/utils/fntraits/fntraits.h b/src/vt/utils/fntraits/fntraits.h new file mode 100644 index 0000000000..bcb17cf982 --- /dev/null +++ b/src/vt/utils/fntraits/fntraits.h @@ -0,0 +1,98 @@ +/* +//@HEADER +// ***************************************************************************** +// +// fntraits.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_UTILS_FNTRAITS_FNTRAITS_H +#define INCLUDED_VT_UTILS_FNTRAITS_FNTRAITS_H + +namespace vt { + +struct NoMsg {}; + +template +struct ObjFuncTraits; + +template +struct ObjFuncTraits< + std::enable_if_t::value>, + ObjT, + Return(*)(Msg*, ObjT*) +> { + using MsgT = Msg; + using ReturnT = Return; +}; + +template +struct ObjFuncTraits< + std::enable_if_t::value>, + ObjT, + Return(ObjT::*)(Msg*) +> { + using MsgT = Msg; + using ReturnT = Return; +}; + +template +struct ObjFuncTraits< + std::enable_if_t>, + ObjT, + Return(ObjT::*)() +> { + using MsgT = NoMsg; + using TupleType = std::tuple<>; + using ReturnT = Return; +}; + +template +struct ObjFuncTraits< + std::enable_if_t::value>, + ObjT, + Return(ObjT::*)(Arg, Args...) +> { + using MsgT = NoMsg; + using TupleType = std::tuple, std::decay_t...>; + using ReturnT = Return; +}; + +} /* end namespace vt */ + +#endif /*INCLUDED_VT_UTILS_FNTRAITS_FNTRAITS_H*/ diff --git a/src/vt/vrt/collection/send/sendable.h b/src/vt/vrt/collection/send/sendable.h index 65f8bf6add..9d00908379 100644 --- a/src/vt/vrt/collection/send/sendable.h +++ b/src/vt/vrt/collection/send/sendable.h @@ -48,6 +48,7 @@ #include "vt/vrt/collection/active/active_funcs.h" #include "vt/messaging/message/smart_ptr.h" #include "vt/messaging/pending_send.h" +#include "vt/utils/fntraits/fntraits.h" namespace vt { namespace vrt { namespace collection { @@ -122,50 +123,6 @@ struct Sendable : BaseProxyT { > messaging::PendingSend send(Args&&... args) const; - struct NoMsg {}; - - template - struct FunctionTraits; - - template - struct FunctionTraits< - std::enable_if_t::value>, - Return(*)(Msg*, ColT*) - > { - using MsgT = Msg; - using ReturnT = Return; - }; - - template - struct FunctionTraits< - std::enable_if_t::value>, - Return(ColT::*)(Msg*) - > { - using MsgT = Msg; - using ReturnT = Return; - }; - - template - struct FunctionTraits< - std::true_type, - ReturnT(ColT::*)() - > { - using MsgT = NoMsg; - using TupleType = std::tuple<>; - using ReturnType = ReturnT; - }; - - template - struct FunctionTraits< - std::enable_if_t::value>, - ReturnT(ColT::*)(Arg, Args...) - > { - using MsgT = NoMsg; - using TupleType = std::tuple, std::decay_t...>; - using ReturnType = ReturnT; - }; - - /** * \brief Create message (with action function handler) and send to collection element * @@ -175,9 +132,9 @@ struct Sendable : BaseProxyT { */ template messaging::PendingSend sendMsg( - messaging::MsgPtrThief::MsgT> msg + messaging::MsgPtrThief::MsgT> msg ) const { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; return sendMsg(msg); } diff --git a/src/vt/vrt/collection/send/sendable.impl.h b/src/vt/vrt/collection/send/sendable.impl.h index 8b51272668..fd9891b917 100644 --- a/src/vt/vrt/collection/send/sendable.impl.h +++ b/src/vt/vrt/collection/send/sendable.impl.h @@ -133,9 +133,9 @@ messaging::PendingSend Sendable::send(Args&&... args) co template template messaging::PendingSend Sendable::send(Params&&... params) const { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; if constexpr (std::is_same_v) { - using Tuple = typename FunctionTraits::TupleType; + using Tuple = typename ObjFuncTraits::TupleType; using SendMsgT = ParamColMsg; auto msg = vt::makeMessage(std::forward(params)...); auto han = auto_registry::makeAutoHandlerCollectionMemParam(); From e206bb07ef9e0ce4e497facc0455a93aef8e433b Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 28 Feb 2023 15:10:08 -0800 Subject: [PATCH 18/32] #276: vrt: implement for broadcasts and invokes --- .../vrt/collection/broadcast/broadcastable.h | 40 +++--------- .../collection/broadcast/broadcastable.impl.h | 61 +++++++++++++++++++ src/vt/vrt/collection/manager.h | 12 ++++ src/vt/vrt/collection/manager.impl.h | 19 ++++++ src/vt/vrt/collection/send/sendable.impl.h | 8 ++- 5 files changed, 106 insertions(+), 34 deletions(-) diff --git a/src/vt/vrt/collection/broadcast/broadcastable.h b/src/vt/vrt/collection/broadcast/broadcastable.h index f747e499a6..835396e9e4 100644 --- a/src/vt/vrt/collection/broadcast/broadcastable.h +++ b/src/vt/vrt/collection/broadcast/broadcastable.h @@ -50,6 +50,7 @@ #include "vt/vrt/collection/active/active_funcs.h" #include "vt/messaging/message/smart_ptr.h" #include "vt/messaging/pending_send.h" +#include "vt/utils/fntraits/fntraits.h" namespace vt { namespace vrt { namespace collection { @@ -196,22 +197,6 @@ struct Broadcastable : BaseProxyT { > void invokeCollective(Args&&... args) const; - - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MsgT = Msg; - using ReturnT = Return; - }; - - template - struct FunctionTraits { - using MsgT = Msg; - using ReturnT = Return; - }; - /** * \brief Rooted broadcast with action function handler * \note Takes ownership of the supplied message @@ -222,9 +207,9 @@ struct Broadcastable : BaseProxyT { */ template messaging::PendingSend broadcastMsg( - messaging::MsgPtrThief::MsgT> msg + messaging::MsgPtrThief::MsgT> msg ) const { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; return broadcastMsg(msg); } @@ -236,10 +221,7 @@ struct Broadcastable : BaseProxyT { * \return a pending send */ template - messaging::PendingSend broadcast(Args&&... args) const { - using MsgT = typename FunctionTraits::MsgT; - return broadcast(std::forward(args)...); - } + messaging::PendingSend broadcast(Args&&... args) const; /** * \brief Collective broadcast with action function handler @@ -251,9 +233,9 @@ struct Broadcastable : BaseProxyT { */ template messaging::PendingSend broadcastCollectiveMsg( - messaging::MsgPtrThief::MsgT> msg + messaging::MsgPtrThief::MsgT> msg ) const { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; return broadcastCollectiveMsg(msg); } @@ -266,10 +248,7 @@ struct Broadcastable : BaseProxyT { * \return a pending send */ template - messaging::PendingSend broadcastCollective(Args&&... args) const { - using MsgT = typename FunctionTraits::MsgT; - return broadcastCollectiveMsg(std::forward(args)...); - } + messaging::PendingSend broadcastCollective(Args&&... args) const; /** * \brief Invoke member message handler on all collection elements @@ -278,10 +257,7 @@ struct Broadcastable : BaseProxyT { * \param[in] args arguments for creating the message */ template - void invokeCollective(Args&&... args) const { - using MsgT = typename FunctionTraits::MsgT; - return invokeCollective(std::forward(args)...); - } + void invokeCollective(Args&&... args) const; }; diff --git a/src/vt/vrt/collection/broadcast/broadcastable.impl.h b/src/vt/vrt/collection/broadcast/broadcastable.impl.h index 89978f4dc3..2680ff27b6 100644 --- a/src/vt/vrt/collection/broadcast/broadcastable.impl.h +++ b/src/vt/vrt/collection/broadcast/broadcastable.impl.h @@ -177,6 +177,67 @@ Broadcastable::invokeCollective(Args&&... args) const return theCollection()->invokeCollectiveMsg(proxy, msg); } +template +template +messaging::PendingSend +Broadcastable::broadcast(Params&&... params) const { + using MsgT = typename ObjFuncTraits::MsgT; + if constexpr (std::is_same_v) { + using Tuple = typename ObjFuncTraits::TupleType; + using SendMsgT = ParamColMsg; + auto msg = vt::makeMessage(std::forward(params)...); + auto han = auto_registry::makeAutoHandlerCollectionMemParam< + ColT, decltype(f), f, SendMsgT + >(); + auto proxy = this->getProxy(); + return theCollection()->broadcastMsgUntypedHandler( + proxy, msg.get(), han, true + ); + } else { + auto msg = makeMessage(std::forward(params)...); + return broadcastMsg(msg); + } +} + +template +template +messaging::PendingSend +Broadcastable::broadcastCollective(Params&&... params) const { + using MsgT = typename ObjFuncTraits::MsgT; + if constexpr (std::is_same_v) { + using Tuple = typename ObjFuncTraits::TupleType; + using SendMsgT = ParamColMsg; + auto msg = vt::makeMessage(std::forward(params)...); + auto han = auto_registry::makeAutoHandlerCollectionMemParam< + ColT, decltype(f), f, SendMsgT + >(); + auto proxy = this->getProxy(); + msg->setVrtHandler(han); + return theCollection()->broadcastCollectiveMsgImpl( + proxy, msg, true + ); + } else { + auto msg = makeMessage(std::forward(params)...); + return broadcastCollectiveMsg(msg); + } +} + +template +template +void +Broadcastable::invokeCollective(Params&&... params) const { + using MsgT = typename ObjFuncTraits::MsgT; + auto proxy = this->getProxy(); + if constexpr (std::is_same_v) { + theCollection()->invokeCollective( + proxy, std::forward(params)... + ); + } else { + auto msg = makeMessage(std::forward(params)...); + return theCollection()->invokeCollectiveMsg(proxy, msg); + } +} + }}} /* end namespace vt::vrt::collection */ #endif /*INCLUDED_VT_VRT_COLLECTION_BROADCAST_BROADCASTABLE_IMPL_H*/ diff --git a/src/vt/vrt/collection/manager.h b/src/vt/vrt/collection/manager.h index fa96a62f49..f404ae90d1 100644 --- a/src/vt/vrt/collection/manager.h +++ b/src/vt/vrt/collection/manager.h @@ -722,6 +722,18 @@ struct CollectionManager messaging::MsgPtrThief msg ); + /** + * \brief Invoke function handler without going through scheduler for all + * elements + * + * \param[in] proxy the whole collection proxy + * \param[in] args the arguments + */ + template + void invokeCollective( + CollectionProxyWrapType const& proxy, Args&&... args + ); + /** * \brief Invoke message action function handler without going through * scheduler for all elements diff --git a/src/vt/vrt/collection/manager.impl.h b/src/vt/vrt/collection/manager.impl.h index 5915ea91e0..58cd5635da 100644 --- a/src/vt/vrt/collection/manager.impl.h +++ b/src/vt/vrt/collection/manager.impl.h @@ -461,6 +461,25 @@ void CollectionManager::invokeCollectiveMsg( }); } +template +void CollectionManager::invokeCollective( + CollectionProxyWrapType const& proxy, Args&&... args +) { + using IndexType = typename ColT::IndexType; + + auto untyped_proxy = proxy.getProxy(); + auto elm_holder = findElmHolder(untyped_proxy); + auto const this_node = theContext()->getNode(); + + elm_holder->foreach([&](IndexType const& idx, Indexable* ptr) { + // be careful not to forward here as we are reusing args + runnable::makeRunnableVoid(false, uninitialized_handler, this_node) + .withCollection(ptr) + .withLBDataVoidMsg(ptr) + .runLambda(f, ptr, args...); + }); +} + template auto CollectionManager::invoke( VirtualElmProxyType const& proxy, Args&&... args diff --git a/src/vt/vrt/collection/send/sendable.impl.h b/src/vt/vrt/collection/send/sendable.impl.h index fd9891b917..379b98063e 100644 --- a/src/vt/vrt/collection/send/sendable.impl.h +++ b/src/vt/vrt/collection/send/sendable.impl.h @@ -138,11 +138,15 @@ messaging::PendingSend Sendable::send(Params&&... params using Tuple = typename ObjFuncTraits::TupleType; using SendMsgT = ParamColMsg; auto msg = vt::makeMessage(std::forward(params)...); - auto han = auto_registry::makeAutoHandlerCollectionMemParam(); + auto han = auto_registry::makeAutoHandlerCollectionMemParam< + ColT, decltype(f), f, SendMsgT + >(); auto col_proxy = this->getCollectionProxy(); auto elm_proxy = this->getElementProxy(); auto proxy = VrtElmProxy(col_proxy, elm_proxy); - return theCollection()->sendMsgUntypedHandler(proxy, msg.get(), han); + return theCollection()->sendMsgUntypedHandler( + proxy, msg.get(), han + ); } else { auto msg = makeMessage(std::forward(params)...); return sendMsg(msg); From 181d8cec71f7629ca62ad7f56eda1157b2346f20 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 1 Mar 2023 12:10:11 -0800 Subject: [PATCH 19/32] #276: vrt: swap ColT and MsgT for plain function handlers --- examples/callback/callback.cc | 2 +- examples/collection/migrate_collection.cc | 10 +++--- examples/collection/polymorphic_collection.cc | 10 +++--- .../hello_world_virtual_context.cc | 2 +- .../hello_world_virtual_context_remote.cc | 2 +- src/vt/registry/auto/auto_registry_common.h | 2 +- .../collection/auto_registry_collection.h | 3 ++ src/vt/utils/fntraits/fntraits.h | 30 ++++++++++++++++- src/vt/vrt/collection/active/active_funcs.h | 6 ++-- src/vt/vrt/collection/balance/col_lb_data.h | 2 +- .../vrt/collection/balance/col_lb_data.impl.h | 2 +- src/vt/vrt/collection/invoke/invokable.impl.h | 13 ++++++-- src/vt/vrt/collection/manager.h | 2 +- src/vt/vrt/collection/manager.impl.h | 6 ++-- src/vt/vrt/collection/send/sendable.impl.h | 6 ++-- src/vt/vrt/context/context_vrt_funcs.h | 4 +-- tests/unit/collection/test_broadcast.h | 6 ++-- .../test_collection_construct_common.h | 2 +- .../test_collection_group.extended.cc | 8 ++--- tests/unit/collection/test_destroy.cc | 6 ++-- tests/unit/collection/test_lb.extended.cc | 16 ++++------ .../unit/collection/test_lb_data_retention.cc | 11 +++---- .../unit/collection/test_lb_lite.extended.cc | 4 +-- tests/unit/collection/test_mapping.cc | 9 ++---- .../test_model_per_collection.extended.cc | 9 ++---- .../unit/collection/test_reduce_collection.cc | 16 +++++----- .../test_reduce_collection_handler.h | 16 +++++----- .../collection/test_reduce_collection_race.cc | 13 ++++---- tests/unit/collection/test_send.h | 16 ++-------- tests/unit/lb/test_lb_data_comm.cc | 32 +++++++++---------- tests/unit/phase/test_phase_insertions.cc | 4 +-- ...test_callback_bcast_collection.extended.cc | 2 +- .../test_callback_send_collection.extended.cc | 2 +- ...st_serialize_messenger_virtual.extended.cc | 2 +- 34 files changed, 144 insertions(+), 132 deletions(-) diff --git a/examples/callback/callback.cc b/examples/callback/callback.cc index c262118616..316ddb0090 100644 --- a/examples/callback/callback.cc +++ b/examples/callback/callback.cc @@ -110,7 +110,7 @@ struct MyObj { struct MyCol : vt::Collection { }; // Collection handler callback endpoint -void colHan(TestMsg* msg, MyCol* col) { +void colHan(MyCol* col, TestMsg* msg) { printOutput(msg, "MyCol colHan (non-intrusive)"); } diff --git a/examples/collection/migrate_collection.cc b/examples/collection/migrate_collection.cc index bc77c205f3..92bee3ce00 100644 --- a/examples/collection/migrate_collection.cc +++ b/examples/collection/migrate_collection.cc @@ -73,12 +73,12 @@ struct ColMsg : vt::CollectionMessage { vt::NodeType from_node = vt::uninitialized_destination; }; -static void doWork(ColMsg* msg, Hello* col) { +static void doWork(Hello* col, ColMsg* msg) { vt::NodeType this_node = vt::theContext()->getNode(); fmt::print("{}: idx={}: val={}\n", this_node, col->getIndex(), col->test_val); } -static void migrateToNext(ColMsg* msg, Hello* col) { +static void migrateToNext(Hello* col, ColMsg* msg) { vt::NodeType this_node = vt::theContext()->getNode(); vt::NodeType num_nodes = vt::theContext()->getNumNodes(); vt::NodeType next_node = (this_node + 1) % num_nodes; @@ -109,13 +109,13 @@ int main(int argc, char** argv) { .wait(); if (this_node == 0) { - vt::runInEpochRooted([=] { proxy.broadcast(this_node); }); + vt::runInEpochRooted([=] { proxy.broadcast(this_node); }); vt::runInEpochRooted( - [=] { proxy.broadcast(this_node); } + [=] { proxy.broadcast(this_node); } ); - vt::runInEpochRooted([=] { proxy.broadcast(this_node); }); + vt::runInEpochRooted([=] { proxy.broadcast(this_node); }); } vt::finalize(); diff --git a/examples/collection/polymorphic_collection.cc b/examples/collection/polymorphic_collection.cc index e470b65576..4f410f93ed 100644 --- a/examples/collection/polymorphic_collection.cc +++ b/examples/collection/polymorphic_collection.cc @@ -147,7 +147,7 @@ void Hello::doWork(ColMsg* msg) { } -static void migrateToNext(ColMsg* msg, Hello* col) { +static void migrateToNext(Hello* col, ColMsg* msg) { vt::NodeType this_node = vt::theContext()->getNode(); vt::NodeType num_nodes = vt::theContext()->getNumNodes(); vt::NodeType next_node = (this_node + 1) % num_nodes; @@ -192,19 +192,19 @@ int main(int argc, char** argv) { for (int p = 0; p < 10; p++) { vt::runInEpochCollective([&]{ - proxy.broadcastCollective(this_node); + proxy.broadcastCollective<&Hello::doWork>(this_node); }); vt::runInEpochCollective([&]{ - proxy.broadcastCollective(this_node); + proxy.broadcastCollective(this_node); }); vt::runInEpochCollective([&]{ - proxy.broadcastCollective(this_node); + proxy.broadcastCollective<&Hello::doWork>(this_node); }); } for (int p = 0; p < 10; p++) { vt::runInEpochCollective([&]{ - proxy.broadcastCollective(this_node); + proxy.broadcastCollective<&Hello::doWork>(this_node); }); vt::thePhase()->nextPhaseCollective(); } diff --git a/examples/hello_world/hello_world_virtual_context.cc b/examples/hello_world/hello_world_virtual_context.cc index 8058287785..8b7e6c7591 100644 --- a/examples/hello_world/hello_world_virtual_context.cc +++ b/examples/hello_world/hello_world_virtual_context.cc @@ -67,7 +67,7 @@ struct MyVC : vt::vrt::VirtualContext { { } }; -static void my_han(TestMsg* msg, MyVC* vc) { +static void my_han(MyVC* vc, TestMsg* msg) { auto this_node = vt::theContext()->getNode(); fmt::print( "{}: vc={}: msg->from={}, vc->my_data={}\n", diff --git a/examples/hello_world/hello_world_virtual_context_remote.cc b/examples/hello_world/hello_world_virtual_context_remote.cc index 98a579aa64..69a1ce73b5 100644 --- a/examples/hello_world/hello_world_virtual_context_remote.cc +++ b/examples/hello_world/hello_world_virtual_context_remote.cc @@ -61,7 +61,7 @@ struct MyVC : vt::vrt::VirtualContext { } }; -static void testHan(TestMsg* msg, MyVC* vc) { +static void testHan(MyVC* vc, TestMsg* msg) { fmt::print("testHan: msg->from={}, my_data={}\n", msg->from, vc->my_data); } diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index 7c326bbfc6..40116a9ef0 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -86,7 +86,7 @@ struct HandlersDispatcher final : BaseHandlersDispatcher { } else if constexpr (std::is_same_v*>) { fp(msg); } else if constexpr (std::is_same_v) { - fp(msg, elm); + fp(elm, msg); } else { if constexpr (std::is_same_v) { std::apply(fp, msg->getTuple()); diff --git a/src/vt/registry/auto/collection/auto_registry_collection.h b/src/vt/registry/auto/collection/auto_registry_collection.h index d025a07646..8436c88ec0 100644 --- a/src/vt/registry/auto/collection/auto_registry_collection.h +++ b/src/vt/registry/auto/collection/auto_registry_collection.h @@ -68,6 +68,9 @@ template < > HandlerType makeAutoHandlerCollectionMem(); +template +HandlerType makeAutoHandlerCollectionMemParam(); + template * f> void setHandlerTraceNameColl(std::string const& name, std::string const& parent = ""); diff --git a/src/vt/utils/fntraits/fntraits.h b/src/vt/utils/fntraits/fntraits.h index bcb17cf982..425dce8cf6 100644 --- a/src/vt/utils/fntraits/fntraits.h +++ b/src/vt/utils/fntraits/fntraits.h @@ -55,18 +55,44 @@ template struct ObjFuncTraits< std::enable_if_t::value>, ObjT, - Return(*)(Msg*, ObjT*) + Return(*)(ObjT*, Msg*) > { + static constexpr bool is_member = false; using MsgT = Msg; using ReturnT = Return; }; +template +struct ObjFuncTraits< + std::enable_if_t>, + ObjT, + Return(*)(ObjT*) +> { + static constexpr bool is_member = false; + using MsgT = NoMsg; + using ReturnT = Return; + using TupleType = std::tuple<>; +}; + +template +struct ObjFuncTraits< + std::enable_if_t::value>, + ObjT, + Return(*)(ObjT*, Arg, Args...) +> { + static constexpr bool is_member = false; + using MsgT = NoMsg; + using TupleType = std::tuple, std::decay_t...>; + using ReturnT = Return; +}; + template struct ObjFuncTraits< std::enable_if_t::value>, ObjT, Return(ObjT::*)(Msg*) > { + static constexpr bool is_member = true; using MsgT = Msg; using ReturnT = Return; }; @@ -77,6 +103,7 @@ struct ObjFuncTraits< ObjT, Return(ObjT::*)() > { + static constexpr bool is_member = true; using MsgT = NoMsg; using TupleType = std::tuple<>; using ReturnT = Return; @@ -88,6 +115,7 @@ struct ObjFuncTraits< ObjT, Return(ObjT::*)(Arg, Args...) > { + static constexpr bool is_member = true; using MsgT = NoMsg; using TupleType = std::tuple, std::decay_t...>; using ReturnT = Return; diff --git a/src/vt/vrt/collection/active/active_funcs.h b/src/vt/vrt/collection/active/active_funcs.h index 86b196d506..3e7327f78b 100644 --- a/src/vt/vrt/collection/active/active_funcs.h +++ b/src/vt/vrt/collection/active/active_funcs.h @@ -51,12 +51,10 @@ namespace vt { namespace vrt { namespace collection { -using ActiveColFnPtrType = void(*)( - ::vt::BaseMessage*, UntypedCollection* -); +using ActiveColFnPtrType = void(*)(UntypedCollection*, ::vt::BaseMessage*); template -using ActiveColTypedFnType = void(MsgT*, ColT*); +using ActiveColTypedFnType = void(ColT*, MsgT*); using ActiveColMemberFnPtrType = void(UntypedCollection::*)(::vt::BaseMessage*); diff --git a/src/vt/vrt/collection/balance/col_lb_data.h b/src/vt/vrt/collection/balance/col_lb_data.h index d256748754..223fcdd52a 100644 --- a/src/vt/vrt/collection/balance/col_lb_data.h +++ b/src/vt/vrt/collection/balance/col_lb_data.h @@ -70,7 +70,7 @@ struct CollectionLBData : elm::ElementLBData { public: template - static void syncNextPhase(CollectStatsMsg* msg, ColT* col); + static void syncNextPhase(ColT* col, CollectStatsMsg* msg); friend struct collection::Migratable; diff --git a/src/vt/vrt/collection/balance/col_lb_data.impl.h b/src/vt/vrt/collection/balance/col_lb_data.impl.h index 271939ced9..fe968618d7 100644 --- a/src/vt/vrt/collection/balance/col_lb_data.impl.h +++ b/src/vt/vrt/collection/balance/col_lb_data.impl.h @@ -60,7 +60,7 @@ namespace vt { namespace vrt { namespace collection { namespace balance { template /*static*/ -void CollectionLBData::syncNextPhase(CollectStatsMsg* msg, ColT* col) { +void CollectionLBData::syncNextPhase(ColT* col, CollectStatsMsg* msg) { auto& lb_data = col->lb_data_; vt_debug_print( diff --git a/src/vt/vrt/collection/invoke/invokable.impl.h b/src/vt/vrt/collection/invoke/invokable.impl.h index 693a691649..ffe96d3047 100644 --- a/src/vt/vrt/collection/invoke/invokable.impl.h +++ b/src/vt/vrt/collection/invoke/invokable.impl.h @@ -46,6 +46,7 @@ #include "vt/vrt/collection/invoke/invokable.h" #include "vt/vrt/collection/manager.h" +#include "vt/utils/fntraits/fntraits.h" namespace vt { namespace vrt { namespace collection { @@ -92,9 +93,15 @@ Invokable::invoke(Args&&... args) const { auto const& proxy = VrtElmProxy( this->getCollectionProxy(), this->getElementProxy()); - return theCollection()->invoke( - proxy, std::forward(args)... - ); + using MsgT = typename ObjFuncTraits::MsgT; + if constexpr (std::is_same_v) { + return theCollection()->invoke( + proxy, std::forward(args)... + ); + } else { + auto msg = makeMessage(std::forward(args)...); + return theCollection()->invokeMsg(proxy, msg, true); + } } }}} /* end namespace vt::vrt::collection */ diff --git a/src/vt/vrt/collection/manager.h b/src/vt/vrt/collection/manager.h index f404ae90d1..54ae55ef2f 100644 --- a/src/vt/vrt/collection/manager.h +++ b/src/vt/vrt/collection/manager.h @@ -1547,7 +1547,7 @@ struct CollectionManager * \param[in] msg the destroy message */ template - static void destroyElmHandler(DestroyElmMsg* msg, ColT*); + static void destroyElmHandler(ColT*, DestroyElmMsg* msg); /** * \brief Try to get a pointer to a collection element diff --git a/src/vt/vrt/collection/manager.impl.h b/src/vt/vrt/collection/manager.impl.h index 58cd5635da..93b66dfcf5 100644 --- a/src/vt/vrt/collection/manager.impl.h +++ b/src/vt/vrt/collection/manager.impl.h @@ -1786,7 +1786,7 @@ void CollectionManager::destroyElm( } else { // Otherwise, we send a destroy message that will be routed (eventually // arriving) where the element resides - proxy(idx).template send, destroyElmHandler>( + proxy(idx).template send>( untyped_proxy, idx, modify_epoch ); } @@ -1796,7 +1796,7 @@ void CollectionManager::destroyElm( template /*static*/ void CollectionManager::destroyElmHandler( - DestroyElmMsg* msg, ColT* + ColT*, DestroyElmMsg* msg ) { CollectionProxyWrapType proxy{msg->proxy_}; ModifierToken token{msg->modifier_epoch_}; @@ -2219,7 +2219,7 @@ void CollectionManager::checkpointToFile( namespace detail { template inline void restoreOffHomeElement( - CollectionManager::RestoreMigrateColMsg* msg, ColT* + ColT*, CollectionManager::RestoreMigrateColMsg* msg ) { auto idx = msg->idx_; auto node = msg->to_node_; diff --git a/src/vt/vrt/collection/send/sendable.impl.h b/src/vt/vrt/collection/send/sendable.impl.h index 379b98063e..17cdc8f754 100644 --- a/src/vt/vrt/collection/send/sendable.impl.h +++ b/src/vt/vrt/collection/send/sendable.impl.h @@ -133,9 +133,11 @@ messaging::PendingSend Sendable::send(Args&&... args) co template template messaging::PendingSend Sendable::send(Params&&... params) const { - using MsgT = typename ObjFuncTraits::MsgT; + using FnTrait = ObjFuncTraits; + + using MsgT = typename FnTrait::MsgT; if constexpr (std::is_same_v) { - using Tuple = typename ObjFuncTraits::TupleType; + using Tuple = typename FnTrait::TupleType; using SendMsgT = ParamColMsg; auto msg = vt::makeMessage(std::forward(params)...); auto han = auto_registry::makeAutoHandlerCollectionMemParam< diff --git a/src/vt/vrt/context/context_vrt_funcs.h b/src/vt/vrt/context/context_vrt_funcs.h index 1790d55dfd..fa6f042bf7 100644 --- a/src/vt/vrt/context/context_vrt_funcs.h +++ b/src/vt/vrt/context/context_vrt_funcs.h @@ -51,10 +51,10 @@ namespace vt { namespace vrt { struct VirtualContext; -using ActiveVirtualFnPtrType = void(*)(BaseMessage *, VirtualContext*); +using ActiveVirtualFnPtrType = void(*)(VirtualContext*, BaseMessage*); template -using ActiveVrtTypedFnType = void(MessageT*, VirtualContextT*); +using ActiveVrtTypedFnType = void(VirtualContextT*, MessageT*); }} /* end namespace vt::context */ diff --git a/tests/unit/collection/test_broadcast.h b/tests/unit/collection/test_broadcast.h index 0f29e902f7..e2fccb8f67 100644 --- a/tests/unit/collection/test_broadcast.h +++ b/tests/unit/collection/test_broadcast.h @@ -98,7 +98,7 @@ template < typename TupleT = typename MessageT::TupleType > struct BroadcastHandlers { - static void handler(MessageT* msg, CollectionT* col) { + static void handler(CollectionT* col, MessageT* msg) { return execute(col,msg->tup); } template @@ -135,9 +135,9 @@ void test_broadcast_1(std::string const& label) { >(args); auto msg = makeMessage(args); - theCollection()->broadcastMsg< + proxy.template broadcastMsg< BroadcastHandlers::handler - >(proxy, msg.get()); + >(msg); } } diff --git a/tests/unit/collection/test_collection_construct_common.h b/tests/unit/collection/test_collection_construct_common.h index c597a0409c..f239434bad 100644 --- a/tests/unit/collection/test_collection_construct_common.h +++ b/tests/unit/collection/test_collection_construct_common.h @@ -71,7 +71,7 @@ struct ConstructHandlers { typename CollectionT, typename MessageT = typename CollectionT::MsgType > - static void handler(MessageT* msg, CollectionT* col) { + static void handler(CollectionT* col, MessageT* msg) { // fmt::print( // "{}: constructed TestCol: idx.x()={}\n", // theContext()->getNode(), col->getInex().x(), print_ptr(col) diff --git a/tests/unit/collection/test_collection_group.extended.cc b/tests/unit/collection/test_collection_group.extended.cc index 752aeb8f18..0d08a1e2c9 100644 --- a/tests/unit/collection/test_collection_group.extended.cc +++ b/tests/unit/collection/test_collection_group.extended.cc @@ -62,7 +62,6 @@ struct MyReduceMsg : collective::ReduceTMsg { }; struct ColA : Collection { - struct TestMsg : CollectionMessage { }; struct TestDataMsg : CollectionMessage { TestDataMsg(int32_t value) : value_(value) {} @@ -75,7 +74,7 @@ struct ColA : Collection { finished = true; } - void doReduce(TestMsg* msg) { + void doReduce() { auto const proxy = getCollectionProxy(); auto cb = theCB()->makeBcast(proxy); auto reduce_msg = makeMessage(getIndex().x()); @@ -99,8 +98,7 @@ struct ColA : Collection { bool reduce_test = false; }; -void colHandler( - ColA::TestDataMsg* msg, typename ColA::TestDataMsg::CollectionType* type) { +void colHandler(typename ColA::TestDataMsg::CollectionType* type, ColA::TestDataMsg*) { --elem_counter; } @@ -121,7 +119,7 @@ TEST_F(TestCollectionGroup, test_collection_group_1) { auto const proxy = theCollection()->construct( range, "test_collection_group_1" ); - proxy.broadcast(); + proxy.broadcast<&ColA::doReduce>(); } } diff --git a/tests/unit/collection/test_destroy.cc b/tests/unit/collection/test_destroy.cc index fae3de8273..cc8a8d00f8 100644 --- a/tests/unit/collection/test_destroy.cc +++ b/tests/unit/collection/test_destroy.cc @@ -69,7 +69,7 @@ struct DestroyTest : Collection { num_destroyed++; } - static void work(WorkMsg* msg, DestroyTest* col); + static void work(DestroyTest* col); }; struct WorkMsg : CollectionMessage {}; @@ -88,7 +88,7 @@ struct FinishedWork { } }; -/*static*/ void DestroyTest::work(WorkMsg* msg, DestroyTest* col) { +/*static*/ void DestroyTest::work(DestroyTest* col) { auto proxy = col->getCollectionProxy(); // ::fmt::print("work idx={}, proxy={:x}\n", col->getIndex(), proxy.getProxy()); auto reduce_msg = makeMessage(proxy); @@ -117,7 +117,7 @@ TEST_F(TestDestroy, test_destroy_1) { ); // ::fmt::print("broadcasting proxy={:x}\n", proxy.getProxy()); - proxy.broadcast(); + proxy.broadcast(); } }); // ::fmt::print("num destroyed={}\n", num_destroyed); diff --git a/tests/unit/collection/test_lb.extended.cc b/tests/unit/collection/test_lb.extended.cc index 1f50cf8c09..409b3a591c 100644 --- a/tests/unit/collection/test_lb.extended.cc +++ b/tests/unit/collection/test_lb.extended.cc @@ -83,10 +83,8 @@ struct MyCol : vt::Collection { double val = 0.0; }; -using MyMsg = vt::CollectionMessage; - // A dummy kernel that does some work depending on the index -void colHandler(MyMsg*, MyCol* col) { +void colHandler(MyCol* col) { for (int i = 0; i < 10; i++) { for (int j = 0; j < col->getIndex().x() * 20; j++) { col->val += (i*29+j*2)-4; @@ -134,7 +132,7 @@ void runTest(std::string const& lb_name, std::string const& label) { for (int phase = 0; phase < num_phases; phase++) { // Do some work. runInEpochCollective([&]{ - proxy.broadcastCollective(); + proxy.broadcastCollective(); }); // Go to the next phase. @@ -342,7 +340,7 @@ TEST_P(TestLBSpecFile, test_node_lb_data_dumping_with_spec_file) { for (int phase = 0; phase < num_phases; phase++) { // Do some work runInEpochCollective([&] { - proxy.broadcastCollective(); + proxy.broadcastCollective(); }); // Go to the next phase @@ -407,7 +405,7 @@ TEST_P(TestNodeLBDataDumper, test_node_lb_data_dumping_with_interval) { for (int phase = 0; phase < num_phases; phase++) { // Do some work runInEpochCollective([&] { - proxy.broadcastCollective(); + proxy.broadcastCollective(); }); // Go to the next phase @@ -792,9 +790,7 @@ struct SerializationTestCol : vt::Collection int unpacked_on_node = -1; }; -using SerializationTestMsg = vt::CollectionMessage; - -void serializationColHandler(SerializationTestMsg *, SerializationTestCol *col) { +void serializationColHandler(SerializationTestCol *col) { auto const cur_phase = thePhase()->getCurrentPhase(); if (cur_phase < 2) { return; @@ -824,7 +820,7 @@ void runSerializationTest() { for (int phase = 0; phase < num_phases; ++phase) { runInEpochCollective([&] { - proxy.broadcastCollective(); + proxy.broadcastCollective(); }); thePhase()->nextPhaseCollective(); } diff --git a/tests/unit/collection/test_lb_data_retention.cc b/tests/unit/collection/test_lb_data_retention.cc index ec090748a1..c02bd745c4 100644 --- a/tests/unit/collection/test_lb_data_retention.cc +++ b/tests/unit/collection/test_lb_data_retention.cc @@ -57,15 +57,12 @@ namespace vt { namespace tests { namespace unit { -template -struct MyMsg : vt::CollectionMessage { }; - struct TestCol : vt::Collection { unsigned int prev_calls_ = 0; unsigned int prevCalls() { return prev_calls_++; } - static void colHandler(MyMsg* msg, TestCol* col) { + static void colHandler(TestCol* col) { auto& lb_data = col->lb_data_; auto load_phase_count = lb_data.getLoadPhaseCount(); @@ -148,7 +145,7 @@ TEST_F(TestLBDataRetention, test_lbdata_retention_last1) { for (int i=0; i, TestCol::colHandler>(); + proxy.broadcastCollective(); }); // Go to the next phase. vt::thePhase()->nextPhaseCollective(); @@ -182,7 +179,7 @@ TEST_F(TestLBDataRetention, test_lbdata_retention_last2) { for (int i=0; i, TestCol::colHandler>(); + proxy.broadcastCollective(); }); // Go to the next phase. vt::thePhase()->nextPhaseCollective(); @@ -216,7 +213,7 @@ TEST_F(TestLBDataRetention, test_lbdata_retention_last4) { for (int i=0; i, TestCol::colHandler>(); + proxy.broadcastCollective(); }); // Go to the next phase. vt::thePhase()->nextPhaseCollective(); diff --git a/tests/unit/collection/test_lb_lite.extended.cc b/tests/unit/collection/test_lb_lite.extended.cc index 18708043c9..6fdad450cc 100644 --- a/tests/unit/collection/test_lb_lite.extended.cc +++ b/tests/unit/collection/test_lb_lite.extended.cc @@ -87,7 +87,7 @@ struct LBTest : Collection { s | val1 | val2 | val3 | data_2; } - static void iterWork(IterMsg* msg, LBTest* col); + static void iterWork(LBTest* col, IterMsg* msg); public: double data_2 = 1.0; @@ -103,7 +103,7 @@ using ColProxyType = CollectionIndexProxy; static double weight = 1.0f; static int32_t num_iter = 8; -/*static*/ void LBTest::iterWork(IterMsg* msg, LBTest* col) { +/*static*/ void LBTest::iterWork(LBTest* col, IterMsg* msg) { double val = 0.1f; double val4 = 0.4f; auto const idx = col->getIndex().x(); diff --git a/tests/unit/collection/test_mapping.cc b/tests/unit/collection/test_mapping.cc index b5a5907364..eeff58ccc1 100644 --- a/tests/unit/collection/test_mapping.cc +++ b/tests/unit/collection/test_mapping.cc @@ -79,13 +79,10 @@ struct MyMapper : vt::mapping::BaseMapper { } }; -template -struct WorkMsg : CollectionMessage> {}; - static int32_t num_work = 0; template -void work(WorkMsg* msg, MappingTest* elm) { +void work(MappingTest* elm) { fmt::print( "node={}: num_work={}, idx={}\n", theContext()->getNode(), num_work, elm->getIndex() @@ -192,7 +189,7 @@ TYPED_TEST_P(TestMapping, test_custom_mapping_1) { .wait(); vt::runInEpochCollective([&]{ - proxy.template broadcastCollective, work>(); + proxy.template broadcastCollective>(); }); EXPECT_EQ(counter, num_work); @@ -204,7 +201,7 @@ TYPED_TEST_P(TestMapping, test_custom_mapping_1) { .wait(); vt::runInEpochCollective([&]{ - proxy2.template broadcastCollective, work>(); + proxy2.template broadcastCollective>(); }); EXPECT_EQ(counter, num_work); diff --git a/tests/unit/collection/test_model_per_collection.extended.cc b/tests/unit/collection/test_model_per_collection.extended.cc index 7f7d8841b7..2c539f0b53 100644 --- a/tests/unit/collection/test_model_per_collection.extended.cc +++ b/tests/unit/collection/test_model_per_collection.extended.cc @@ -82,13 +82,10 @@ struct ConstantTestModel : ComposedModel { VirtualProxyType proxy_ = 0; }; -template -struct MyMsg : vt::CollectionMessage { }; - std::unordered_map id_proxy_map; template -void colHandler(MyMsg*, ColT* col) { +void colHandler(ColT* col) { // do nothing, except setting up our map using the temp ID, which will hit // every node id_proxy_map[col->getElmID()] = col->getProxy(); @@ -141,8 +138,8 @@ TEST_F(TestModelPerCollection, test_model_per_collection_1) { // Do some work. runInEpochCollective([&]{ - proxy1.broadcastCollective, colHandler>(); - proxy2.broadcastCollective, colHandler>(); + proxy1.broadcastCollective>(); + proxy2.broadcastCollective>(); }); // Add a hook for after LB runs, but before instrumentation is cleared diff --git a/tests/unit/collection/test_reduce_collection.cc b/tests/unit/collection/test_reduce_collection.cc index 0588d8e030..231a0bd43e 100644 --- a/tests/unit/collection/test_reduce_collection.cc +++ b/tests/unit/collection/test_reduce_collection.cc @@ -60,16 +60,16 @@ TEST_P(TestReduceCollection, test_reduce_op) { auto proxy = theCollection()->construct(range, "test_reduce_op"); switch (reduce_case) { - case 0: proxy.broadcast(my_node); break; - case 1: proxy.broadcast(my_node); break; - case 2: proxy.broadcast(my_node); break; - case 3: proxy.broadcast(my_node); break; - case 4: proxy.broadcast(my_node); break; + case 0: proxy.broadcast(); break; + case 1: proxy.broadcast(); break; + case 2: proxy.broadcast(); break; + case 3: proxy.broadcast(); break; + case 4: proxy.broadcast(); break; #if ENABLE_REDUCE_EXPR_CALLBACK - case 5: proxy.broadcast(my_node); break; - case 6: proxy.broadcast(my_node); break; - case 7: proxy.broadcast(my_node); break; + case 5: proxy.broadcast(); break; + case 6: proxy.broadcast(); break; + case 7: proxy.broadcast(); break; #endif default: vtAbort("Failure: should not be reached"); } diff --git a/tests/unit/collection/test_reduce_collection_handler.h b/tests/unit/collection/test_reduce_collection_handler.h index e43da68286..b5acedcded 100644 --- a/tests/unit/collection/test_reduce_collection_handler.h +++ b/tests/unit/collection/test_reduce_collection_handler.h @@ -51,7 +51,7 @@ namespace vt { namespace tests { namespace unit { namespace reduce { -void colHanBasic(ColMsg* msg, MyCol* col) { +void colHanBasic(MyCol* col) { auto const& idx = col->getIndex(); vt_debug_print( @@ -71,7 +71,7 @@ void colHanBasic(ColMsg* msg, MyCol* col) { >(proxy, reduce_msg.get()); } -void colHanVec(ColMsg* msg, MyCol* col) { +void colHanVec(MyCol* col) { auto const& idx = col->getIndex(); vt_debug_print( normal, reduce, @@ -93,7 +93,7 @@ void colHanVec(ColMsg* msg, MyCol* col) { >(proxy, reduce_msg.get()); } -void colHanVecProxy(ColMsg* msg, MyCol* col) { +void colHanVecProxy(MyCol* col) { auto const& idx = col->getIndex(); vt_debug_print( normal, reduce, @@ -110,7 +110,7 @@ void colHanVecProxy(ColMsg* msg, MyCol* col) { proxy.reduce, CheckVec>(reduce_msg.get()); } -void colHanVecProxyCB(ColMsg* msg, MyCol* col) { +void colHanVecProxyCB(MyCol* col) { auto const& idx = col->getIndex(); vt_debug_print( normal, reduce, @@ -130,7 +130,7 @@ void colHanVecProxyCB(ColMsg* msg, MyCol* col) { proxy.reduce>(reduce_msg.get(),cb); } -void colHanNoneCB(ColMsg* msg, MyCol* col) { +void colHanNoneCB(MyCol* col) { auto const& idx = col->getIndex(); vt_debug_print( normal, reduce, @@ -148,7 +148,7 @@ void colHanNoneCB(ColMsg* msg, MyCol* col) { // Using reduceExpr with callback is broken and has fundamental flaws. // These tests are disabled for now. #if ENABLE_REDUCE_EXPR_CALLBACK -void colHanPartial(ColMsg* msg, MyCol* col) { +void colHanPartial(MyCol* col) { auto const& idx = col->getIndex(); vt_debug_print( @@ -172,7 +172,7 @@ void colHanPartial(ColMsg* msg, MyCol* col) { ); } -void colHanPartialMulti(ColMsg* msg, MyCol* col) { +void colHanPartialMulti(MyCol* col) { auto const& idx = col->getIndex(); auto const& grouping = idx.x() % index_tresh; @@ -204,7 +204,7 @@ void colHanPartialMulti(ColMsg* msg, MyCol* col) { ); } -void colHanPartialProxy(ColMsg* msg, MyCol* col) { +void colHanPartialProxy(MyCol* col) { auto const& idx = col->getIndex(); vt_debug_print( diff --git a/tests/unit/collection/test_reduce_collection_race.cc b/tests/unit/collection/test_reduce_collection_race.cc index 0043728681..37459a7bc6 100644 --- a/tests/unit/collection/test_reduce_collection_race.cc +++ b/tests/unit/collection/test_reduce_collection_race.cc @@ -49,7 +49,6 @@ namespace vt { namespace tests { namespace unit { namespace race { using TestReduceCollectionRace = TestParallelHarnessParam; struct MyCol : vt::Collection {}; -struct TestMsg : vt::CollectionMessage {}; using ReduceMsg = vt::collective::ReduceTMsg; static int multipler = 0; @@ -63,7 +62,7 @@ struct ReduceFunctor { } }; -static void handler(TestMsg*, MyCol* col) { +static void handler(MyCol* col) { auto proxy = col->getCollectionProxy(); auto msg = vt::makeMessage(static_cast(col->getIndex().x())); auto cb = vt::theCB()->makeSend(0); @@ -79,11 +78,11 @@ TEST_P(TestReduceCollectionRace, test_reduce_race_1) { range, "test_reduce_race_1" ); - proxy.broadcastCollective(); - proxy.broadcastCollective(); - proxy.broadcastCollective(); - proxy.broadcastCollective(); - proxy.broadcastCollective(); + proxy.broadcastCollective<&handler>(); + proxy.broadcastCollective<&handler>(); + proxy.broadcastCollective<&handler>(); + proxy.broadcastCollective<&handler>(); + proxy.broadcastCollective<&handler>(); } INSTANTIATE_TEST_SUITE_P( diff --git a/tests/unit/collection/test_send.h b/tests/unit/collection/test_send.h index 9187f08c2b..d6b629e06c 100644 --- a/tests/unit/collection/test_send.h +++ b/tests/unit/collection/test_send.h @@ -135,7 +135,7 @@ template < typename TupleT = typename MessageT::TupleType > struct SendHandlers { - static void handler(MessageT* msg, CollectionT* col) { + static void handler(CollectionT* col, MessageT* msg) { return execute(col,msg->tup); } template @@ -158,7 +158,7 @@ template < > struct SendSzHandlers : SendHandlers { using BaseT = SendHandlers; - static void handler(MessageT* msg, CollectionT* col) { + static void handler(CollectionT* col, MessageT* msg) { // Verify payload size is correct EXPECT_EQ(msg->buff_size, sizeof(PayloadT)); auto smart_ptr = vt::MsgSharedPtr(msg); @@ -196,10 +196,6 @@ void test_collection_send_1(std::string const& label) { EXPECT_EQ(msg.size(), sizeof(MsgType)); if (i % 2 == 0) { proxy[i].template sendMsg::handler>(msg.get()); - } else { - theCollection()->sendMsg::handler>( - proxy[i], msg.get() - ); } } } @@ -241,13 +237,7 @@ void test_collection_send_ptm_1(std::string const& label) { for (int i = 0; i < col_size; i++) { auto msg = makeMessage(args); //proxy[i].template send::handler>(msg); - if (i % 2 == 0) { - proxy[i].template sendMsg<&ColType::handler>(msg.get()); - } else { - theCollection()->sendMsg<&ColType::handler>( - proxy[i], msg.get() - ); - } + proxy[i].template sendMsg<&ColType::handler>(msg.get()); } } } diff --git a/tests/unit/lb/test_lb_data_comm.cc b/tests/unit/lb/test_lb_data_comm.cc index 6bd5808821..cdea44d670 100644 --- a/tests/unit/lb/test_lb_data_comm.cc +++ b/tests/unit/lb/test_lb_data_comm.cc @@ -150,7 +150,7 @@ struct ProxyMsg : vt::CollectionMessage { ProxyType obj_proxy; }; -void handler2(MyMsg* msg, MyCol* col) {} +void handler2(MyCol* col, MyMsg*) {} void MyObj::simulateObjGroupColTSends(ColProxyMsg* msg) { auto proxy = msg->proxy; @@ -162,7 +162,7 @@ void MyObj::simulateObjGroupColTSends(ColProxyMsg* msg) { auto node = vt::theCollection()->getMappedNode(proxy, idx); if (node == next) { for (int j = 0; j < num_sends; j++) { - proxy(idx).template send(); + proxy(idx).template send(); } } } @@ -178,16 +178,16 @@ void MyObj::simulateObjGroupObjGroupSends(ProxyMsg* msg) { } } -void simulateColTColTSends(MyMsg* msg, MyCol* col) { +void simulateColTColTSends(MyCol* col) { auto proxy = col->getCollectionProxy(); auto index = col->getIndex(); auto next = (index.x() + 1) % dim1; for (int i = 0; i < num_sends; i++) { - proxy(next).template send(); + proxy(next).template send(); } } -void simulateColTObjGroupSends(ProxyMsg* msg, MyCol* col) { +void simulateColTObjGroupSends(MyCol* col, ProxyMsg* msg) { auto obj_proxy = msg->obj_proxy; auto this_node = theContext()->getNode(); auto num_nodes = theContext()->getNumNodes(); @@ -199,7 +199,7 @@ void simulateColTObjGroupSends(ProxyMsg* msg, MyCol* col) { void bareDummyHandler(MyObjMsg* msg) {} -void simulateColTHandlerSends(MyMsg* msg, MyCol* col) { +void simulateColTHandlerSends(MyCol* col) { auto this_node = theContext()->getNode(); auto num_nodes = theContext()->getNumNodes(); auto next = (this_node + 1) % num_nodes; @@ -229,7 +229,7 @@ void simulateHandlerColTSends(ColProxyMsg* msg) { auto node = vt::theCollection()->getMappedNode(proxy, idx); if (node == next) { for (int j = 0; j < num_sends; j++) { - proxy(idx).template send(); + proxy(idx).template send(); } } } @@ -263,7 +263,7 @@ auto idxToElmID = [](vt::Index1D i) -> vt::elm::ElementIDType { void recvElementIDs(ReduceMsg* msg) { all_elms = msg->getVal().elms; } -void doReduce(MyMsg*, MyCol* col) { +void doReduce(MyCol* col) { auto proxy = col->getCollectionProxy(); auto index = col->getIndex(); auto cb = theCB()->makeBcast(); @@ -282,7 +282,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_col_to_col_send) { vt::runInEpochCollective("simulateColTColTSends", [&]{ for (int i = 0; i < dim1; i++) { if (proxy(i).tryGetLocalPtr()) { - proxy(i).invoke(); + proxy(i).invoke(); } } }); @@ -292,7 +292,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_col_to_col_send) { vt::runInEpochCollective("doReduce", [&]{ for (int i = 0; i < dim1; i++) { if (proxy(i).tryGetLocalPtr()) { - proxy(i).invoke(); + proxy(i).invoke(); } } }); @@ -342,7 +342,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_col_to_objgroup_send) { vt::runInEpochCollective("simulateColTObjGroupSends", [&]{ for (int i = 0; i < dim1; i++) { if (proxy(i).tryGetLocalPtr()) { - proxy(i).invoke(obj_proxy); + proxy(i).invoke(obj_proxy); } } }); @@ -352,7 +352,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_col_to_objgroup_send) { vt::runInEpochCollective("doReduce", [&]{ for (int i = 0; i < dim1; i++) { if (proxy(i).tryGetLocalPtr()) { - proxy(i).invoke(); + proxy(i).invoke(); } } }); @@ -416,7 +416,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_objgroup_to_col_send) { vt::runInEpochCollective("doReduce", [&]{ for (int i = 0; i < dim1; i++) { if (proxy(i).tryGetLocalPtr()) { - proxy(i).invoke(); + proxy(i).invoke(); } } }); @@ -528,7 +528,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_handler_to_col_send) { vt::runInEpochCollective("doReduce", [&]{ for (int i = 0; i < dim1; i++) { if (proxy(i).tryGetLocalPtr()) { - proxy(i).invoke(); + proxy(i).invoke(); } } }); @@ -578,7 +578,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_col_to_handler_send) { vt::runInEpochCollective("simulateColTHandlerSends", [&]{ for (int i = 0; i < dim1; i++) { if (proxy(i).tryGetLocalPtr()) { - proxy(i).invoke(); + proxy(i).invoke(); } } }); @@ -588,7 +588,7 @@ TEST_F(TestLBDataComm, test_lb_data_comm_col_to_handler_send) { vt::runInEpochCollective("doReduce", [&]{ for (int i = 0; i < dim1; i++) { if (proxy(i).tryGetLocalPtr()) { - proxy(i).invoke(); + proxy(i).invoke(); } } }); diff --git a/tests/unit/phase/test_phase_insertions.cc b/tests/unit/phase/test_phase_insertions.cc index 1627118504..615ab7c3b0 100644 --- a/tests/unit/phase/test_phase_insertions.cc +++ b/tests/unit/phase/test_phase_insertions.cc @@ -83,7 +83,7 @@ struct MyCol : vt::Collection { using MyMsg = vt::CollectionMessage; // A dummy kernel that does some work depending on the index -void colHandler(MyMsg*, MyCol* col) { +void colHandler(MyCol* col) { fmt::print("running colHandler: idx={}, phase={}\n", col->getIndex(), col->getPhase()); for (int i = 0; i < 10; i++) { for (int j = 0; j < col->getIndex().x() * 20; j++) { @@ -130,7 +130,7 @@ TEST_F(TestPhaseInsertions, test_phase_insertions_1) { // Do some work. runInEpochCollective([&]{ if (this_node == 0) { - proxy.broadcast(); + proxy.broadcast(); } }); diff --git a/tests/unit/pipe/test_callback_bcast_collection.extended.cc b/tests/unit/pipe/test_callback_bcast_collection.extended.cc index 0cd621c788..ca31be1ebe 100644 --- a/tests/unit/pipe/test_callback_bcast_collection.extended.cc +++ b/tests/unit/pipe/test_callback_bcast_collection.extended.cc @@ -119,7 +119,7 @@ struct TestCol : vt::Collection { bool other = false; }; -static void cb3(DataMsg* msg, TestCol* col) { +static void cb3(TestCol* col, DataMsg* msg) { EXPECT_EQ(msg->a, 8); EXPECT_EQ(msg->b, 9); EXPECT_EQ(msg->c, 10); diff --git a/tests/unit/pipe/test_callback_send_collection.extended.cc b/tests/unit/pipe/test_callback_send_collection.extended.cc index d58edd4f4c..5dfad65c5c 100644 --- a/tests/unit/pipe/test_callback_send_collection.extended.cc +++ b/tests/unit/pipe/test_callback_send_collection.extended.cc @@ -116,7 +116,7 @@ struct TestCol : vt::Collection { int32_t val = 17; }; -static void cb3(DataMsg* msg, TestCol* col) { +static void cb3(TestCol* col, DataMsg* msg) { EXPECT_EQ(msg->a, 8); EXPECT_EQ(msg->b, 9); EXPECT_EQ(msg->c, 10); diff --git a/tests/unit/serialization/test_serialize_messenger_virtual.extended.cc b/tests/unit/serialization/test_serialize_messenger_virtual.extended.cc index 2053b7878b..fa0040c4be 100644 --- a/tests/unit/serialization/test_serialize_messenger_virtual.extended.cc +++ b/tests/unit/serialization/test_serialize_messenger_virtual.extended.cc @@ -94,7 +94,7 @@ struct DataMsg : vt::vrt::VirtualMessage { struct TestSerialMessengerVirtual : TestParallelHarness { using TestMsg = TestStaticBytesShortMsg<4>; - static void testHandler(DataMsg* msg, TestCtx* ctx) { + static void testHandler(TestCtx* ctx, DataMsg* msg) { msg->check(); } }; From 04de002971537d0ceea449d0d355b6b123ebf46a Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 1 Mar 2023 12:37:00 -0800 Subject: [PATCH 20/32] #276: registry: simplify constexpr dispatch code --- src/vt/registry/auto/auto_registry_common.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index 40116a9ef0..35fdb788e9 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -87,16 +87,12 @@ struct HandlersDispatcher final : BaseHandlersDispatcher { fp(msg); } else if constexpr (std::is_same_v) { fp(elm, msg); + } else if constexpr (std::is_same_v) { + (elm->*fp)(msg); + } else if constexpr (std::is_same_v) { + std::apply(fp, msg->getTuple()); } else { - if constexpr (std::is_same_v) { - std::apply(fp, msg->getTuple()); - } else { - if constexpr (std::is_same_v) { - (elm->*fp)(msg); - } else { - std::apply(fp, std::tuple_cat(std::make_tuple(elm), msg->getTuple())); - } - } + std::apply(fp, std::tuple_cat(std::make_tuple(elm), msg->getTuple())); } } From cd2e1a648110077d93c425c10849cae346c4566f Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 1 Mar 2023 12:37:24 -0800 Subject: [PATCH 21/32] #276: vrt: use new handlers to remove messages --- src/vt/vrt/collection/manager.h | 51 ++++------------------------ src/vt/vrt/collection/manager.impl.h | 26 ++++++-------- 2 files changed, 17 insertions(+), 60 deletions(-) diff --git a/src/vt/vrt/collection/manager.h b/src/vt/vrt/collection/manager.h index 54ae55ef2f..c44b9716d6 100644 --- a/src/vt/vrt/collection/manager.h +++ b/src/vt/vrt/collection/manager.h @@ -1726,55 +1726,18 @@ struct CollectionManager typename ColT::IndexType range, std::string const& file_base ); - /** - * \internal \struct RestoreMigrateMsg - * - * \brief Migrate elements to restore where it belongs based on the checkpoint - */ - template < - typename ColT, - typename MsgT = vt::Message, - typename IdxT = typename ColT::IndexType - > - struct RestoreMigrateMsg : MsgT { - RestoreMigrateMsg() = default; - RestoreMigrateMsg( - NodeType in_to_node, IdxT in_idx, CollectionProxyWrapType in_proxy - ) : to_node_(in_to_node), - idx_(in_idx), - proxy_(in_proxy) - { } - - NodeType to_node_ = uninitialized_destination; - IdxT idx_; - CollectionProxyWrapType proxy_; - }; - - /** - * \internal \struct RestoreMigrateColMsg - * - * \brief Migrate collection element to restore where it belongs - */ - template - struct RestoreMigrateColMsg - : RestoreMigrateMsg, IdxT> - { - RestoreMigrateColMsg() = default; - RestoreMigrateColMsg( - NodeType in_to_node, IdxT in_idx, CollectionProxyWrapType in_proxy - ) : RestoreMigrateMsg, IdxT>( - in_to_node, in_idx, in_proxy - ) - { } - }; - /** * \internal \brief Migrate element to restore location from checkpoint * - * \param[in] msg the migrate message + * \param[in] node the node + * \param[in] idx the element index + * \param[in] proxy the collection proxy */ template - static void migrateToRestoreLocation(RestoreMigrateMsg* msg); + static void migrateToRestoreLocation( + NodeType node, typename ColT::IndexType idx, + CollectionProxyWrapType proxy + ); /** * \brief Restore the collection (collective) from file on top of an existing diff --git a/src/vt/vrt/collection/manager.impl.h b/src/vt/vrt/collection/manager.impl.h index 93b66dfcf5..a922472dd5 100644 --- a/src/vt/vrt/collection/manager.impl.h +++ b/src/vt/vrt/collection/manager.impl.h @@ -2219,28 +2219,24 @@ void CollectionManager::checkpointToFile( namespace detail { template inline void restoreOffHomeElement( - ColT*, CollectionManager::RestoreMigrateColMsg* msg + ColT*, NodeType node, typename ColT::IndexType idx, + CollectionProxy proxy ) { - auto idx = msg->idx_; - auto node = msg->to_node_; - auto proxy = msg->proxy_; theCollection()->migrate(proxy(idx), node); } } /* end namespace detail */ template /*static*/ void CollectionManager::migrateToRestoreLocation( - RestoreMigrateMsg* msg + NodeType node, typename ColT::IndexType idx, + CollectionProxyWrapType proxy ) { - auto idx = msg->idx_; - auto node = msg->to_node_; - auto proxy = msg->proxy_; if (proxy(idx).tryGetLocalPtr() != nullptr) { theCollection()->migrate(proxy(idx), node); } else { - proxy(idx).template send< - RestoreMigrateColMsg, detail::restoreOffHomeElement - >(node, idx, proxy); + proxy(idx).template send>( + node, idx, proxy + ); } } @@ -2279,14 +2275,12 @@ void CollectionManager::restoreFromFileInPlace( vtAssertExpr(mapped_node != uninitialized_destination); auto this_node = theContext()->getNode(); - using MsgType = RestoreMigrateMsg; - auto msg = makeMessage(this_node, idx, proxy); if (mapped_node != this_node) { - theMsg()->sendMsg>( - mapped_node, msg + theMsg()->send>( + vt::Node{mapped_node}, this_node, idx, proxy ); } else { - migrateToRestoreLocation(msg.get()); + migrateToRestoreLocation(this_node, idx, proxy); } } } From f224238ffcf65230f1ef779cd3c88d786afc9048 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 1 Mar 2023 23:06:12 -0800 Subject: [PATCH 22/32] #276: collective: fix scatter --- src/vt/collective/reduce/reduce.h | 38 ++--- src/vt/collective/scatter/scatter.h | 14 +- src/vt/group/group_manager.h | 14 +- src/vt/messaging/active.h | 31 +--- src/vt/objgroup/manager.h | 40 ++--- src/vt/objgroup/proxy/proxy_objgroup.h | 31 +--- src/vt/objgroup/proxy/proxy_objgroup_elm.h | 27 +--- src/vt/utils/fntraits/fntraits.h | 150 ++++++++++++++---- .../vrt/collection/broadcast/broadcastable.h | 8 +- .../collection/broadcast/broadcastable.impl.h | 10 +- src/vt/vrt/collection/invoke/invokable.impl.h | 2 +- src/vt/vrt/collection/manager.h | 36 ++--- src/vt/vrt/collection/send/sendable.h | 4 +- src/vt/vrt/collection/send/sendable.impl.h | 2 +- 14 files changed, 195 insertions(+), 212 deletions(-) diff --git a/src/vt/collective/reduce/reduce.h b/src/vt/collective/reduce/reduce.h index 75bf0120dd..71a3809827 100644 --- a/src/vt/collective/reduce/reduce.h +++ b/src/vt/collective/reduce/reduce.h @@ -58,6 +58,7 @@ #include "vt/collective/tree/tree.h" #include "vt/utils/hash/hash_tuple.h" #include "vt/messaging/pending_send.h" +#include "vt/utils/fntraits/fntraits.h" #include #include @@ -146,15 +147,6 @@ struct Reduce : virtual collective::tree::Tree { ReduceNumType num_contrib = 1 ); - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MsgT = T; - using ReturnType = ReturnT; - }; - /** * \brief Reduce a message up the tree, possibly delayed through a pending send * @@ -168,11 +160,11 @@ struct Reduce : virtual collective::tree::Tree { template PendingSendType reduce( NodeType root, - typename FunctionTraits::MsgT* const msg, + typename FuncTraits::MsgT* const msg, detail::ReduceStamp id = detail::ReduceStamp{}, ReduceNumType num_contrib = 1 ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; return reduce(root, msg, id, num_contrib); } @@ -206,11 +198,11 @@ struct Reduce : virtual collective::tree::Tree { template detail::ReduceStamp reduceImmediate( NodeType root, - typename FunctionTraits::MsgT* const msg, + typename FuncTraits::MsgT* const msg, detail::ReduceStamp id = detail::ReduceStamp{}, ReduceNumType num_contrib = 1 ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; return reduceImmediate(root, msg, id, num_contrib); } @@ -270,12 +262,12 @@ struct Reduce : virtual collective::tree::Tree { template PendingSendType reduce( NodeType const& root, - typename FunctionTraits::MsgT* msg, - Callback::MsgT> cb, + typename FuncTraits::MsgT* msg, + Callback::MsgT> cb, detail::ReduceStamp id = detail::ReduceStamp{}, ReduceNumType const& num_contrib = 1 ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; return reduce(root, msg, cb, id, num_contrib); } @@ -335,12 +327,12 @@ struct Reduce : virtual collective::tree::Tree { template detail::ReduceStamp reduceImmediate( NodeType const& root, - typename FunctionTraits::MsgT* msg, - Callback::MsgT> cb, + typename FuncTraits::MsgT* msg, + Callback::MsgT> cb, detail::ReduceStamp id = detail::ReduceStamp{}, ReduceNumType const& num_contrib = 1 ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; return reduceImmediate(root, msg, cb, id, num_contrib); } @@ -401,11 +393,11 @@ struct Reduce : virtual collective::tree::Tree { > PendingSendType reduce( NodeType const& root, - typename FunctionTraits::MsgT* msg, + typename FuncTraits::MsgT* msg, detail::ReduceStamp id = detail::ReduceStamp{}, ReduceNumType const& num_contrib = 1 ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; return reduce(root, msg, id, num_contrib); } @@ -466,11 +458,11 @@ struct Reduce : virtual collective::tree::Tree { > detail::ReduceStamp reduceImmediate( NodeType const& root, - typename FunctionTraits::MsgT* msg, + typename FuncTraits::MsgT* msg, detail::ReduceStamp id = detail::ReduceStamp{}, ReduceNumType const& num_contrib = 1 ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; return reduceImmediate(root, msg, id, num_contrib); } diff --git a/src/vt/collective/scatter/scatter.h b/src/vt/collective/scatter/scatter.h index e1a3464b94..291527211b 100644 --- a/src/vt/collective/scatter/scatter.h +++ b/src/vt/collective/scatter/scatter.h @@ -49,6 +49,7 @@ #include "vt/activefn/activefn.h" #include "vt/messaging/message.h" #include "vt/collective/tree/tree.h" +#include "vt/utils/fntraits/fntraits.h" #include #include @@ -89,15 +90,6 @@ struct Scatter : virtual collective::tree::Tree { FuncSizeType size_fn, FuncDataType data_fn ); - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MessageT = T; - using ReturnType = ReturnT; - }; - /** * \brief Scatter data to all nodes * @@ -114,8 +106,8 @@ struct Scatter : virtual collective::tree::Tree { std::size_t const& total_size, std::size_t const& max_proc_size, FuncSizeType size_fn, FuncDataType data_fn ) { - using MessageT = typename FunctionTraits::MessageT; - return scatter(total_size, max_proc_size, size_fn, data_fn); + using MsgT = std::remove_pointer_t::Arg1>; + return scatter(total_size, max_proc_size, size_fn, data_fn); } protected: diff --git a/src/vt/group/group_manager.h b/src/vt/group/group_manager.h index d091877d2e..63c9f61e8b 100644 --- a/src/vt/group/group_manager.h +++ b/src/vt/group/group_manager.h @@ -62,6 +62,7 @@ #include "vt/collective/reduce/reduce.h" #include "vt/collective/collective_scope.h" #include "vt/runtime/component/component_pack.h" +#include "vt/utils/fntraits/fntraits.h" #include #include @@ -193,21 +194,12 @@ struct GroupManager : runtime::component::Component { template *f> void sendMsg(GroupType const group, MsgT* msg); - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MsgT = T; - using ReturnType = ReturnT; - }; - template void sendMsg( GroupType const group, - typename FunctionTraits::MsgT* msg + typename FuncTraits::MsgT* msg ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; return sendMsg(group, msg); } diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index d521fe65a4..50eb123096 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -65,6 +65,7 @@ #include "vt/elm/elm_id.h" #include "vt/elm/elm_lb_data.h" #include "vt/utils/strong/strong_type.h" +#include "vt/utils/fntraits/fntraits.h" #if vt_check_enabled(trace_enabled) #include "vt/trace/trace_headers.h" @@ -693,15 +694,6 @@ struct ActiveMessenger : runtime::component::PollableComponent TagType tag = no_tag ); - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MsgT = T; - using ReturnType = ReturnT; - }; - /** * \brief Broadcast a message (message type not required). * @@ -715,11 +707,11 @@ struct ActiveMessenger : runtime::component::PollableComponent */ template PendingSendType broadcastMsg( - MsgPtrThief::MsgT> msg, + MsgPtrThief::MsgT> msg, bool deliver_to_sender = true, TagType tag = no_tag ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; return broadcastMsg(msg, deliver_to_sender, tag); } @@ -755,22 +747,13 @@ struct ActiveMessenger : runtime::component::PollableComponent template PendingSendType sendMsg( NodeType dest, - MsgPtrThief::MsgT> msg, + MsgPtrThief::MsgT> msg, TagType tag = no_tag ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; return sendMsg(dest, msg, tag); } - template - struct FunctionTraitsArgs; - - template - struct FunctionTraitsArgs { - using TupleType = std::tuple...>; - using ReturnType = ReturnT; - }; - /** * \brief Send parameters to a handler in a message * @@ -781,7 +764,7 @@ struct ActiveMessenger : runtime::component::PollableComponent */ template PendingSendType send(Node dest, Params&&... params) { - using Tuple = typename FunctionTraitsArgs::TupleType; + using Tuple = typename FuncTraits::TupleType; using MsgT = ParamMsg; auto msg = vt::makeMessage(std::forward(params)...); auto han = auto_registry::makeAutoHandlerParam(); @@ -797,7 +780,7 @@ struct ActiveMessenger : runtime::component::PollableComponent */ template PendingSendType broadcast(Params&&... params) { - using Tuple = typename FunctionTraitsArgs::TupleType; + using Tuple = typename FuncTraits::TupleType; using MsgT = ParamMsg; auto msg = vt::makeMessage(std::forward(params)...); auto han = auto_registry::makeAutoHandlerParam(); diff --git a/src/vt/objgroup/manager.h b/src/vt/objgroup/manager.h index cf817b1955..6da88b4ac8 100644 --- a/src/vt/objgroup/manager.h +++ b/src/vt/objgroup/manager.h @@ -57,6 +57,7 @@ #include "vt/messaging/message/smart_ptr.h" #include "vt/messaging/pending_send.h" #include "vt/elm/elm_id.h" +#include "vt/utils/fntraits/fntraits.h" #include #include @@ -217,16 +218,6 @@ struct ObjGroupManager : runtime::component::Component { template fn> PendingSendType send(ProxyElmType proxy, MsgSharedPtr msg); - template - struct FunctionTraits; - - template - struct FunctionTraits { - using ObjT = Obj; - using MsgT = Msg; - using ReturnT = Return; - }; - /** * \internal \brief Send a message to an element of the object group * @@ -235,11 +226,11 @@ struct ObjGroupManager : runtime::component::Component { */ template PendingSendType send( - ProxyElmType::ObjT> proxy, - MsgSharedPtr::MsgT> msg + ProxyElmType::ObjT> proxy, + MsgSharedPtr::MsgT> msg ) { - using ObjType = typename FunctionTraits::ObjT; - using MsgType = typename FunctionTraits::MsgT; + using ObjType = typename ObjFuncTraits::ObjT; + using MsgType = typename ObjFuncTraits::MsgT; return send(proxy, msg); } @@ -280,11 +271,11 @@ struct ObjGroupManager : runtime::component::Component { */ template PendingSendType broadcast( - ProxyType::ObjT> proxy, - MsgSharedPtr::MsgT> msg + ProxyType::ObjT> proxy, + MsgSharedPtr::MsgT> msg ) { - using ObjType = typename FunctionTraits::ObjT; - using MsgType = typename FunctionTraits::MsgT; + using ObjType = typename ObjFuncTraits::ObjT; + using MsgType = typename ObjFuncTraits::MsgT; return broadcast(proxy, msg); } @@ -315,15 +306,6 @@ struct ObjGroupManager : runtime::component::Component { collective::reduce::ReduceStamp const& stamp ); - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MsgT = T; - using ReturnType = ReturnT; - }; - /** * \brief Perform a reduction over an objgroup * @@ -336,10 +318,10 @@ struct ObjGroupManager : runtime::component::Component { template PendingSendType reduce( ProxyType proxy, - messaging::MsgPtrThief::MsgT> msg, + messaging::MsgPtrThief::MsgT> msg, collective::reduce::ReduceStamp const& stamp ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; return reduce(proxy, msg, stamp); } diff --git a/src/vt/objgroup/proxy/proxy_objgroup.h b/src/vt/objgroup/proxy/proxy_objgroup.h index 7c9113089f..5ee5353fec 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup.h +++ b/src/vt/objgroup/proxy/proxy_objgroup.h @@ -58,6 +58,7 @@ #include "vt/rdmahandle/handle.fwd.h" #include "vt/rdmahandle/handle_set.fwd.h" #include "vt/messaging/pending_send.h" +#include "vt/utils/fntraits/fntraits.h" namespace vt { namespace objgroup { namespace proxy { @@ -126,15 +127,6 @@ struct Proxy { template fn> PendingSendType broadcastMsg(messaging::MsgPtrThief msg) const; - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MsgT = Msg; - using ReturnT = Return; - }; - /** * \brief Broadcast a message to all nodes to be delivered to the local object * instance @@ -144,9 +136,9 @@ struct Proxy { */ template PendingSendType broadcastMsg( - messaging::MsgPtrThief::MsgT> msg + messaging::MsgPtrThief::MsgT> msg ) const { - using MsgType = typename FunctionTraits::MsgT; + using MsgType = typename ObjFuncTraits::MsgT; return broadcastMsg(msg); } @@ -167,7 +159,7 @@ struct Proxy { */ template PendingSendType broadcast(Args&&... args) const { - using MsgType = typename FunctionTraits::MsgT; + using MsgType = typename ObjFuncTraits::MsgT; return broadcast(std::forward(args)...); } @@ -406,15 +398,6 @@ struct Proxy { template * f, typename... Args> messaging::PendingSend broadcast(Args&&... args) const; - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MsgT = Msg; - using ReturnT = Return; - }; - /** * \brief Broadcast a message. * @@ -426,7 +409,7 @@ struct Proxy { */ template messaging::PendingSend broadcast(Args&&... args) const { - using MsgType = typename FunctionTraits::MsgT; + using MsgType = typename FuncTraits::MsgT; return broadcast(std::forward(args)...); } @@ -456,10 +439,10 @@ struct Proxy { */ template messaging::PendingSend broadcastMsg( - messaging::MsgPtrThief::MsgT> msg, + messaging::MsgPtrThief::MsgT> msg, TagType tag = no_tag ) const { - using MsgType = typename FunctionTraits::MsgT; + using MsgType = typename FuncTraits::MsgT; return broadcastMsg(msg, tag); } diff --git a/src/vt/objgroup/proxy/proxy_objgroup_elm.h b/src/vt/objgroup/proxy/proxy_objgroup_elm.h index 1f4da7c6c1..58e18cc273 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup_elm.h +++ b/src/vt/objgroup/proxy/proxy_objgroup_elm.h @@ -51,6 +51,7 @@ #include "vt/messaging/message/smart_ptr.h" #include "vt/activefn/activefn.h" #include "vt/messaging/pending_send.fwd.h" +#include "vt/utils/fntraits/fntraits.h" namespace vt { namespace objgroup { namespace proxy { @@ -120,15 +121,6 @@ struct ProxyElm { template fn> PendingSendType sendMsg(messaging::MsgPtrThief msg) const; - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MsgT = Msg; - using ReturnT = Return; - }; - /** * \brief Send a message to the node/element indexed by this proxy to be * delivered to the local object instance @@ -138,9 +130,9 @@ struct ProxyElm { */ template decltype(auto) sendMsg( - messaging::MsgPtrThief::MsgT> msg + messaging::MsgPtrThief::MsgT> msg ) const { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; return sendMsg(msg); } @@ -161,7 +153,7 @@ struct ProxyElm { */ template decltype(auto) send(Args&&... args) const { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; return send(std::forward(args)...); } @@ -249,15 +241,6 @@ struct ProxyElm { template * f, typename... Args> void send(Args&&... args) const; - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MsgT = T; - using ReturnType = ReturnT; - }; - /** * \brief Send a message to the node indexed by this proxy to be * delivered to the local object instance @@ -266,7 +249,7 @@ struct ProxyElm { */ template void send(Args&&... args) const { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename FuncTraits::MsgT; send(std::forward(args)...); } diff --git a/src/vt/utils/fntraits/fntraits.h b/src/vt/utils/fntraits/fntraits.h index 425dce8cf6..92dbde7af1 100644 --- a/src/vt/utils/fntraits/fntraits.h +++ b/src/vt/utils/fntraits/fntraits.h @@ -44,83 +44,171 @@ #if !defined INCLUDED_VT_UTILS_FNTRAITS_FNTRAITS_H #define INCLUDED_VT_UTILS_FNTRAITS_FNTRAITS_H -namespace vt { +namespace vt::util::fntraits::detail { struct NoMsg {}; -template -struct ObjFuncTraits; +template +struct ObjFuncTraitsImpl; -template -struct ObjFuncTraits< - std::enable_if_t::value>, - ObjT, - Return(*)(ObjT*, Msg*) +template +struct ObjFuncTraitsImpl< + std::enable_if_t< + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value + >, + Return(*)(Obj*, Msg*) > { static constexpr bool is_member = false; + using ObjT = Obj; using MsgT = Msg; using ReturnT = Return; }; -template -struct ObjFuncTraits< +template +struct ObjFuncTraitsImpl< std::enable_if_t>, - ObjT, - Return(*)(ObjT*) + Return(*)(Obj*) > { static constexpr bool is_member = false; + using ObjT = Obj; using MsgT = NoMsg; using ReturnT = Return; using TupleType = std::tuple<>; }; -template -struct ObjFuncTraits< - std::enable_if_t::value>, - ObjT, - Return(*)(ObjT*, Arg, Args...) +template +struct ObjFuncTraitsImpl< + std::enable_if_t< + not ( + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value + ) + >, + Return(*)(Obj*, Arg, Args...) > { static constexpr bool is_member = false; + using ObjT = Obj; using MsgT = NoMsg; using TupleType = std::tuple, std::decay_t...>; using ReturnT = Return; }; -template -struct ObjFuncTraits< - std::enable_if_t::value>, - ObjT, - Return(ObjT::*)(Msg*) +template +struct ObjFuncTraitsImpl< + std::enable_if_t< + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value + >, + Return(Obj::*)(Msg*) > { static constexpr bool is_member = true; + using ObjT = Obj; using MsgT = Msg; using ReturnT = Return; }; -template -struct ObjFuncTraits< +template +struct ObjFuncTraitsImpl< std::enable_if_t>, - ObjT, - Return(ObjT::*)() + Return(Obj::*)() > { static constexpr bool is_member = true; + using ObjT = Obj; using MsgT = NoMsg; using TupleType = std::tuple<>; using ReturnT = Return; }; -template -struct ObjFuncTraits< - std::enable_if_t::value>, - ObjT, - Return(ObjT::*)(Arg, Args...) +template +struct ObjFuncTraitsImpl< + std::enable_if_t< + not ( + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value + ) + >, + Return(Obj::*)(Arg, Args...) > { static constexpr bool is_member = true; + using ObjT = Obj; using MsgT = NoMsg; using TupleType = std::tuple, std::decay_t...>; using ReturnT = Return; }; +/////////////////////////////////////////////////////////////////////////////// + +template +struct FuncTraitsImpl; + +template +struct FuncTraitsImpl< + std::enable_if_t< + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value + >, + Return(*)(Msg*) +> { + static constexpr bool is_member = false; + using MsgT = Msg; + using ReturnT = Return; +}; + +template +struct FuncTraitsImpl< + std::enable_if_t>, + Return(*)() +> { + static constexpr bool is_member = false; + using MsgT = NoMsg; + using ReturnT = Return; + using TupleType = std::tuple<>; +}; + +template +struct FuncTraitsImpl< + std::enable_if_t< + not ( + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value or + std::is_convertible::value + ) + >, + Return(*)(Arg, Args...) +> { + static constexpr bool is_member = false; + using MsgT = NoMsg; + using Arg1 = Arg; + using TupleType = std::tuple, std::decay_t...>; + using ReturnT = Return; +}; + +} /* end namespace vt::util::fntraits::detail */ + +/////////////////////////////////////////////////////////////////////////////// + +namespace vt { + +template +struct ObjFuncTraits : util::fntraits::detail::ObjFuncTraitsImpl {}; + +template +struct FuncTraits : util::fntraits::detail::FuncTraitsImpl {}; + +using NoMsg = util::fntraits::detail::NoMsg; + } /* end namespace vt */ #endif /*INCLUDED_VT_UTILS_FNTRAITS_FNTRAITS_H*/ diff --git a/src/vt/vrt/collection/broadcast/broadcastable.h b/src/vt/vrt/collection/broadcast/broadcastable.h index 835396e9e4..2c7061c317 100644 --- a/src/vt/vrt/collection/broadcast/broadcastable.h +++ b/src/vt/vrt/collection/broadcast/broadcastable.h @@ -207,9 +207,9 @@ struct Broadcastable : BaseProxyT { */ template messaging::PendingSend broadcastMsg( - messaging::MsgPtrThief::MsgT> msg + messaging::MsgPtrThief::MsgT> msg ) const { - using MsgT = typename ObjFuncTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; return broadcastMsg(msg); } @@ -233,9 +233,9 @@ struct Broadcastable : BaseProxyT { */ template messaging::PendingSend broadcastCollectiveMsg( - messaging::MsgPtrThief::MsgT> msg + messaging::MsgPtrThief::MsgT> msg ) const { - using MsgT = typename ObjFuncTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; return broadcastCollectiveMsg(msg); } diff --git a/src/vt/vrt/collection/broadcast/broadcastable.impl.h b/src/vt/vrt/collection/broadcast/broadcastable.impl.h index 2680ff27b6..6be3e1d607 100644 --- a/src/vt/vrt/collection/broadcast/broadcastable.impl.h +++ b/src/vt/vrt/collection/broadcast/broadcastable.impl.h @@ -181,9 +181,9 @@ template template messaging::PendingSend Broadcastable::broadcast(Params&&... params) const { - using MsgT = typename ObjFuncTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; if constexpr (std::is_same_v) { - using Tuple = typename ObjFuncTraits::TupleType; + using Tuple = typename ObjFuncTraits::TupleType; using SendMsgT = ParamColMsg; auto msg = vt::makeMessage(std::forward(params)...); auto han = auto_registry::makeAutoHandlerCollectionMemParam< @@ -203,9 +203,9 @@ template template messaging::PendingSend Broadcastable::broadcastCollective(Params&&... params) const { - using MsgT = typename ObjFuncTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; if constexpr (std::is_same_v) { - using Tuple = typename ObjFuncTraits::TupleType; + using Tuple = typename ObjFuncTraits::TupleType; using SendMsgT = ParamColMsg; auto msg = vt::makeMessage(std::forward(params)...); auto han = auto_registry::makeAutoHandlerCollectionMemParam< @@ -226,7 +226,7 @@ template template void Broadcastable::invokeCollective(Params&&... params) const { - using MsgT = typename ObjFuncTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; auto proxy = this->getProxy(); if constexpr (std::is_same_v) { theCollection()->invokeCollective( diff --git a/src/vt/vrt/collection/invoke/invokable.impl.h b/src/vt/vrt/collection/invoke/invokable.impl.h index ffe96d3047..37980330ab 100644 --- a/src/vt/vrt/collection/invoke/invokable.impl.h +++ b/src/vt/vrt/collection/invoke/invokable.impl.h @@ -93,7 +93,7 @@ Invokable::invoke(Args&&... args) const { auto const& proxy = VrtElmProxy( this->getCollectionProxy(), this->getElementProxy()); - using MsgT = typename ObjFuncTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; if constexpr (std::is_same_v) { return theCollection()->invoke( proxy, std::forward(args)... diff --git a/src/vt/vrt/collection/manager.h b/src/vt/vrt/collection/manager.h index c44b9716d6..a2c8f5a97a 100644 --- a/src/vt/vrt/collection/manager.h +++ b/src/vt/vrt/collection/manager.h @@ -74,6 +74,7 @@ #include "vt/context/runnable_context/lb_data.fwd.h" #include "vt/vrt/collection/param/construct_params.h" #include "vt/vrt/collection/param/construct_params_msg.h" +#include "vt/utils/fntraits/fntraits.h" #include #include @@ -493,23 +494,6 @@ struct CollectionManager VirtualElmProxyType const& proxy, MsgT *msg ); - template - struct FunctionTraits; - - template - struct FunctionTraits { - using MsgT = Msg; - using ColT = Col; - using ReturnT = Return; - }; - - template - struct FunctionTraits { - using ColT = Col; - using MsgT = Msg; - using ReturnT = Return; - }; - /** * \brief Send collection element a message from active function handler * @@ -520,10 +504,12 @@ struct CollectionManager */ template messaging::PendingSend sendMsg( - VirtualElmProxyType::MsgT::CollectionType> const& proxy, - typename FunctionTraits::MsgT *msg + VirtualElmProxyType< + typename ObjFuncTraits::MsgT::CollectionType + > const& proxy, + typename ObjFuncTraits::MsgT *msg ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; return sendMsg(proxy, msg); } @@ -1021,13 +1007,15 @@ struct CollectionManager * * \return a pending send */ - template < auto f> + template messaging::PendingSend broadcastMsg( - CollectionProxyWrapType::MsgT::CollectionType> const& proxy, - typename FunctionTraits::MsgT *msg, + CollectionProxyWrapType< + typename ObjFuncTraits::MsgT::CollectionType + > const& proxy, + typename ObjFuncTraits::MsgT *msg, bool instrument = true ) { - using MsgT = typename FunctionTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; return broadcastMsg(proxy, msg, instrument); } diff --git a/src/vt/vrt/collection/send/sendable.h b/src/vt/vrt/collection/send/sendable.h index 9d00908379..fb9191eb90 100644 --- a/src/vt/vrt/collection/send/sendable.h +++ b/src/vt/vrt/collection/send/sendable.h @@ -132,9 +132,9 @@ struct Sendable : BaseProxyT { */ template messaging::PendingSend sendMsg( - messaging::MsgPtrThief::MsgT> msg + messaging::MsgPtrThief::MsgT> msg ) const { - using MsgT = typename ObjFuncTraits::MsgT; + using MsgT = typename ObjFuncTraits::MsgT; return sendMsg(msg); } diff --git a/src/vt/vrt/collection/send/sendable.impl.h b/src/vt/vrt/collection/send/sendable.impl.h index 17cdc8f754..9ae9cecb78 100644 --- a/src/vt/vrt/collection/send/sendable.impl.h +++ b/src/vt/vrt/collection/send/sendable.impl.h @@ -133,7 +133,7 @@ messaging::PendingSend Sendable::send(Args&&... args) co template template messaging::PendingSend Sendable::send(Params&&... params) const { - using FnTrait = ObjFuncTraits; + using FnTrait = ObjFuncTraits; using MsgT = typename FnTrait::MsgT; if constexpr (std::is_same_v) { From 629ead7d4c5c4be9f8866dd4280e2d7488bc77d8 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 2 Mar 2023 17:16:55 -0800 Subject: [PATCH 23/32] #276: objgroup: implement parameterization --- src/vt/objgroup/manager.fwd.h | 4 +-- src/vt/objgroup/manager.h | 10 +++--- src/vt/objgroup/manager.impl.h | 12 +++---- src/vt/objgroup/manager.static.h | 11 +++--- src/vt/objgroup/proxy/proxy_objgroup.h | 13 +++---- src/vt/objgroup/proxy/proxy_objgroup.impl.h | 22 ++++++++++++ src/vt/objgroup/proxy/proxy_objgroup_elm.h | 7 ++-- .../objgroup/proxy/proxy_objgroup_elm.impl.h | 34 ++++++++++++++++--- src/vt/registry/auto/auto_registry_impl.h | 20 +++++++++++ 9 files changed, 100 insertions(+), 33 deletions(-) diff --git a/src/vt/objgroup/manager.fwd.h b/src/vt/objgroup/manager.fwd.h index c95045240c..588a254a9e 100644 --- a/src/vt/objgroup/manager.fwd.h +++ b/src/vt/objgroup/manager.fwd.h @@ -70,8 +70,8 @@ std::unordered_map>& getPending(); template messaging::PendingSend send(MsgSharedPtr msg, HandlerType han, NodeType node); -template -void invoke(messaging::MsgPtrThief msg, HandlerType han, NodeType node); +template +decltype(auto) invoke(messaging::MsgPtrThief msg, HandlerType han, NodeType node); template messaging::PendingSend broadcast(MsgSharedPtr msg, HandlerType han); diff --git a/src/vt/objgroup/manager.h b/src/vt/objgroup/manager.h index 6da88b4ac8..c6eb74258e 100644 --- a/src/vt/objgroup/manager.h +++ b/src/vt/objgroup/manager.h @@ -242,7 +242,7 @@ struct ObjGroupManager : runtime::component::Component { * \param[in] msg message */ template fn> - void invoke(ProxyElmType proxy, messaging::MsgPtrThief msg); + decltype(auto) invoke(ProxyElmType proxy, messaging::MsgPtrThief msg); /** * \internal \brief Invoke function 'f' on an element of the object group @@ -252,7 +252,7 @@ struct ObjGroupManager : runtime::component::Component { * \param[in] args function arguments */ template - auto invoke(ProxyElmType proxy, Args&&... args); + decltype(auto) invoke(ProxyElmType proxy, Args&&... args); /** * \internal \brief Broadcast a message to all nodes in object group @@ -398,8 +398,10 @@ struct ObjGroupManager : runtime::component::Component { * \param[in] han handler to invoke * \param[in] node node to invoke the handler on */ - template - void invoke(messaging::MsgPtrThief msg, HandlerType han, NodeType node); + template + decltype(auto) invoke( + messaging::MsgPtrThief msg, HandlerType han, NodeType node + ); /** * \internal \brief Broadcast message to an objgroup diff --git a/src/vt/objgroup/manager.impl.h b/src/vt/objgroup/manager.impl.h index 898057609a..cc5add355a 100644 --- a/src/vt/objgroup/manager.impl.h +++ b/src/vt/objgroup/manager.impl.h @@ -193,7 +193,7 @@ ObjGroupManager::PendingSendType ObjGroupManager::send(ProxyElmType proxy, } template fn> -void ObjGroupManager::invoke( +decltype(auto) ObjGroupManager::invoke( ProxyElmType proxy, messaging::MsgPtrThief msg ) { auto const proxy_bits = proxy.getProxy(); @@ -207,11 +207,11 @@ void ObjGroupManager::invoke( proxy_bits, dest_node, ctrl, han ); - invoke(msg, han, dest_node); + return invoke(msg, han, dest_node); } template -auto +decltype(auto) ObjGroupManager::invoke(ProxyElmType proxy, Args&&... args) { auto const dest_node = proxy.getNode(); auto const this_node = theContext()->getNode(); @@ -250,11 +250,11 @@ ObjGroupManager::PendingSendType ObjGroupManager::send( return objgroup::send(msg,han,dest_node); } -template -void ObjGroupManager::invoke( +template +decltype(auto) ObjGroupManager::invoke( messaging::MsgPtrThief msg, HandlerType han, NodeType dest_node ) { - objgroup::invoke(msg, han, dest_node); + return objgroup::invoke(msg, han, dest_node); } template diff --git a/src/vt/objgroup/manager.static.h b/src/vt/objgroup/manager.static.h index c7df5e30d5..1a0d218305 100644 --- a/src/vt/objgroup/manager.static.h +++ b/src/vt/objgroup/manager.static.h @@ -74,8 +74,10 @@ messaging::PendingSend send(MsgSharedPtr msg, HandlerType han, NodeType de } } -template -void invoke(messaging::MsgPtrThief msg, HandlerType han, NodeType dest_node) { +template +decltype(auto) invoke( + messaging::MsgPtrThief msg, HandlerType han, NodeType dest_node +) { auto const this_node = theContext()->getNode(); vtAssert( @@ -91,11 +93,12 @@ void invoke(messaging::MsgPtrThief msg, HandlerType han, NodeType dest_nod auto const& elm_id = holder->getElmID(); auto elm = holder->getPtr(); auto lb_data = &holder->getLBData(); - runnable::makeRunnable(msg.msg_, false, han, this_node) + auto msg2 = msg.msg_; + return runnable::makeRunnableVoid(false, han, this_node) .withObjGroup(elm) .withTDEpochFromMsg() .withLBData(lb_data, elm_id) - .run(); + .runLambda(f, static_cast(elm), msg2.get()); } template diff --git a/src/vt/objgroup/proxy/proxy_objgroup.h b/src/vt/objgroup/proxy/proxy_objgroup.h index 5ee5353fec..b235bdcf95 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup.h +++ b/src/vt/objgroup/proxy/proxy_objgroup.h @@ -158,10 +158,7 @@ struct Proxy { * \param[in] args args to pass to the message constructor */ template - PendingSendType broadcast(Args&&... args) const { - using MsgType = typename ObjFuncTraits::MsgT; - return broadcast(std::forward(args)...); - } + PendingSendType broadcast(Args&&... args) const; /** * \brief Reduce over the objgroup instances on each node with a callback @@ -182,6 +179,7 @@ struct Proxy { PendingSendType reduce( MsgPtrT msg, Callback cb, ReduceStamp stamp = ReduceStamp{} ) const; + template < typename OpT = collective::None, typename MsgPtrT, @@ -189,16 +187,15 @@ struct Proxy { > PendingSendType reduce( MsgPtrT msg, Callback cb, ReduceStamp stamp = ReduceStamp{} - ) const - { + ) const { return reduce< OpT, MsgPtrT, MsgT, &MsgT::template msgHandler< MsgT, OpT, collective::reduce::operators::ReduceCallback - > - >(msg, cb, stamp); + > + >(msg, cb, stamp); } /** diff --git a/src/vt/objgroup/proxy/proxy_objgroup.impl.h b/src/vt/objgroup/proxy/proxy_objgroup.impl.h index 078e65231c..e188bf0fe6 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup.impl.h +++ b/src/vt/objgroup/proxy/proxy_objgroup.impl.h @@ -52,6 +52,8 @@ #include "vt/collective/reduce/operators/default_op.h" #include "vt/pipe/callback/cb_union/cb_raw_base.h" #include "vt/rdmahandle/manager.h" +#include "vt/messaging/param_msg.h" +#include "vt/objgroup/proxy/proxy_bits.h" namespace vt { namespace objgroup { namespace proxy { @@ -82,6 +84,26 @@ typename Proxy::PendingSendType Proxy::broadcast(Args&&... args) con return broadcastMsg(makeMessage(std::forward(args)...)); } +template +template +typename Proxy::PendingSendType +Proxy::broadcast(Params&&... params) const { + using MsgT = typename ObjFuncTraits::MsgT; + if constexpr (std::is_same_v) { + using Tuple = typename ObjFuncTraits::TupleType; + using SendMsgT = messaging::ParamMsg; + auto msg = vt::makeMessage(std::forward(params)...); + auto const ctrl = proxy::ObjGroupProxy::getID(proxy_); + auto const han = auto_registry::makeAutoHandlerObjGroupParam< + ObjT, decltype(f), f, SendMsgT + >(ctrl); + return theObjGroup()->broadcast(msg, han); + } else { + auto msg = makeMessage(std::forward(params)...); + return broadcastMsg(msg); + } +} + template template < typename OpT, typename MsgPtrT, typename MsgT, ActiveTypedFnType *f diff --git a/src/vt/objgroup/proxy/proxy_objgroup_elm.h b/src/vt/objgroup/proxy/proxy_objgroup_elm.h index 58e18cc273..812de35633 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup_elm.h +++ b/src/vt/objgroup/proxy/proxy_objgroup_elm.h @@ -152,10 +152,7 @@ struct ProxyElm { * \param[in] args args to pass to the message constructor */ template - decltype(auto) send(Args&&... args) const { - using MsgT = typename ObjFuncTraits::MsgT; - return send(std::forward(args)...); - } + PendingSendType send(Args&&... args) const; /** * \brief Invoke locally a message handler on the node/element indexed by this proxy. @@ -164,7 +161,7 @@ struct ProxyElm { * \param[in] args args to pass to the message constructor */ template fn, typename... Args> - void invoke(Args&&... args) const; + decltype(auto) invoke(Args&&... args) const; /** * \brief Invoke locally a function 'f' on the node/element indexed by this proxy. diff --git a/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h b/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h index 4641f718bc..3c77a93bcd 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h +++ b/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h @@ -78,10 +78,30 @@ typename ProxyElm::PendingSendType ProxyElm::send(Args&&... args) co } template -template fn, typename... Args> -void ProxyElm::invoke(Args&&... args) const { +template +typename ProxyElm::PendingSendType +ProxyElm::send(Params&&... params) const { + using MsgT = typename ObjFuncTraits::MsgT; + if constexpr (std::is_same_v) { + using Tuple = typename ObjFuncTraits::TupleType; + using SendMsgT = messaging::ParamMsg; + auto msg = vt::makeMessage(std::forward(params)...); + auto const ctrl = proxy::ObjGroupProxy::getID(proxy_); + auto const han = auto_registry::makeAutoHandlerObjGroupParam< + ObjT, decltype(f), f, SendMsgT + >(ctrl); + return theObjGroup()->send(msg, han, node_); + } else { + auto msg = makeMessage(std::forward(params)...); + return sendMsg(msg); + } +} + +template +template f, typename... Args> +decltype(auto) ProxyElm::invoke(Args&&... args) const { auto proxy = ProxyElm(*this); - theObjGroup()->invoke( + return theObjGroup()->invoke( proxy, makeMessage(std::forward(args)...) ); } @@ -90,7 +110,13 @@ template template decltype(auto) ProxyElm::invoke(Args&&... args) const { auto proxy = ProxyElm(*this); - return theObjGroup()->invoke(proxy, std::forward(args)...); + using MsgT = typename ObjFuncTraits::MsgT; + if constexpr (std::is_same_v) { + return theObjGroup()->invoke(proxy, std::forward(args)...); + } else { + auto msg = makeMessage(std::forward(args)...); + return theObjGroup()->invoke(proxy, msg); + } } template diff --git a/src/vt/registry/auto/auto_registry_impl.h b/src/vt/registry/auto/auto_registry_impl.h index 1ca2a679e0..a36a133697 100644 --- a/src/vt/registry/auto/auto_registry_impl.h +++ b/src/vt/registry/auto/auto_registry_impl.h @@ -68,6 +68,26 @@ inline AutoHandlerType getAutoHandlerObjTypeIdx(HandlerType han) { return getAutoRegistryGen().at(id).getObjIdx(); } +template +inline HandlerType makeAutoHandlerObjGroupParam(HandlerControlType ctrl) { + using AdapterT = FunctorAdapterMember; + using ContainerType = AutoActiveObjGroupContainerType; + using RegInfoType = AutoRegInfoType; + using FuncType = T; + using RunType = RunnableGen; + + constexpr bool is_auto = true; + constexpr bool is_functor = false; + auto const idx = RunType::idx; + constexpr auto reg_type = RegistryTypeEnum::RegObjGroup; + auto const han = HandlerManagerType::makeHandler( + is_auto, is_functor, idx, reg_type, ctrl + ); + auto obj_idx = objgroup::registry::makeObjIdx(); + getAutoRegistryGen().at(idx).setObjIdx(obj_idx); + return han; +} + template f> inline HandlerType makeAutoHandlerObjGroup(HandlerControlType ctrl) { using AdapterT = From 09865e0b019c3351e8c04c3936f401477cfe925f Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 6 Mar 2023 12:00:34 -0800 Subject: [PATCH 24/32] #276: objgroup: fix msg pointer access issues --- src/vt/objgroup/manager.fwd.h | 2 +- src/vt/objgroup/manager.h | 2 +- src/vt/objgroup/manager.impl.h | 5 +++-- src/vt/objgroup/manager.static.h | 5 ++--- src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h | 5 ++--- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/vt/objgroup/manager.fwd.h b/src/vt/objgroup/manager.fwd.h index 588a254a9e..14ad2bb4af 100644 --- a/src/vt/objgroup/manager.fwd.h +++ b/src/vt/objgroup/manager.fwd.h @@ -71,7 +71,7 @@ std::unordered_map>& getPending(); template messaging::PendingSend send(MsgSharedPtr msg, HandlerType han, NodeType node); template -decltype(auto) invoke(messaging::MsgPtrThief msg, HandlerType han, NodeType node); +decltype(auto) invoke(messaging::MsgSharedPtr msg, HandlerType han, NodeType node); template messaging::PendingSend broadcast(MsgSharedPtr msg, HandlerType han); diff --git a/src/vt/objgroup/manager.h b/src/vt/objgroup/manager.h index c6eb74258e..0080182e5e 100644 --- a/src/vt/objgroup/manager.h +++ b/src/vt/objgroup/manager.h @@ -400,7 +400,7 @@ struct ObjGroupManager : runtime::component::Component { */ template decltype(auto) invoke( - messaging::MsgPtrThief msg, HandlerType han, NodeType node + messaging::MsgSharedPtr msg, HandlerType han, NodeType node ); /** diff --git a/src/vt/objgroup/manager.impl.h b/src/vt/objgroup/manager.impl.h index cc5add355a..936d2bc40b 100644 --- a/src/vt/objgroup/manager.impl.h +++ b/src/vt/objgroup/manager.impl.h @@ -207,7 +207,8 @@ decltype(auto) ObjGroupManager::invoke( proxy_bits, dest_node, ctrl, han ); - return invoke(msg, han, dest_node); + auto& msg_ptr = msg.msg_; + return invoke(msg_ptr, han, dest_node); } template @@ -252,7 +253,7 @@ ObjGroupManager::PendingSendType ObjGroupManager::send( template decltype(auto) ObjGroupManager::invoke( - messaging::MsgPtrThief msg, HandlerType han, NodeType dest_node + messaging::MsgSharedPtr msg, HandlerType han, NodeType dest_node ) { return objgroup::invoke(msg, han, dest_node); } diff --git a/src/vt/objgroup/manager.static.h b/src/vt/objgroup/manager.static.h index 1a0d218305..0402fe6397 100644 --- a/src/vt/objgroup/manager.static.h +++ b/src/vt/objgroup/manager.static.h @@ -76,7 +76,7 @@ messaging::PendingSend send(MsgSharedPtr msg, HandlerType han, NodeType de template decltype(auto) invoke( - messaging::MsgPtrThief msg, HandlerType han, NodeType dest_node + messaging::MsgSharedPtr msg, HandlerType han, NodeType dest_node ) { auto const this_node = theContext()->getNode(); @@ -93,12 +93,11 @@ decltype(auto) invoke( auto const& elm_id = holder->getElmID(); auto elm = holder->getPtr(); auto lb_data = &holder->getLBData(); - auto msg2 = msg.msg_; return runnable::makeRunnableVoid(false, han, this_node) .withObjGroup(elm) .withTDEpochFromMsg() .withLBData(lb_data, elm_id) - .runLambda(f, static_cast(elm), msg2.get()); + .runLambda(f, static_cast(elm), msg.get()); } template diff --git a/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h b/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h index 3c77a93bcd..9ff699b67f 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h +++ b/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h @@ -101,9 +101,8 @@ template template f, typename... Args> decltype(auto) ProxyElm::invoke(Args&&... args) const { auto proxy = ProxyElm(*this); - return theObjGroup()->invoke( - proxy, makeMessage(std::forward(args)...) - ); + auto msg = makeMessage(std::forward(args)...); + return theObjGroup()->invoke(proxy, msg); } template From 1109fba25ddc3869308c2a87f414bca6ebbcc1d9 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 6 Mar 2023 12:01:16 -0800 Subject: [PATCH 25/32] #276: examples: update for new interface --- examples/hello_world/hello_world_collection.cc | 8 +++----- .../hello_world_collection_collective.cc | 10 +++++----- examples/hello_world/objgroup.cc | 15 +++++---------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/examples/hello_world/hello_world_collection.cc b/examples/hello_world/hello_world_collection.cc index 0bfbd3d826..bd9305dc2e 100644 --- a/examples/hello_world/hello_world_collection.cc +++ b/examples/hello_world/hello_world_collection.cc @@ -51,10 +51,8 @@ struct Hello : vt::Collection { vtAssert(counter_ == 1, "Must be equal"); } - using TestMsg = vt::CollectionMessage; - - void doWork(TestMsg* msg) { - fmt::print("Hello from {}\n", this->getIndex()); + void doWork(int val) { + fmt::print("Hello from {}: val={}\n", this->getIndex(), val); counter_++; } @@ -79,7 +77,7 @@ int main(int argc, char** argv) { .bounds(range) .bulkInsert() .wait(); - proxy.broadcast(); + proxy.broadcast<&Hello::doWork>(10); } vt::finalize(); diff --git a/examples/hello_world/hello_world_collection_collective.cc b/examples/hello_world/hello_world_collection_collective.cc index 091f67101a..d0e06fcd59 100644 --- a/examples/hello_world/hello_world_collection_collective.cc +++ b/examples/hello_world/hello_world_collection_collective.cc @@ -52,11 +52,11 @@ struct Hello : vt::Collection { vtAssert(counter_ == num_nodes, "Should receive # nodes broadcasts"); } - using TestMsg = vt::CollectionMessage; - - void doWork(TestMsg* msg) { + void doWork(int val) { counter_++; - fmt::print("Hello from {}, counter_={}\n", this->getIndex().x(), counter_); + fmt::print( + "Hello from {}, val={}, counter_={}\n", getIndex(), val, counter_ + ); } private: @@ -78,7 +78,7 @@ int main(int argc, char** argv) { .wait(); // All nodes send a broadcast to all elements - proxy.broadcast(); + proxy.broadcast<&Hello::doWork>(29); vt::finalize(); diff --git a/examples/hello_world/objgroup.cc b/examples/hello_world/objgroup.cc index a9d5620657..73b377000c 100644 --- a/examples/hello_world/objgroup.cc +++ b/examples/hello_world/objgroup.cc @@ -44,15 +44,10 @@ #include /// [Object group creation] -struct MyMsg : vt::Message { - MyMsg(int in_a, int in_b) : a(in_a), b(in_b) { } - int a = 0, b = 0; -}; - struct MyObjGroup { - void handler(MyMsg* msg) { + void handler(int a, int b) { auto node = vt::theContext()->getNode(); - fmt::print("{}: MyObjGroup::handler on a={}, b={}\n", node, msg->a, msg->b); + fmt::print("{}: MyObjGroup::handler on a={}, b={}\n", node, a, b); } }; @@ -67,11 +62,11 @@ int main(int argc, char** argv) { ); if (this_node == 0) { - proxy[0].send(5,10); + proxy[0].send<&MyObjGroup::handler>(5,10); if (num_nodes > 1) { - proxy[1].send(10,20); + proxy[1].send<&MyObjGroup::handler>(10,20); } - proxy.broadcast(400,500); + proxy.broadcast<&MyObjGroup::handler>(400,500); } vt::finalize(); From b94209732cc81a08220688b638a4788569244fce Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 6 Mar 2023 13:53:14 -0800 Subject: [PATCH 26/32] #276: objgroup: fix epoch capture without message --- src/vt/objgroup/manager.static.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vt/objgroup/manager.static.h b/src/vt/objgroup/manager.static.h index 0402fe6397..ac24a78aec 100644 --- a/src/vt/objgroup/manager.static.h +++ b/src/vt/objgroup/manager.static.h @@ -95,7 +95,6 @@ decltype(auto) invoke( auto lb_data = &holder->getLBData(); return runnable::makeRunnableVoid(false, han, this_node) .withObjGroup(elm) - .withTDEpochFromMsg() .withLBData(lb_data, elm_id) .runLambda(f, static_cast(elm), msg.get()); } From d7e91f0197ed37866204daa60edfe4d74985142b Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 6 Mar 2023 15:17:31 -0800 Subject: [PATCH 27/32] #276: registry: add static assert for invalid paths --- src/vt/registry/auto/auto_registry_common.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index 35fdb788e9..d811da2e67 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -127,6 +127,8 @@ struct MapsDispatcher final : BaseMapsDispatcher { static_cast(range_ptr), num_nodes ); + } else { + static_assert(false, "Invalid function type for map handler"); } } @@ -149,6 +151,8 @@ struct ScatterDispatcher final : BaseScatterDispatcher { if constexpr (std::is_same_v*>) { fp(static_cast(msg)); + } else { + static_assert(false, "Invalid function type for scatter handler"); } } From 36d0707c4f71735b1bc7b2442429937e8095d360 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 6 Mar 2023 15:22:37 -0800 Subject: [PATCH 28/32] #276: registry: switch to regular assert --- src/vt/registry/auto/auto_registry_common.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index d811da2e67..eba3e47dc7 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -128,7 +128,8 @@ struct MapsDispatcher final : BaseMapsDispatcher { num_nodes ); } else { - static_assert(false, "Invalid function type for map handler"); + vtAssert(false, "Invalid function type for map handler"); + return uninitialized_destination; } } @@ -152,7 +153,7 @@ struct ScatterDispatcher final : BaseScatterDispatcher { if constexpr (std::is_same_v*>) { fp(static_cast(msg)); } else { - static_assert(false, "Invalid function type for scatter handler"); + vtAssert(false, "Invalid function type for scatter handler"); } } From 47d3a3298bcb5311fb7ca6e447e338a07772e573 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 6 Mar 2023 15:36:59 -0800 Subject: [PATCH 29/32] #276: examples: simplify with new syntax --- examples/collection/lb_iter.cc | 29 ++++--------- examples/collection/migrate_collection.cc | 22 +++------- examples/collection/polymorphic_collection.cc | 41 ++++++------------- examples/hello_world/hello_world.cc | 4 +- .../hello_world_collection_reduce.cc | 6 +-- .../hello_world_collection_staged_insert.cc | 6 +-- 6 files changed, 30 insertions(+), 78 deletions(-) diff --git a/examples/collection/lb_iter.cc b/examples/collection/lb_iter.cc index 5b4a3ac2ca..6d467b0347 100644 --- a/examples/collection/lb_iter.cc +++ b/examples/collection/lb_iter.cc @@ -47,22 +47,7 @@ static constexpr int32_t const default_num_elms = 64; static int32_t num_iter = 8; struct IterCol : vt::Collection { - IterCol() = default; - - struct IterMsg : vt::CollectionMessage { - IterMsg() = default; - IterMsg( - int64_t const in_work_amt, int64_t const in_iter, int64_t const subphase - ) - : iter_(in_iter), work_amt_(in_work_amt), subphase_(subphase) - { } - - int64_t iter_ = 0; - int64_t work_amt_ = 0; - int64_t subphase_ = 0; - }; - - void iterWork(IterMsg* msg); + void iterWork(int64_t work_amt, int64_t iter, int subphase); template void serialize(SerializerT& s) { @@ -76,10 +61,10 @@ struct IterCol : vt::Collection { static double weight = 1.0f; -void IterCol::iterWork(IterMsg* msg) { - this->lb_data_.setSubPhase(msg->subphase_); +void IterCol::iterWork(int64_t work_amt, int64_t iter, int subphase) { + this->lb_data_.setSubPhase(subphase); double val = 0.1f; - double val2 = 0.4f * msg->work_amt_; + double val2 = 0.4f * work_amt; auto const idx = getIndex().x(); int64_t const max_work = 1000 * weight; int64_t const mid_work = 100 * weight; @@ -131,13 +116,13 @@ int main(int argc, char** argv) { auto cur_time = vt::timing::getCurrentTime(); vt::runInEpochCollective([=]{ - proxy.broadcastCollective(10, i, 0); + proxy.broadcastCollective<&IterCol::iterWork>(10, i, 0); }); vt::runInEpochCollective([=]{ - proxy.broadcastCollective(5, i, 1); + proxy.broadcastCollective<&IterCol::iterWork>(5, i, 1); }); vt::runInEpochCollective([=]{ - proxy.broadcastCollective(15, i, 2); + proxy.broadcastCollective<&IterCol::iterWork>(15, i, 2); }); auto total_time = vt::timing::getCurrentTime() - cur_time; diff --git a/examples/collection/migrate_collection.cc b/examples/collection/migrate_collection.cc index 92bee3ce00..ee86a8bd2d 100644 --- a/examples/collection/migrate_collection.cc +++ b/examples/collection/migrate_collection.cc @@ -65,20 +65,12 @@ struct Hello : vt::Collection { double test_val = 0.0; }; -struct ColMsg : vt::CollectionMessage { - explicit ColMsg(vt::NodeType const& in_from_node) - : from_node(in_from_node) - { } - - vt::NodeType from_node = vt::uninitialized_destination; -}; - -static void doWork(Hello* col, ColMsg* msg) { +static void doWork(Hello* col) { vt::NodeType this_node = vt::theContext()->getNode(); fmt::print("{}: idx={}: val={}\n", this_node, col->getIndex(), col->test_val); } -static void migrateToNext(Hello* col, ColMsg* msg) { +static void migrateToNext(Hello* col) { vt::NodeType this_node = vt::theContext()->getNode(); vt::NodeType num_nodes = vt::theContext()->getNumNodes(); vt::NodeType next_node = (this_node + 1) % num_nodes; @@ -109,13 +101,9 @@ int main(int argc, char** argv) { .wait(); if (this_node == 0) { - vt::runInEpochRooted([=] { proxy.broadcast(this_node); }); - - vt::runInEpochRooted( - [=] { proxy.broadcast(this_node); } - ); - - vt::runInEpochRooted([=] { proxy.broadcast(this_node); }); + vt::runInEpochRooted([=] { proxy.broadcast(); }); + vt::runInEpochRooted([=] { proxy.broadcast(); }); + vt::runInEpochRooted([=] { proxy.broadcast(); }); } vt::finalize(); diff --git a/examples/collection/polymorphic_collection.cc b/examples/collection/polymorphic_collection.cc index 4f410f93ed..88bab1448f 100644 --- a/examples/collection/polymorphic_collection.cc +++ b/examples/collection/polymorphic_collection.cc @@ -46,7 +46,6 @@ /// [Polymorphic collection example] static constexpr int32_t const default_num_elms = 16; struct InitialConsTag{}; -struct ColMsg; struct Hello : vt::Collection { checkpoint_virtual_serialize_root() @@ -62,19 +61,11 @@ struct Hello : vt::Collection { s | test_val; } - virtual void doWork(ColMsg* msg); + virtual void doWork(); double test_val = 0.0; }; -struct ColMsg : vt::CollectionMessage { - explicit ColMsg(vt::NodeType const& in_from_node) - : from_node(in_from_node) - { } - - vt::NodeType from_node = vt::uninitialized_destination; -}; - template struct HelloTyped : Hello { checkpoint_virtual_serialize_derived_from(Hello) @@ -84,7 +75,7 @@ struct HelloTyped : Hello { : Hello(checkpoint::SERIALIZE_CONSTRUCT_TAG{}) {} - virtual void doWork(ColMsg* msg) override; + virtual void doWork() override; template void serialize(Serializer& s) { @@ -95,14 +86,14 @@ struct HelloTyped : Hello { }; template <> -void HelloTyped::doWork(ColMsg* msg) { +void HelloTyped::doWork() { fmt::print("correctly doing this -- int!\n"); - Hello::doWork(msg); + Hello::doWork(); } template <> -void HelloTyped::doWork(ColMsg* msg) { - Hello::doWork(msg); +void HelloTyped::doWork() { + Hello::doWork(); fmt::print("correctly doing this -- double!\n"); } @@ -124,7 +115,7 @@ HelloTyped::HelloTyped(InitialConsTag) } } -void Hello::doWork(ColMsg* msg) { +void Hello::doWork() { vt_print( gen, "idx={}: val={}, type={}\n", getIndex(), test_val, typeid(*this).name() @@ -147,7 +138,7 @@ void Hello::doWork(ColMsg* msg) { } -static void migrateToNext(Hello* col, ColMsg* msg) { +static void migrateToNext(Hello* col) { vt::NodeType this_node = vt::theContext()->getNode(); vt::NodeType num_nodes = vt::theContext()->getNumNodes(); vt::NodeType next_node = (this_node + 1) % num_nodes; @@ -191,21 +182,13 @@ int main(int argc, char** argv) { .wait(); for (int p = 0; p < 10; p++) { - vt::runInEpochCollective([&]{ - proxy.broadcastCollective<&Hello::doWork>(this_node); - }); - vt::runInEpochCollective([&]{ - proxy.broadcastCollective(this_node); - }); - vt::runInEpochCollective([&]{ - proxy.broadcastCollective<&Hello::doWork>(this_node); - }); + vt::runInEpochCollective([&]{ proxy.broadcastCollective<&Hello::doWork>(); }); + vt::runInEpochCollective([&]{ proxy.broadcastCollective(); }); + vt::runInEpochCollective([&]{ proxy.broadcastCollective<&Hello::doWork>(); }); } for (int p = 0; p < 10; p++) { - vt::runInEpochCollective([&]{ - proxy.broadcastCollective<&Hello::doWork>(this_node); - }); + vt::runInEpochCollective([&]{ proxy.broadcastCollective<&Hello::doWork>(); }); vt::thePhase()->nextPhaseCollective(); } diff --git a/examples/hello_world/hello_world.cc b/examples/hello_world/hello_world.cc index cc3ca80b25..5200de3783 100644 --- a/examples/hello_world/hello_world.cc +++ b/examples/hello_world/hello_world.cc @@ -49,7 +49,7 @@ struct HelloMsg : vt::Message { vt::NodeType from = 0; }; -void helloWorld(int a, int b, float c) { +void hello_world(int a, int b, float c) { vt::NodeType this_node = vt::theContext()->getNode(); fmt::print("{}: Hello from node vals = {} {} {}\n", this_node, a, b, c); } @@ -65,7 +65,7 @@ int main(int argc, char** argv) { } if (this_node == 0) { - vt::theMsg()->send(vt::Node{1}, 10, 20, 11.3f); + vt::theMsg()->send(vt::Node{1}, 10, 20, 11.3f); } vt::finalize(); diff --git a/examples/hello_world/hello_world_collection_reduce.cc b/examples/hello_world/hello_world_collection_reduce.cc index dcbb5f2930..38db1bde36 100644 --- a/examples/hello_world/hello_world_collection_reduce.cc +++ b/examples/hello_world/hello_world_collection_reduce.cc @@ -51,9 +51,7 @@ struct Hello : vt::Collection { fmt::print("Reduce complete at {} value {}\n", this->getIndex(), msg->getVal()); } - using TestMsg = vt::CollectionMessage; - - void doWork(TestMsg* msg) { + void doWork() { fmt::print("Hello from {}\n", this->getIndex()); // Get the proxy for the collection @@ -85,7 +83,7 @@ int main(int argc, char** argv) { .wait(); if (this_node == 0) { - proxy.broadcast(); + proxy.broadcast<&Hello::doWork>(); } vt::finalize(); diff --git a/examples/hello_world/hello_world_collection_staged_insert.cc b/examples/hello_world/hello_world_collection_staged_insert.cc index e3c026d5ec..ef097c61cd 100644 --- a/examples/hello_world/hello_world_collection_staged_insert.cc +++ b/examples/hello_world/hello_world_collection_staged_insert.cc @@ -58,9 +58,7 @@ struct Hello : vt::Collection { vtAssert(counter_ == 1, "Must be equal"); } - using TestMsg = vt::CollectionMessage; - - void doWork(TestMsg* msg) { + void doWork() { counter_++; vt::NodeType this_node = vt::theContext()->getNode(); @@ -107,7 +105,7 @@ int main(int argc, char** argv) { .wait(); if (this_node == 1) { - proxy.broadcast(); + proxy.broadcast<&Hello::doWork>(); } vt::finalize(); From df46d65ab6a0d0a20c8e692b9a420b77128a1f71 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 6 Mar 2023 15:50:25 -0800 Subject: [PATCH 30/32] #276: param: remove old component --- docs/md/param.md | 8 - docs/md/vt.md | 1 - examples/hello_world/CMakeLists.txt | 1 - examples/hello_world/param.cc | 100 ------- src/CMakeLists.txt | 2 +- src/vt/configs/arguments/args.cc | 3 - src/vt/configs/debug/debug_config.h | 38 ++- src/vt/parameterization/param_meta.h | 95 ------- src/vt/parameterization/parameterization.cc | 48 ---- src/vt/parameterization/parameterization.h | 280 -------------------- src/vt/runtime/runtime.cc | 13 - src/vt/runtime/runtime.h | 1 - src/vt/runtime/runtime_get.cc | 2 - src/vt/transport.h | 1 - 14 files changed, 19 insertions(+), 574 deletions(-) delete mode 100644 docs/md/param.md delete mode 100644 examples/hello_world/param.cc delete mode 100644 src/vt/parameterization/param_meta.h delete mode 100644 src/vt/parameterization/parameterization.cc delete mode 100644 src/vt/parameterization/parameterization.h diff --git a/docs/md/param.md b/docs/md/param.md deleted file mode 100644 index e51af1a698..0000000000 --- a/docs/md/param.md +++ /dev/null @@ -1,8 +0,0 @@ -\page param Parameterization -\brief Handler parameterization - -@m_class{m-label m-danger} **Experimental** - -The parameterization component `vt::param::Param`, accessed via `vt::theParam()` -is an experimental component for parameterizing arguments into active function -handlers as an alternative to messages. diff --git a/docs/md/vt.md b/docs/md/vt.md index b48654074a..a9c4064320 100644 --- a/docs/md/vt.md +++ b/docs/md/vt.md @@ -50,7 +50,6 @@ management. | \subpage location | `vt::theLocMan()` | \copybrief location | @m_class{m-label m-success} **Core** | | \subpage mem-usage | `vt::theMemUsage()` | \copybrief mem-usage | @m_class{m-label m-warning} **Optional** | | \subpage objgroup | `vt::theObjGroup()` | \copybrief objgroup | @m_class{m-label m-success} **Core** | -| \subpage param | `vt::theParam()` | \copybrief param | @m_class{m-label m-danger} **Experimental** | | \subpage pipe | `vt::theCB()` | \copybrief pipe | @m_class{m-label m-success} **Core** | | \subpage node-lb-data | `vt::theNodeLBData()` | \copybrief node-lb-data | @m_class{m-label m-warning} **Optional** | | \subpage phase | `vt::thePhase()` | \copybrief phase | @m_class{m-label m-success} **Core** | diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt index 2fa6194395..1b7d464fc1 100644 --- a/examples/hello_world/CMakeLists.txt +++ b/examples/hello_world/CMakeLists.txt @@ -10,7 +10,6 @@ set( hello_world_virtual_context hello_world_virtual_context_remote ring - param objgroup ) diff --git a/examples/hello_world/param.cc b/examples/hello_world/param.cc deleted file mode 100644 index d9af0a2b10..0000000000 --- a/examples/hello_world/param.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// param.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 - -#define VT_COMPILE_PARAM_EXAMPLE 0 - -#if VT_COMPILE_PARAM_EXAMPLE - -static void fnTest(int a, int b, bool x) { - fmt::print("fn: a={}, b={}, x={}\n", a, b, x ? "true" : "false"); -} - -static void fnTest2(int x, int y) { - fmt::print("fn2: x={},y={}\n",x,y); -} - -static void fnTest3(int x, double y) { - fmt::print("fn3: x={},y={}\n",x,y); -} - -struct FunctorTest1 { - void operator()(int x, double y) const { - fmt::print("FunctorTest1: x={},y={}\n",x,y); - } -}; - -#endif - -int main(int argc, char** argv) { - vt::initialize(argc, argv); - - vt::NodeType num_nodes = vt::theContext()->getNumNodes(); - - if (num_nodes == 1) { - return vt::rerror("requires at least 2 nodes"); - } - -#if VT_COMPILE_PARAM_EXAMPLE - vt::NodeType this_node = vt::theContext()->getNode(); - - if (this_node == 0) { - vt::theParam()->sendData(1, vt::buildData(10, 20, false), PARAM_FUNCTION_RHS(fnTest)); - vt::theParam()->sendData(1, PARAM_FUNCTION_RHS(fnTest), 50, 29, false); - vt::theParam()->sendData(1, vt::buildData(10, 20, false)); - vt::theParam()->sendData(1, 45, 23, true); - - vt::theParam()->sendData(1, 20, 10); - vt::theParam()->sendData(1, 20, 50.0); - - vt::theParam()->sendData(1, vt::buildData(20, 50.0)); - vt::theParam()->sendData(1, 20, 100.0); - vt::theParam()->sendData(1, vt::buildData(10, 70.0)); - } -#endif - - vt::finalize(); - - return 0; -} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c57f1d8405..aaf8f70a82 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,7 +19,7 @@ set(TOP_LEVEL_SUBDIRS runnable activefn # Add single-directory components - context event handler parameterization sequence termination + context event handler sequence termination scheduler standalone runtime trace timing demangle rdmahandle ) set( diff --git a/src/vt/configs/arguments/args.cc b/src/vt/configs/arguments/args.cc index bc5d1e5825..7ee0b87ac5 100644 --- a/src/vt/configs/arguments/args.cc +++ b/src/vt/configs/arguments/args.cc @@ -356,7 +356,6 @@ void addDebugPrintArgs(CLI::App& app, AppConfig& appConfig) { auto lap = "Enable debug_rdma = \"" debug_pp(rdma) "\""; auto map = "Enable debug_rdma_channel = \"" debug_pp(rdma_channel) "\""; auto nap = "Enable debug_rdma_state = \"" debug_pp(rdma_state) "\""; - auto oap = "Enable debug_param = \"" debug_pp(param) "\""; auto pap = "Enable debug_handler = \"" debug_pp(handler) "\""; auto qap = "Enable debug_hierlb = \"" debug_pp(hierlb) "\""; auto qbp = "Enable debug_temperedlb = \"" debug_pp(temperedlb) "\""; @@ -393,7 +392,6 @@ void addDebugPrintArgs(CLI::App& app, AppConfig& appConfig) { auto la = app.add_flag("--vt_debug_rdma", appConfig.vt_debug_rdma, lap); auto ma = app.add_flag("--vt_debug_rdma_channel", appConfig.vt_debug_rdma_channel, map); auto na = app.add_flag("--vt_debug_rdma_state", appConfig.vt_debug_rdma_state, nap); - auto oa = app.add_flag("--vt_debug_param", appConfig.vt_debug_param, oap); auto pa = app.add_flag("--vt_debug_handler", appConfig.vt_debug_handler, pap); auto qa = app.add_flag("--vt_debug_hierlb", appConfig.vt_debug_hierlb, qap); auto qb = app.add_flag("--vt_debug_temperedlb", appConfig.vt_debug_temperedlb, qbp); @@ -430,7 +428,6 @@ void addDebugPrintArgs(CLI::App& app, AppConfig& appConfig) { la->group(debugGroup); ma->group(debugGroup); na->group(debugGroup); - oa->group(debugGroup); pa->group(debugGroup); qa->group(debugGroup); qb->group(debugGroup); diff --git a/src/vt/configs/debug/debug_config.h b/src/vt/configs/debug/debug_config.h index e9edddcd06..999586b1fc 100644 --- a/src/vt/configs/debug/debug_config.h +++ b/src/vt/configs/debug/debug_config.h @@ -63,25 +63,24 @@ enum CatEnum : uint64_t { rdma = 1ull<<11, rdma_channel = 1ull<<12, rdma_state = 1ull<<13, - param = 1ull<<14, - handler = 1ull<<15, - hierlb = 1ull<<16, - scatter = 1ull<<17, - serial_msg = 1ull<<18, - trace = 1ull<<19, - location = 1ull<<20, - lb = 1ull<<21, - vrt = 1ull<<22, - vrt_coll = 1ull<<23, - worker = 1ull<<24, - group = 1ull<<25, - broadcast = 1ull<<26, - objgroup = 1ull<<27, - temperedlb = 1ull<<28, - phase = 1ull<<29, - context = 1ull<<30, - epoch = 1ull<<31, - temperedwmin = 1ull<<32 + handler = 1ull<<14, + hierlb = 1ull<<15, + scatter = 1ull<<16, + serial_msg = 1ull<<17, + trace = 1ull<<18, + location = 1ull<<19, + lb = 1ull<<20, + vrt = 1ull<<21, + vrt_coll = 1ull<<22, + worker = 1ull<<23, + group = 1ull<<24, + broadcast = 1ull<<25, + objgroup = 1ull<<26, + temperedlb = 1ull<<27, + phase = 1ull<<28, + context = 1ull<<29, + epoch = 1ull<<30, + temperedwmin = 1ull<<31 }; enum CtxEnum : uint64_t { @@ -132,7 +131,6 @@ vt_option_category_pretty_print(temperedwmin, "TemperedWMin") vt_option_category_pretty_print(lb, "lb") vt_option_category_pretty_print(location, "location") vt_option_category_pretty_print(objgroup, "objgroup") -vt_option_category_pretty_print(param, "parameterization") vt_option_category_pretty_print(phase, "phase") vt_option_category_pretty_print(pipe, "pipe") vt_option_category_pretty_print(pool, "pool") diff --git a/src/vt/parameterization/param_meta.h b/src/vt/parameterization/param_meta.h deleted file mode 100644 index ef556e5dff..0000000000 --- a/src/vt/parameterization/param_meta.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// param_meta.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_PARAMETERIZATION_PARAM_META_H -#define INCLUDED_VT_PARAMETERIZATION_PARAM_META_H - -#include "vt/config.h" - -#include -#include -#include -#include - -namespace vt { namespace param { - -template -using MultiParamType = void(*)(Args...); - -template -struct NonType {}; - -#define PARAM_FUNCTION_RHS(value) vt::param::NonType() -#define PARAM_FUNCTION(value) decltype(&value),(&value) - -template -auto callFnTuple(Function f, Tuple t, std::index_sequence) { - return f( - std::forward::type>( - std::get(t) - )... - ); -} - -template -void invokeFnTuple(TypedFnT f, std::tuple t) { - using TupleType = std::tuple; - callFnTuple(f, std::forward(t), std::make_index_sequence{}); -} - -template -void invokeCallableTuple(std::tuple& tup, FnT fn, bool const& is_functor) { - using TupleType = typename std::decay::type; - static constexpr auto size = std::tuple_size::value; - if (is_functor) { - auto typed_fn = reinterpret_cast>(fn); - return invokeFnTuple(typed_fn, tup); - } else { - auto typed_fn = reinterpret_cast>(fn); - return invokeFnTuple(typed_fn, tup); - } -} - -}} /* end namespace vt::param */ - -#endif /*INCLUDED_VT_PARAMETERIZATION_PARAM_META_H*/ diff --git a/src/vt/parameterization/parameterization.cc b/src/vt/parameterization/parameterization.cc deleted file mode 100644 index 379db2ac0c..0000000000 --- a/src/vt/parameterization/parameterization.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// parameterization.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/parameterization/parameterization.h" - -namespace vt { namespace param { - -}} //end namespace vt::param diff --git a/src/vt/parameterization/parameterization.h b/src/vt/parameterization/parameterization.h deleted file mode 100644 index 9c427ac33a..0000000000 --- a/src/vt/parameterization/parameterization.h +++ /dev/null @@ -1,280 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// parameterization.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_PARAMETERIZATION_PARAMETERIZATION_H -#define INCLUDED_VT_PARAMETERIZATION_PARAMETERIZATION_H - -#include "vt/config.h" -#include "vt/messaging/message.h" -#include "vt/messaging/active.h" -#include "vt/registry/auto/auto_registry_interface.h" -#include "vt/utils/static_checks/all_true.h" -#include "vt/parameterization/param_meta.h" -#include "vt/runtime/component/component_pack.h" - -#include -#include -#include -#include - -namespace vt { namespace param { - -using namespace ::vt::util; - -using HandlerManagerType = vt::HandlerManager; - -template -struct DataMsg : vt::Message { - using MessageParentType = vt::Message; - vt_msg_serialize_if_needed_by_parent_or_type1(Tuple); // by tup - - Tuple tup; - HandlerType sub_han = uninitialized_handler; - - DataMsg() = default; - DataMsg(HandlerType const in_sub_han, Tuple&& a) - : Message(), tup(std::forward(a)), sub_han(in_sub_han) - { } - - template - DataMsg(HandlerType const in_sub_han, Args&&... a) - : Message(), tup(std::forward(a)...), sub_han(in_sub_han) - { } - - template - void serialize(SerializerT& s) { - MessageParentType::serialize(s); - s | tup; - s | sub_han; - } -}; - - -template -static void dataMessageHandler(DataMsg* msg) { - vt_debug_print( - normal, param, - "dataMessageHandler: id={}\n", msg->sub_han - ); - -#if vt_check_enabled(trace_enabled) - trace::TraceProcessingTag processing_tag; - { - trace::TraceEntryIDType ep = auto_registry::handlerTraceID(msg->sub_han); - trace::TraceEventIDType event = envelopeGetTraceEvent(msg->env); - - size_t msg_size = sizeof(*msg); - NodeType const& from_node = theContext()->getFromNodeCurrentTask(); - - processing_tag = - theTrace()->beginProcessing(ep, msg_size, event, from_node, timing::getCurrentTime()); - } -#endif - - if (HandlerManagerType::isHandlerFunctor(msg->sub_han)) { - auto const& fn = auto_registry::getAutoHandlerFunctor(msg->sub_han); - invokeCallableTuple(msg->tup, fn, true); - } else { - // regular active function - auto const& fn = auto_registry::getAutoHandler(msg->sub_han); - invokeCallableTuple(msg->tup, fn, false); - } - -#if vt_check_enabled(trace_enabled) - theTrace()->endProcessing(processing_tag, timing::getCurrentTime()); -#endif -} - -/** - * \struct Param - * - * \brief An experimental component for parameterizing handlers. - * - * Clean support for parameterization does not exist until C++17. This component - * is an attempt at parameterizing for C++14 with non-type templates. - * - * \warning This is an experimental component. - */ -struct Param : runtime::component::Component { - - std::string name() override { return "Param"; } - - template - void sendDataTuple( - NodeType const& dest, HandlerType const han, std::tuple&& tup - ) { - staticCheckCopyable(); - - using TupleType = typename std::decay::type; - - auto m = makeMessage>( - han, std::forward>(tup) - ); - theMsg()->sendMsg(dest, m); - } - - template - void staticCheckCopyable() { - using cond = all_true::value...>; - - static_assert( - std::is_same::value == true, - "All types passed for parameterization must be trivially copyable" - ); - } - - template - void sendDataMsg( - NodeType const& dest, HandlerType const __attribute__((unused)) han, - MsgSharedPtr m - ) { - auto pmsg = promoteMsg(m.get()); - theMsg()->sendMsg(dest, pmsg); - } - - template - void sendData( - NodeType const& dest, Tuple tup, - NonType __attribute__((unused)) non = NonType() - ) { - auto const& han = auto_registry::makeAutoHandlerParam(); - sendDataTuple(dest, han, std::forward(tup)); - } - - template - void sendData( - NodeType const& dest, MsgSharedPtr>> msg, - NonType __attribute__((unused)) non = NonType() - ) { - auto const& han = auto_registry::makeAutoHandlerParam(); - msg->sub_han = han; - sendDataMsg(dest, han, msg); - } - - template - void sendData( - NodeType const& dest, NonType __attribute__((unused)) non, - Args&&... a - ) { - auto const& han = auto_registry::makeAutoHandlerParam(); - - staticCheckCopyable(); - - using TupleType = std::tuple; - - auto m = makeMessage>(han, std::forward(a)...); - sendDataMsg(dest, han, m); - } - - template - void sendData(NodeType const& dest, Args&&... a) { - sendData(dest, NonType(), std::forward(a)...); - } - - /* - * Functor variants - */ - - template - void sendDataHelperFunctor( - NodeType const& dest, std::tuple&& tup - ) { - auto const& han = auto_registry::makeAutoHandlerFunctor< - FunctorT, false, Args... - >(); - sendDataTuple(dest, han, std::forward>(tup)); - } - - template - void sendData(NodeType const& dest, Tuple tup) { - sendDataHelperFunctor(dest, std::forward(tup)); - } - - template - void sendData( - NodeType const& dest, MsgSharedPtr>> msg - ) { - staticCheckCopyable(); - - auto const& han = auto_registry::makeAutoHandlerFunctor< - FunctorT, false, Args... - >(); - msg->sub_han = han; - - sendDataMsg(dest, han, msg); - } - - template - void sendData(NodeType const& dest, Args&&... a) { - staticCheckCopyable(); - - auto const& han = auto_registry::makeAutoHandlerFunctor< - FunctorT, false, Args... - >(); - - using TupleType = std::tuple; - - auto m = makeMessage>(han, std::forward(a)...); - sendDataMsg(dest, han, m); - } - - template - void serialize(Serializer&) {} -}; - -}} //end namespace vt::param - -namespace vt { - -extern param::Param* theParam(); - -template -MsgSharedPtr>> buildData(Args&&... a) { - return makeMessage>>( - uninitialized_handler, std::forward(a)... - ); -} - -} //end namespace vt - -#endif /*INCLUDED_VT_PARAMETERIZATION_PARAMETERIZATION_H*/ diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index 6f12d6b0b3..f5f6737fd4 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -50,7 +50,6 @@ #include "vt/termination/termination.h" #include "vt/pool/pool.h" #include "vt/rdma/rdma_headers.h" -#include "vt/parameterization/parameterization.h" #include "vt/pipe/pipe_manager.h" #include "vt/objgroup/manager.h" #include "vt/scheduler/scheduler.h" @@ -785,13 +784,6 @@ void Runtime::initializeComponents() { >{} ); - p_->registerComponent( - &theParam, Deps< - ctx::Context, // Everything depends on theContext - messaging::ActiveMessenger // Depends on active messenger sending - >{} - ); - p_->registerComponent( &theLocMan, Deps< ctx::Context, // Everything depends on theContext @@ -884,7 +876,6 @@ void Runtime::initializeComponents() { p_->add(); p_->add(); p_->add(); - p_->add(); p_->add(); p_->add(); p_->add(); @@ -1048,10 +1039,6 @@ void Runtime::printMemoryFootprint() const { printComponentFootprint( static_cast(base) ); - } else if (name == "Param") { - printComponentFootprint( - static_cast(base) - ); } else if (name == "RDMAManager") { printComponentFootprint( static_cast(base) diff --git a/src/vt/runtime/runtime.h b/src/vt/runtime/runtime.h index f562100c6b..ef573dfce3 100644 --- a/src/vt/runtime/runtime.h +++ b/src/vt/runtime/runtime.h @@ -404,7 +404,6 @@ struct Runtime { ComponentPtrType theCollective = nullptr; ComponentPtrType thePool = nullptr; ComponentPtrType theRDMA = nullptr; - ComponentPtrType theParam = nullptr; ComponentPtrType theSched = nullptr; ComponentPtrType theLocMan = nullptr; ComponentPtrType theVirtualManager = nullptr; diff --git a/src/vt/runtime/runtime_get.cc b/src/vt/runtime/runtime_get.cc index d14ca6212d..40610b387f 100644 --- a/src/vt/runtime/runtime_get.cc +++ b/src/vt/runtime/runtime_get.cc @@ -54,7 +54,6 @@ #include "vt/collective/collective_alg.h" #include "vt/pool/pool.h" #include "vt/rdma/rdma.h" -#include "vt/parameterization/parameterization.h" #include "vt/trace/trace.h" #include "vt/scheduler/scheduler.h" #include "vt/topos/location/location_headers.h" @@ -100,7 +99,6 @@ vrt::VirtualContextManager* theVirtualManager() { return curRT->theVirtualMa collective::CollectiveAlg* theCollective() { return curRT->theCollective; } event::AsyncEvent* theEvent() { return curRT->theEvent; } messaging::ActiveMessenger* theMsg() { return curRT->theMsg; } -param::Param* theParam() { return curRT->theParam; } rdma::RDMAManager* theRDMA() { return curRT->theRDMA; } sched::Scheduler* theSched() { return curRT->theSched; } term::TerminationDetector* theTerm() { return curRT->theTerm; } diff --git a/src/vt/transport.h b/src/vt/transport.h index fe49e3c4a3..3db2d37da5 100644 --- a/src/vt/transport.h +++ b/src/vt/transport.h @@ -56,7 +56,6 @@ #include "vt/collective/collective.h" #include "vt/event/event.h" #include "vt/messaging/active.h" -#include "vt/parameterization/parameterization.h" #include "vt/event/event_msgs.h" #include "vt/termination/termination.h" #include "vt/rdma/rdma_headers.h" From aeed39d9271d97360494715de9d996c94ce4e7c1 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Fri, 10 Mar 2023 14:17:08 -0500 Subject: [PATCH 31/32] #276: Clarify boolean literal function argument --- src/vt/messaging/active.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index 50eb123096..b1d8e198a7 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -784,7 +784,8 @@ struct ActiveMessenger : runtime::component::PollableComponent using MsgT = ParamMsg; auto msg = vt::makeMessage(std::forward(params)...); auto han = auto_registry::makeAutoHandlerParam(); - return broadcastMsg(han, msg, true, no_tag); + constexpr bool deliver_to_sender = true; + return broadcastMsg(han, msg, deliver_to_sender, no_tag); } /** From 6b69c913df9316275d2332daec11ade21dca77bd Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Fri, 10 Mar 2023 14:19:12 -0500 Subject: [PATCH 32/32] #276: Turn `vtAssert(false, ...)` into `vtAbort(...)` to avoid issues in non-debug builds --- src/vt/registry/auto/auto_registry_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vt/registry/auto/auto_registry_common.h b/src/vt/registry/auto/auto_registry_common.h index eba3e47dc7..f309021a77 100644 --- a/src/vt/registry/auto/auto_registry_common.h +++ b/src/vt/registry/auto/auto_registry_common.h @@ -128,7 +128,7 @@ struct MapsDispatcher final : BaseMapsDispatcher { num_nodes ); } else { - vtAssert(false, "Invalid function type for map handler"); + vtAbort("Invalid function type for map handler"); return uninitialized_destination; } } @@ -153,7 +153,7 @@ struct ScatterDispatcher final : BaseScatterDispatcher { if constexpr (std::is_same_v*>) { fp(static_cast(msg)); } else { - vtAssert(false, "Invalid function type for scatter handler"); + vtAbort("Invalid function type for scatter handler"); } }