Skip to content

Commit

Permalink
#728: Overload templates rather than instantiating in default argumen…
Browse files Browse the repository at this point in the history
…t to avoid ICE in Intel 19.x
  • Loading branch information
PhilMiller authored and cz4rs committed Dec 21, 2020
1 parent 7290bec commit 92c5084
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 20 deletions.
136 changes: 132 additions & 4 deletions src/vt/collective/reduce/reduce.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ struct Reduce : virtual collective::tree::Tree {
template <
typename OpT,
typename MsgT,
ActiveTypedFnType<MsgT> *f = MsgT::template msgHandler<
MsgT, OpT, collective::reduce::operators::ReduceCallback<MsgT>
>
ActiveTypedFnType<MsgT> *f
>
SequentialIDType reduce(
NodeType const& root, MsgT* msg, Callback<MsgT> cb,
Expand All @@ -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<MsgT> cb,
detail::ReduceStamp id = detail::ReduceStamp{},
ReduceNumType const& num_contrib = 1
)
{
return reduce<
OpT,
MsgT,
MsgT::template msgHandler<
MsgT,
OpT,
collective::reduce::operators::ReduceCallback<MsgT>
>
>(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<MsgT> *f
>
detail::ReduceStamp reduceImmediate(
NodeType const& root, MsgT* msg, Callback<MsgT> 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<MsgT> cb,
detail::ReduceStamp id = detail::ReduceStamp{},
ReduceNumType const& num_contrib = 1
)
{
return reduceImmediate<
OpT,
MsgT,
MsgT::template msgHandler<
MsgT,
OpT,
collective::reduce::operators::ReduceCallback<MsgT>
>
>(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<MsgT> *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<MsgT, OpT, FunctorT>
>(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<MsgT> *f = MsgT::template msgHandler<MsgT, OpT, FunctorT>
ActiveTypedFnType<MsgT> *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<MsgT, OpT, FunctorT>
>(root, msg, id, num_contrib);
}

template <typename MessageT>
void reduceAddMsg(
Expand Down
46 changes: 38 additions & 8 deletions src/vt/objgroup/proxy/proxy_objgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,56 @@ struct Proxy {
template <
typename OpT = collective::None,
typename MsgPtrT,
typename MsgT = typename util::MsgPtrType<MsgPtrT>::MsgType,
ActiveTypedFnType<MsgT> *f = MsgT::template msgHandler<
MsgT, OpT, collective::reduce::operators::ReduceCallback<MsgT>
>
typename MsgT,
ActiveTypedFnType<MsgT> *f
>
EpochType reduce(
MsgPtrT msg, Callback<MsgT> cb, EpochType epoch = no_epoch,
TagType tag = no_tag
) const;
template <
typename OpT = collective::None,
typename MsgPtrT,
typename MsgT = typename util::MsgPtrType<MsgPtrT>::MsgType
>
PendingSendType reduce(
MsgPtrT msg, Callback<MsgT> cb, ReduceStamp stamp = ReduceStamp{}
) const
{
return reduce<
OpT,
MsgPtrT,
MsgT,
MsgT::template msgHandler<
MsgT, OpT, collective::reduce::operators::ReduceCallback<MsgT>
>
>(msg, cb, stamp);
}

template <
typename OpT = collective::None,
typename FunctorT,
typename MsgPtrT,
typename MsgT = typename util::MsgPtrType<MsgPtrT>::MsgType,
ActiveTypedFnType<MsgT> *f = MsgT::template msgHandler<MsgT, OpT, FunctorT>
ActiveTypedFnType<MsgT> *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<MsgPtrT>::MsgType
>
PendingSendType reduce(MsgPtrT msg, ReduceStamp stamp = ReduceStamp{}) const
{
return reduce<
OpT,
FunctorT,
MsgPtrT,
MsgT,
MsgT::template msgHandler<MsgT, OpT, FunctorT>
>(msg, stamp);
}

template <
typename MsgPtrT,
Expand Down
41 changes: 33 additions & 8 deletions src/vt/vrt/collection/reducable/reducable.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,50 @@ struct Reducable : BaseProxyT {
template <
typename OpT = collective::None,
typename MsgT,
ActiveTypedFnType<MsgT> *f = MsgT::template msgHandler<
MsgT, OpT, collective::reduce::operators::ReduceCallback<MsgT>
>
ActiveTypedFnType<MsgT> *f
>
EpochType reduce(
MsgT *const msg, Callback<MsgT> 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<MsgT> cb, ReduceStamp stamp = ReduceStamp{}
) const
{
return reduce<
OpT,
MsgT,
MsgT::template msgHandler<
MsgT, OpT, collective::reduce::operators::ReduceCallback<MsgT>
>
>(msg, cb, stamp);
}

template <
typename OpT,
typename FunctorT,
typename MsgT,
ActiveTypedFnType<MsgT> *f = MsgT::template msgHandler<MsgT, OpT, FunctorT>
ActiveTypedFnType<MsgT> *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<MsgT, OpT, FunctorT>
>(msg, stamp);
}

template <typename MsgT, ActiveTypedFnType<MsgT> *f>
EpochType reduce(
Expand Down

0 comments on commit 92c5084

Please sign in to comment.