MulticoreBSP for C  Version 2.0.4
Data Structures | Macros | Functions | Variables
mcbsp.h File Reference
#include "mcbsp-internal-macros.h"
#include "bsp.h"
#include "mcbsp-affinity.h"
#include "mcbsp-profiling.h"
#include "mcbsp-resiliency.h"
#include <time.h>
#include <stdio.h>
#include <errno.h>
#include <sched.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <signal.h>
#include <pthread.h>
#include <stdbool.h>
#include "mcutil.h"
#include "bsp-active-hooks.h"
Include dependency graph for mcbsp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mcbsp_superstep_stats
 Struct used to store tracked of superstep statistics. More...
 
struct  mcbsp_init_data
 Initialisation struct. More...
 
struct  mcbsp_thread_data
 Thread-local data. More...
 
struct  mcbsp_get_request
 A DRMA communication request for `get'-requests. More...
 
struct  mcbsp_message
 A generic BSP communication message. More...
 
struct  mcbsp_hp_request
 A DRMA communication request for hpput and hpget requests. More...
 
struct  mcbsp_hpsend_request
 A high-performance (non-buffering) BSMP message request. More...
 
struct  mcbsp_push_request
 Struct corresponding to a single push request. More...
 

Macros

#define MCBSP_SUPERSTEP_STATS_NAME_MAX   255
 

Functions

int main (int argc, char **argv)
 To support direct SPMD mode, created threads may call main(). More...
 
void bsp_init_internal (struct mcbsp_init_data *const initialisationData)
 Performs a BSP intialisation using the init struct supplied. More...
 
struct mcbsp_util_machine_infomcbsp_internal_getMachineInfo (void)
 Gets the machine info currently active for this MulticoreBSP session. More...
 
void mcbsp_internal_check_keys_allocated (void)
 Singleton thread-safe allocator for mcbsp_internal_init_data. More...
 
void * mcbsp_internal_spmd (void *p)
 Entry-point of MulticoreBSP threads. More...
 
void mcbsp_internal_check_aborted (void)
 Checks if a abort has been requested, and if so, exits the current thread. More...
 
void mcbsp_internal_spinlock (struct mcbsp_init_data *const init, unsigned char *const cond, const size_t bsp_id)
 Alias for mcbsp_internal_syncWithCondition using the standard init.condition. More...
 
void mcbsp_internal_sync (struct mcbsp_init_data *const init, pthread_cond_t *cond)
 Alias for mcbsp_internal_syncWithCondition using the standard init.condition. More...
 
struct mcbsp_thread_datamcbsp_internal_const_prefunction (void)
 Common part executed by all BSP primitives when in SPMD part. More...
 
struct mcbsp_thread_datamcbsp_internal_prefunction (void)
 Common part executed by all BSP primitives when in SPMD part. More...
 
struct mcbsp_thread_datamcbsp_internal_allocate_thread_data (struct mcbsp_init_data *const init, const size_t s)
 Allcates and initialises the `plain old data' parts of the mcbsp_thread_data struct, using the supplied parameters. More...
 
struct mcbsp_thread_datamcbsp_internal_initialize_thread_data (struct mcbsp_thread_data *const data)
 Finishes initialisation of a mcbsp_thread_data struct. More...
 
void mcbsp_internal_destroy_thread_data (struct mcbsp_thread_data *const data)
 Deallocates a fully initialised mcbsp_thread_data struct. More...
 
int mcbsp_internal_call_checkpoint (void)
 Does the checkpointing from within a critical section. More...
 
void mcbsp_internal_update_checkpointStats (struct mcbsp_init_data *const init)
 On encountering a new superstep, this function takes care of bookkeeping regarding checkpointing frequencies; including checks for the existance of the failure indicating file, `/etc/bsp_failure'. More...
 
void mcbsp_internal_print_profile (const struct mcbsp_init_data *const init)
 Prints any collected profiling statistics to stdout. More...
 
void mcbsp_internal_init_superstep_stats (struct mcbsp_superstep_stats *const stats, const size_t superstep)
 (Re-)initialises the superstep stats structure. More...
 
double mcbsp_internal_time (struct mcbsp_thread_data *const data)
 Gets the time relative to the SPMD start section. More...
 

Variables

pthread_key_t mcbsp_internal_init_data
 Per-initialising thread initialisation data. More...
 
pthread_key_t mcbsp_internal_thread_data
 Per-thread data. More...
 
pthread_key_t mcbsp_local_machine_info
 Per-thread machine info. More...
 
bool mcbsp_internal_keys_allocated
 Whether mcbsp_internal_init_data is initialised. More...
 
pthread_mutex_t mcbsp_internal_keys_mutex
 Contorls thread-safe singleton access to mcbsp_internal_init_data. More...
 

Macro Definition Documentation

#define MCBSP_SUPERSTEP_STATS_NAME_MAX   255

Function Documentation

void bsp_init_internal ( struct mcbsp_init_data *const  initialisationData)

Performs a BSP intialisation using the init struct supplied.

The construction of this struct differs when called from C code, or when called from the C++ wrapper.

int main ( int  argc,
char **  argv 
)

To support direct SPMD mode, created threads may call main().

struct mcbsp_thread_data* mcbsp_internal_allocate_thread_data ( struct mcbsp_init_data *const  init,
const size_t  s 
)

Allcates and initialises the `plain old data' parts of the mcbsp_thread_data struct, using the supplied parameters.

