Lightweight Parallel Foundations 1.0.1-alpha 2023-06-26T11:02:34Z
A high performance and model-compliant communication layer
Functions | Variables
Specific to implementations based on MPI
Collaboration diagram for Specific to implementations based on MPI:

Functions

lpf_err_t lpf_mpi_initialize_with_mpicomm (MPI_Comm comm, lpf_init_t *init)
 
lpf_err_t lpf_mpi_initialize_over_tcp (const char *server, const char *port, int timeout, lpf_pid_t pid, lpf_pid_t nprocs, lpf_init_t *init)
 
lpf_err_t lpf_mpi_finalize (lpf_init_t init)
 

Variables

const int LPF_MPI_AUTO_INITIALIZE
 

Detailed Description

Function Documentation

◆ lpf_mpi_initialize_with_mpicomm()

lpf_err_t lpf_mpi_initialize_with_mpicomm ( MPI_Comm  comm,
lpf_init_t init 
)

Initialises a lpf_init_t object with an MPI communicator for use with lpf_hook(). This function must be called collectively by all processes in the MPI communicator. An obvious use for this function is to allow existing MPI applications to use LPF codes.

Parameters
[in]commThe MPI communicator
[out]initThe lpf_init_t object that can be used through lpf_hook().
Returns
LPF_SUCCESS when the initialisation was successful.
LPF_ERR_OUT_OF_MEMORY when there wasn't enough memory.
LPF_ERR_FATAL when the system encountered an unrecoverable error.

◆ lpf_mpi_initialize_over_tcp()

lpf_err_t lpf_mpi_initialize_over_tcp ( const char *  server,
const char *  port,
int  timeout,
lpf_pid_t  pid,
lpf_pid_t  nprocs,
lpf_init_t init 
)

Initialises a lpf_init_t object over TCP/IP for use with lpf_hook(). This function must be called collectively by nprocs processes. On each process the parameters must be the same, except pid which must be a unique number ranging from to 0 to nprocs - 1. An obvious use for this function is to allow an arbitrary application to use LPF code.

Parameters
[in]serverThe Internet host that will execute this function with pid = 0.
[in]portThe port number that the server will use.
[in]timeoutMaximum number of milliseconds allowed to establish connection. If any of the clients fails to connect within that timeout, an error is returned and the MPI runtime is left in undefined state. Do not call MPI_Finalize() and use _exit() or _Exit() to exit.
[in]pidThe process identifier must be a number in the range from 0 to and inclusive nprocs - 1. This number must be unique among the processes that calls function. The process with pid = 0, must be located on the Internet host server.
[in]nprocsThe number of processes that shall be part of init.
[out]initThe lpf_init_t object that can be used through lpf_hook().
Returns
LPF_SUCCESS when the initialisation was successful.
LPF_ERR_OUT_OF_MEMORY when there wasn't enough memory available.
LPF_ERR_FATAL when the system encountered an unrecoverable error, such as when a timeout occurs or when the underlying MPI implementation does not support dynamic connections. Do not call MPI_Finalize() and use _exit() or _Exit() to exit.

◆ lpf_mpi_finalize()

lpf_err_t lpf_mpi_finalize ( lpf_init_t  init)

Variable Documentation

◆ LPF_MPI_AUTO_INITIALIZE

const int LPF_MPI_AUTO_INITIALIZE
extern

Whether the LPF library should automatically initialize itself. If so, it calls MPI_Init() itself and pauses the processes with PID != 0 until a call to lpf_exec(). When disabled, the user code should call MPI_Init() and arrange for processes to call either lpf_mpi_initialize_with_mpicomm() or lpf_mpi_initialize_over_tcp(), followed by lpf_hook().

Rationale
The setting it represents must be known to the implementation before the program starts, because it decides whether MPI processes with rank > 0 enter a wait-loop instead of main(). So, this rules out a function call to modify this behaviour. Additionally, the operation of this setting is strongly coupled with how the program text is structured: "Is it going to use lpf_hook() or lpf_exec()?" That disqualifies the use of an environment variable. Therefore, a constant with static storage is chosen. By letting the implementation define it as a weak symbol equal to one, the normal way to start a program, through lpf_exec(), is enabled by default.