From 92c5084ffe2cb00300c5a0201fc597f87218c658 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Fri, 4 Dec 2020 12:37:00 -0700 Subject: [PATCH] #728: Overload templates rather than instantiating in default argument to avoid ICE in Intel 19.x --- src/vt/collective/reduce/reduce.h | 136 +++++++++++++++++++- src/vt/objgroup/proxy/proxy_objgroup.h | 46 +++++-- src/vt/vrt/collection/reducable/reducable.h | 41 ++++-- 3 files changed, 203 insertions(+), 20 deletions(-) diff --git a/src/vt/collective/reduce/reduce.h b/src/vt/collective/reduce/reduce.h index 64c93e3626..ccd7a60a3e 100644 --- a/src/vt/collective/reduce/reduce.h +++ b/src/vt/collective/reduce/reduce.h @@ -87,9 +87,7 @@ struct Reduce : virtual collective::tree::Tree { template < typename OpT, typename MsgT, - ActiveTypedFnType *f = MsgT::template msgHandler< - MsgT, OpT, collective::reduce::operators::ReduceCallback - > + ActiveTypedFnType *f > SequentialIDType reduce( NodeType const& root, MsgT* msg, Callback cb, @@ -98,18 +96,148 @@ struct Reduce : virtual collective::tree::Tree { VirtualProxyType const& proxy = no_vrt_proxy, ObjGroupProxyType objgroup = no_obj_group ); + template < + typename OpT, + typename MsgT + > + PendingSendType reduce( + NodeType const& root, MsgT* msg, Callback cb, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType const& num_contrib = 1 + ) + { + return reduce< + OpT, + MsgT, + MsgT::template msgHandler< + MsgT, + OpT, + collective::reduce::operators::ReduceCallback + > + >(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 < + typename OpT, + typename MsgT, + ActiveTypedFnType *f + > + detail::ReduceStamp reduceImmediate( + NodeType const& root, MsgT* msg, Callback cb, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType const& num_contrib = 1 + ); + template < + typename OpT, + typename MsgT + > + detail::ReduceStamp reduceImmediate( + NodeType const& root, MsgT* msg, Callback cb, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType const& num_contrib = 1 + ) + { + return reduceImmediate< + OpT, + MsgT, + MsgT::template msgHandler< + MsgT, + OpT, + collective::reduce::operators::ReduceCallback + > + >(root, msg, cb, 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, + typename MsgT, + ActiveTypedFnType *f + > + PendingSendType reduce( + NodeType const& root, MsgT* msg, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType const& num_contrib = 1 + ); + template < + typename OpT, + typename FunctorT, + typename MsgT + > + PendingSendType reduce( + NodeType const& root, MsgT* msg, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType const& num_contrib = 1 + ) + { + return reduce< + OpT, + FunctorT, + MsgT, + MsgT::template msgHandler + >(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, typename MsgT, - ActiveTypedFnType *f = MsgT::template msgHandler + ActiveTypedFnType *f > SequentialIDType reduce( NodeType const& root, MsgT* msg, TagType const& tag = no_tag, SequentialIDType const& seq = no_seq_id, ReduceNumType const& num_contrib = 1, VirtualProxyType const& proxy = no_vrt_proxy ); + template < + typename OpT, + typename FunctorT, + typename MsgT + > + detail::ReduceStamp reduceImmediate( + NodeType const& root, MsgT* msg, + detail::ReduceStamp id = detail::ReduceStamp{}, + ReduceNumType const& num_contrib = 1 + ) + { + return reduceImmediate< + OpT, + FunctorT, + MsgT, + MsgT::template msgHandler + >(root, msg, id, num_contrib); + } template void reduceAddMsg( diff --git a/src/vt/objgroup/proxy/proxy_objgroup.h b/src/vt/objgroup/proxy/proxy_objgroup.h index 5772125b74..4ee44ed090 100644 --- a/src/vt/objgroup/proxy/proxy_objgroup.h +++ b/src/vt/objgroup/proxy/proxy_objgroup.h @@ -89,26 +89,56 @@ struct Proxy { template < typename OpT = collective::None, typename MsgPtrT, - typename MsgT = typename util::MsgPtrType::MsgType, - ActiveTypedFnType *f = MsgT::template msgHandler< - MsgT, OpT, collective::reduce::operators::ReduceCallback - > + typename MsgT, + ActiveTypedFnType *f > EpochType reduce( MsgPtrT msg, Callback cb, EpochType epoch = no_epoch, TagType tag = no_tag ) const; + template < + typename OpT = collective::None, + typename MsgPtrT, + typename MsgT = typename util::MsgPtrType::MsgType + > + PendingSendType reduce( + MsgPtrT msg, Callback cb, ReduceStamp stamp = ReduceStamp{} + ) const + { + return reduce< + OpT, + MsgPtrT, + MsgT, + MsgT::template msgHandler< + MsgT, OpT, collective::reduce::operators::ReduceCallback + > + >(msg, cb, stamp); + } template < typename OpT = collective::None, typename FunctorT, typename MsgPtrT, typename MsgT = typename util::MsgPtrType::MsgType, - ActiveTypedFnType *f = MsgT::template msgHandler + ActiveTypedFnType *f > - EpochType reduce( - MsgPtrT msg, EpochType epoch = no_epoch, TagType tag = no_tag - ) const; + PendingSendType reduce(MsgPtrT msg, ReduceStamp stamp = ReduceStamp{}) const; + template < + typename OpT = collective::None, + typename FunctorT, + typename MsgPtrT, + typename MsgT = typename util::MsgPtrType::MsgType + > + PendingSendType reduce(MsgPtrT msg, ReduceStamp stamp = ReduceStamp{}) const + { + return reduce< + OpT, + FunctorT, + MsgPtrT, + MsgT, + MsgT::template msgHandler + >(msg, stamp); + } template < typename MsgPtrT, diff --git a/src/vt/vrt/collection/reducable/reducable.h b/src/vt/vrt/collection/reducable/reducable.h index f77e6e1e2b..ebe4cde9ef 100644 --- a/src/vt/vrt/collection/reducable/reducable.h +++ b/src/vt/vrt/collection/reducable/reducable.h @@ -70,25 +70,50 @@ struct Reducable : BaseProxyT { template < typename OpT = collective::None, typename MsgT, - ActiveTypedFnType *f = MsgT::template msgHandler< - MsgT, OpT, collective::reduce::operators::ReduceCallback - > + ActiveTypedFnType *f > EpochType reduce( MsgT *const msg, Callback cb, EpochType const& epoch = no_epoch, TagType const& tag = no_tag ) const; + template < + typename OpT = collective::None, + typename MsgT + > + messaging::PendingSend reduce( + MsgT *const msg, Callback cb, ReduceStamp stamp = ReduceStamp{} + ) const + { + return reduce< + OpT, + MsgT, + MsgT::template msgHandler< + MsgT, OpT, collective::reduce::operators::ReduceCallback + > + >(msg, cb, stamp); + } template < typename OpT, typename FunctorT, typename MsgT, - ActiveTypedFnType *f = MsgT::template msgHandler + ActiveTypedFnType *f > - EpochType reduce( - MsgT *const msg, EpochType const& epoch = no_epoch, - TagType const& tag = no_tag - ) const; + messaging::PendingSend reduce(MsgT *const msg, ReduceStamp stamp = ReduceStamp{}) const; + template < + typename OpT, + typename FunctorT, + typename MsgT + > + messaging::PendingSend reduce(MsgT *const msg, ReduceStamp stamp = ReduceStamp{}) const + { + return reduce< + OpT, + FunctorT, + MsgT, + MsgT::template msgHandler + >(msg, stamp); + } template *f> EpochType reduce(