next up previous
Next: Results Up: Writing BSP programs in Previous: BSPMainWork.

Sample Code.

  Figure 7 shows a matrix multiplication example demonstrating the use of the Bayanihan BSP programming interface. Here, we use a single BSPMainWork subclass with separate bsp_main() and bsp_run() methods. The initVars() method is called in both the worker and main work objects before running bsp_run() and bsp_main(). The algorithm used is based on one of the MPI example programs in [12], where each process i from 1 to n is given a copy of the matrix B and row i-1 of A, and computes row i-1 of the product C.

  
Figure 7: Bayanihan BSP code for matrix multiplication.
\begin{figure}
\begin{scriptsize}

\begin{verbatim}

public class BSPMatMultMa...
 ...C = \n'' + C ) // print C
 }
 }
}\end{verbatim}
\end{scriptsize}
\end{figure}



Luis Sarmenta
1/19/1999