com.multicorebsp.core
Class BSP_PROGRAM

java.lang.Object
  extended by java.lang.Thread
      extended by com.multicorebsp.core.BSP_PROGRAM
All Implemented Interfaces:
java.lang.Runnable

public abstract class BSP_PROGRAM
extends java.lang.Thread

This class represents an executable concurrent program.

This framework is designed according a 'single program, multiple data (SPMD)'- principle; extending (non-abstract) classes must define sequential instructions (main_part) and instructions to be executed in parallel (parallel_part).

The parallel part is called from the sequential part by calling bsp_begin(P), with P the number of threads to be spawned. The parallel part is ended by bsp_end(), after which the sequential part executes any remaining instructions.

Global variables are available within this package; they are BSP_REGISTER for single variables, and BSP_CONTIGUOUS_ARRAY for global arrays. Refer to the documentation of those classes for information how to perform inter-process communication.

BSPOnJava stands for Bulk Synchronous Processing on Java. The BSP-model itself has been around for decades, and has seen many implementations; most of them in C (with additional Fortran interfaces). One of the more recent implementations is BSPOnMPI, which implements the Oxford BSP library (BSPlib) interface on top of the more popular Message Passing Interface (MPI) parallel model.

Unlike BSPOnMPI, BSPOnJava has a very different interface than that of the Oxford BSP implementation. This is due to two things:
- Java is a clean, object-oriented language and thus calls for a more object-oriented approach for a parallel model, and
- BSPOnJava explicitly targets multiple processors, multiple cores, shared-memory machines only.
Like the original BSP model, we advocate portability which is synergetic with the Java language.

Key property of the BSP model is the synchronisation barrier. In-between barriers, each processor executes the same code and may or may not call inter- process communication commands. Communication is however not performed before synchronisation, but is guaranteed to be performed after the next synchronisation.

Please refer to the main documentation or the example programs bundled with this library for more details.

Since:
0.1 , 17th of April 2008
See Also:
BSP_REGISTER, BSP_ARRAY

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
BSP_PROGRAM()
          Base constructor.
 
Method Summary
protected  void bsp_abort()
          Aborts the parallel part.
protected  void bsp_begin(int P)
          Starts P threads, each performing the instructions in parallel_part().
protected  int bsp_nprocs()
          Method to request the total number of threads active in parallel.
protected  int bsp_pid()
          Method to request the current thread (processor) ID.
protected  void bsp_sync()
          Synchronises all threads.
 int getPid()
           
protected abstract  void main_part()
          Stuff that only 1 processor is supposed to do until bsp_begin() is encountered.
protected abstract  void parallel_part()
          The part of the algorithm that needs to run in parallel.
 void run()
          Basic run method.
 void waitForEnd()
          Lets threads not associated to this parallel program wait until execution is done.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BSP_PROGRAM

public BSP_PROGRAM()
Base constructor.

Method Detail

bsp_begin

protected final void bsp_begin(int P)
                        throws java.lang.InstantiationException,
                               java.lang.IllegalAccessException,
                               java.lang.InterruptedException,
                               EmptyQueueException
Starts P threads, each performing the instructions in parallel_part().

Parameters:
P - The number of threads to spawn.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.InterruptedException
EmptyQueueException

run

public final void run()
Basic run method. Simply calls the sequential_part function.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

main_part

protected abstract void main_part()
                           throws java.lang.InterruptedException
Stuff that only 1 processor is supposed to do until bsp_begin() is encountered. The same processor will continue from there on out when the parallel part encounters bsp_end().

Throws:
java.lang.InterruptedException

parallel_part

protected abstract void parallel_part()
                               throws java.lang.InterruptedException,
                                      java.lang.IllegalAccessException,
                                      EmptyQueueException
The part of the algorithm that needs to run in parallel.

Throws:
java.lang.InterruptedException
java.lang.IllegalAccessException
EmptyQueueException

bsp_sync

protected final void bsp_sync()
                       throws java.lang.InterruptedException,
                              java.lang.IllegalAccessException
Synchronises all threads.

Throws:
java.lang.InterruptedException
java.lang.IllegalAccessException

bsp_abort

protected final void bsp_abort()
Aborts the parallel part. Currently calls system exit and will halt the entire program(!)


bsp_nprocs

protected final int bsp_nprocs()
Method to request the total number of threads active in parallel.

Returns:
The total number of threads spawned.

bsp_pid

protected final int bsp_pid()
Method to request the current thread (processor) ID.

Returns:
The processor ID.

waitForEnd

public void waitForEnd()
                throws java.lang.InterruptedException
Lets threads not associated to this parallel program wait until execution is done.

Throws:
java.lang.InterruptedException

getPid

public int getPid()
Returns:
The thread's current ID number.