MulticoreBSP for C  Version 2.0.4
Public Member Functions | Protected Member Functions | Friends
mcbsp::BSP_program Class Referenceabstract

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

#include <bsp.hpp>

Public Member Functions

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

Protected Member Functions

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

Friends

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

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

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

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

Abstract classes should have virtual destructors.

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

Member Function Documentation

void mcbsp::BSP_program::begin ( const bsp_pid_t  P = bsp_nprocs())
virtual void mcbsp::BSP_program::destroyInstance ( BSP_program *const  instance)
protectedvirtual
virtual BSP_program* mcbsp::BSP_program::newInstance ( )
protectedpure virtual
virtual void mcbsp::BSP_program::spmd ( )
protectedpure virtual

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 bsp.hpp file).


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