incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Hama Wiki] Trivial Update of "BSPModel" by edwardyoon
Date Tue, 15 Feb 2011 23:52:01 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hama Wiki" for change notification.

The "BSPModel" page has been changed by edwardyoon.
http://wiki.apache.org/hama/BSPModel

--------------------------------------------------

New page:
<<TableOfContents(5)>>

Hama provides a user-defined function “bsp()” that can be used to write your own BSP program.
The bsp() function handles whole parallel part of the program. (It means that the bsp() function
is not a iteration part of the program.) 
It takes one argument, which is a communication protocol interface. (Later, it'll take one
more arguments for input data and reporter, and so on.)

Basically, a BSP program consists of a sequence of supersteps. Each superstep consists of
the three phases:

 * Local computation
 * Process communication
 * Barrier synchronization

NOTE that these phases should be always sequential order. 


=== Communication ===

Within bsp() function, you can use the powerful communication functions for many purposes
using BSPPeerProtocol. We tried to follow the standard library of BSP world as much as possible.
The following table describes all the functions you can use:
||Function||Description||
||send(String peerName, BSPMessage msg)||Send a message to another peer.||
||put(BSPMessage msg)||Put a message to local queue.||
||getCurrentMessage()||Get a received message.||
||getNumCurrentMessages()||Get the number of received messages.||
||sync()||Barrier synchronization.||
||getPeerName()||Get a peer’s hostname.||
||getAllPeerNames()||Get all peer’s hostname.||

The send(), put() and the other all functions are very flexible. For example, you can send
one more messages on to any other processes in bsp() function:

{{{
  public void bsp(BSPPeerProtocol bspPeer) throws IOException,
        KeeperException, InterruptedException {
    for (String otherPeer : bspPeer.getAllPeerNames()) {
      String peerName = bspPeer.getPeerName();
      BSPMessage msg = 
        new BSPMessage(Bytes.toBytes(peerName), Bytes.toBytes(“Hi”));
      bspPeer.send(peerName, mgs);
    }
  bspPeer.sync();
}
}}}

=== Synchronization ===

When all processes have entered the barrier by sync() function, the Hama proceeds to the next
superstep. In previous example case, the BSP job will be finished by one synchronization after
sending a message “Hi” to all peers.

But, keep in mind that the sync() function not means the end of BSP job. As mentioned previously,
the all communication functions are very flexible. For example, the sync() function can be
also located in a for loop:

{{{
public void bsp(BSPPeerProtocol bspPeer) throws IOException,
  KeeperException, InterruptedException {
    for (int i = 0; i < 100; i++) {
      ….
      bspPeer.sync();
    }
  }
}}}

The BSP job will be finished only when all processes have no more local and outgoing queues
entries and all processes done. (or killed by user.)

Mime
View raw message