Abstract class which a user can extend to write BSP programs.
Class-based BSP programming implies that each SPMD thread executes the same BSP_program::spmd() program on different class instances; thus class-local variables are automatically also thread-local. This is somewhat more elegant than declaring everything locally, within functions, as is necessary in C.
Furthermore, the functions bsp_init(), bsp_begin(), and bsp_end() are implied and no longer need to be called explicitly; users instead call BSP_program::begin().
BSP algorithms using this C++ wrapper extend the BSP_program class, and provide implementations for the parallel part of the program in BSP_program::spmd(). The user furthermore supplies the C++ wrapper a means of constructing new instances of their BSP program by implementing BSP_program::newInstance(). This lets the wrapper provide a separate instance to each thread executing the parallel program.
- See also:
- BSP_program::spmd()
-
BSP_program::newInstance()
-
BSP_program::begin()
Initialises and starts the current BSP program.
Automatically implies (correct) calls to bsp_init() and bsp_begin().
The parallel SPMD section is the overloaded function spmd() of this class instance.
The SPMD program makes use of the same globally defined BSP primitives as available in plain C; there are no special C++ wrappers for communication.
bsp_end() is automatically called after the spmd() function exits.
virtual BSP_program* mcbsp::BSP_program::newInstance |
( |
| ) |
|
|
protectedpure virtual |
Creates a new instance of the implementing class, which will be used by new threads spawned by bsp_begin().
Note that this need not be a copy if your BSP program does not require this! The recommended implementation is the following:
virtual BSP_program * newInstance() { return new FinalType(); }
where FinalType is the name of the BSP program you are implementing (FinalType must be a non-abstract subclass of BSP_program).
void mcbsp_cpp_callback |
( |
| ) |
|
|
friend |
This function enables C++ wrapping of MulticoreBSP for C.
It is defined as a friend function of BSP_program, and used as the SPMD entry-point of the plain-C bsp_init() function, which requires a globally-defined function.
This function is only of interest to the C++ wrapper, and is therefore not exposed to the public (i.e., it is not included in the public mcbsp.hpp file).