Parameters
initPointer to the initialising process' init data.
sProcess ID of the thread corresponding to this data.
Returns
The newly allocated thread data.
int mcbsp_internal_call_checkpoint ( void  )

Does the checkpointing from within a critical section.

THIS MEANS THIS FUNCTION IS NOT THREADSAFE. Restoring from a checkpoint necessarily means the restored program exits from this function.

Returns
-1 on error, 0 on success, 1 on exit from recovery.
void mcbsp_internal_check_aborted ( void  )

Checks if a abort has been requested, and if so, exits the current thread.

void mcbsp_internal_check_keys_allocated ( void  )

Singleton thread-safe allocator for mcbsp_internal_init_data.

struct mcbsp_thread_data* mcbsp_internal_const_prefunction ( void  )

Common part executed by all BSP primitives when in SPMD part.

This version assumes local thread data used by BSP remains unchanged.

void mcbsp_internal_destroy_thread_data ( struct mcbsp_thread_data *const  data)

Deallocates a fully initialised mcbsp_thread_data struct.

Parameters
dataThe thread data to destroy.
struct mcbsp_util_machine_info* mcbsp_internal_getMachineInfo ( void  )

Gets the machine info currently active for this MulticoreBSP session.

Returns
A pointer to the current machine info struct.
void mcbsp_internal_init_superstep_stats ( struct mcbsp_superstep_stats *const  stats,
const size_t  superstep 
)

(Re-)initialises the superstep stats structure.

Will set the descriptor name of the current superstep to `Superstep i', with i-th the current superstep number.

Parameters
statsThe pre-allocated superstep stats structure to (re-)initialise the fields of.
superstepThe current superstep number.
struct mcbsp_thread_data* mcbsp_internal_initialize_thread_data ( struct mcbsp_thread_data *const  data)

Finishes initialisation of a mcbsp_thread_data struct.

The plain-old-data fields of a given thread_data are copied, and the remaining data fields are properly initialised. The old thread_data struct will be freed.

Parameters
dataThe initial data to copy.
Returns
New process-local thread data.
struct mcbsp_thread_data* mcbsp_internal_prefunction ( void  )

Common part executed by all BSP primitives when in SPMD part.

This is the non-const version of mcbsp_internal_const_prefunction.

void mcbsp_internal_print_profile ( const struct mcbsp_init_data *const  init)

Prints any collected profiling statistics to stdout.

Parameters
initThe profiled SPMD init structure.
void mcbsp_internal_spinlock ( struct mcbsp_init_data *const  init,
unsigned char *const  cond,
const size_t  bsp_id 
)

Alias for mcbsp_internal_syncWithCondition using the standard init.condition.

Parameters
initPointer to the BSP init corresponding to our current SPMD group.
condThe array to spinlock on.
bsp_idThe unique ID number corresponding to the thread that calls this sync function.
void* mcbsp_internal_spmd ( void *  p)

Entry-point of MulticoreBSP threads.

Initialises internals and then executes the user-defined SPMD program.

Parameters
pThe passed POSIX threads init data.
void mcbsp_internal_sync ( struct mcbsp_init_data *const  init,
pthread_cond_t *  cond 
)

Alias for mcbsp_internal_syncWithCondition using the standard init.condition.

Parameters
initPointer to the BSP init corresponding to our current SPMD group.
condThe condition to use for synchronisation.
double mcbsp_internal_time ( struct mcbsp_thread_data *const  data)

Gets the time relative to the SPMD start section.

Works on Linux (via POSIX realtime extensions), Windows, and Mach (OS X).

Parameters
dataThread-local data structure that contains the relative start time, plus any other data required for getting the current time.
Returns
The elapsed time.
void mcbsp_internal_update_checkpointStats ( struct mcbsp_init_data *const  init)

On encountering a new superstep, this function takes care of bookkeeping regarding checkpointing frequencies; including checks for the existance of the failure indicating file, `/etc/bsp_failure'.

This function is NOT thread-safe and should be called by PID 0 only.

Parameters
initThe initialisation struct where to update check- point related information in.

Variable Documentation

pthread_key_t mcbsp_internal_init_data

Per-initialising thread initialisation data.

Per-thread machine info.

Necessary for nested MulticoreBSP SPMD calls.

bool mcbsp_internal_keys_allocated

Whether mcbsp_internal_init_data is initialised.

pthread_mutex_t mcbsp_internal_keys_mutex

Contorls thread-safe singleton access to mcbsp_internal_init_data.

Required for safe initialisation.

pthread_key_t mcbsp_internal_thread_data

Per-thread data.

pthread_key_t mcbsp_local_machine_info

Per-thread machine info.