PLE
Parallel Location and Exchange
|
Set up communication with coupled codes. More...
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ple_defs.h"
#include "ple_config_defs.h"
#include "ple_coupling.h"
Functions | |
int | ple_coupling_mpi_name_to_id (MPI_Comm comm, const char *group_name) |
Build a group id within a communicator based on its name. More... | |
ple_coupling_mpi_set_t * | ple_coupling_mpi_set_create (int sync_flag, const char *app_type, const char *app_name, MPI_Comm base_comm, MPI_Comm app_comm) |
Discover other applications in a set with a common communicator. More... | |
void | ple_coupling_mpi_set_destroy (ple_coupling_mpi_set_t **s) |
Free an PLE coupling MPI set info structure. More... | |
int | ple_coupling_mpi_set_n_apps (const ple_coupling_mpi_set_t *s) |
Return the number of applications in a coupled set. More... | |
int | ple_coupling_mpi_set_get_app_id (const ple_coupling_mpi_set_t *s) |
Return the id of the local application in a coupled set. More... | |
ple_coupling_mpi_set_info_t | ple_coupling_mpi_set_get_info (const ple_coupling_mpi_set_t *s, int app_id) |
Return application information in set's common communicator. More... | |
void | ple_coupling_mpi_set_synchronize (ple_coupling_mpi_set_t *s, int sync_flag, double time_step) |
Synchronize applications in a set. More... | |
const int * | ple_coupling_mpi_set_get_status (const ple_coupling_mpi_set_t *s) |
Get status of applications in a set. More... | |
const double * | ple_coupling_mpi_set_get_timestep (const ple_coupling_mpi_set_t *s) |
Get time steps in a set. More... | |
void | ple_coupling_mpi_intracomm_create (MPI_Comm base_comm, MPI_Comm app_comm, int distant_root, MPI_Comm *new_comm, int local_range[2], int distant_range[2]) |
Create an intracommunicator from a local and distant communicator within a base communicator. More... | |
void | ple_coupling_mpi_set_dump (const ple_coupling_mpi_set_t *s) |
Dump printout of an PLE coupling MPI set info structure. More... | |
Set up communication with coupled codes.
void ple_coupling_mpi_intracomm_create | ( | MPI_Comm | base_comm, |
MPI_Comm | app_comm, | ||
int | distant_root, | ||
MPI_Comm * | new_comm, | ||
int | local_range[2], | ||
int | distant_range[2] | ||
) |
Create an intracommunicator from a local and distant communicator within a base communicator.
[in] | base_comm | communicator associated with both applications |
[in] | app_comm | communicator associated with local application |
[in] | distant_root | rank of distant group leader in base_comm |
[in] | new_comm | pointer to new communicator |
[in] | local_range | first and past-the last ranks of local application in new communicator |
[in] | distant_range | first and past-the last ranks of distant application in new communicator |
int ple_coupling_mpi_name_to_id | ( | MPI_Comm | comm, |
const char * | group_name | ||
) |
Build a group id within a communicator based on its name.
If multiple groups are present, ids are number from 0 to n_groups - 1, based on the odering of group names. If all processes have the same group name, the returned value is -1.
The returned id may typically be used as a "color" argument for MPI_Comm_split().
As this function requires communication between applications, it is a collective function in comm.
[in] | comm | MPI communicator. |
[in] | group_name | name associated with current group. |
ple_coupling_mpi_set_t* ple_coupling_mpi_set_create | ( | int | sync_flag, |
const char * | app_type, | ||
const char * | app_name, | ||
MPI_Comm | base_comm, | ||
MPI_Comm | app_comm | ||
) |
Discover other applications in a set with a common communicator.
In most cases, the base communicator is MPI_COMM_WORLD, and the local application communicator app_comm is usually obtained from it using MPI_Comm_split, but other combinations may be possible using MPI-2 process management functions.
As this function requires communication between applications, it is a collective function in base_comm.
[in] | sync_flag | 1 if application is to be synchronized at each time step, 0 if independent from others. |
[in] | app_type | name of current application type (software name). |
[in] | app_name | name of current application (data/case name). |
[in] | base_comm | communicator associated with all applications. |
[in] | app_comm | communicator associated with local application. |
void ple_coupling_mpi_set_destroy | ( | ple_coupling_mpi_set_t ** | s | ) |
Free an PLE coupling MPI set info structure.
[in,out] | s | pointer to structure that should be freed. |
void ple_coupling_mpi_set_dump | ( | const ple_coupling_mpi_set_t * | s | ) |
Dump printout of an PLE coupling MPI set info structure.
[in] | s | pointer to PLE coupling MPI set info structure. |
int ple_coupling_mpi_set_get_app_id | ( | const ple_coupling_mpi_set_t * | s | ) |
Return the id of the local application in a coupled set.
[in] | s | pointer to PLE coupling MPI set info structure. |
ple_coupling_mpi_set_info_t ple_coupling_mpi_set_get_info | ( | const ple_coupling_mpi_set_t * | s, |
int | app_id | ||
) |
Return application information in set's common communicator.
[in] | s | pointer to PLE coupling MPI set info structure. |
[in] | app_id | application id |
const int* ple_coupling_mpi_set_get_status | ( | const ple_coupling_mpi_set_t * | s | ) |
Get status of applications in a set.
This function allows access to the status flag of each synchronized application in the set. It may be used immediately after ple_coupling_mpi_set_create(), and flags are updated after each call to ple_coupling_mpi_set_synchronize().
param[in] s pointer to PLE coupling MPI set info structure.
const double* ple_coupling_mpi_set_get_timestep | ( | const ple_coupling_mpi_set_t * | s | ) |
Get time steps in a set.
This function may be called after ple_coupling_mpi_set_synchronize() to access the time step values of each synchronized application in the set.
[in] | s | pointer to PLE coupling MPI set info structure. |
int ple_coupling_mpi_set_n_apps | ( | const ple_coupling_mpi_set_t * | s | ) |
Return the number of applications in a coupled set.
[in] | s | pointer to PLE coupling MPI set info structure. |
void ple_coupling_mpi_set_synchronize | ( | ple_coupling_mpi_set_t * | s, |
int | sync_flag, | ||
double | time_step | ||
) |
Synchronize applications in a set.
Note that if a member of the set has used a PLE_COUPLING_STOP or PLE_COUPLING_LAST flag when calling ple_coupling_mpi_set_create() or or at the previous call to this function, it will not be synchronized anymore (i.e. the PLE_COUPLING_NO_SYNC flag will be added).
param[in] s pointer to PLE coupling MPI set info structure. param[in] sync_flag synchronization info for current application. param[in] time_step time step for current application.