Loading...
Searching...
No Matches
PLMD::thread_mpi Namespace Reference

Classes

struct  cart_topol
 
struct  coll_env
 
struct  coll_env_coll
 
struct  coll_env_thread
 
struct  coll_sync
 
struct  envelope
 
struct  free_envelope_list
 
struct  recv_envelope_list
 
struct  req_list
 
struct  send_envelope_list
 
struct  tMPI_Atomic
 Atomic operations datatype. More...
 
struct  tMPI_Atomic_ptr
 Atomic pointer type equivalent to tMPI_Atomic_t. More...
 
struct  tMPI_Barrier_t
 
struct  tmpi_comm_
 
struct  tmpi_datatype_
 
struct  tmpi_datatype_component
 
struct  tmpi_errhandler_
 
struct  tMPI_Event_t
 
struct  tmpi_global
 
struct  tmpi_group_
 
struct  tMPI_Lock
 
struct  tMPI_Mutex
 
struct  tMPI_Reduce_req
 
struct  tmpi_req_
 
struct  tMPI_Spinlock
 
struct  tmpi_split
 
struct  tMPI_Stack
 
struct  tMPI_Stack_element
 A single element in stack. More...
 
struct  tmpi_status_
 tMPI Status. More...
 
struct  tMPI_Thread
 
struct  tmpi_thread
 
struct  tMPI_Thread_barrier
 
struct  tMPI_Thread_barrier_t
 Pthread implementation of barrier type. More...
 
struct  tMPI_Thread_cond
 
struct  tMPI_Thread_cond_t
 Condition variable handle for threads. More...
 
struct  tMPI_Thread_key
 
struct  tMPI_Thread_key_t
 Pthread implementation of the abstract tMPI_Thread_key type. More...
 
struct  tMPI_Thread_mutex_t
 Opaque mutex datatype. More...
 
struct  tMPI_Thread_once
 
struct  tMPI_Thread_once_t
 One-time initialization data for thread. More...
 

Typedefs

typedef struct tmpi_comm_ * MPI_Comm
 
typedef struct tmpi_datatype_ * MPI_Datatype
 
typedef struct tmpi_group_ * MPI_Group
 
typedef tMPI_Op MPI_Op
 
typedef struct tmpi_req_ * MPI_Request
 
typedef struct tmpi_status_ MPI_Status
 
typedef struct PLMD::thread_mpi::tMPI_Atomic_ptr tMPI_Atomic_ptr_t
 Atomic pointer type equivalent to tMPI_Atomic_t.
 
typedef struct PLMD::thread_mpi::tMPI_Atomic tMPI_Atomic_t
 Atomic operations datatype.
 
typedef struct tMPI_Barrier_t tMPI_Barrier_t
 
typedef int tmpi_bool
 
typedef struct tmpi_comm_ * tMPI_Comm
 tMPI Communicator
 
typedef struct tmpi_datatype_ * tMPI_Datatype
 tMPI datatype
 
typedef struct tmpi_datatype_ tmpi_dt
 
typedef struct tmpi_errhandler_ * tMPI_Errhandler
 error handler object
 
typedef void(* tMPI_Errhandler_fn) (tMPI_Comm *, int *)
 error handler function
 
typedef struct tMPI_Event_t tMPI_Event
 
typedef struct tmpi_group_ * tMPI_Group
 tMPI Group
 
typedef struct tMPI_Lock tMPI_Lock_t
 
typedef void(* tMPI_Op_fn) (void *, const void *, const void *, int)
 
typedef struct tmpi_req_ * tMPI_Request
 tMPI Request
 
typedef struct tMPI_Spinlock * tMPI_Spinlock_t
 Spinlock.
 
typedef struct PLMD::thread_mpi::tMPI_Stack_element tMPI_Stack_element
 A single element in stack.
 
typedef struct PLMD::thread_mpi::tmpi_status_ tMPI_Status
 tMPI Status.
 
typedef struct tMPI_Thread * tMPI_Thread_t
 

Enumerations

enum  {
  TMPI_SUCCESS = 0 , TMPI_ERR_NO_MEM , TMPI_ERR_IO , TMPI_ERR_INIT ,
  TMPI_ERR_FINALIZE , TMPI_ERR_GROUP , TMPI_ERR_COMM , TMPI_ERR_STATUS ,
  TMPI_ERR_GROUP_RANK , TMPI_ERR_DIMS , TMPI_ERR_COORDS , TMPI_ERR_CART_CREATE_NPROCS ,
  TMPI_ERR_XFER_COUNTERPART , TMPI_ERR_XFER_BUFSIZE , TMPI_ERR_XFER_BUF_OVERLAP , TMPI_ERR_SEND_DEST ,
  TMPI_ERR_RECV_SRC , TMPI_ERR_BUF , TMPI_ERR_MULTI_MISMATCH , TMPI_ERR_OP_FN ,
  TMPI_ERR_ENVELOPES , TMPI_ERR_REQUESTS , TMPI_ERR_COPY_NBUFFERS , TMPI_ERR_COPY_BUFFER_SIZE ,
  TMPI_ERR_IN_STATUS , TMPI_ERR_PROCNR , TMPI_FAILURE , TMPI_ERR_TYPE ,
  TMPI_ERR_UNKNOWN , N_TMPI_ERR
}
 Error codes. More...
 
enum  envelope_state { env_unmatched = 0 , env_copying = 1 , env_cb_available = 2 , env_finished = 3 }
 
enum  tMPI_Affinity_strategy { TMPI_AFFINITY_NONE = 0 , TMPI_AFFINITY_ALL_CORES }
 
enum  tMPI_Op {
  TMPI_MAX , TMPI_MIN , TMPI_SUM , TMPI_PROD ,
  TMPI_LAND , TMPI_BAND , TMPI_LOR , TMPI_BOR ,
  TMPI_LXOR , TMPI_BXOR
}
 tMPI_Reduce operators. More...
 

Functions

int main (int argc, char **argv)
 
TMPI_EXPORT int tMPI_Atomic_add_return (tMPI_Atomic_t *a, int i)
 Add integer to atomic variable.
 
TMPI_EXPORT int tMPI_Atomic_cas (tMPI_Atomic_t *a, int old_val, int new_val)
 Atomic compare-and-swap operation.
 
TMPI_EXPORT int tMPI_Atomic_fetch_add (tMPI_Atomic_t *a, int i)
 Add to variable, return the old value.
 
TMPI_EXPORT int tMPI_Atomic_get (const tMPI_Atomic_t *a)
 Return value of an atomic integer.
 
TMPI_EXPORT int tMPI_Atomic_ptr_cas (tMPI_Atomic_ptr_t *a, void *old_val, void *new_val)
 Atomic pointer compare-and-swap operation.
 
TMPI_EXPORT void * tMPI_Atomic_ptr_get (const tMPI_Atomic_ptr_t *a)
 Return value of an atomic pointer.
 
TMPI_EXPORT void tMPI_Atomic_ptr_set (tMPI_Atomic_ptr_t *a, void *p)
 Write value to an atomic pointer.
 
TMPI_EXPORT void * tMPI_Atomic_ptr_swap (tMPI_Atomic_ptr_t *a, void *b)
 Atomic swap pointer operation.
 
TMPI_EXPORT void tMPI_Atomic_set (tMPI_Atomic_t *a, int i)
 Write value to an atomic integer.
 
TMPI_EXPORT int tMPI_Atomic_swap (tMPI_Atomic_t *a, int b)
 Atomic swap operation.
 
TMPI_EXPORT void tMPI_Barrier_init (tMPI_Barrier_t *barrier, int count)
 Initialize barrier.
 
TMPI_EXPORT int tMPI_Barrier_wait (tMPI_Barrier_t *barrier)
 Perform yielding, busy-waiting barrier synchronization.
 
TMPI_EXPORT void * tMPI_Calloc_local (size_t nmemb, size_t size)
 Allocate local memory by array and element size.
 
void tMPI_Cart_destroy (struct cart_topol *top)
 
void tMPI_Coll_env_destroy (struct coll_env *mev)
 
int tMPI_Coll_env_init (struct coll_env *mev, int N)
 
void tMPI_Coll_root_xfer (tMPI_Comm comm, tMPI_Datatype sendtype, tMPI_Datatype recvtype, size_t sendsize, size_t recvsize, void *sendbuf, void *recvbuf, int *ret)
 
void tMPI_Coll_sync_destroy (struct coll_sync *msc)
 
int tMPI_Coll_sync_init (struct coll_sync *msc, int N)
 
int tMPI_Comm_alloc (tMPI_Comm *newcomm, tMPI_Comm parent, int N)
 
int tMPI_Comm_destroy (tMPI_Comm comm, tmpi_bool do_link_lock)
 
int tMPI_Comm_N (tMPI_Comm comm)
 
int tMPI_Comm_seek_rank (tMPI_Comm comm, struct tmpi_thread *th)
 
int tMPI_Error (tMPI_Comm comm, int tmpi_errno)
 
void tmpi_errors_are_fatal_fn (tMPI_Comm *comm, int *err)
 
void tmpi_errors_return_fn (tMPI_Comm *comm, int *err)
 
TMPI_EXPORT void tMPI_Event_destroy (tMPI_Event *ev)
 Deallocate the internals of the contents of event object.
 
TMPI_EXPORT void tMPI_Event_init (tMPI_Event *ev)
 Initialize the event object.
 
TMPI_EXPORT int tMPI_Event_wait (tMPI_Event *ev)
 Wait for an event to occur.
 
TMPI_EXPORT void tMPI_Fatal_error (const char *file, int line, const char *message,...)
 handle a fatal error.
 
void tMPI_Free (void *p)
 
void tMPI_Free_env_list_destroy (struct free_envelope_list *evl)
 
int tMPI_Free_env_list_init (struct free_envelope_list *evl, int N)
 
TMPI_EXPORT int tMPI_Free_numa (void *ptr)
 Free memory allocate with any of the NUMA-aware allocators.
 
struct coll_env * tMPI_Get_cev (tMPI_Comm comm, int myrank, int *synct)
 
tMPI_Comm tMPI_Get_comm_self (void)
 
TMPI_EXPORT int tMPI_Get_hw_nthreads (void)
 
TMPI_EXPORT int tMPI_Get_recommended_nthreads (void)
 Determine the recommended number of hardware threads to run on.
 
struct tmpi_req_ * tMPI_Get_req (struct req_list *rl)
 
tMPI_Group tMPI_Group_alloc (void)
 
tmpi_bool tMPI_In_group (tMPI_Group group)
 
tmpi_bool tMPI_Is_master (void)
 
TMPI_EXPORT void tMPI_Lock_init (tMPI_Lock_t *lock)
 Initialize lock.
 
TMPI_EXPORT int tMPI_Lock_islocked (tMPI_Lock_t *lock)
 Check the status of the lock without affecting its state.
 
TMPI_EXPORT void tMPI_Lock_lock (tMPI_Lock_t *lock)
 Perform yielding, busy-waiting locking.
 
TMPI_EXPORT int tMPI_Lock_trylock (tMPI_Lock_t *lock)
 Try to lock the lock but don't block if it is locked.
 
TMPI_EXPORT void tMPI_Lock_unlock (tMPI_Lock_t *lock)
 Unlock the lock.
 
void * tMPI_Malloc (size_t size)
 
TMPI_EXPORT void * tMPI_Malloc_local (size_t size)
 Allocate local memory by size in bytes.
 
void tMPI_Mult_recv (tMPI_Comm comm, struct coll_env *cev, int rank, int index, int expected_tag, tMPI_Datatype recvtype, size_t recvsize, void *recvbuf, int *ret)
 
TMPI_EXPORT int tMPI_Once (tMPI_Comm comm, void(*function)(void *), void *param, int *was_first)
 
TMPI_EXPORT void * tMPI_Once_wait (tMPI_Comm comm, void *(*function)(void *), void *param, int *was_first)
 Execute function once over comm, and wait for the function to return its value.
 
struct envelope * tMPI_Post_match_recv (struct tmpi_thread *cur, tMPI_Comm comm, struct tmpi_thread *src, void *recv_buf, int recv_count, tMPI_Datatype datatype, int tag, tmpi_bool nonblock)
 
int tMPI_Post_multi (struct coll_env *cev, int myrank, int index, int tag, tMPI_Datatype datatype, size_t bufsize, void *buf, int n_remaining, int synct, int dest)
 
struct envelope * tMPI_Post_send (struct tmpi_thread *cur, tMPI_Comm comm, struct tmpi_thread *dest, void *send_buf, int send_count, tMPI_Datatype datatype, int tag, tmpi_bool nonblock)
 
void * tMPI_Realloc (void *p, size_t size)
 
TMPI_EXPORT void * tMPI_Realloc_local (void *ptr, size_t size)
 Re-allocate to local memory.
 
void tMPI_Recv_env_list_destroy (struct recv_envelope_list *evl)
 
int tMPI_Recv_env_list_init (struct recv_envelope_list *evl)
 
TMPI_EXPORT tMPI_Reduce_req * tMPI_Reduce_req_alloc (tMPI_Comm comm)
 Allocate data structure for asynchronous reduce.
 
int tMPI_Reduce_run_op (void *dest, const void *src_a, const void *src_b, tMPI_Datatype datatype, int count, tMPI_Op op, tMPI_Comm comm)
 
