Skip to content

Commit

Permalink
#672: docs: add page of theCollective
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Jun 16, 2020
1 parent a1005fe commit 5ae6be6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
42 changes: 42 additions & 0 deletions src/collective.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
\page collective Collectives
\brief Collective operations

The collective component `vt::collective::CollectiveAlg`, accessed via
`vt::theCollective()` implements active-message-based distributed collectives
over the \vt runtime. It performs asynchronous reductions, scatters, barriers,
and allows one to safely use MPI interspersed through \vt code, while running in
a handler.

\section collective-reduce-example A Simple Reduction

\code{.cpp}
#include <vt/transport.h>

// Reduce ints
struct ReduceDataMsg : ::vt::collective::ReduceTMsg<int> {};

// Handler to target for reduction
struct ReduceResult {
void operator()(ReduceDataMsg* msg) {
auto num_nodes = vt::theContext()->getNumNodes();
auto output = msg->getConstVal();
fmt::print("reduction value={}\n", output);
vtAssert(num_nodes * 50 == output, "Must be equal);
}
};

int main(int argc, char** argv) {
vt::initialize(argc, argv);

auto reduce_msg = vt::makeMessage<ReduceDataMsg>();
reduce_msg->getVal() = 50;

NodeType const root_reduce_node = 0;
vt::theCollective()->global()->reduce<vt::collective::PlusOp<int>,ReduceResult>(
root_reduce_node, reduce_msg.get()
);

vt::finalize(); // spins in scheduler until termination
return 0;
}
\endcode
9 changes: 5 additions & 4 deletions src/vt.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ management.

\section vt-components Components in vt

| Component | Singleton | Details |
| --------------------------- | ------------------- | --------------------------- |
| \subpage context | `vt::theContext()` | \copybrief context |
| \subpage active-messenger | `vt::theMsg()` | \copybrief active-messenger |
| Component | Singleton | Details |
| --------------------------- | --------------------- | --------------------------- |
| \subpage context | `vt::theContext()` | \copybrief context |
| \subpage active-messenger | `vt::theMsg()` | \copybrief active-messenger |
| \subpage collective | `vt::theCollective()` | \copybrief collective |

\section vt-hello-world Example

Expand Down

0 comments on commit 5ae6be6

Please sign in to comment.