MulticoreBSP for C  Version 1.2
Data Structures | Functions | Variables
mcinternal.h File Reference
#include "mcbsp-internal.h"
#include "mcutil.h"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <assert.h>
#include <pthread.h>
#include <stdbool.h>
Include dependency graph for mcinternal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

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_hpsend_request
 A high-performance (non-buffering) BSMP message request. More...
 
struct  mcbsp_push_request
 Struct corresponding to a single push request. More...
 

Functions

void bsp_init_internal (struct mcbsp_init_data *const initialisationData)
 Performs a BSP intialisation using the init struct supplied. More...
 
struct mcbsp_init_databsp_begin_check (void)
 Checks if everything is all right to start an SPMD program. 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_sync (struct mcbsp_init_data *const init)
 Alias for mcbsp_internal_syncWithCondition using the standard init.condition. More...
 
void mcbsp_internal_syncWithCondition (struct mcbsp_init_data *const init, pthread_cond_t *const condition)
 Implements an actual synchronisation. 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...
 
int main ()
 Default SPMD function to call. 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_initialise_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...
 

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

Function Documentation

struct mcbsp_init_data* bsp_begin_check ( void  )
read

Checks if everything is all right to start an SPMD program.

If there is an error, execution is stopped using mcbsp_util_fatal.

Returns
NULL if the call to bsp_begin was valid, but no further action is required; or a pointer to an initialisation struct when the SPMD program is yet to be spawned.
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 ( )

Default SPMD function to call.

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

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

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

Gets the machine info currently active for this MulticoreBSP session.

Returns
A pointer to the current machine info struct.
struct mcbsp_thread_data* mcbsp_internal_initialise_thread_data ( struct mcbsp_thread_data *const  data)
read

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

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

Alias for mcbsp_internal_syncWithCondition using the standard init.condition.

Parameters
initPointer to the BSP init corresponding to our current SPMD group.
void mcbsp_internal_syncWithCondition ( struct mcbsp_init_data *const  init,
pthread_cond_t *const  condition 
)

Implements an actual synchronisation.

This is used within bsp_sync, but also in bsp_begin to ensure all is initialised before getting into a real communication-enabled sync (necessary to support high-performant put, get, or send operations).

Parameters
initPointer to the BSP init corresponding to our current SPMD group.
conditionThe condition to use with this particular sync.

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.