void tMPI_Req_init (struct tmpi_req_ *rq, struct envelope *ev)
 
void tMPI_Req_list_destroy (struct req_list *rl)
 
int tMPI_Req_list_init (struct req_list *rl, int N_reqs)
 
void tMPI_Return_req (struct req_list *rl, struct tmpi_req_ *req)
 
void tMPI_Send_env_list_destroy (struct send_envelope_list *evl)
 
int tMPI_Send_env_list_init (struct send_envelope_list *evl, int N)
 
void tMPI_Set_status (struct tmpi_req_ *req, tMPI_Status *st)
 
TMPI_EXPORT void * tMPI_Shmalloc (tMPI_Comm comm, size_t size)
 Allocate a shared block of memory as a collective call.
 
TMPI_EXPORT void tMPI_Spinlock_init (tMPI_Spinlock_t *x)
 Initialize spinlock.
 
static int tMPI_Spinlock_islocked (const tMPI_Spinlock_t *x)
 
static TMPI_EXPORT int tMPI_Spinlock_islocked (const tMPI_Spinlock_t *x)
 
static int tMPI_Spinlock_islocked (const tMPI_Spinlock_t *x)
 
static int tMPI_Spinlock_islocked (const tMPI_Spinlock_t *x)
 
static int tMPI_Spinlock_islocked (const tMPI_Spinlock_t *x)
 
static int tMPI_Spinlock_islocked (const tMPI_Spinlock_t *x)
 
static int tMPI_Spinlock_islocked (const tMPI_Spinlock_t *x)
 
TMPI_EXPORT int tMPI_Spinlock_islocked (tMPI_Spinlock_t *x)
 Check if spinlock is locked.
 
TMPI_EXPORT void tMPI_Spinlock_lock (tMPI_Spinlock_t *x)
 Acquire spinlock.
 
TMPI_EXPORT int tMPI_Spinlock_trylock (tMPI_Spinlock_t *x)
 Attempt to acquire spinlock.
 
TMPI_EXPORT void tMPI_Spinlock_unlock (tMPI_Spinlock_t *x)
 Release spinlock.
 
TMPI_EXPORT void tMPI_Spinlock_wait (tMPI_Spinlock_t *x)
 Wait for a spinlock to become available.
 
TMPI_EXPORT void tMPI_Stack_destroy (tMPI_Stack *st)
 Deallocates a stack.
 
TMPI_EXPORT tMPI_Stack_element * tMPI_Stack_detach (tMPI_Stack *st)
 Detaches entire stack for use by a single thread.
 
TMPI_EXPORT void tMPI_Stack_init (tMPI_Stack *st)
 Initialize a stack.
 
TMPI_EXPORT tMPI_Stack_element * tMPI_Stack_pop (tMPI_Stack *st)
 Pops a stack element from a stack.
 
TMPI_EXPORT void tMPI_Stack_push (tMPI_Stack *st, tMPI_Stack_element *el)
 Pushes a stack element onto a stack.
 
tmpi_bool tMPI_Test_multi (struct tmpi_thread *cur, struct tmpi_req_ *rqs, tmpi_bool *any_done)
 
tmpi_bool tMPI_Test_single (struct tmpi_thread *cur, struct tmpi_req_ *rq)
 
void tMPI_Wait_for_data (struct tmpi_thread *cur, struct coll_env *cev, int myrank)
 
void tMPI_Wait_for_others (struct coll_env *cev, int myrank)
 
void tMPI_Wait_process_incoming (struct tmpi_thread *th)
 
void tMPI_Wait_single (struct tmpi_thread *cur, struct tmpi_req_ *rq)
 
Initialization and exit functions
TMPI_EXPORT int tMPI_Init (int *argc, char ***argv, int(*start_function)(int, char **))
 Traditional MPI initializer; spawns threads that start at the given function.
 
TMPI_EXPORT int tMPI_Init_fn (int main_thread_returns, int N, tMPI_Affinity_strategy aff_strategy, void(*start_function)(const void *), const void *arg)
 Generic init function thread MPI intializer and thread spawner.
 
TMPI_EXPORT int tMPI_Get_N (int *argc, char ***argv, const char *optname, int *nthreads)
 get the number of threads from the command line
 
TMPI_EXPORT int tMPI_Finalize (void)
 Waits for all other threads to finish and cleans up.
 
TMPI_EXPORT int tMPI_Abort (tMPI_Comm comm, int errorcode)
 Just kills all threads.
 
TMPI_EXPORT int tMPI_Initialized (int *flag)
 whether tMPI_Init, but not yet tMPI_Finalize, has been run
 
TMPI_EXPORT int tMPI_Finalized (int *flag)
 Determine whether tMPI_Finalize has been run.
 
Error handling functions
TMPI_EXPORT int tMPI_Create_errhandler (tMPI_Errhandler_fn *function, tMPI_Errhandler *errhandler)
 Create an error handler object from a function.
 
TMPI_EXPORT int tMPI_Errhandler_free (tMPI_Errhandler *errhandler)
 Free the error handler object.
 
TMPI_EXPORT int tMPI_Comm_set_errhandler (tMPI_Comm comm, tMPI_Errhandler errhandler)
 Set the error handler.
 
TMPI_EXPORT int tMPI_Comm_get_errhandler (tMPI_Comm comm, tMPI_Errhandler *errhandler)
 get the error handler.
 
TMPI_EXPORT int tMPI_Error_string (int errorcode, char *string, int *resultlen)
 get the error string associated with an error code.
 
Environment query functions
TMPI_EXPORT int tMPI_Get_processor_name (char *name, int *resultlen)
 returns string with thread number.
 
TMPI_EXPORT double tMPI_Wtime (void)
 get a time value as a double, in seconds.
 
TMPI_EXPORT double tMPI_Wtick (void)
 get the resolution of tMPI_Wtime as a double, in seconds
 
tMPI_Group functions
TMPI_EXPORT int tMPI_Group_size (tMPI_Group group, int *size)
 Get the size (number of members) of a group.
 
TMPI_EXPORT int tMPI_Group_rank (tMPI_Group group, int *rank)
 Get the rank of a thread in a group.
 
TMPI_EXPORT int tMPI_Group_incl (tMPI_Group group, int n, const int *ranks, tMPI_Group *newgroup)
 Create a new group as a the collection of threads with given ranks.
 
TMPI_EXPORT int tMPI_Comm_group (tMPI_Comm comm, tMPI_Group *group)
 Get a pointer to the group in the comm.
 
TMPI_EXPORT int tMPI_Group_free (tMPI_Group *group)
 De-allocate a group.
 
