MulticoreBSP for C  Version 1.1
Public Member Functions | Protected Member Functions | Friends
mcbsp::BSP_program Class Reference

Abstract class which a user can extend to write BSP programs. More...

#include <mcbsp-internal.hpp>

Public Member Functions

void begin (const MCBSP_PROCESSOR_INDEX_DATATYPE P=bsp_nprocs())
virtual ~BSP_program ()
void begin (const MCBSP_PROCESSOR_INDEX_DATATYPE P=bsp_nprocs())
 Initialises and starts the current BSP program.
virtual ~BSP_program ()
 Abstract classes should have virtual destructors.

Protected Member Functions

 BSP_program ()
virtual void spmd ()=0
virtual BSP_programnewInstance ()=0
 BSP_program ()
 Base constructor is only accessible by self, derived instances, and friends.
virtual void spmd ()=0
 The parallel SPMD code to be implemented by user.
virtual BSP_programnewInstance ()=0
 Creates a new instance of the implementing class, which will be used by new threads spawned by bsp_begin().

Friends

void mcbsp_cpp_callback ()
 This function enables C++ wrapping of MulticoreBSP for C.

Detailed Description

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()

Constructor & Destructor Documentation

mcbsp::BSP_program::BSP_program ( )
inlineprotected
virtual mcbsp::BSP_program::~BSP_program ( )
inlinevirtual
mcbsp::BSP_program::BSP_program ( )
inlineprotected

Base constructor is only accessible by self, derived instances, and friends.

virtual mcbsp::BSP_program::~BSP_program ( )
inlinevirtual

Abstract classes should have virtual destructors.


Member Function Documentation

void mcbsp::BSP_program::begin ( const MCBSP_PROCESSOR_INDEX_DATATYPE  P = bsp_nprocs())
void mcbsp::BSP_program::begin ( const MCBSP_PROCESSOR_INDEX_DATATYPE  P = bsp_nprocs())

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
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).

virtual void mcbsp::BSP_program::spmd ( )
protectedpure virtual
virtual void mcbsp::BSP_program::spmd ( )
protectedpure virtual

The parallel SPMD code to be implemented by user.


Friends And Related Function Documentation

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).


The documentation for this class was generated from the following files: