Skip to content

Commit

Permalink
[doc] Update README.md to match changes in DIY
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzv committed Mar 6, 2017
1 parent 5a727f5 commit 56e0768
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions README.md
Expand Up @@ -11,7 +11,7 @@ possible in- and out-of-core in DIY.

## Licensing

DIY is released as open source software under a BSD style [license](./LICENSE.txt).
DIY is released as open source software under a BSD-style [license](./LICENSE.txt).

## Dependencies

Expand All @@ -26,7 +26,7 @@ DIY requires an MPI installation. We recommend [MPICH](http://www.mpich.org/).

DIY is a header-only library. It does not need to be built; you can simply
include it in your project. The examples can be built using `cmake` from the
top level directory.
top-level directory.

## Documentation

Expand All @@ -39,10 +39,10 @@ A simple DIY program, shown below, consists of the following components:
- `struct`s called blocks,
- a diy object called the `master`,
- a set of callback functions performed on each block by `master.foreach()`,
- optionally one or more message exchanges between the blocks by `master.exchange()`, and
- optionally, one or more message exchanges between the blocks by `master.exchange()`, and
- there may be other collectives and global reductions not shown below.

The callback functions (`enqueue_block()` and `average()` in the example below) are given the block
The callback functions (`enqueue_local()` and `average()` in the example below) receive the block
pointer and a communication proxy for the message exchange between blocks. It is usual for the
callback functions to enqueue or dequeue messages from the proxy, so that information can be
received and sent during rounds of message exchange.
Expand All @@ -54,31 +54,24 @@ received and sent during rounds of message exchange.

Master master(world); // world = MPI_Comm
... // populate master with blocks
master.foreach<Block>(&enqueue_local); // call enqueue_local() for each block
master.foreach(&enqueue_local); // call enqueue_local() for each block
master.exchange(); // exchange enqueued data between blocks
master.foreach<Block>(&average); // call average() for each block
master.foreach(&average); // call average() for each block

// --- callback functions --- //

// enqueue block data prior to exchanging it
void enqueue_local(Block* b, // one block
const Proxy& cp, // communication proxy
// i.e., the neighbor blocks with which
// this block communicates
void* aux) // user-defined additional arguments
void enqueue_local(Block* b, // current block
const Proxy& cp) // communication proxy provides access to the neighbor blocks
{
for (size_t i = 0; i < cp.link()->size(); i++) // for all neighbor blocks
cp.enqueue(cp.link()->target(i), b->local); // enqueue the data to be sent
// to this neighbor block in the next
// exchange
cp.enqueue(cp.link()->target(i), b->local); // enqueue the data to be sent to this neighbor
// block in the next exchange
}

// use the received data after exchanging it, in this case compute its average
void average(Block* b, // one block
const Proxy& cp, // communication proxy
// i.e., the neighbor blocks with which
// this block communicates
void* aux) // user-defined additional arguments
void average(Block* b, // current block
const Proxy& cp) // communication proxy provides access to the neighbor blocks
{
float x, average = 0;
for (size_t i = 0; i < cp.link()->size(); i++) // for all neighbor blocks
Expand Down

0 comments on commit 56e0768

Please sign in to comment.