tMPI_Comm functions
TMPI_EXPORT int tMPI_Comm_size (tMPI_Comm comm, int *size)
 Get the comm size (nr.
 
TMPI_EXPORT int tMPI_Comm_rank (tMPI_Comm comm, int *rank)
 get the rank in comm of the current process
 
TMPI_EXPORT int tMPI_Comm_compare (tMPI_Comm comm1, tMPI_Comm comm2, int *result)
 Compare two comms.
 
TMPI_EXPORT int tMPI_Comm_free (tMPI_Comm *comm)
 De-allocate a comm.
 
TMPI_EXPORT int tMPI_Comm_create (tMPI_Comm comm, tMPI_Group group, tMPI_Comm *newcomm)
 Create a comm based on group membership.
 
TMPI_EXPORT int tMPI_Comm_split (tMPI_Comm comm, int color, int key, tMPI_Comm *newcomm)
 Split up a group into same-colored sub-groups ordered by key.
 
TMPI_EXPORT int tMPI_Comm_dup (tMPI_Comm comm, tMPI_Comm *newcomm)
 Make a duplicate of a comm.
 
Topology functions
TMPI_EXPORT int tMPI_Topo_test (tMPI_Comm comm, int *status)
 Check what type of topology the comm has.
 
TMPI_EXPORT int tMPI_Cartdim_get (tMPI_Comm comm, int *ndims)
 Get the dimensionality of a comm with a topology.
 
TMPI_EXPORT int tMPI_Cart_get (tMPI_Comm comm, int maxdims, int *dims, int *periods, int *coords)
 Get the size and pbc a of a comm with a Cartesian topology has.
 
TMPI_EXPORT int tMPI_Cart_rank (tMPI_Comm comm, const int *coords, int *rank)
 Get rank that a specific set of process coordinates has in a Cartesian topology.
 
TMPI_EXPORT int tMPI_Cart_coords (tMPI_Comm comm, int rank, int maxdims, int *coords)
 Get coordinates of a process rank in a Cartesian topology.
 
TMPI_EXPORT int tMPI_Cart_map (tMPI_Comm comm, int ndims, const int *dims, const int *periods, int *newrank)
 Get optimal rank this process would have in a Cartesian topology.
 
TMPI_EXPORT int tMPI_Cart_create (tMPI_Comm comm_old, int ndims, const int *dims, const int *periods, int reorder, tMPI_Comm *comm_cart)
 Create a comm with a Cartesian topology.
 
TMPI_EXPORT int tMPI_Cart_sub (tMPI_Comm comm, const int *remain_dims, tMPI_Comm *newcomm)
 Create a comms that are sub-spaces of the Cartesian topology communicator.
 
Data type manipulation functions
TMPI_EXPORT int tMPI_Type_contiguous (int count, tMPI_Datatype oldtype, tMPI_Datatype *newtype)
 Create a contiguous data type (the only type possible right now).
 
TMPI_EXPORT int tMPI_Type_commit (tMPI_Datatype *datatype)
 Make a data type ready for use.
 
TMPI_EXPORT int tMPI_Type_free (tMPI_Datatype *datatype)
 Free the datatype.
 
Point-to-point communication functions
TMPI_EXPORT int tMPI_Send (const void *buf, int count, tMPI_Datatype datatype, int dest, int tag, tMPI_Comm comm)
 Send message; blocks until buf is reusable.
 
TMPI_EXPORT int tMPI_Recv (void *buf, int count, tMPI_Datatype datatype, int source, int tag, tMPI_Comm comm, tMPI_Status *status)
 Receive message; blocks until buf is filled.
 
TMPI_EXPORT int tMPI_Sendrecv (const void *sendbuf, int sendcount, tMPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, tMPI_Datatype recvtype, int source, int recvtag, tMPI_Comm comm, tMPI_Status *status)
 Send & receive message at the same time.
 
TMPI_EXPORT int tMPI_Isend (const void *buf, int count, tMPI_Datatype datatype, int dest, int tag, tMPI_Comm comm, tMPI_Request *request)
 Initiate sending a message, non-blocking.
 
TMPI_EXPORT int tMPI_Irecv (void *buf, int count, tMPI_Datatype datatype, int source, int tag, tMPI_Comm comm, tMPI_Request *request)
 Initiate receiving a message.
 
TMPI_EXPORT int tMPI_Test (tMPI_Request *request, int *flag, tMPI_Status *status)
 Test whether a message is transferred.
 
TMPI_EXPORT int tMPI_Wait (tMPI_Request *request, tMPI_Status *status)
 Wait until a message is transferred.
 
TMPI_EXPORT int tMPI_Waitall (int count, tMPI_Request *array_of_requests, tMPI_Status *array_of_statuses)
 Wait until several messages are transferred.
 
TMPI_EXPORT int tMPI_Testall (int count, tMPI_Request *array_of_requests, int *flag, tMPI_Status *array_of_statuses)
 Test whether several messages are transferred.
 
TMPI_EXPORT int tMPI_Waitany (int count, tMPI_Request *array_of_requests, int *index, tMPI_Status *status)
 Wait until one of several messages is transferred.
 
TMPI_EXPORT int tMPI_Testany (int count, tMPI_Request *array_of_requests, int *index, int *flag, tMPI_Status *status)
 Test whether one of several messages is transferred.
 
TMPI_EXPORT int tMPI_Waitsome (int incount, tMPI_Request *array_of_requests, int *outcount, int *array_of_indices, tMPI_Status *array_of_statuses)
 Wait until some of several messages are transferred.
 
TMPI_EXPORT int tMPI_Testsome (int incount, tMPI_Request *array_of_requests, int *outcount, int *array_of_indices, tMPI_Status *array_of_statuses)
 Test whether some of several messages are transferred.
 
TMPI_EXPORT int tMPI_Get_count (const tMPI_Status *status, tMPI_Datatype datatype, int *count)
 get the number of actually transferred items from a receive status.
 
Synchronization functions
TMPI_EXPORT int tMPI_Barrier (tMPI_Comm comm)
 Block until all threads in the comm call this function.
 
Multicast communication functions
TMPI_EXPORT int tMPI_Bcast (void *buffer, int count, tMPI_Datatype datatype, int root, tMPI_Comm comm)
 Broadcast from one thread to all others in comm.
 
TMPI_EXPORT int tMPI_Gather (const void *sendbuf, int sendcount, tMPI_Datatype sendtype, void *recvbuf, int recvcount, tMPI_Datatype recvtype, int root, tMPI_Comm comm)
 Gather data from all threads in comm to root.
 
TMPI_EXPORT int tMPI_Gatherv (const void *sendbuf, int sendcount, tMPI_Datatype sendtype, void *recvbuf, const int *recvcounts, const int *displs, tMPI_Datatype recvtype, int root, tMPI_Comm comm)
 Gather irregularly laid out data from all processes in comm to root.
 
TMPI_EXPORT int tMPI_Scatter (const void *sendbuf, int sendcount, tMPI_Datatype sendtype, void *recvbuf, int recvcount, tMPI_Datatype recvtype, int root, tMPI_Comm comm)
 Spread parts of sendbuf to all processes in comm from root.
 
TMPI_EXPORT int tMPI_Scatterv (const void *sendbuf, const int *sendcounts, const int *displs, tMPI_Datatype sendtype, void *recvbuf, int recvcount, tMPI_Datatype recvtype, int root, tMPI_Comm comm)
 Spread irregularly laid out parts of sendbuf to all processes in comm from root.
 
TMPI_EXPORT int tMPI_Alltoall (const void *sendbuf, int sendcount, tMPI_Datatype sendtype, void *recvbuf, int recvcount, tMPI_Datatype recvtype, tMPI_Comm comm)
 Spread out parts of sendbuf to all processes from all processes in comm.
 
TMPI_EXPORT int tMPI_Alltoallv (const void *sendbuf, const int *sendcounts, const int *sdispls, tMPI_Datatype sendtype, void *recvbuf, const int *recvcounts, const int *rdispls, tMPI_Datatype recvtype, tMPI_Comm comm)
 Spread out irregularly laid out parts of sendbuf to all processes from all processes in comm.
 
Reduce functions
TMPI_EXPORT int tMPI_Reduce (const void *sendbuf, void *recvbuf, int count, tMPI_Datatype datatype, tMPI_Op op, int root, tMPI_Comm comm)
 Do an operation between all locally held buffers on all items in the buffers, and send the results to root.
 
TMPI_EXPORT int tMPI_Allreduce (const void *sendbuf, void *recvbuf, int count, tMPI_Datatype datatype, tMPI_Op op, tMPI_Comm comm)
 Do an operation between all locally held buffers on all items in the buffers and broadcast the results.
 
TMPI_EXPORT int tMPI_Reduce_fast (const void *sendbuf, void *recvbuf, int count, tMPI_Datatype datatype, tMPI_Op op, int root, tMPI_Comm comm)
 Do an tMPI_Reduce, but with the following assumption: recvbuf points to a valid buffer in all calling threads, or sendbuf has the value TMPI_IN_PLACE (in which case the values of sendbuf may be changed in that thread).
 
TMPI_EXPORT int tMPI_Scan (const void *sendbuf, void *recvbuf, int count, tMPI_Datatype datatype, tMPI_Op op, tMPI_Comm comm)
 Do a partial reduce operation, based on rank: the results of the reduction operation of ranks 0 - i will be put in the recvbuf of rank i.
 
Mutexes
TMPI_EXPORT int tMPI_Thread_mutex_init (tMPI_Thread_mutex_t *mtx)
 Initialize a new mutex.
 
TMPI_EXPORT int tMPI_Thread_mutex_destroy (tMPI_Thread_mutex_t *mtx)
 Kill a mutex you no longer need.
 
TMPI_EXPORT int tMPI_Thread_mutex_lock (tMPI_Thread_mutex_t *mtx)
 Wait for exclusive access to a mutex.
 
TMPI_EXPORT int tMPI_Thread_mutex_trylock (tMPI_Thread_mutex_t *mtx)
 Try to lock a mutex, return if busy.
 
TMPI_EXPORT int tMPI_Thread_mutex_unlock (tMPI_Thread_mutex_t *mtx)
 Release the exclusive access to a mutex.
 
Thread-specific storage
TMPI_EXPORT int tMPI_Thread_key_create (tMPI_Thread_key_t *key, void(*destructor)(void *))
 Initialize thread-specific-storage handle.
 
TMPI_EXPORT int tMPI_Thread_key_delete (tMPI_Thread_key_t key)
 Delete thread-specific-storage handle.
 
TMPI_EXPORT void * tMPI_Thread_getspecific (tMPI_Thread_key_t key)
 Get value for thread-specific-storage in this thread.
 
TMPI_EXPORT int tMPI_Thread_setspecific (tMPI_Thread_key_t key, void *value)
 Set value for thread-specific-storage in this thread.
 
Run-once
TMPI_EXPORT int tMPI_Thread_once (tMPI_Thread_once_t *once_data, void(*init_routine)(void))
 Run the provided routine exactly once.
 
Condition variables
TMPI_EXPORT int tMPI_Thread_cond_init (tMPI_Thread_cond_t *cond)
 Initialize condition variable.
 
TMPI_EXPORT int tMPI_Thread_cond_destroy (tMPI_Thread_cond_t *cond)
 Destroy condition variable.
 
TMPI_EXPORT int tMPI_Thread_cond_wait (tMPI_Thread_cond_t *cond, tMPI_Thread_mutex_t *mtx)
 Wait for a condition to be signaled.
 
TMPI_EXPORT int tMPI_Thread_cond_signal (tMPI_Thread_cond_t *cond)
 Unblock one waiting thread.
 
TMPI_EXPORT int tMPI_Thread_cond_broadcast (tMPI_Thread_cond_t *cond)
 Unblock all waiting threads.
 
Barriers
TMPI_EXPORT int tMPI_Thread_barrier_init (tMPI_Thread_barrier_t *barrier, int count)
 Initialize a synchronization barrier type.
 
TMPI_EXPORT int tMPI_Thread_barrier_destroy (tMPI_Thread_barrier_t *barrier)
 Release data in a barrier datatype.
 
TMPI_EXPORT int tMPI_Thread_barrier_wait (tMPI_Thread_barrier_t *barrier)
 Perform barrier synchronization.
 

Variables

tMPI_Thread_key_t id_key
 
int Nthreads
 
struct tmpi_thread * threads
 
TMPI_EXPORT tMPI_Comm TMPI_COMM_WORLD
 Pre-initialized communicator with all available threads.
 
tMPI_Errhandler TMPI_ERRORS_ARE_FATAL
 pre-defined error handler that abort()s on every error
 
tMPI_Errhandler TMPI_ERRORS_RETURN
 pre-defined error handler that tries to continue on every error
 
struct tmpi_global * tmpi_global
 
tMPI_Group TMPI_GROUP_EMPTY
 the empty group
 
tMPI Data types

These are MPI data types as specified by the MPI standard. Note that not all are available.

TMPI_EXPORT const tMPI_Datatype TMPI_C_BOOL
 bool
 
TMPI_EXPORT const tMPI_Datatype TMPI_CHAR
 char
 
TMPI_EXPORT const tMPI_Datatype TMPI_SHORT
 short
 
TMPI_EXPORT const tMPI_Datatype TMPI_INT
 int
 
TMPI_EXPORT const tMPI_Datatype TMPI_LONG
 long
 
TMPI_EXPORT const tMPI_Datatype TMPI_SIGNED_CHAR
 signed char
 
TMPI_EXPORT const tMPI_Datatype TMPI_UNSIGNED_CHAR
 unsigned char
 
TMPI_EXPORT const tMPI_Datatype TMPI_UNSIGNED_SHORT
 unsigned short
 
TMPI_EXPORT const tMPI_Datatype TMPI_UNSIGNED
 unsigned int
 
TMPI_EXPORT const tMPI_Datatype TMPI_UNSIGNED_LONG
 unsigned long
 
TMPI_EXPORT const tMPI_Datatype TMPI_FLOAT
 float
 
TMPI_EXPORT const tMPI_Datatype TMPI_DOUBLE
 double
 
TMPI_EXPORT const tMPI_Datatype TMPI_LONG_DOUBLE
 long double
 
TMPI_EXPORT const tMPI_Datatype TMPI_BYTE
 byte (for binary xmissions)
 
TMPI_EXPORT const tMPI_Datatype TMPI_POINTER
 pointer (thread_mpi specific)
 
TMPI_EXPORT const tMPI_Datatype TMPI_INT64_T
 int64_t
 

Thread creation, destruction, and inspection

enum  tMPI_Thread_support { TMPI_THREAD_SUPPORT_NO = 0 , TMPI_THREAD_SUPPORT_YES = 1 }
 Thread support status enumeration. More...
 
enum  tMPI_Thread_setaffinity_support { TMPI_SETAFFINITY_SUPPORT_NO = 0 , TMPI_SETAFFINITY_SUPPORT_YES = 1 }
 Thread setaffinity support status enumeration. More...
 
TMPI_EXPORT int tMPI_Thread_get_hw_number (void)
 Get the number of hardware threads that can be run simultaneously.
 
TMPI_EXPORT int tMPI_Thread_create (tMPI_Thread_t *thread, void *(*start_routine)(void *), void *arg)
 Create a new thread.
 
TMPI_EXPORT int tMPI_Thread_join (tMPI_Thread_t thread, void **value_ptr)
 Wait for a specific thread to finish executing.
 
TMPI_EXPORT void tMPI_Thread_exit (void *value_ptr)
 Terminate calling thread.
 
TMPI_EXPORT int tMPI_Thread_cancel (tMPI_Thread_t thread)
 Ask a thread to exit.
 
TMPI_EXPORT tMPI_Thread_t tMPI_Thread_self (void)
 Get a thread ID of the calling thread.
 
TMPI_EXPORT int tMPI_Thread_equal (tMPI_Thread_t t1, tMPI_Thread_t t2)
 Check whether two thread pointers point to the same thread.
 
TMPI_EXPORT int tMPI_Thread_setaffinity_single (tMPI_Thread_t thread, unsigned int nr)
 Set thread affinity to a single core.
 

Typedef Documentation

◆ MPI_Comm

◆ MPI_Datatype

◆ MPI_Group

◆ MPI_Op

◆ MPI_Request

◆ MPI_Status

◆ tMPI_Atomic_ptr_t

Atomic pointer type equivalent to tMPI_Atomic_t.

Useful for lock-free and wait-free data structures. The only operations available for this type are:

See also

◆ tMPI_Atomic_t

Atomic operations datatype.

Portable synchronization primitives like mutexes are effective for many purposes, but usually not very high performance. One of the problem is that you have the overhead of a function call, and another is that Mutexes often have extra overhead to make the scheduling fair. Finally, if performance is important we don't want to suspend the thread if we cannot lock a mutex, but spin-lock at 100% CPU usage until the resources is available (e.g. increment a counter).

These things can often be implemented with inline-assembly or other system-dependent functions, and we provide such functionality for the most common platforms. For portability we also have a fallback implementation using a mutex for locking.

Performance-wise, the fastest solution is always to avoid locking completely (obvious, but remember it!). If you cannot do that, the next best thing is to use atomic operations that e.g. increment a counter without explicit locking. Spinlocks are useful to lock an entire region, but leads to more overhead and can be difficult to debug - it is up to you to make sure that only the thread owning the lock unlocks it!

You should normally NOT use atomic operations for things like I/O threads. These should yield to other threads while waiting for the disk instead of spinning at 100% CPU usage.

It is imperative that you use the provided routines for reading and writing, since some implementations require memory barriers before the CPU or memory sees an updated result. The structure contents is only visible here so it can be inlined for performance - it might change without further notice.

Note
No initialization is required for atomic variables.

Currently, we have (real) atomic operations for:

  • gcc version 4.1 and later (all platforms)
  • x86 or x86_64, using GNU compilers
  • x86 or x86_64, using Intel compilers
  • x86 or x86_64, using Pathscale compilers
  • Itanium, using GNU compilers
  • Itanium, using Intel compilers
  • Itanium, using HP compilers
  • PowerPC, using GNU compilers
  • PowerPC, using IBM AIX compilers
  • PowerPC, using IBM compilers >=7.0 under Linux or Mac OS X.
  • Sparc64, using Fujitsu compilers.
See also

◆ tMPI_Barrier_t

typedef struct tMPI_Barrier_t PLMD::thread_mpi::tMPI_Barrier_t

◆ tmpi_bool

◆ tMPI_Comm

tMPI Communicator

Holds the group of processes to communicate with, and defines the scope for global operations such as broadcast.

◆ tMPI_Datatype

tMPI datatype

tMPI data type structure. Holds info about datatypes.

◆ tmpi_dt

◆ tMPI_Errhandler

error handler object

◆ tMPI_Errhandler_fn

typedef void(* PLMD::thread_mpi::tMPI_Errhandler_fn) (tMPI_Comm *, int *)

error handler function

◆ tMPI_Event

◆ tMPI_Group

tMPI Group

The group structure. Contains a list of threads.

◆ tMPI_Lock_t

◆ tMPI_Op_fn

typedef void(* PLMD::thread_mpi::tMPI_Op_fn) (void *, const void *, const void *, int)

◆ tMPI_Request

tMPI Request

Request structure for holding data about non-blocking transfers.

◆ tMPI_Spinlock_t

Spinlock.

Spinlocks provide a faster synchronization than mutexes, although they consume CPU-cycles while waiting. They are implemented with atomic operations and inline assembly whenever possible, and otherwise we use a fallback implementation where a spinlock is identical to a mutex (this is one of the reasons why you have to initialize them).

There are no guarantees whatsoever about fair scheduling or debugging if you make a mistake and unlock a variable somebody else has locked - performance is the primary goal of spinlocks.

See also

◆ tMPI_Stack_element

typedef struct PLMD::thread_mpi::tMPI_Stack_element PLMD::thread_mpi::tMPI_Stack_element

A single element in stack.

◆ tMPI_Status

tMPI Status.

Holds status info (tag, sender, amount of data transmitted) for receives. The status object is user-maintained.

◆ tMPI_Thread_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Error codes.

Enumerator
TMPI_SUCCESS 

No error

TMPI_ERR_NO_MEM 

Out of memory

TMPI_ERR_IO 

I/O Error (used for system errors)

TMPI_ERR_INIT 

Initialization error

TMPI_ERR_FINALIZE 

Finalize error

TMPI_ERR_GROUP 

Group error

TMPI_ERR_COMM 

Comm error

TMPI_ERR_STATUS 

Status error

TMPI_ERR_GROUP_RANK 

Group rank error

TMPI_ERR_DIMS 

Invalid topology dimensions

TMPI_ERR_COORDS 

Invalid topology coordinates

TMPI_ERR_CART_CREATE_NPROCS 

Not enough processes for topology

TMPI_ERR_XFER_COUNTERPART 

Invalid counterpart for xfer

TMPI_ERR_XFER_BUFSIZE 

buffer size too small

TMPI_ERR_XFER_BUF_OVERLAP 

buffer overlaps (thread error?)

TMPI_ERR_SEND_DEST 

Faulty send destination

TMPI_ERR_RECV_SRC 

Faulty receive source

TMPI_ERR_BUF 

Invalid buffer

TMPI_ERR_MULTI_MISMATCH 

Comm not the same in collective call

TMPI_ERR_OP_FN 

Invalid reduce operator

TMPI_ERR_ENVELOPES 

out of envelopes (tMPI internal)

TMPI_ERR_REQUESTS 

out of requests (tMPI internal)

TMPI_ERR_COPY_NBUFFERS 

out of copy buffers (tMPI internal)

TMPI_ERR_COPY_BUFFER_SIZE 

copy buffer size err (tMPI internal)

TMPI_ERR_IN_STATUS 

error code in tMPI_Status

TMPI_ERR_PROCNR 

Hardware processor number (such as for thread affinity) error

TMPI_FAILURE 

Transmission failure

TMPI_ERR_TYPE 

Invalid datatype argument

TMPI_ERR_UNKNOWN 

Unknown error

N_TMPI_ERR 

◆ envelope_state

Enumerator
env_unmatched 
env_copying 
env_cb_available 
env_finished 

◆ tMPI_Affinity_strategy

Enumerator
TMPI_AFFINITY_NONE 

Do not set any thread affinity.

TMPI_AFFINITY_ALL_CORES 

Only set affinity if the number of threads is equal to the number of hardware threads (cores + hyperthreads).

This is the only safe way to set thread affinity, without clashes between multiple instances of the same program.

◆ tMPI_Op

tMPI_Reduce operators.

These all work (except obviously bad combinations like bitwise and/or/xor on floats, etc):

Enumerator
TMPI_MAX 

calculate maximum value

TMPI_MIN 

calculate minimum value

TMPI_SUM 

calculate sum

TMPI_PROD 

calculate product

TMPI_LAND 

calculate logical and

TMPI_BAND 

calculate binary and

TMPI_LOR 

calculate logical or

TMPI_BOR 

calculate binary or

TMPI_LXOR 

calculate logical xor

TMPI_BXOR 

calculate binary xor

◆ tMPI_Thread_setaffinity_support

Thread setaffinity support status enumeration.

Check whether this platform supports setting of thread affinity.

This function returns TMPI_SETAFFINITY_SUPPORT_YES if setting thread affinity is supported by the platform, and TMPI_SETAFFINITY_SUPPORT_NO if not. If this function returns 0, the function tMPI_Thread_setaffinity_single will simply return 0 itself, effectively ignoring the request.

Returns
TMPI_SETAFFINITY_SUPPORT_YES if setting affinity is supported, TMPI_SETAFFINITY_SUPPORT_NO otherwise
Enumerator
TMPI_SETAFFINITY_SUPPORT_NO 

Setting thread affinity not supported

TMPI_SETAFFINITY_SUPPORT_YES 

Setting thread affinity supported

◆ tMPI_Thread_support

Thread support status enumeration.

Check if threads are supported.

This routine provides a cleaner way to check if threads are supported instead of sprinkling your code with preprocessor conditionals.

All thread functions are still available even without thread support, but some of them might return failure error codes, for instance if you try to start a thread.

Returns
1 if threads are supported, 0 if not.
Enumerator
TMPI_THREAD_SUPPORT_NO 

Starting threads will fail

TMPI_THREAD_SUPPORT_YES 

Thread support available

Function Documentation

◆ main()

int PLMD::thread_mpi::main ( int argc,
char ** argv )

◆ tMPI_Abort()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Abort ( tMPI_Comm comm,
int errorcode )

Just kills all threads.

Not really neccesary because exit() would do that for us anyway.

Parameters
[in]commComm to kill threads for
[in]errorcodeError code to exit with
Returns
Never returns.

◆ tMPI_Allreduce()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Allreduce ( const void * sendbuf,
void * recvbuf,
int count,
tMPI_Datatype datatype,
tMPI_Op op,
tMPI_Comm comm )

Do an operation between all locally held buffers on all items in the buffers and broadcast the results.

Collective function.

Parameters
[in]sendbufThe operand parameters. Any process may specify TMPI_IN_PLACE, in which case recvbuf will hold the operand parameters for that process.
[in,out]recvbufThe result buffer.
[in]countThe number of items to do operation on.
[in]datatypeThe data type of the items.
[in]opThe operation to perform.
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Alltoall()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Alltoall ( const void * sendbuf,
int sendcount,
tMPI_Datatype sendtype,
void * recvbuf,
int recvcount,
tMPI_Datatype recvtype,
tMPI_Comm comm )

Spread out parts of sendbuf to all processes from all processes in comm.

Collective function.

Parameters
[in]sendbufThe send buffer.
[in]sendcountThe number of items for to send to each thread.
[in]sendtypeThe type of the items to send.
[out]recvbufThe receive buffer for all threads.
[in]recvcountThe number of items recvbuf can receive per thread.
[in]recvtypeThe type of items to receive.
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Alltoallv()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Alltoallv ( const void * sendbuf,
const int * sendcounts,
const int * sdispls,
tMPI_Datatype sendtype,
void * recvbuf,
const int * recvcounts,
const int * rdispls,
tMPI_Datatype recvtype,
tMPI_Comm comm )

Spread out irregularly laid out parts of sendbuf to all processes from all processes in comm.

Collective function.

Parameters
[in]sendbufThe send buffer.
[in]sendcountsList of the number of items for to send to each thread.
[in]sdisplsList of the displacements in sendbuf of items to send to each thread.
[in]sendtypeThe type of the items to send.
[out]recvbufThe receive buffer for all threads.
[in]recvcountsList of the number of items recvbuf can receive from each thread.
[in]rdisplsList of the displacements in recvbuf of items to receive from each thread.
[in]recvtypeThe type of items to receive.
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Atomic_add_return()

static int PLMD::thread_mpi::tMPI_Atomic_add_return ( tMPI_Atomic_t * a,
int i )
inline

Add integer to atomic variable.

Also implements proper memory barriers when necessary. The actual implementation is system-dependent.

Parameters
aatomic datatype to modify
iinteger to increment with. Use i<0 to subtract atomically.
Returns
The new value (after summation).

◆ tMPI_Atomic_cas()

static int PLMD::thread_mpi::tMPI_Atomic_cas ( tMPI_Atomic_t * a,
int old_val,
int new_val )
inline

Atomic compare-and-swap operation.

The old value is compared with the memory value in the atomic datatype. If the are identical, the atomic type is swapped with the new value, and otherwise left unchanged.

This is the synchronization primitive: it has a consensus number of infinity, and is available in some form on all modern CPU architectures. In the words of Herlihy&Shavit (The art of multiprocessor programming), it is the 'king of all wild things'.

In practice, use it as follows: You can start by reading a value (without locking anything), perform some calculations, and then atomically try to update it in memory unless it has changed. If it has changed you will get an error return code - reread the new value an repeat the calculations in that case.

Parameters
aAtomic datatype ('memory' value)
old_valInteger value read from the atomic type at an earlier point
new_valNew value to write to the atomic type if it currently is identical to the old value.
Returns
True (1) if the swap occurred: i.e. if the value in a was equal to old_val. False (0) if the swap didn't occur and the value was not equal to old_val.
Note
The exchange occured if the return value is identical to old.

◆ tMPI_Atomic_fetch_add()

static int PLMD::thread_mpi::tMPI_Atomic_fetch_add ( tMPI_Atomic_t * a,
int i )
inline

Add to variable, return the old value.

This operation is quite useful for synchronization counters. By performing a fetchadd with N, a thread can e.g. reserve a chunk with the next N iterations, and the return value is the index of the first element to treat.

Also implements proper memory barriers when necessary. The actual implementation is system-dependent.

Parameters
aatomic datatype to modify
iinteger to increment with. Use i<0 to subtract atomically.
Returns
The value of the atomic variable before addition.

◆ tMPI_Atomic_get()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Atomic_get ( const tMPI_Atomic_t * a)

Return value of an atomic integer.

Also implements proper memory barriers when necessary. The actual implementation is system-dependent.

Parameters
aAtomic variable to read
Returns
Integer value of the atomic variable

◆ tMPI_Atomic_ptr_cas()

static int PLMD::thread_mpi::tMPI_Atomic_ptr_cas ( tMPI_Atomic_ptr_t * a,
void * old_val,
void * new_val )
inline

Atomic pointer compare-and-swap operation.

The old value is compared with the memory value in the atomic datatype. If the are identical, the atomic type is swapped with the new value, and otherwise left unchanged.

This is essential for implementing wait-free lists and other data structures. See 'tMPI_Atomic_cas()'.

Parameters
aAtomic datatype ('memory' value)
old_valPointer value read from the atomic type at an earlier point
new_valNew value to write to the atomic type if it currently is identical to the old value.
Returns
True (1) if the swap occurred: i.e. if the value in a was equal to old_val. False (0) if the swap didn't occur and the value was not equal to old_val.
Note
The exchange occured if the return value is identical to old.

◆ tMPI_Atomic_ptr_get()

TMPI_EXPORT void * PLMD::thread_mpi::tMPI_Atomic_ptr_get ( const tMPI_Atomic_ptr_t * a)

Return value of an atomic pointer.

Also implements proper memory barriers when necessary. The actual implementation is system-dependent.

Parameters
aAtomic variable to read
Returns
Pointer value of the atomic variable

◆ tMPI_Atomic_ptr_set()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Atomic_ptr_set ( tMPI_Atomic_ptr_t * a,
void * p )

Write value to an atomic pointer.

Also implements proper memory barriers when necessary. The actual implementation is system-dependent.

Parameters
aAtomic variable
pPointer value to set the atomic variable to.

◆ tMPI_Atomic_ptr_swap()

static void * PLMD::thread_mpi::tMPI_Atomic_ptr_swap ( tMPI_Atomic_ptr_t * a,
void * b )
inline

Atomic swap pointer operation.

Atomically swaps the pointer in the tMPI_Atomic_ptr_t operand with the value of b. Note: This has no good assembly counterparts on many architectures, so it might not be faster than a repreated CAS.

Parameters
aPointer to atomic type
bValue to swap
Returns
the original value of a

◆ tMPI_Atomic_set()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Atomic_set ( tMPI_Atomic_t * a,
int i )

Write value to an atomic integer.

Also implements proper memory barriers when necessary. The actual implementation is system-dependent.

Parameters
aAtomic variable
iInteger to set the atomic variable to.

◆ tMPI_Atomic_swap()

static int PLMD::thread_mpi::tMPI_Atomic_swap ( tMPI_Atomic_t * a,
int b )
inline

Atomic swap operation.

Atomically swaps the data in the tMPI_Atomic_t operand with the value of b. Note: This has no good assembly counterparts on many architectures, so it might not be faster than a repreated CAS.

Parameters
aPointer to atomic type
bValue to swap
Returns
the original value of a

◆ tMPI_Barrier()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Barrier ( tMPI_Comm comm)

Block until all threads in the comm call this function.

Parameters
[in]commThe comm object.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Barrier_init()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Barrier_init ( tMPI_Barrier_t * barrier,
int count )

Initialize barrier.

Parameters
barrierPointer to spinlock barrier. Note that this is not the same datatype as the full, thread based, barrier.
countNumber of threads to synchronize. All threads will be released after count calls to tMPI_Barrier_wait().

◆ tMPI_Barrier_wait()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Barrier_wait ( tMPI_Barrier_t * barrier)

Perform yielding, busy-waiting barrier synchronization.

This function blocks until it has been called N times, where N is the count value the barrier was initialized with. After N total calls all threads return. The barrier automatically cycles, and thus requires another N calls to unblock another time.

Parameters
barrierPointer to previously created barrier.
Returns
The last thread returns -1, all the others 0.

◆ tMPI_Bcast()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Bcast ( void * buffer,
int count,
tMPI_Datatype datatype,
int root,
tMPI_Comm comm )

Broadcast from one thread to all others in comm.

Collective function; data is transferred from root's buffer to all others' buffer.

Parameters
[in,out]bufferThe buffer to send from (root)/receive from (other threads).
[in]countThe number of items to send/receive.
[in]datatypeThe type of the items to send/receive.
[in]rootThe rank of the sending thread.
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Calloc_local()

TMPI_EXPORT void * PLMD::thread_mpi::tMPI_Calloc_local ( size_t nmemb,
size_t size )

Allocate local memory by array and element size.

See also
calloc()
Parameters
[in]nmemb= number of array members
[in]size= size in units of sizeof() of a single array element
Returns
Pointer to allocated memory, or NULL in case of failure

◆ tMPI_Cart_coords()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Cart_coords ( tMPI_Comm comm,
int rank,
int maxdims,
int * coords )

Get coordinates of a process rank in a Cartesian topology.

Parameters
[in]commThe comm to query.
[in]rankThe rank associated with the coordinates.
[in]maxdimsThe maximum number of dimensions in the coords parameter.
[out]coordsThe coordinates in each dimension.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Cart_create()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Cart_create ( tMPI_Comm comm_old,
int ndims,
const int * dims,
const int * periods,
int reorder,
tMPI_Comm * comm_cart )

Create a comm with a Cartesian topology.

Parameters
[in]comm_oldThe originating comm.
[in]ndimsThe number of dimensions.
[in]dimsThe size in each dimension.
[in]periodsThe periodicity in each dimension.
[in]reorderWhether to allow reordering of the threads according to tMPI_Cart_map().
[out]comm_cartThe new comm with Cartesian topology.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Cart_destroy()

void PLMD::thread_mpi::tMPI_Cart_destroy ( struct cart_topol * top)

◆ tMPI_Cart_get()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Cart_get ( tMPI_Comm comm,
int maxdims,
int * dims,
int * periods,
int * coords )

Get the size and pbc a of a comm with a Cartesian topology has.

Parameters
[in]commThe comm to query.
[in]maxdimsThe maximum number of dimensions in the periods and coords parameter.
[out]dimsThe number of dimensions.
[out]periodsThe periodicity in each dimension.
[out]coordsThe number of coordinates in each dimension.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Cart_map()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Cart_map ( tMPI_Comm comm,
int ndims,
const int * dims,
const int * periods,
int * newrank )

Get optimal rank this process would have in a Cartesian topology.

Parameters
[in]commThe comm to query.
[in]ndimsThe number of dimensions.
[in]dimsThe size in each dimension.
[in]periodsThe periodicity in each dimension.
[out]newrankThe rank the thread would have given the topology.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Cart_rank()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Cart_rank ( tMPI_Comm comm,
const int * coords,
int * rank )

Get rank that a specific set of process coordinates has in a Cartesian topology.

Parameters
[in]commThe comm to query.
[in]coordsThe coordinates in each dimension.
[out]rankThe rank associated with the coordinates.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Cart_sub()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Cart_sub ( tMPI_Comm comm,
const int * remain_dims,
tMPI_Comm * newcomm )

Create a comms that are sub-spaces of the Cartesian topology communicator.

Works like a MPI_Comm_split() for the Cartesian dimensions specified as false in remain_dims.

Parameters
[in]commThe originating comm with Cartesian topology.
[in]remain_dimsAn Boolean array that decides whether a specific dimensionality should remain in newcomm (if true), or should be split up (if false).
[out]newcommThe new split communicator
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Cartdim_get()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Cartdim_get ( tMPI_Comm comm,
int * ndims )

Get the dimensionality of a comm with a topology.

Parameters
[in]commThe comm to query.
[out]ndimsThe number of dimensions.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Coll_env_destroy()

void PLMD::thread_mpi::tMPI_Coll_env_destroy ( struct coll_env * mev)

◆ tMPI_Coll_env_init()

int PLMD::thread_mpi::tMPI_Coll_env_init ( struct coll_env * mev,
int N )

◆ tMPI_Coll_root_xfer()

void PLMD::thread_mpi::tMPI_Coll_root_xfer ( tMPI_Comm comm,
tMPI_Datatype sendtype,
tMPI_Datatype recvtype,
size_t sendsize,
size_t recvsize,
void * sendbuf,
void * recvbuf,
int * ret )

◆ tMPI_Coll_sync_destroy()

void PLMD::thread_mpi::tMPI_Coll_sync_destroy ( struct coll_sync * msc)

◆ tMPI_Coll_sync_init()

int PLMD::thread_mpi::tMPI_Coll_sync_init ( struct coll_sync * msc,
int N )

◆ tMPI_Comm_alloc()

int PLMD::thread_mpi::tMPI_Comm_alloc ( tMPI_Comm * newcomm,
tMPI_Comm parent,
int N )

◆ tMPI_Comm_compare()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Comm_compare ( tMPI_Comm comm1,
tMPI_Comm comm2,
int * result )

Compare two comms.

Returns TMPI_IDENT if the two comms point to the same underlying comm structure, TMPI_CONGRUENT if all members appear in the both comms in the same order, TMPI_SIMILAR if both comms have the smae members but not in the same order, or TMPI_UNEQUAL if the comms have different members.

Parameters
[in]comm1The first comm to compare.
[in]comm2The second comm to compare.
[out]resultThe output result, one of the values described above.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Comm_create()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Comm_create ( tMPI_Comm comm,
tMPI_Group group,
tMPI_Comm * newcomm )

Create a comm based on group membership.

Collective function that creates a new comm containing only proceses that are members of the given group.

Parameters
[in]commThe originating comm.
[in]groupThe group of threads to create a comm from.
[out]newcommThe new comm.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Comm_destroy()

int PLMD::thread_mpi::tMPI_Comm_destroy ( tMPI_Comm comm,
tmpi_bool do_link_lock )

◆ tMPI_Comm_dup()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Comm_dup ( tMPI_Comm comm,
tMPI_Comm * newcomm )

Make a duplicate of a comm.

Collective function.

Parameters
[in]commThe originating comm.
[in]newcommThe new comm.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Comm_free()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Comm_free ( tMPI_Comm * comm)

De-allocate a comm.

Collective function.

Parameters
[in]commThe comm to free.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Comm_get_errhandler()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Comm_get_errhandler ( tMPI_Comm comm,
tMPI_Errhandler * errhandler )

get the error handler.

Gets the error handler associated with a comm

Parameters
[in]commthe communicator to get the error handler for.
[out]errhandlerthe error handler.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Comm_group()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Comm_group ( tMPI_Comm comm,
tMPI_Group * group )

Get a pointer to the group in the comm.

Parameters
[in]commThe comm from which to take the group.
[out]groupThe comm's group.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Comm_N()

int PLMD::thread_mpi::tMPI_Comm_N ( tMPI_Comm comm)

◆ tMPI_Comm_rank()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Comm_rank ( tMPI_Comm comm,
int * rank )

get the rank in comm of the current process

Parameters
[in]commThe comm to query.
[out]rankThread rank in comm.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Comm_seek_rank()

int PLMD::thread_mpi::tMPI_Comm_seek_rank ( tMPI_Comm comm,
struct tmpi_thread * th )

◆ tMPI_Comm_set_errhandler()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Comm_set_errhandler ( tMPI_Comm comm,
tMPI_Errhandler errhandler )

Set the error handler.

Parameters
[in]commthe communicator to set the error handler for.
[in]errhandlerthe error handler.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Comm_size()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Comm_size ( tMPI_Comm comm,
int * size )

Get the comm size (nr.

of threads).

Parameters
[in]commThe comm to query.
[out]sizeThe comm size.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Comm_split()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Comm_split ( tMPI_Comm comm,
int color,
int key,
tMPI_Comm * newcomm )

Split up a group into same-colored sub-groups ordered by key.

This is the main comm creation function: it's a collective call that takes a color and a key from each process, and arranges all threads that call tMPI_Split() withe the same color together into a comm.

The rank in the new group will be based on the value given in key.

Passing TMPI_UNDEFINED as a color will result in the thread not being part of any group, and getting TMPI_COMM_NULL back in newcomm.

Parameters
[in]commThe originating comm.
[in]colorThis thread's color (determines which comm it will be in). Giving TMPI_UNDEFINED will result in this thread not being in any group.
[in]keyThis thread's key (determines rank).
[out]newcommThe new comm.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Create_errhandler()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Create_errhandler ( tMPI_Errhandler_fn * function,
tMPI_Errhandler * errhandler )

Create an error handler object from a function.

Parameters
[in]functionThe function to make an error handler of.
[out]errhandlerThe error handler.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Errhandler_free()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Errhandler_free ( tMPI_Errhandler * errhandler)

Free the error handler object.

Parameters
[in]errhandlerThe error handler.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Error()

int PLMD::thread_mpi::tMPI_Error ( tMPI_Comm comm,
int tmpi_errno )

◆ tMPI_Error_string()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Error_string ( int errorcode,
char * string,
int * resultlen )

get the error string associated with an error code.

The length of the error string will never exceed TMPI_MAX_ERROR_STRING.

Parameters
[in]errorcodeThe error code.
[out]stringThe pre-allocated char pointer to output to.
[out]resultlenThe length of the error string. Will never be longer than TMPI_MAX_ERROR_STRING.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tmpi_errors_are_fatal_fn()

void PLMD::thread_mpi::tmpi_errors_are_fatal_fn ( tMPI_Comm * comm,
int * err )

◆ tmpi_errors_return_fn()

void PLMD::thread_mpi::tmpi_errors_return_fn ( tMPI_Comm * comm,
int * err )

◆ tMPI_Event_destroy()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Event_destroy ( tMPI_Event * ev)

Deallocate the internals of the contents of event object.

Parameters
evThe event structure to be destroyed.

◆ tMPI_Event_init()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Event_init ( tMPI_Event * ev)

Initialize the event object.

Parameters
evThe event structure to be intialized.

◆ tMPI_Event_wait()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Event_wait ( tMPI_Event * ev)

Wait for an event to occur.

Sets the number of events that had occurred during the wait in N.

Parameters
evThe event structure to wait on.
Returns
The number of events that have occurred at function return time.

◆ tMPI_Fatal_error()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Fatal_error ( const char * file,
int line,
const char * message,
... )

handle a fatal error.

Parameters
filesource code file name of error.
linesource code line number of error.
messageformat string for error message.

◆ tMPI_Finalize()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Finalize ( void )

Waits for all other threads to finish and cleans up.

Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Finalized()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Finalized ( int * flag)

Determine whether tMPI_Finalize has been run.

Parameters
[out]flagSet to TRUE if tMPI_Finalize() has been called, FALSE if not.
Returns
always returns TMPI_SUCCESS.

◆ tMPI_Free()

void PLMD::thread_mpi::tMPI_Free ( void * p)

◆ tMPI_Free_env_list_destroy()

void PLMD::thread_mpi::tMPI_Free_env_list_destroy ( struct free_envelope_list * evl)

◆ tMPI_Free_env_list_init()

int PLMD::thread_mpi::tMPI_Free_env_list_init ( struct free_envelope_list * evl,
int N )

◆ tMPI_Free_numa()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Free_numa ( void * ptr)

Free memory allocate with any of the NUMA-aware allocators.

See also
calloc()
Parameters
[in]ptr= pointer to block of memory allocated with a NUMA allocator
Returns
Returns debug info: 0 if the memory was allocated with a NUMA allocator, 1 if it was allocated by another allocator.

◆ tMPI_Gather()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Gather ( const void * sendbuf,
int sendcount,
tMPI_Datatype sendtype,
void * recvbuf,
int recvcount,
tMPI_Datatype recvtype,
int root,
tMPI_Comm comm )

Gather data from all threads in comm to root.

Collective function; assumes that all data is received in blocks of recvcount.

Parameters
[in]sendbufThe send buffer for all threads (root may specify TMPI_IN_PLACE, in which case it transfers nothing to itself).
[in]sendcountThe number of items to send for all threads.
[in]sendtypeThe type of the items to send.
[out]recvbufThe receiving buffer (for root thread).
[in]recvcountThe number of items to receive (for root).
[in]recvtypeThe type of the items to receive (for root).
[in]rootThe rank of root.
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Gatherv()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Gatherv ( const void * sendbuf,
int sendcount,
tMPI_Datatype sendtype,
void * recvbuf,
const int * recvcounts,
const int * displs,
tMPI_Datatype recvtype,
int root,
tMPI_Comm comm )

Gather irregularly laid out data from all processes in comm to root.

Collective function.

Parameters
[in]sendbufThe send buffer for all threads (root may specify TMPI_IN_PLACE, in which case it transfers nothing to itself).
[in]sendcountThe number of items to send for all threads.
[in]sendtypeThe type of the items to send.
[out]recvbufThe receiving buffer (for root thread).
[in]recvcountsThe list of number of items to receive (for root).
[in]displsThe list of displacements in recvbuf to receive data in (for root).
[in]recvtypeThe type of the items to receive (for root).
[in]rootThe rank of root.
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Get_cev()

struct coll_env * PLMD::thread_mpi::tMPI_Get_cev ( tMPI_Comm comm,
int myrank,
int * synct )

◆ tMPI_Get_comm_self()

tMPI_Comm PLMD::thread_mpi::tMPI_Get_comm_self ( void )

◆ tMPI_Get_count()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Get_count ( const tMPI_Status * status,
tMPI_Datatype datatype,
int * count )

get the number of actually transferred items from a receive status.

Parameters
[in]statusThe status.
[in]datatypeThe data type which was received.
[out]countThe number of items actually received.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Get_hw_nthreads()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Get_hw_nthreads ( void )

◆ tMPI_Get_N()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Get_N ( int * argc,
char *** argv,
const char * optname,
int * nthreads )

get the number of threads from the command line

can be called before tMPI_Init()

Parameters
[in]argcargc from main()
[in]argvargv from main()
[in]optnamename of the argument specifying the number of threads to run. If this is NULL, this function will read the first argument and interpret it as the number of threads.
[out]nthreadsthe number of threads
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Get_processor_name()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Get_processor_name ( char * name,
int * resultlen )

returns string with thread number.

Parameters
[out]namePre-allocated string to output name to (will not be longer than TMPI_MAX_PROCESSOR_NAME).
[out]resultlenThe length of the output. Note that this is an int instead of a size_t because the MPI standard for some reason defines all sizes as int
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Get_recommended_nthreads()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Get_recommended_nthreads ( void )

Determine the recommended number of hardware threads to run on.

Returns the total number of cores and SMT threads to run on. This is equal to the number of hardware threads available, or 1 if the number can't be determined, or if there are no atomics for this platform.

Returns
The maximum number of threads to run on.

◆ tMPI_Get_req()

struct tmpi_req_ * PLMD::thread_mpi::tMPI_Get_req ( struct req_list * rl)

◆ tMPI_Group_alloc()

tMPI_Group PLMD::thread_mpi::tMPI_Group_alloc ( void )

◆ tMPI_Group_free()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Group_free ( tMPI_Group * group)

De-allocate a group.

Parameters
[in]groupThe group to de-allocate.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Group_incl()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Group_incl ( tMPI_Group group,
int n,
const int * ranks,
tMPI_Group * newgroup )

Create a new group as a the collection of threads with given ranks.

Parameters
[in]groupThe group from which the ranks are taken.
[in]nThe number of new group members.
[in]ranksThe ranks of the threads to add to the new group.
[out]newgroupThe new group.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Group_rank()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Group_rank ( tMPI_Group group,
int * rank )

Get the rank of a thread in a group.

Parameters
[in]groupThe group.
[out]rankVariable for the rank, or TMPI_UNDEFINED if not in group.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Group_size()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Group_size ( tMPI_Group group,
int * size )

Get the size (number of members) of a group.

Parameters
[in]groupThe group.
[out]sizeSize.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_In_group()

tmpi_bool PLMD::thread_mpi::tMPI_In_group ( tMPI_Group group)

◆ tMPI_Init()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Init ( int * argc,
char *** argv,
int(* start_function )(int, char **) )

Traditional MPI initializer; spawns threads that start at the given function.

Seeks the argument '-nt n', where n is the number of threads that will be created. If n==0, the number of threads will be the recommended number of threads for this platform as obtained from tMPI_Get_recommended_ntreads().

The new threads then run the function start_function, with the original argc and argv. This function could be main(), or any other function; calling this function again - whether from the started threads or from the main thread - has no effect.

On platforms that support thread affinity setting, this function will use the 'all-cores' affinity strategy: it will only set thread affinity if the number of threads is equal to the number of hardware threads (cores + hyperthreads).

Parameters
[in]argcargc of original main() invocation, or NULL
[in]argvargv of original main() invocation, or NULL.
[in]start_functionStarting function of type int start_function(int argc, char *argv[]);
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Init_fn()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Init_fn ( int main_thread_returns,
int N,
tMPI_Affinity_strategy aff_strategy,
void(* start_function )(const void *),
const void * arg )

Generic init function thread MPI intializer and thread spawner.

Creates N threads (including main thread) that run the function start_function, which takes a void* argument, given by arg. The function start_function also gets called by the main thread. When the function start_function returns it, will behave as if tMPI_Finalize is called, and if it's a sub-thread it will stop running.

If N==0, the number of threads will be the recommended number of threads for this platform as obtained from tMPI_Get_recommended_ntreads().

Note that thread affinity strategy only has an effect when this is supported by the underlying platform. As of yet (2012), this is not the case for Mac OS X, for example.

Parameters
[in]main_thread_returnswhether the control in the main thread should return immediately (if true), or the start_function() should be called from the main thread, too (if false).
[in]NThe number of threads to start (or 0 to automatically determine this).
[in]aff_strategyThe thread affinity strategy to use.
[in]start_functionThe function to start threads at (including main thread if main_thread_returns).
[in]argAn optional argument for start_function().
Returns
TMPI_FAILURE on failure, TMPI_SUCCESS on succes (after all threads have finished if main_thread_returns=true).

◆ tMPI_Initialized()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Initialized ( int * flag)

whether tMPI_Init, but not yet tMPI_Finalize, has been run

Parameters
[out]flagSet to TRUE if tMPI_Init() has been called, FALSE if not.
Returns
always returns TMPI_SUCCESS.

◆ tMPI_Irecv()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Irecv ( void * buf,
int count,
tMPI_Datatype datatype,
int source,
int tag,
tMPI_Comm comm,
tMPI_Request * request )

Initiate receiving a message.

This makes the buffer available to be filled with data. The contents of buf should not be relied on before the transmission is finished with tMPI_Wait(), tMPI_Test() or tMPI_Waitall().

Parameters
[out]bufThe buffer for data to receive.
[in]countThe maximum number of items to receive.
[in]datatypeThe data type of the items in buf.
[in]sourceThe rank of the source thread (or TMPI_ANY_SOURCE).
[in]tagThe message tag (or TMPI_ANY_TAG).
[in]commThe shared communicator.
[out]requestThe request object that can be used in tMPI_Wait(), tMPI_Test, etc.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Is_master()

tmpi_bool PLMD::thread_mpi::tMPI_Is_master ( void )

◆ tMPI_Isend()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Isend ( const void * buf,
int count,
tMPI_Datatype datatype,
int dest,
int tag,
tMPI_Comm comm,
tMPI_Request * request )

Initiate sending a message, non-blocking.

This makes the buffer available to be received. The contents of buf should not be touched before the transmission is finished with tMPI_Wait(), tMPI_Test() or tMPI_Waitall().

Parameters
[in]bufThe buffer with data to send.
[in]countThe number of items to send.
[in]datatypeThe data type of the items in buf.
[in]destThe rank of the destination thread.
[in]tagThe message tag.
[in]commThe shared communicator.
[out]requestThe request object that can be used in tMPI_Wait(), tMPI_Test, etc.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Lock_init()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Lock_init ( tMPI_Lock_t * lock)

Initialize lock.

Parameters
lockPointer to the new lock.

◆ tMPI_Lock_islocked()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Lock_islocked ( tMPI_Lock_t * lock)

Check the status of the lock without affecting its state.

Parameters
lockPointer to previously created lock.

◆ tMPI_Lock_lock()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Lock_lock ( tMPI_Lock_t * lock)

Perform yielding, busy-waiting locking.

This function blocks until the lock is locked.

Parameters
lockPointer to previously created lock.

◆ tMPI_Lock_trylock()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Lock_trylock ( tMPI_Lock_t * lock)

Try to lock the lock but don't block if it is locked.

Parameters
lockPointer to previously created lock.

◆ tMPI_Lock_unlock()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Lock_unlock ( tMPI_Lock_t * lock)

Unlock the lock.

Parameters
lockPointer to previously created lock.

◆ tMPI_Malloc()

void * PLMD::thread_mpi::tMPI_Malloc ( size_t size)

◆ tMPI_Malloc_local()

TMPI_EXPORT void * PLMD::thread_mpi::tMPI_Malloc_local ( size_t size)

Allocate local memory by size in bytes.

See also
malloc()
Parameters
[in]size= size in units of sizeof() of the memory to be allocated
Returns
Pointer to allocated memory, or NULL in case of failure

◆ tMPI_Mult_recv()

void PLMD::thread_mpi::tMPI_Mult_recv ( tMPI_Comm comm,
struct coll_env * cev,
int rank,
int index,
int expected_tag,
tMPI_Datatype recvtype,
size_t recvsize,
void * recvbuf,
int * ret )

◆ tMPI_Once()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Once ( tMPI_Comm comm,
void(* function )(void *),
void * param,
int * was_first )

◆ tMPI_Once_wait()

TMPI_EXPORT void * PLMD::thread_mpi::tMPI_Once_wait ( tMPI_Comm comm,
void *(* function )(void *),
void * param,
int * was_first )

Execute function once over comm, and wait for the function to return its value.

Executes a given function only once per collective call over comm.

Collective function.

Parameters
[in]functionthe function to call
[in]paramthe parameter to the function
[out]was_firstset to 1 if the current thread was the one to execute the function. unchanged if current thread was not the one to execute the function; ignored if NULL.
[in]commThe communicator.
Returns
the return value of the function

◆ tMPI_Post_match_recv()

struct envelope * PLMD::thread_mpi::tMPI_Post_match_recv ( struct tmpi_thread * cur,
tMPI_Comm comm,
struct tmpi_thread * src,
void * recv_buf,
int recv_count,
tMPI_Datatype datatype,
int tag,
tmpi_bool nonblock )

◆ tMPI_Post_multi()

int PLMD::thread_mpi::tMPI_Post_multi ( struct coll_env * cev,
int myrank,
int index,
int tag,
tMPI_Datatype datatype,
size_t bufsize,
void * buf,
int n_remaining,
int synct,
int dest )

◆ tMPI_Post_send()

struct envelope * PLMD::thread_mpi::tMPI_Post_send ( struct tmpi_thread * cur,
tMPI_Comm comm,
struct tmpi_thread * dest,
void * send_buf,
int send_count,
tMPI_Datatype datatype,
int tag,
tmpi_bool nonblock )

◆ tMPI_Realloc()

void * PLMD::thread_mpi::tMPI_Realloc ( void * p,
size_t size )

◆ tMPI_Realloc_local()

TMPI_EXPORT void * PLMD::thread_mpi::tMPI_Realloc_local ( void * ptr,
size_t size )

Re-allocate to local memory.

See also
realloc()
Parameters
[in]ptr= input pointer of originally allocated memory (can be allocated with NUMA or non-NUMA malloc())
[in]size= new size in units of sizeof().
Returns
Pointer to allocated memory, or NULL in case of failure

◆ tMPI_Recv()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Recv ( void * buf,
int count,
tMPI_Datatype datatype,
int source,
int tag,
tMPI_Comm comm,
tMPI_Status * status )

Receive message; blocks until buf is filled.

Parameters
[out]bufThe buffer for data to receive.
[in]countThe maximum number of items to receive.
[in]datatypeThe data type of the items in buf.
[in]sourceThe rank of the source thread (or TMPI_ANY_SOURCE).
[in]tagThe message tag (or TMPI_ANY_TAG).
[in]commThe shared communicator.
[out]statusThe message status.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Recv_env_list_destroy()

void PLMD::thread_mpi::tMPI_Recv_env_list_destroy ( struct recv_envelope_list * evl)

◆ tMPI_Recv_env_list_init()

int PLMD::thread_mpi::tMPI_Recv_env_list_init ( struct recv_envelope_list * evl)

◆ tMPI_Reduce()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Reduce ( const void * sendbuf,
void * recvbuf,
int count,
tMPI_Datatype datatype,
tMPI_Op op,
int root,
tMPI_Comm comm )

Do an operation between all locally held buffers on all items in the buffers, and send the results to root.

Collective function.

Parameters
[in]sendbufThe operand parameters. Root may specify TMPI_IN_PLACE, in which case recvbuf will hold the operand parameters.
[out]recvbufThe result buffer at root.
[in]countThe number of items to do operation on.
[in]datatypeThe data type of the items.
[in]opThe operation to perform.
[in]rootThe root thread (which is to receive the results).
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Reduce_fast()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Reduce_fast ( const void * sendbuf,
void * recvbuf,
int count,
tMPI_Datatype datatype,
tMPI_Op op,
int root,
tMPI_Comm comm )

Do an tMPI_Reduce, but with the following assumption: recvbuf points to a valid buffer in all calling threads, or sendbuf has the value TMPI_IN_PLACE (in which case the values of sendbuf may be changed in that thread).

This avoids unnecessary memory allocations associated with the normal tMPI_Reduce.

Collective function.

Parameters
[in]sendbufThe operand parameters (or TMPI_IN_PLACE, in which case the operand parameters will be in recvbuf).
[in,out]recvbufThe result buffer.
[in]countThe number of items to do operation on.
[in]datatypeThe data type of the items.
[in]opThe operation to perform.
[in]rootThe root thread (which is to receive the final results).
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Reduce_req_alloc()

TMPI_EXPORT tMPI_Reduce_req * PLMD::thread_mpi::tMPI_Reduce_req_alloc ( tMPI_Comm comm)

Allocate data structure for asynchronous reduce.

◆ tMPI_Reduce_run_op()

int PLMD::thread_mpi::tMPI_Reduce_run_op ( void * dest,
const void * src_a,
const void * src_b,
tMPI_Datatype datatype,
int count,
tMPI_Op op,
tMPI_Comm comm )

◆ tMPI_Req_init()

void PLMD::thread_mpi::tMPI_Req_init ( struct tmpi_req_ * rq,
struct envelope * ev )

◆ tMPI_Req_list_destroy()

void PLMD::thread_mpi::tMPI_Req_list_destroy ( struct req_list * rl)

◆ tMPI_Req_list_init()

int PLMD::thread_mpi::tMPI_Req_list_init ( struct req_list * rl,
int N_reqs )

◆ tMPI_Return_req()

void PLMD::thread_mpi::tMPI_Return_req ( struct req_list * rl,
struct tmpi_req_ * req )

◆ tMPI_Scan()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Scan ( const void * sendbuf,
void * recvbuf,
int count,
tMPI_Datatype datatype,
tMPI_Op op,
tMPI_Comm comm )

Do a partial reduce operation, based on rank: the results of the reduction operation of ranks 0 - i will be put in the recvbuf of rank i.

Collective function.

Parameters
[in]sendbufThe operand parameters. All ranks may specify TMPI_IN_PLACE, in which case recvbuf will hold the operand parameters.
[in,out]recvbufThe result buffer.
[in]countThe number of items to do operation on.
[in]datatypeThe data type of the items.
[in]opThe operation to perform.
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Scatter()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Scatter ( const void * sendbuf,
int sendcount,
tMPI_Datatype sendtype,
void * recvbuf,
int recvcount,
tMPI_Datatype recvtype,
int root,
tMPI_Comm comm )

Spread parts of sendbuf to all processes in comm from root.

Collective function.

Parameters
[in]sendbufThe send buffer for root.
[in]sendcountThe number of items for root to send to each thread.
[in]sendtypeThe type of the items root sends.
[out]recvbufThe receiving buffer for all receiving threads (root may specify TMPI_IN_PLACE, in which case it transmits nothing to itself).
[in]recvcountThe number of items recvbuf can receive.
[in]recvtypeThe type of items to receive.
[in]rootThe rank of root.
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Scatterv()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Scatterv ( const void * sendbuf,
const int * sendcounts,
const int * displs,
tMPI_Datatype sendtype,
void * recvbuf,
int recvcount,
tMPI_Datatype recvtype,
int root,
tMPI_Comm comm )

Spread irregularly laid out parts of sendbuf to all processes in comm from root.

Collective function.

Parameters
[in]sendbufThe send buffer for root.
[in]sendcountsList of the number of items for root to send to each thread.
[in]displsList of displacements in sendbuf from which to start transmission to each thread.
[in]sendtypeThe type of the items root sends.
[out]recvbufThe receiving buffer for all receiving threads (root may specify TMPI_IN_PLACE, in which case it transmits nothing to itself).
[in]recvcountThe number of items recvbuf can receive.
[in]recvtypeThe type of items to receive.
[in]rootThe rank of root.
[in]commThe communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Send()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Send ( const void * buf,
int count,
tMPI_Datatype datatype,
int dest,
int tag,
tMPI_Comm comm )

Send message; blocks until buf is reusable.

Parameters
[in]bufThe buffer with data to send.
[in]countThe number of items to send.
[in]datatypeThe data type of the items in buf.
[in]destThe rank of the destination thread.
[in]tagThe message tag.
[in]commThe shared communicator.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Send_env_list_destroy()

void PLMD::thread_mpi::tMPI_Send_env_list_destroy ( struct send_envelope_list * evl)

◆ tMPI_Send_env_list_init()

int PLMD::thread_mpi::tMPI_Send_env_list_init ( struct send_envelope_list * evl,
int N )

◆ tMPI_Sendrecv()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Sendrecv ( const void * sendbuf,
int sendcount,
tMPI_Datatype sendtype,
int dest,
int sendtag,
void * recvbuf,
int recvcount,
tMPI_Datatype recvtype,
int source,
int recvtag,
tMPI_Comm comm,
tMPI_Status * status )

Send & receive message at the same time.

Blocks until recvbuf is filled, and sendbuf is ready for reuse.

Parameters
[in]sendbufThe buffer with data to send.
[in]sendcountThe number of items to send.
[in]sendtypeThe data type of the items in send buf.
[in]destThe rank of the destination thread.
[in]sendtagThe send message tag.
[out]recvbufThe buffer for data to receive.
[in]recvcountThe maximum number of items to receive.
[in]recvtypeThe data type of the items in recvbuf.
[in]sourceThe rank of the source thread (or TMPI_ANY_SOURCE).
[in]recvtagThe receive message tag (or TMPI_ANY_TAG).
[in]commThe shared communicator.
[out]statusThe received message status.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Set_status()

void PLMD::thread_mpi::tMPI_Set_status ( struct tmpi_req_ * req,
tMPI_Status * st )

◆ tMPI_Shmalloc()

TMPI_EXPORT void * PLMD::thread_mpi::tMPI_Shmalloc ( tMPI_Comm comm,
size_t size )

Allocate a shared block of memory as a collective call.

Collective function.

Parameters
[in]commThe communicator
[in]sizeThe size in bytes to allocate

◆ tMPI_Spinlock_init()

static void PLMD::thread_mpi::tMPI_Spinlock_init ( tMPI_Spinlock_t * x)
inline

Initialize spinlock.

In theory you can call this from multiple threads, but remember that we don't check for errors. If the first thread proceeded to lock the spinlock after initialization, the second will happily overwrite the contents and unlock it without warning you.

Parameters
xSpinlock pointer.

◆ tMPI_Spinlock_islocked() [1/8]

static int PLMD::thread_mpi::tMPI_Spinlock_islocked ( const tMPI_Spinlock_t * x)
inlinestatic

◆ tMPI_Spinlock_islocked() [2/8]

static TMPI_EXPORT int PLMD::thread_mpi::tMPI_Spinlock_islocked ( const tMPI_Spinlock_t * x)
inlinestatic

◆ tMPI_Spinlock_islocked() [3/8]

static int PLMD::thread_mpi::tMPI_Spinlock_islocked ( const tMPI_Spinlock_t * x)
inlinestatic

◆ tMPI_Spinlock_islocked() [4/8]

static int PLMD::thread_mpi::tMPI_Spinlock_islocked ( const tMPI_Spinlock_t * x)
inlinestatic

◆ tMPI_Spinlock_islocked() [5/8]

static int PLMD::thread_mpi::tMPI_Spinlock_islocked ( const tMPI_Spinlock_t * x)
inlinestatic

◆ tMPI_Spinlock_islocked() [6/8]

static int PLMD::thread_mpi::tMPI_Spinlock_islocked ( const tMPI_Spinlock_t * x)
inlinestatic

◆ tMPI_Spinlock_islocked() [7/8]

static int PLMD::thread_mpi::tMPI_Spinlock_islocked ( const tMPI_Spinlock_t * x)
inlinestatic

◆ tMPI_Spinlock_islocked() [8/8]

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Spinlock_islocked ( tMPI_Spinlock_t * x)

Check if spinlock is locked.

This routine returns immediately with the lock status.

Parameters
xSpinlock pointer
Returns
1 if the spinlock is locked, 0 otherwise.

◆ tMPI_Spinlock_lock()

static void PLMD::thread_mpi::tMPI_Spinlock_lock ( tMPI_Spinlock_t * x)
inline

Acquire spinlock.

This routine blocks until the spinlock is available, and the locks it again before returning.

Parameters
xSpinlock pointer

◆ tMPI_Spinlock_trylock()

static int PLMD::thread_mpi::tMPI_Spinlock_trylock ( tMPI_Spinlock_t * x)
inline

Attempt to acquire spinlock.

This routine acquires the spinlock if possible, but if already locked it return an error code immediately.

Parameters
xSpinlock pointer
Returns
0 if the mutex was available so we could lock it, otherwise a non-zero integer (1) if the lock is busy.

◆ tMPI_Spinlock_unlock()

static void PLMD::thread_mpi::tMPI_Spinlock_unlock ( tMPI_Spinlock_t * x)
inline

Release spinlock.

Parameters
xSpinlock pointer

Unlocks the spinlock, regardless if which thread locked it.

◆ tMPI_Spinlock_wait()

static void PLMD::thread_mpi::tMPI_Spinlock_wait ( tMPI_Spinlock_t * x)
inline

Wait for a spinlock to become available.

This routine blocks until the spinlock is unlocked, but in contrast to tMPI_Spinlock_lock() it returns without trying to lock the spinlock.

Parameters
xSpinlock pointer

◆ tMPI_Stack_destroy()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Stack_destroy ( tMPI_Stack * st)

Deallocates a stack.

◆ tMPI_Stack_detach()

TMPI_EXPORT tMPI_Stack_element * PLMD::thread_mpi::tMPI_Stack_detach ( tMPI_Stack * st)

Detaches entire stack for use by a single thread.

◆ tMPI_Stack_init()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Stack_init ( tMPI_Stack * st)

Initialize a stack.

◆ tMPI_Stack_pop()

TMPI_EXPORT tMPI_Stack_element * PLMD::thread_mpi::tMPI_Stack_pop ( tMPI_Stack * st)

Pops a stack element from a stack.

◆ tMPI_Stack_push()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Stack_push ( tMPI_Stack * st,
tMPI_Stack_element * el )

Pushes a stack element onto a stack.

◆ tMPI_Test()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Test ( tMPI_Request * request,
int * flag,
tMPI_Status * status )

Test whether a message is transferred.

Parameters
[in,out]requestThe request obtained wit tMPI_Isend()/tMPI_Irecv().
[out]flagA flag set to TRUE(1) if the request is finished, FALSE(0) otherwise.
[out]statusMessage status (can be set to TMPI_STATUS_IGNORE).
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Test_multi()

tmpi_bool PLMD::thread_mpi::tMPI_Test_multi ( struct tmpi_thread * cur,
struct tmpi_req_ * rqs,
tmpi_bool * any_done )

◆ tMPI_Test_single()

tmpi_bool PLMD::thread_mpi::tMPI_Test_single ( struct tmpi_thread * cur,
struct tmpi_req_ * rq )

◆ tMPI_Testall()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Testall ( int count,
tMPI_Request * array_of_requests,
int * flag,
tMPI_Status * array_of_statuses )

Test whether several messages are transferred.

Parameters
[in]countThe number of requests
[in,out]array_of_requestsList of count requests obtained with tMPI_Isend()/tMPI_Irecv().
[out]flagWhether all requests have completed.
[out]array_of_statusesList of count message statuses (can be set to TMPI_STATUSES_IGNORE).
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Testany()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Testany ( int count,
tMPI_Request * array_of_requests,
int * index,
int * flag,
tMPI_Status * status )

Test whether one of several messages is transferred.

Parameters
[in]countThe number of requests
[in,out]array_of_requestsList of count requests obtained with tMPI_Isend()/tMPI_Irecv().
[out]indexIndex of the request that has completed.
[out]flagWhether any request has completed.
[out]statusPointer to tMPI_Status object associated with completed request.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Testsome()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Testsome ( int incount,
tMPI_Request * array_of_requests,
int * outcount,
int * array_of_indices,
tMPI_Status * array_of_statuses )

Test whether some of several messages are transferred.

Parameters
[in]incountThe number of requests
[in,out]array_of_requestsList of count requests obtained with tMPI_Isend()/tMPI_Irecv().
[out]outcountNumber of completed requests
[out]array_of_indicesArray of ints that gets filled with the indices of the completed requests.
[out]array_of_statusesList of count message statuses (can be set to TMPI_STATUSES_IGNORE).
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Thread_barrier_destroy()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_barrier_destroy ( tMPI_Thread_barrier_t * barrier)

Release data in a barrier datatype.

Parameters
barrierPointer to previously initialized barrier.

◆ tMPI_Thread_barrier_init()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_barrier_init ( tMPI_Thread_barrier_t * barrier,
int count )

Initialize a synchronization barrier type.

You only need to initialize a barrier once. They cycle automatically, so after release it is immediately ready to accept waiting threads again.

Parameters
barrierPointer to previously allocated barrier type
countNumber of threads to synchronize. All threads will be released after count calls to tMPI_Thread_barrier_wait().

◆ tMPI_Thread_barrier_wait()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_barrier_wait ( tMPI_Thread_barrier_t * barrier)

Perform barrier synchronization.

This routine blocks until it has been called N times, where N is the count value the barrier was initialized with. After N total calls all threads return. The barrier automatically cycles, and thus requires another N calls to unblock another time.

Parameters
barrierPointer to previously create barrier.
Returns
The last thread returns -1, all the others 0.

◆ tMPI_Thread_cancel()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_cancel ( tMPI_Thread_t thread)

Ask a thread to exit.

This routine tries to end the execution of another thread, but there are no guarantees it will succeed.

Parameters
threadHandle to thread we want to see dead.
Returns
0 or a non-zero error message.

◆ tMPI_Thread_cond_broadcast()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_cond_broadcast ( tMPI_Thread_cond_t * cond)

Unblock all waiting threads.

This routine signals a condition variable to all (if any) threads that are waiting for it after calling tMPI_Thread_cond_wait().

Parameters
condcondition variable
Returns
0 or a non-zero error message.

◆ tMPI_Thread_cond_destroy()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_cond_destroy ( tMPI_Thread_cond_t * cond)

Destroy condition variable.

This routine should be called when you are done with a condition variable. Note that it only releases memory allocated internally, not the tMPI_Thread_cond_t structure you provide a pointer to.

Parameters
condPointer to condition variable.
Returns
0 or a non-zero error message.

◆ tMPI_Thread_cond_init()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_cond_init ( tMPI_Thread_cond_t * cond)

Initialize condition variable.

This routine must be called before using any condition variable not initialized with static storage class and TMPI_THREAD_COND_INITIALIZER.

Parameters
condPointer to previously allocated condition variable
Returns
0 or a non-zero error message.

◆ tMPI_Thread_cond_signal()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_cond_signal ( tMPI_Thread_cond_t * cond)

Unblock one waiting thread.

This routine signals a condition variable to one thread (if any) waiting for it after calling tMPI_Thread_cond_wait().

Parameters
condcondition variable
Returns
0 or a non-zero error message.

◆ tMPI_Thread_cond_wait()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_cond_wait ( tMPI_Thread_cond_t * cond,
tMPI_Thread_mutex_t * mtx )

Wait for a condition to be signaled.

This routine releases the mutex, and waits for the condition to be signaled by another thread before it returns.

Note that threads waiting for conditions with tMPI_Thread_cond_wait may be subject to spurious wakeups: use this function in a while loop and check the state of a predicate associated with the wakeup before leaving the loop.

Parameters
condcondition variable
mtxMutex protecting the condition variable
Returns
0 or a non-zero error message.

◆ tMPI_Thread_create()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_create ( tMPI_Thread_t * thread,
void *(* start_routine )(void *),
void * arg )

Create a new thread.

The new thread will call start_routine() with the argument arg.

Please be careful not to change arg after calling this function.

Parameters
[out]threadPointer to thread ID
[in]start_routineThe function to call in the new thread
[in]argArgument to call with
Returns
Status - 0 on success, or an error code.

◆ tMPI_Thread_equal()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_equal ( tMPI_Thread_t t1,
tMPI_Thread_t t2 )

Check whether two thread pointers point to the same thread.

Parameters
[in]t1Thread ID 1
[in]t2Thread ID 2
Returns
non-zero if the thread structs refer to the same thread, 0 if the threads are different

◆ tMPI_Thread_exit()

TMPI_EXPORT void PLMD::thread_mpi::tMPI_Thread_exit ( void * value_ptr)

Terminate calling thread.

Die voluntarily.

Parameters
value_ptrPointer to a return value. Threads waiting for us to join them can read this value if they try.
Returns

◆ tMPI_Thread_get_hw_number()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_get_hw_number ( void )

Get the number of hardware threads that can be run simultaneously.

Returns the total number of cores and SMT threads that can run.

Returns
The maximum number of threads that can run simulataneously. If this number cannot be determined for the current architecture, 0 is returned.

◆ tMPI_Thread_getspecific()

TMPI_EXPORT void * PLMD::thread_mpi::tMPI_Thread_getspecific ( tMPI_Thread_key_t key)

Get value for thread-specific-storage in this thread.

If it has not yet been set, NULL is returned.

Parameters
keyThread-specific-storage handle.
Returns
Pointer-to-void, the value of the data in this thread.

◆ tMPI_Thread_join()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_join ( tMPI_Thread_t thread,
void ** value_ptr )

Wait for a specific thread to finish executing.

If the thread has already finished the routine returns immediately.

Parameters
[in]threadPointer to thread ID
[out]value_ptrPointer to location where to store pointer to exit value from threads that called tMPI_Thread_exit().
Returns
0 if the join went ok, or a non-zero error code.

◆ tMPI_Thread_key_create()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_key_create ( tMPI_Thread_key_t * key,
void(* destructor )(void *) )

Initialize thread-specific-storage handle.

The tMPI_Thread_key_t handle must always be initialized dynamically with this routine. If you need to initialize it statically in a file, use the tMPI_Thread_once() routine and corresponding data to initialize the thread-specific-storage key the first time you access it.

Parameters
keyPointer to opaque thread key type.
destructorRoutine to call (to free memory of key) when we quit
Returns
status - 0 on sucess or a standard error code.

◆ tMPI_Thread_key_delete()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_key_delete ( tMPI_Thread_key_t key)

Delete thread-specific-storage handle.

Calling this routine will kill the handle, and invoke the automatic destructor routine for each non-NULL value pointed to by key.

Parameters
keyOpaque key type to destroy
Returns
0 or a non-zero error message.

◆ tMPI_Thread_mutex_destroy()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_mutex_destroy ( tMPI_Thread_mutex_t * mtx)

Kill a mutex you no longer need.

Note that this call only frees resources allocated inside the mutex. It does not free the tMPI_Thread_mutex_t memory area itself if you created it with dynamic memory allocation.

Parameters
mtxPointer to a mutex variable to get rid of.
Returns
0 or a non-zero error code.

◆ tMPI_Thread_mutex_init()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_mutex_init ( tMPI_Thread_mutex_t * mtx)

Initialize a new mutex.

This routine must be called before using any mutex not initialized with static storage class and TMPI_THREAD_MUTEX_INITIALIZER.

Parameters
mtxPointer to a mutex opaque type.
Returns
0 or an error code.

◆ tMPI_Thread_mutex_lock()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_mutex_lock ( tMPI_Thread_mutex_t * mtx)

Wait for exclusive access to a mutex.

This routine does not return until the mutex has been acquired.

Parameters
mtxPointer to the mutex to lock
Returns
0 or a non-zero error code.

◆ tMPI_Thread_mutex_trylock()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_mutex_trylock ( tMPI_Thread_mutex_t * mtx)

Try to lock a mutex, return if busy.

This routine always returns directly.

Parameters
mtxPointer to the mutex to try and lock
Returns
If the mutex was available and we successfully locked it, we return 0. If the mutex was unavailable because it was already locked by another thread, we return non-zero. If the mutex was already held by this thread, the return value is implementation-defined (pthreads non-zero, winthreads zero).

◆ tMPI_Thread_mutex_unlock()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_mutex_unlock ( tMPI_Thread_mutex_t * mtx)

Release the exclusive access to a mutex.

Parameters
mtxPointer to the mutex to release
Returns
0 or a non-zero error code.

◆ tMPI_Thread_once()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_once ( tMPI_Thread_once_t * once_data,
void(* init_routine )(void) )

Run the provided routine exactly once.

The control data must have been initialized before calling this routine, but you can do it with the static initialzer TMPI_THREAD_ONCE_INIT.

tMPI_Thread_once() will not return to any of the calling routines until the initialization function has been completed.

Parameters
once_dataInitialized one-time execution data
init_routineFunction to call exactly once
Returns
0 or a non-zero error message.

◆ tMPI_Thread_self()

TMPI_EXPORT tMPI_Thread_t PLMD::thread_mpi::tMPI_Thread_self ( void )

Get a thread ID of the calling thread.

This function also works on threads not started with tMPI_Thread_create, or any other function in thread_mpi. This makes it possible to, for example assign thread affinities to any thread.

Returns
A thread ID of the calling thread

◆ tMPI_Thread_setaffinity_single()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_setaffinity_single ( tMPI_Thread_t thread,
unsigned int nr )

Set thread affinity to a single core.

This function sets the thread affinity of a thread to a a specific numbered processor. This only works if the underlying operating system supports it. The processor number must be between 0 and the number returned by tMPI_Thread_get_hw_number().

Parameters
[in]threadThread ID of the thread to set affinity for
[in]nrProcessor number to set affinity to
Returns
zero on success, non-zero on error

◆ tMPI_Thread_setspecific()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Thread_setspecific ( tMPI_Thread_key_t key,
void * value )

Set value for thread-specific-storage in this thread.

Parameters
keyThread-specific-storage handle.
valueWhat to set the data to (pointer-to-void).
Returns
0 or a non-zero error message.

◆ tMPI_Topo_test()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Topo_test ( tMPI_Comm comm,
int * status )

Check what type of topology the comm has.

Parameters
[in]commThe comm to query
[out]statusThe type of topology.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Type_commit()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Type_commit ( tMPI_Datatype * datatype)

Make a data type ready for use.

Parameters
[in,out]datatypeThe new datatype.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Type_contiguous()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Type_contiguous ( int count,
tMPI_Datatype oldtype,
tMPI_Datatype * newtype )

Create a contiguous data type (the only type possible right now).

Creates a datatype that is a vector of oldtype.

Parameters
[in]countThe number of oldtype types in the new type.
[in]oldtypeThe old data type.
[out]newtypeThe new data type (still needs to be committed).
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Type_free()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Type_free ( tMPI_Datatype * datatype)

Free the datatype.

Parameters
[in,out]datatypeThe datatype to destroy.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Wait()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Wait ( tMPI_Request * request,
tMPI_Status * status )

Wait until a message is transferred.

Parameters
[in,out]requestThe request obtained wit tMPI_Isend()/tMPI_Irecv().
[out]statusMessage status.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Wait_for_data()

void PLMD::thread_mpi::tMPI_Wait_for_data ( struct tmpi_thread * cur,
struct coll_env * cev,
int myrank )

◆ tMPI_Wait_for_others()

void PLMD::thread_mpi::tMPI_Wait_for_others ( struct coll_env * cev,
int myrank )

◆ tMPI_Wait_process_incoming()

void PLMD::thread_mpi::tMPI_Wait_process_incoming ( struct tmpi_thread * th)

◆ tMPI_Wait_single()

void PLMD::thread_mpi::tMPI_Wait_single ( struct tmpi_thread * cur,
struct tmpi_req_ * rq )

◆ tMPI_Waitall()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Waitall ( int count,
tMPI_Request * array_of_requests,
tMPI_Status * array_of_statuses )

Wait until several messages are transferred.

Parameters
[in]countThe number of requests
[in,out]array_of_requestsList of count requests obtained with tMPI_Isend()/tMPI_Irecv().
[out]array_of_statusesList of count message statuses (can be set to TMPI_STATUSES_IGNORE).
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Waitany()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Waitany ( int count,
tMPI_Request * array_of_requests,
int * index,
tMPI_Status * status )

Wait until one of several messages is transferred.

Parameters
[in]countThe number of requests
[in,out]array_of_requestsList of count requests obtained with tMPI_Isend()/tMPI_Irecv().
[out]indexIndex of the request that has completed.
[out]statusPointer to tMPI_Status object associated with completed request.
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Waitsome()

TMPI_EXPORT int PLMD::thread_mpi::tMPI_Waitsome ( int incount,
tMPI_Request * array_of_requests,
int * outcount,
int * array_of_indices,
tMPI_Status * array_of_statuses )

Wait until some of several messages are transferred.

Waits until at least one message is transferred.

Parameters
[in]incountThe number of requests
[in,out]array_of_requestsList of count requests obtained with tMPI_Isend()/tMPI_Irecv().
[out]outcountNumber of completed requests
[out]array_of_indicesArray of ints that gets filled with the indices of the completed requests.
[out]array_of_statusesList of count message statuses (can be set to TMPI_STATUSES_IGNORE).
Returns
TMPI_SUCCESS on success, TMPI_FAILURE on failure.

◆ tMPI_Wtick()

TMPI_EXPORT double PLMD::thread_mpi::tMPI_Wtick ( void )

get the resolution of tMPI_Wtime as a double, in seconds

Returns
time resolution.

◆ tMPI_Wtime()

TMPI_EXPORT double PLMD::thread_mpi::tMPI_Wtime ( void )

get a time value as a double, in seconds.

Returns
time value.

Variable Documentation

◆ id_key

tMPI_Thread_key_t PLMD::thread_mpi::id_key
extern

◆ Nthreads

int PLMD::thread_mpi::Nthreads
extern

◆ threads

struct tmpi_thread* PLMD::thread_mpi::threads
extern

◆ TMPI_BYTE

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_BYTE
extern

byte (for binary xmissions)

◆ TMPI_C_BOOL

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_C_BOOL
extern

bool

◆ TMPI_CHAR

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_CHAR
extern

char

◆ TMPI_COMM_WORLD

TMPI_EXPORT tMPI_Comm PLMD::thread_mpi::TMPI_COMM_WORLD
extern

Pre-initialized communicator with all available threads.

◆ TMPI_DOUBLE

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_DOUBLE
extern

double

◆ TMPI_ERRORS_ARE_FATAL

tMPI_Errhandler PLMD::thread_mpi::TMPI_ERRORS_ARE_FATAL
extern

pre-defined error handler that abort()s on every error

◆ TMPI_ERRORS_RETURN

tMPI_Errhandler PLMD::thread_mpi::TMPI_ERRORS_RETURN
extern

pre-defined error handler that tries to continue on every error

◆ TMPI_FLOAT

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_FLOAT
extern

float

◆ tmpi_global

struct tmpi_global* PLMD::thread_mpi::tmpi_global
extern

◆ TMPI_GROUP_EMPTY

tMPI_Group PLMD::thread_mpi::TMPI_GROUP_EMPTY
extern

the empty group

◆ TMPI_INT

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_INT
extern

int

◆ TMPI_INT64_T

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_INT64_T
extern

int64_t

◆ TMPI_LONG

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_LONG
extern

long

◆ TMPI_LONG_DOUBLE

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_LONG_DOUBLE
extern

long double

◆ TMPI_POINTER

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_POINTER
extern

pointer (thread_mpi specific)

◆ TMPI_SHORT

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_SHORT
extern

short

◆ TMPI_SIGNED_CHAR

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_SIGNED_CHAR
extern

signed char

◆ TMPI_UNSIGNED

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_UNSIGNED
extern

unsigned int

◆ TMPI_UNSIGNED_CHAR

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_UNSIGNED_CHAR
extern

unsigned char

◆ TMPI_UNSIGNED_LONG

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_UNSIGNED_LONG
extern

unsigned long

◆ TMPI_UNSIGNED_SHORT

TMPI_EXPORT const tMPI_Datatype PLMD::thread_mpi::TMPI_UNSIGNED_SHORT
extern

unsigned short