From 322a53678e74eef323174d3a2b64594699b95526 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 12 Oct 2023 13:56:58 -0700 Subject: [PATCH 01/12] #410: reduce: fix warning --- src/vt/collective/reduce/reduce_manager.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vt/collective/reduce/reduce_manager.cc b/src/vt/collective/reduce/reduce_manager.cc index 9faa9783b4..bd2bba08fa 100644 --- a/src/vt/collective/reduce/reduce_manager.cc +++ b/src/vt/collective/reduce/reduce_manager.cc @@ -46,12 +46,12 @@ namespace vt { namespace collective { namespace reduce { +static std::unique_ptr makeReduceScope(detail::ReduceScope const& scope) { + return std::make_unique(scope); +} + ReduceManager::ReduceManager() - : reducers_( // default cons reducer for non-group - [](detail::ReduceScope const& scope) { - return std::make_unique(scope); - } - ) + : reducers_(makeReduceScope) { // insert the default reducer scope reducers_.make( From 49fde59b8627a6db3034663790d88ea2612809e2 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 7 Nov 2023 16:44:32 -0800 Subject: [PATCH 02/12] #2212: param: add properties as optional first argument --- src/vt/messaging/active.h | 6 +- src/vt/messaging/active.impl.h | 2 + src/vt/messaging/param_msg.h | 144 ++++++++++++++++-- src/vt/messaging/param_msg.impl.h | 81 ++++++++++ src/vt/objgroup/proxy/proxy_objgroup.impl.h | 3 +- .../objgroup/proxy/proxy_objgroup_elm.impl.h | 3 +- src/vt/pipe/callback/cb_union/cb_raw_base.h | 6 +- .../collection/broadcast/broadcastable.impl.h | 6 +- .../vrt/collection/messages/param_col_msg.h | 46 ++++-- src/vt/vrt/collection/send/sendable.impl.h | 3 +- 10 files changed, 266 insertions(+), 34 deletions(-) create mode 100644 src/vt/messaging/param_msg.impl.h diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index 9901166fa3..ca0c9b30d1 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -766,7 +766,8 @@ struct ActiveMessenger : runtime::component::PollableComponent PendingSendType send(Node dest, Params&&... params) { using Tuple = typename FuncTraits::TupleType; using MsgT = ParamMsg; - auto msg = vt::makeMessage(std::forward(params)...); + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); auto han = auto_registry::makeAutoHandlerParam(); return sendMsg(dest.get(), han, msg, no_tag); } @@ -782,7 +783,8 @@ struct ActiveMessenger : runtime::component::PollableComponent PendingSendType broadcast(Params&&... params) { using Tuple = typename FuncTraits::TupleType; using MsgT = ParamMsg; - auto msg = vt::makeMessage(std::forward(params)...); + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); auto han = auto_registry::makeAutoHandlerParam(); constexpr bool deliver_to_sender = true; return broadcastMsg(han, msg, deliver_to_sender, no_tag); diff --git a/src/vt/messaging/active.impl.h b/src/vt/messaging/active.impl.h index 610b8ece67..2cb263f9ea 100644 --- a/src/vt/messaging/active.impl.h +++ b/src/vt/messaging/active.impl.h @@ -512,4 +512,6 @@ inline EpochType ActiveMessenger::setupEpochMsg(MsgSharedPtr const& msg) { }} //end namespace vt::messaging +#include "vt/messaging/param_msg.impl.h" + #endif /*INCLUDED_VT_MESSAGING_ACTIVE_IMPL_H*/ diff --git a/src/vt/messaging/param_msg.h b/src/vt/messaging/param_msg.h index d3e7c25087..6703362382 100644 --- a/src/vt/messaging/param_msg.h +++ b/src/vt/messaging/param_msg.h @@ -46,7 +46,101 @@ #include "vt/messaging/message/message_serialize.h" -namespace vt { namespace messaging { +namespace vt { + +struct MsgProps { + + MsgProps() = default; + + MsgProps&& asLocationMsg(bool set = true) { + as_location_msg_ = set; + return std::move(*this); + } + + MsgProps&& asTerminationMsg(bool set = true) { + as_termination_msg_ = set; + return std::move(*this); + } + + MsgProps&& asCollectionMsg(bool set = true) { + as_collection_msg_ = set; + return std::move(*this); + } + + MsgProps&& asSerializationMsg(bool set = true) { + as_serial_msg_ = set; + return std::move(*this); + } + + MsgProps&& withEpoch(EpochType in_ep) { + ep_ = in_ep; + return std::move(*this); + } + + MsgProps&& withPriority(PriorityType in_priority) { +#if vt_check_enabled(priorities) + priority_ = in_priority; +#endif + return std::move(*this); + } + + MsgProps&& withPriorityLevel(PriorityLevelType in_priority_level) { +#if vt_check_enabled(priorities) + priority_level_ = in_priority_level; +#endif + return std::move(*this); + } + + template + void apply(MsgT& msg); + +private: + bool as_location_msg_ = false; + bool as_termination_msg_ = false; + bool as_serial_msg_ = false; + bool as_collection_msg_ = false; + EpochType ep_ = no_epoch; + PriorityType priority_ = no_priority; + PriorityLevelType priority_level_ = no_priority_level; +}; + +} /* end namespace vt */ + +namespace vt::messaging::detail { + +template +struct GetTraits; + +template <> +struct GetTraits>> { + using TupleType = std::tuple<>; +}; + +template +struct GetTraits< + std::enable_if_t>, Param, Params... +> { + using TupleType = std::tuple; +}; + +template +struct GetTraits< + std::enable_if_t>, Param, Params... +> { + using TupleType = std::tuple; +}; + +template +struct GetTraitsTuple; + +template +struct GetTraitsTuple> { + using TupleType = typename GetTraits::TupleType; +}; + +} /* end namespace vt::messaging::detail */ + +namespace vt::messaging { template struct ParamMsg; @@ -56,15 +150,24 @@ struct ParamMsg< Tuple, std::enable_if_t::value> > : vt::Message { + using TupleType = typename detail::GetTraitsTuple::TupleType; + ParamMsg() = default; - template - explicit ParamMsg(Params&&... in_params) - : params(std::forward(in_params)...) - { } + void setParams() { } + + template + void setParams(Param&& p, Params&&... in_params) { + if constexpr (std::is_same_v) { + params = TupleType{std::forward(in_params)...}; + p.apply(*this); + } else { + params = TupleType{std::forward(p), std::forward(in_params)...}; + } + } - Tuple params; - Tuple& getTuple() { return params; } + TupleType params; + TupleType& getTuple() { return params; } }; template @@ -75,16 +178,29 @@ struct ParamMsg< using MessageParentType = vt::Message; vt_msg_serialize_if_needed_by_parent_or_type1(Tuple); // by tup + using TupleType = typename detail::GetTraitsTuple::TupleType; + ParamMsg() = default; - template - explicit ParamMsg(Params&&... in_params) - : params(std::make_unique(std::forward(in_params)...)) - { } + void setParams() { + params = std::make_unique(); + } + + template + void setParams(Param&& p, Params&&... in_params) { + if constexpr (std::is_same_v) { + params = std::make_unique(std::forward(in_params)...); + p.apply(*this); + } else { + params = std::make_unique( + std::forward(p), std::forward(in_params)... + ); + } + } - std::unique_ptr params; + std::unique_ptr params; - Tuple& getTuple() { return *params.get(); } + TupleType& getTuple() { return *params.get(); } template void serialize(SerializerT& s) { @@ -93,6 +209,6 @@ struct ParamMsg< } }; -}} /* end namespace vt::messaging */ +} /* end namespace vt::messaging */ #endif /*INCLUDED_VT_MESSAGING_PARAM_MSG_H*/ diff --git a/src/vt/messaging/param_msg.impl.h b/src/vt/messaging/param_msg.impl.h new file mode 100644 index 0000000000..5fb254b6a2 --- /dev/null +++ b/src/vt/messaging/param_msg.impl.h @@ -0,0 +1,81 @@ +/* +//@HEADER +// ***************************************************************************** +// +// param_msg.impl.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_IMPL_H +#define INCLUDED_VT_MESSAGING_PARAM_MSG_IMPL_H + +#include "vt/messaging/param_msg.h" + +namespace vt { + +template +void MsgProps::apply(MsgT& msg) { + if (as_location_msg_) { + theMsg()->markAsLocationMessage(msg); + } + if (as_termination_msg_) { + theMsg()->markAsTermMessage(msg); + } + if (as_serial_msg_) { + theMsg()->markAsSerialMsgMessage(msg); + } + if (as_collection_msg_) { + theMsg()->markAsCollectionMessage(msg); + } + if (ep_ != no_epoch) { + envelopeSetEpoch(msg->env, ep_); + } +#if vt_check_enabled(priorities) + if (priority_ != no_priority) { + envelopeSetPriority(msg->env, priority_); + } + if (priority_level_ != no_priority_level) { + envelopeSetPriorityLevel(msg->env, priority_level_); + } +#endif +} + +} /* end namespace vt */ + +#endif /*INCLUDED_VT_MESSAGING_PARAM_MSG_IMPL_H*/ + diff --git a/src/vt/objgroup/proxy/proxy_objgroup.impl.h b/src/vt/objgroup/proxy/proxy_objgroup.impl.h index 906e6d0738..9d06f014e2 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup.impl.h +++ b/src/vt/objgroup/proxy/proxy_objgroup.impl.h @@ -94,7 +94,8 @@ Proxy::broadcast(Params&&... params) const { if constexpr (std::is_same_v) { using Tuple = typename ObjFuncTraits::TupleType; using SendMsgT = messaging::ParamMsg; - auto msg = vt::makeMessage(std::forward(params)...); + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); auto const ctrl = proxy::ObjGroupProxy::getID(proxy_); auto const han = auto_registry::makeAutoHandlerObjGroupParam< ObjT, decltype(f), f, SendMsgT diff --git a/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h b/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h index dccd7b4f09..ec0eda110e 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h +++ b/src/vt/objgroup/proxy/proxy_objgroup_elm.impl.h @@ -85,7 +85,8 @@ ProxyElm::send(Params&&... params) const { if constexpr (std::is_same_v) { using Tuple = typename ObjFuncTraits::TupleType; using SendMsgT = messaging::ParamMsg; - auto msg = vt::makeMessage(std::forward(params)...); + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); auto const ctrl = proxy::ObjGroupProxy::getID(proxy_); auto const han = auto_registry::makeAutoHandlerObjGroupParam< ObjT, decltype(f), f, SendMsgT diff --git a/src/vt/pipe/callback/cb_union/cb_raw_base.h b/src/vt/pipe/callback/cb_union/cb_raw_base.h index 9eb619865c..f5ecec165a 100644 --- a/src/vt/pipe/callback/cb_union/cb_raw_base.h +++ b/src/vt/pipe/callback/cb_union/cb_raw_base.h @@ -234,7 +234,8 @@ struct CallbackTyped : CallbackRawBaseSingle { void sendTuple(std::tuple tup) { using Trait = CBTraits; using MsgT = messaging::ParamMsg; - auto msg = vt::makeMessage(std::move(tup)); + auto msg = vt::makeMessage(); + msg->setParams(std::move(tup)); CallbackRawBaseSingle::sendMsg(msg); } @@ -243,7 +244,8 @@ struct CallbackTyped : CallbackRawBaseSingle { using Trait = CBTraits; if constexpr (std::is_same_v) { using MsgT = messaging::ParamMsg; - auto msg = vt::makeMessage(std::forward(params)...); + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); CallbackRawBaseSingle::sendMsg(msg); } else { using MsgT = typename Trait::MsgT; diff --git a/src/vt/vrt/collection/broadcast/broadcastable.impl.h b/src/vt/vrt/collection/broadcast/broadcastable.impl.h index f48672da5e..bad98d2f69 100644 --- a/src/vt/vrt/collection/broadcast/broadcastable.impl.h +++ b/src/vt/vrt/collection/broadcast/broadcastable.impl.h @@ -185,7 +185,8 @@ Broadcastable::broadcast(Params&&... params) const { if constexpr (std::is_same_v) { using Tuple = typename ObjFuncTraits::TupleType; using SendMsgT = ParamColMsg; - auto msg = vt::makeMessage(std::forward(params)...); + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); auto han = auto_registry::makeAutoHandlerCollectionMemParam< ColT, decltype(f), f, SendMsgT >(); @@ -210,7 +211,8 @@ Broadcastable::broadcastCollective(Params&&... params) if constexpr (std::is_same_v) { using Tuple = typename ObjFuncTraits::TupleType; using SendMsgT = ParamColMsg; - auto msg = vt::makeMessage(std::forward(params)...); + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); auto han = auto_registry::makeAutoHandlerCollectionMemParam< ColT, decltype(f), f, SendMsgT >(); diff --git a/src/vt/vrt/collection/messages/param_col_msg.h b/src/vt/vrt/collection/messages/param_col_msg.h index 7c6cfbdd39..ff8dd05bd2 100644 --- a/src/vt/vrt/collection/messages/param_col_msg.h +++ b/src/vt/vrt/collection/messages/param_col_msg.h @@ -46,6 +46,7 @@ #include "vt/vrt/collection/messages/user.h" #include "vt/messaging/message/message_serialize.h" +#include "vt/messaging/param_msg.h" namespace vt { namespace vrt { namespace collection { @@ -58,15 +59,25 @@ struct ParamColMsg< ColT, std::enable_if_t::value> > : CollectionMessage { + + using TupleType = typename messaging::detail::GetTraitsTuple::TupleType; + ParamColMsg() = default; - template - explicit ParamColMsg(Params&&... in_params) - : params(std::forward(in_params)...) - { } + void setParams() { } + + template + void setParams(Param&& p, Params&&... in_params) { + if constexpr (std::is_same_v) { + params = TupleType{std::forward(in_params)...}; + p.apply(*this); + } else { + params = TupleType{std::forward(p), std::forward(in_params)...}; + } + } - Tuple params; - Tuple& getTuple() { return params; } + TupleType params; + TupleType& getTuple() { return params; } }; template @@ -78,16 +89,29 @@ struct ParamColMsg< using MessageParentType = CollectionMessage; vt_msg_serialize_if_needed_by_parent_or_type1(Tuple); // by params + using TupleType = typename messaging::detail::GetTraitsTuple::TupleType; + ParamColMsg() = default; - template - explicit ParamColMsg(Params&&... in_params) - : params(std::make_unique(std::forward(in_params)...)) - { } + void setParams() { + params = std::make_unique(); + } + + template + void setParams(Param&& p, Params&&... in_params) { + if constexpr (std::is_same_v) { + params = std::make_unique(std::forward(in_params)...); + p.apply(*this); + } else { + params = std::make_unique( + std::forward(p), std::forward(in_params)... + ); + } + } std::unique_ptr params; - Tuple& getTuple() { return *params.get(); } + TupleType& getTuple() { return *params.get(); } template void serialize(SerializerT& s) { diff --git a/src/vt/vrt/collection/send/sendable.impl.h b/src/vt/vrt/collection/send/sendable.impl.h index 9118a84884..3a200a5424 100644 --- a/src/vt/vrt/collection/send/sendable.impl.h +++ b/src/vt/vrt/collection/send/sendable.impl.h @@ -139,7 +139,8 @@ messaging::PendingSend Sendable::send(Params&&... params if constexpr (std::is_same_v) { using Tuple = typename FnTrait::TupleType; using SendMsgT = ParamColMsg; - auto msg = vt::makeMessage(std::forward(params)...); + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); auto han = auto_registry::makeAutoHandlerCollectionMemParam< ColT, decltype(f), f, SendMsgT >(); From 96689ecff0b947b4eedb35b306e52340613287ae Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 7 Nov 2023 17:21:46 -0800 Subject: [PATCH 03/12] #2212: param: fix call which should be a pointer --- src/vt/messaging/param_msg.h | 4 ++-- src/vt/vrt/collection/messages/param_col_msg.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vt/messaging/param_msg.h b/src/vt/messaging/param_msg.h index 6703362382..fef13e75ee 100644 --- a/src/vt/messaging/param_msg.h +++ b/src/vt/messaging/param_msg.h @@ -160,7 +160,7 @@ struct ParamMsg< void setParams(Param&& p, Params&&... in_params) { if constexpr (std::is_same_v) { params = TupleType{std::forward(in_params)...}; - p.apply(*this); + p.apply(this); } else { params = TupleType{std::forward(p), std::forward(in_params)...}; } @@ -190,7 +190,7 @@ struct ParamMsg< void setParams(Param&& p, Params&&... in_params) { if constexpr (std::is_same_v) { params = std::make_unique(std::forward(in_params)...); - p.apply(*this); + p.apply(this); } else { params = std::make_unique( std::forward(p), std::forward(in_params)... diff --git a/src/vt/vrt/collection/messages/param_col_msg.h b/src/vt/vrt/collection/messages/param_col_msg.h index ff8dd05bd2..47d4972424 100644 --- a/src/vt/vrt/collection/messages/param_col_msg.h +++ b/src/vt/vrt/collection/messages/param_col_msg.h @@ -70,7 +70,7 @@ struct ParamColMsg< void setParams(Param&& p, Params&&... in_params) { if constexpr (std::is_same_v) { params = TupleType{std::forward(in_params)...}; - p.apply(*this); + p.apply(this); } else { params = TupleType{std::forward(p), std::forward(in_params)...}; } @@ -101,7 +101,7 @@ struct ParamColMsg< void setParams(Param&& p, Params&&... in_params) { if constexpr (std::is_same_v) { params = std::make_unique(std::forward(in_params)...); - p.apply(*this); + p.apply(this); } else { params = std::make_unique( std::forward(p), std::forward(in_params)... From 554734202c2e4e3be58a1bb22961bcc7a03d312a Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 7 Nov 2023 17:22:18 -0800 Subject: [PATCH 04/12] #2212: tests: add a simple test for message properties --- src/vt/messaging/pending_send.h | 9 +++++++++ tests/unit/active/test_active_send.cc | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/vt/messaging/pending_send.h b/src/vt/messaging/pending_send.h index 8c83be82bc..c081363fb9 100644 --- a/src/vt/messaging/pending_send.h +++ b/src/vt/messaging/pending_send.h @@ -153,6 +153,15 @@ struct PendingSend final { */ void release(); + /** + * \internal \brief Get the message stored in the pending send + * + * \note Used for testing purposes + * + * \return a reference to the message + */ + MsgPtr& getMsg() { return msg_; } + private: /** diff --git a/tests/unit/active/test_active_send.cc b/tests/unit/active/test_active_send.cc index 8313daf0fe..5d6367b430 100644 --- a/tests/unit/active/test_active_send.cc +++ b/tests/unit/active/test_active_send.cc @@ -242,4 +242,21 @@ TEST_F(TestActiveSend, test_active_message_serialization) { EXPECT_EQ(handler_count, num_msg_sent); } +void testPropertiesHandler(int a, double b) { + // do nothing +} + +TEST_F(TestActiveSend, test_active_message_properties) { + auto const this_node = theContext()->getNode(); + auto const num_nodes = theContext()->getNumNodes(); + NodeType const next_node = (this_node + 1) % num_nodes; + + if (num_nodes > 1) { + auto ps = theMsg()->send( + vt::Node{next_node}, MsgProps().asTerminationMsg(), 10, 20.0 + ); + EXPECT_TRUE(messaging::envelopeIsTerm(ps.getMsg()->env)); + } +} + }}}} // end namespace vt::tests::unit::send From 65a334d883aef62864cc3d50cf2a71fb8f990417 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 7 Nov 2023 17:24:18 -0800 Subject: [PATCH 05/12] #2212: param: remove reference --- src/vt/messaging/param_msg.h | 4 ++-- src/vt/messaging/param_msg.impl.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vt/messaging/param_msg.h b/src/vt/messaging/param_msg.h index fef13e75ee..e1ec3fc7f9 100644 --- a/src/vt/messaging/param_msg.h +++ b/src/vt/messaging/param_msg.h @@ -91,8 +91,8 @@ struct MsgProps { return std::move(*this); } - template - void apply(MsgT& msg); + template + void apply(MsgPtrT msg); private: bool as_location_msg_ = false; diff --git a/src/vt/messaging/param_msg.impl.h b/src/vt/messaging/param_msg.impl.h index 5fb254b6a2..940e44372d 100644 --- a/src/vt/messaging/param_msg.impl.h +++ b/src/vt/messaging/param_msg.impl.h @@ -48,8 +48,8 @@ namespace vt { -template -void MsgProps::apply(MsgT& msg) { +template +void MsgProps::apply(MsgPtrT msg) { if (as_location_msg_) { theMsg()->markAsLocationMessage(msg); } From 7283a21c34088393247e77a2867f4c6355ff9f87 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 8 Nov 2023 08:36:41 -0800 Subject: [PATCH 06/12] #2212: param: fix unused variable warnings --- src/vt/messaging/param_msg.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vt/messaging/param_msg.h b/src/vt/messaging/param_msg.h index e1ec3fc7f9..49f0ec05e6 100644 --- a/src/vt/messaging/param_msg.h +++ b/src/vt/messaging/param_msg.h @@ -100,8 +100,10 @@ struct MsgProps { bool as_serial_msg_ = false; bool as_collection_msg_ = false; EpochType ep_ = no_epoch; +#if vt_check_enabled(priorities) PriorityType priority_ = no_priority; PriorityLevelType priority_level_ = no_priority_level; +#endif }; } /* end namespace vt */ From 5268dfcda9a59b892081500fe49082247c87d54c Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 8 Nov 2023 11:04:56 -0800 Subject: [PATCH 07/12] #2212: param: remove blank line --- src/vt/messaging/param_msg.impl.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vt/messaging/param_msg.impl.h b/src/vt/messaging/param_msg.impl.h index 940e44372d..51d3437005 100644 --- a/src/vt/messaging/param_msg.impl.h +++ b/src/vt/messaging/param_msg.impl.h @@ -78,4 +78,3 @@ void MsgProps::apply(MsgPtrT msg) { } /* end namespace vt */ #endif /*INCLUDED_VT_MESSAGING_PARAM_MSG_IMPL_H*/ - From e7efdac60173df9a68e9c254390b3e8fbd205e2a Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 9 Nov 2023 09:20:38 -0800 Subject: [PATCH 08/12] #2212: param: modify new multicast to use setParams --- src/vt/objgroup/proxy/proxy_objgroup.impl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vt/objgroup/proxy/proxy_objgroup.impl.h b/src/vt/objgroup/proxy/proxy_objgroup.impl.h index 9d06f014e2..7a3448de28 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup.impl.h +++ b/src/vt/objgroup/proxy/proxy_objgroup.impl.h @@ -118,7 +118,8 @@ Proxy::multicast(GroupType type, Params&&... params) const{ if constexpr (std::is_same_v) { using Tuple = typename ObjFuncTraits::TupleType; using SendMsgT = messaging::ParamMsg; - auto msg = vt::makeMessage(std::forward(params)...); + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); vt::envelopeSetGroup(msg->env, type); auto const ctrl = proxy::ObjGroupProxy::getID(proxy_); auto const han = auto_registry::makeAutoHandlerObjGroupParam< From dc81d4e8d56dd2e1cbe201d06c920694159705c1 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 29 Nov 2023 13:36:41 -0800 Subject: [PATCH 09/12] #2212: param: fix missing decay_t causing lack of detection of properties --- src/vt/messaging/param_msg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vt/messaging/param_msg.h b/src/vt/messaging/param_msg.h index 49f0ec05e6..1ad19f0f5c 100644 --- a/src/vt/messaging/param_msg.h +++ b/src/vt/messaging/param_msg.h @@ -160,7 +160,7 @@ struct ParamMsg< template void setParams(Param&& p, Params&&... in_params) { - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v, MsgProps>) { params = TupleType{std::forward(in_params)...}; p.apply(this); } else { @@ -190,7 +190,7 @@ struct ParamMsg< template void setParams(Param&& p, Params&&... in_params) { - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v, MsgProps>) { params = std::make_unique(std::forward(in_params)...); p.apply(this); } else { From 05bb801f25bf887af54195fbedc6a1416375aa8a Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 29 Nov 2023 13:38:05 -0800 Subject: [PATCH 10/12] #2212: callback: stop using CBTrait for params which misses the MsgProps --- src/vt/pipe/callback/cb_union/cb_raw_base.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/vt/pipe/callback/cb_union/cb_raw_base.h b/src/vt/pipe/callback/cb_union/cb_raw_base.h index f5ecec165a..36d2c3f5a6 100644 --- a/src/vt/pipe/callback/cb_union/cb_raw_base.h +++ b/src/vt/pipe/callback/cb_union/cb_raw_base.h @@ -232,8 +232,7 @@ struct CallbackTyped : CallbackRawBaseSingle { template void sendTuple(std::tuple tup) { - using Trait = CBTraits; - using MsgT = messaging::ParamMsg; + using MsgT = messaging::ParamMsg...>>; auto msg = vt::makeMessage(); msg->setParams(std::move(tup)); CallbackRawBaseSingle::sendMsg(msg); @@ -243,7 +242,7 @@ struct CallbackTyped : CallbackRawBaseSingle { void send(Params&&... params) { using Trait = CBTraits; if constexpr (std::is_same_v) { - using MsgT = messaging::ParamMsg; + using MsgT = messaging::ParamMsg...>>; auto msg = vt::makeMessage(); msg->setParams(std::forward(params)...); CallbackRawBaseSingle::sendMsg(msg); From ae4bae5b3c5aa0d7a2967ec1165b5afbc36abad5 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 29 Nov 2023 15:45:07 -0800 Subject: [PATCH 11/12] #2212: callback: fix problem with Args/Params conflict incorrect message type --- src/vt/pipe/callback/cb_union/cb_raw_base.h | 31 +++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/vt/pipe/callback/cb_union/cb_raw_base.h b/src/vt/pipe/callback/cb_union/cb_raw_base.h index 36d2c3f5a6..b0a337453d 100644 --- a/src/vt/pipe/callback/cb_union/cb_raw_base.h +++ b/src/vt/pipe/callback/cb_union/cb_raw_base.h @@ -232,7 +232,8 @@ struct CallbackTyped : CallbackRawBaseSingle { template void sendTuple(std::tuple tup) { - using MsgT = messaging::ParamMsg...>>; + using Trait = CBTraits; + using MsgT = messaging::ParamMsg; auto msg = vt::makeMessage(); msg->setParams(std::move(tup)); CallbackRawBaseSingle::sendMsg(msg); @@ -242,10 +243,30 @@ struct CallbackTyped : CallbackRawBaseSingle { void send(Params&&... params) { using Trait = CBTraits; if constexpr (std::is_same_v) { - using MsgT = messaging::ParamMsg...>>; - auto msg = vt::makeMessage(); - msg->setParams(std::forward(params)...); - CallbackRawBaseSingle::sendMsg(msg); + // We have to go through some tricky code to make the MsgProps case work + // If we use the type for Params to send, it's possible that we have a + // type mismatch in the actual handler type. A possible edge case is when + // a char const* is sent, but the handler is a std::string. In this case, + // the ParamMsg will be cast incorrectly during the virual dispatch to a + // collection because callbacks don't have the collection type. Thus, the + // wrong ParamMsg will be cast to which requires serialization, leading to + // a failure. + if constexpr (sizeof...(Params) == sizeof...(Args) + 1) { + using MsgT = messaging::ParamMsg< + std::tuple< + std::decay_t>>, + std::decay_t... + > + >; + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); + CallbackRawBaseSingle::sendMsg(msg); + } else { + using MsgT = messaging::ParamMsg; + auto msg = vt::makeMessage(); + msg->setParams(std::forward(params)...); + CallbackRawBaseSingle::sendMsg(msg); + } } else { using MsgT = typename Trait::MsgT; auto msg = makeMessage(std::forward(params)...); From e38bed277872e3ff034ce23adc2e90948cc13778 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 29 Nov 2023 17:26:26 -0800 Subject: [PATCH 12/12] #2212: collection: add decay_t for collection parameterized messages --- src/vt/vrt/collection/messages/param_col_msg.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vt/vrt/collection/messages/param_col_msg.h b/src/vt/vrt/collection/messages/param_col_msg.h index 47d4972424..c6c04c51f8 100644 --- a/src/vt/vrt/collection/messages/param_col_msg.h +++ b/src/vt/vrt/collection/messages/param_col_msg.h @@ -68,7 +68,7 @@ struct ParamColMsg< template void setParams(Param&& p, Params&&... in_params) { - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v, MsgProps>) { params = TupleType{std::forward(in_params)...}; p.apply(this); } else { @@ -99,7 +99,7 @@ struct ParamColMsg< template void setParams(Param&& p, Params&&... in_params) { - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v, MsgProps>) { params = std::make_unique(std::forward(in_params)...); p.apply(this); } else {