MulticoreBSP for C  Version 2.0.4
Functions
mcbsp-templates.hpp File Reference
#include "mcbsp.hpp"
Include dependency graph for mcbsp-templates.hpp:

Go to the source code of this file.

Functions

template<typename T >
void bsp_push_reg (T *const address, const size_t size=1)
 Registers a memory area for communication. More...
 
template<typename T >
bsp_size_t bsp_set_tagsize (const T &tag_type=T())
 Sets the tag size of inter-thread messages. More...
 
template<typename T >
void bsp_put (const bsp_pid_t pid, const void *const source, T *const destination, const size_t offset=0, const size_t size=1)
 Put data in a remote memory location. More...
 
template<typename T >
void bsp_get (const bsp_pid_t pid, const T *const source, const size_t offset, void *const destination, const size_t size=1)
 Get data from a remote memory location. More...
 
template<typename T >
void bsp_direct_get (const bsp_pid_t pid, const T *const source, const bsp_size_t offset, void *const destination, const bsp_size_t size=1)
 Get data from a remote memory location. More...
 
template<typename T >
void bsp_send (const bsp_pid_t pid, const void *const tag, const T *const payload, const size_t size=1)
 Sends a message to a remote thread. More...
 
template<typename T >
void bsp_hpsend (const bsp_pid_t pid, const void *const tag, const T *const payload, const size_t size=1)
 This is a non-buffering and non-blocking send request. More...
 
template<typename T >
void bsp_move (T *const payload, const size_t max_copy_size=1)
 Retrieves the payload from the first message in the queue of incoming messages, and removes that message. More...
 
template<typename T >
void bsp_hpput (const bsp_pid_t pid, const void *const source, const T *const destination, const size_t offset=0, const size_t size=1)
 Put data in a remote memory location. More...
 
template<typename T >
void bsp_hpget (const bsp_pid_t pid, const T *const source, const size_t offset, void *const destination, const size_t size)
 Get data from a remote memory location. More...
 

Detailed Description

Enables C++-style BSP communication; sizes and offsets are given in number of elements of a specific type. If any of the data pointers are of type (void*), then offset and sizes must be given in bytes as in plain C.

An example is the following. Consider each SPMD process having an array of P doubles and one given value x that needs to be broadcast to all other processes. Normally, the below suffices (assuming the array is registered):

* for( unsigned int k = 0; k < bsp_nprocs(); ++k ) {
* bsp_put( k, &x, arr, bsp_pid() * sizeof(double), sizeof(double) );
* }
*

With C++ and mcbsp-templates extensions, this becomes instead:

* for( unsigned int k = 0; k < bsp_nprocs(); ++k ) {
* bsp_put( k, &x, array, bsp_pid(), 1 );
* }
*

Additionally, the last two parameters are optional; the length defaults to 1 element, while the offset defaults to 0, making very short statements possible whenever appropriate.

Function Documentation

template<typename T >
void bsp_send ( const bsp_pid_t  pid,
const void *const  tag,
const T *const  payload,
const size_t  size = 1 
)

Sends a message to a remote thread.

This is the templated variant of a regular bsp_send().

A message is actually a tuple (tag,payload). Tag is of a fixed size (see bsp_set_tagsize), the payload size is set per message. Messages will be available at the destination thread in the next superstep.

Note: If MCBSP_COMPATIBILITY_MODE is defined, then pid and size are of type `int'. Otherwise, pid is of type `unsigned int' and size of type `size_t'.

Parameters
pidID of the remote thread to send this message to.
tagPointer to the tag data.
payloadPointer to one or more payload data elements.
sizeNumber of data elements in the payload.