Skip to content

Commit

Permalink
#276: active: finish up interface with extractor and modify example
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Jan 13, 2023
1 parent 12d1907 commit 1429af2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/hello_world/hello_world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main(int argc, char** argv) {

if (this_node == 0) {
auto msg = vt::makeMessage<HelloMsg>(this_node);
vt::theMsg()->broadcastMsg<HelloMsg, hello_world>(msg);
vt::theMsg()->broadcastMsg<hello_world>(msg);
}

vt::finalize();
Expand Down
47 changes: 45 additions & 2 deletions src/vt/messaging/active.h
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,37 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
TagType tag = no_tag
);

template <typename ReturnT, typename... Args>
struct FunctionTraits;

template <typename ReturnT, typename T>
struct FunctionTraits<ReturnT(*)(T*)> {
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 <auto f>
PendingSendType broadcastMsg(
MsgPtrThief<typename FunctionTraits<decltype(f)>::MsgT> msg,
bool deliver_to_sender = true,
TagType tag = no_tag
) {
using MsgT = typename FunctionTraits<decltype(f)>::MsgT;
return broadcastMsg<MsgT, f>(msg, deliver_to_sender, tag);
}

/**
* \brief Send a message.
*
Expand All @@ -704,12 +735,24 @@ struct ActiveMessenger : runtime::component::PollableComponent<ActiveMessenger>
TagType tag = no_tag
);

template <auto f, typename MsgT>
/**
* \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 <auto f>
PendingSendType sendMsg(
NodeType dest,
MsgPtrThief<MsgT> msg,
MsgPtrThief<typename FunctionTraits<decltype(f)>::MsgT> msg,
TagType tag = no_tag
) {
using MsgT = typename FunctionTraits<decltype(f)>::MsgT;
return sendMsg<MsgT, f>(dest, msg, tag);
}

Expand Down

0 comments on commit 1429af2

Please sign in to comment.