#include "utils.h"
#include "usempi.h"
#include "exchangeinfo.h"
#include "parser.h"
#include "fd.h"
Go to the source code of this file.
Classes | |
struct | s_PARALLELINFO |
Parallel information (MPI, MPI Cartesian grid, OpenMP). More... | |
struct | s_IWAVE |
Wave simulation struct. More... | |
Typedefs | |
typedef s_PARALLELINFO | PARALLELINFO |
Parallel information (MPI, MPI Cartesian grid, OpenMP). | |
typedef s_IWAVE | IWAVE |
Wave simulation struct. | |
Functions | |
int | initparallel (int ts) |
Stores MPI and OMP data for global access. | |
void | initparallel_global (int) |
Stores global MPI and OMP data for global access. | |
int | initparallel_local (PARARRAY, FILE *) |
Stores local (group, remote) MPI and OMP data for global access. | |
int | initpinfo (PARALLELINFO *pinfo, FILE *stream) |
Initializes those parts of the parallel info struct which are indep of phys grid dimn - depend only on cart comm. | |
int | initexch (PARALLELINFO *pinfo, int ndim, FILE *stream) |
int | destroypinfo (PARALLELINFO *pinfo, int fabort) |
resets data exchange info | |
int | iwave_construct (IWAVE *state, PARARRAY *pars, FILE *stream, IWaveInfo const &ic) |
IWAVE struct constructor. | |
void | iwave_printf (IWAVE *state, PARARRAY *pars, FILE *stream, IWaveInfo const &ic) |
Dump information of all arrays including the allocated, computational virtual, send and recv ones as well as parallel info. | |
void | iwave_dynamic_init (IWAVE *state, int it, IWaveInfo const &ic) |
Resets all dynamical fields zeros, time index = it and internal step index = 0. | |
void | iwave_destroy (IWAVE *state, FD_MODELDEST d) |
STORAGE DEALLOCATION for IMODEL struct and frees the communicator and destroys the send and recv info. | |
void | quietexit (PARARRAY *pars, FILE **stream) |
Normal exit. | |
void | abortexit (int err, PARARRAY *pars, FILE **stream) |
Cleans up environment and exits. | |
int | initoutstream (FILE **stream, int rk, int sz) |
Initializes parallel output stream. | |
int | readinput (PARARRAY **pars, FILE *stream, int argc, char **argv) |
Initializes input parameter structures and populates them. | |
void | readparpars (PARARRAY *pars, int *stats, int *nopts, int *printact, FILE *out) |
Reads miscellaneous flags from param array, such as stats, nopts and printact. | |
void | storeparallel (PARALLELINFO *pinfo) |
Static storage of MPI comm params. | |
int | setrecvexchange (IMODEL *model, PARALLELINFO *pinfo, FILE *stream, IWaveInfo const &ic) |
Sets up parallel information for communication - sets the MPI_DATATYPE for sending and receiving. | |
int | dump_pi (PARARRAY *pars, PARALLELINFO *pinfo, FILE *stream) |
Dumps parallel info. | |
void | dump_ac (PARARRAY *pars, IMODEL *model, FILE *stream) |
Dumps information of all arrays including the allocated, and computational virtual ones. | |
void | dump_rs (PARARRAY *pars, IMODEL *model, FILE *stream, int sends, IWaveInfo const &ic, PARALLELINFO *pinfo) |
Dumps information of all arrays including the send and recv virtual ones. |
Contains the IMODEL struct and the parallel information.
Definition in file iwave.h.
typedef struct s_PARALLELINFO PARALLELINFO |
Parallel information (MPI, MPI Cartesian grid, OpenMP).
Assumption: cartesian grid for 1D/2D/3D.
Wave simulation struct.
It includes:
int initparallel | ( | int | ts | ) |
Stores MPI and OMP data for global access.
[in] | ts | - (int) thread support level |
void initparallel_global | ( | int | ) |
Stores global MPI and OMP data for global access.
[in] | ts | - (int) thread support level |
int initparallel_local | ( | PARARRAY | , | |
FILE * | ||||
) |
Stores local (group, remote) MPI and OMP data for global access.
reads cartesian grid info
[in] | ts | - (int) thread support level |
int initpinfo | ( | PARALLELINFO * | pinfo, | |
FILE * | stream | |||
) |
Initializes those parts of the parallel info struct which are indep of phys grid dimn - depend only on cart comm.
Called in iwave_construct.
[out] | pinfo | - (PARALLELINFO *) parallel info struct |
[in] | stream | - (FILE *) file pointer where to dump run-time message |
int initexch | ( | PARALLELINFO * | pinfo, | |
int | ndim, | |||
FILE * | stream | |||
) |
int destroypinfo | ( | PARALLELINFO * | pinfo, | |
int | fabort | |||
) |
resets data exchange info
[out] | pinfo | - (PARALLELINFO *) parallel info pointer |
[in] | fabort | - (int) physical grid dimension (as opposed to MPI cart comm dim) |
IWAVE struct constructor.
Does the following operations: - parallel info (PARALLELINFO) related operation: - initializes the parallel info struct, references initpinfo - determines the number of processes in each dimension and asgnrk in PARALLELINFO, references readparallel - creates MPI Cartesian grid and computes neighbor processor ranks - model struct (IMODEL) related operation: - sets model struct defaults, references im_construct - initializes model struct, references minit - read other misc flags of an IWAVE struct, references readparpars - create model struct, references IMODEL::mcrea: - read grid info - make action list - create stencil - compute size of the domain on its host processor according to the parallel info Cartesian grid dimensions (cdims) and Cartesian rank (crank) - allocated memory, NOTE: STORAGE ALLOCATION occurs only once, that is for IMODEL::ld_a and set the dimension information for IMODEL::ld_r[i], IMODEL::ld_s[i], but let
IMODEL::ld_r[i]._s[j]._s = IMODEL::ld_s[i]._s[j]._s = IMODEL::ld_a[i]._s[j]._s,
where the first '_s' is RARR type and the second '_s' is (ireal *) type - etc - set up paralle information for communication - set the MPI_DATATYPE for sending and receiving: - let
PARALLELINFO::reinfo[ia][i].buf = IMODEL::ld_r[i]._s[ia]._s (two pointers)
PARALLELINFO::seinfo[ia][i].buf = IMODEL::ld_s[i]._s[ia]._s (two pointers) - constructor the EXCHANGEINFO::type, which the vector datatype striding the continuous memory to the pieces for communication (send and receive)
NOTE: as mentioned before, STORAGE ALLOCATION occurs only once, that is for IMODEL::ld_a. All other domains in IMODEL struct is of different dimension information, but refer to the same chunk of physical memories of (ireal *) type with IMODEL::ld_a.
[out] | state | - (IWAVE *) IWAVE struct pointer |
[in] | pars | - (PARARRAY *) parameter array pointer |
[in] | stream | - (FILE *) file pointer for dumping run-time message and warning |
[in] | minit | - a function pointer that initializes an IMODEL struct. References IMODEL::minit |
Dump information of all arrays including the allocated, computational virtual, send and recv ones as well as parallel info.
Resets all dynamical fields zeros, time index = it and internal step index = 0.
void iwave_destroy | ( | IWAVE * | state, | |
FD_MODELDEST | d | |||
) |
STORAGE DEALLOCATION for IMODEL struct and frees the communicator and destroys the send and recv info.
state | - (IWAVE *) target IWAVE struct |
void quietexit | ( | PARARRAY * | pars, | |
FILE ** | stream | |||
) |
Normal exit.
should only be called after everything is done, so assume stream exists.
void abortexit | ( | int | err, | |
PARARRAY * | pars, | |||
FILE ** | stream | |||
) |
Cleans up environment and exits.
int initoutstream | ( | FILE ** | stream, | |
int | rk, | |||
int | sz | |||
) |
Initializes parallel output stream.
Called in driver.
[out] | stream | - (FILE **) a pointer of FILE pointer |
[in] | rk | - (int) rank in MPI_COMM_WORLD |
[in] | sz | - (int) number of processes in the group of MPI_COMM_WORLD |
int readinput | ( | PARARRAY ** | pars, | |
FILE * | stream, | |||
int | argc, | |||
char ** | argv | |||
) |
Initializes input parameter structures and populates them.
Called in driver.
void readparpars | ( | PARARRAY * | pars, | |
int * | stats, | |||
int * | nopts, | |||
int * | printact, | |||
FILE * | out | |||
) |
Reads miscellaneous flags from param array, such as stats, nopts and printact.
Called in iwave_construct.
void storeparallel | ( | PARALLELINFO * | pinfo | ) |
Static storage of MPI comm params.
int setrecvexchange | ( | IMODEL * | model, | |
PARALLELINFO * | pinfo, | |||
FILE * | stream, | |||
IWaveInfo const & | ic | |||
) |
Sets up parallel information for communication - sets the MPI_DATATYPE for sending and receiving.
Calls rd_setexchangeinfo.
int dump_pi | ( | PARARRAY * | pars, | |
PARALLELINFO * | pinfo, | |||
FILE * | stream | |||
) |
Dumps parallel info.
Dumps information of all arrays including the allocated, and computational virtual ones.
void dump_rs | ( | PARARRAY * | pars, | |
IMODEL * | model, | |||
FILE * | stream, | |||
int | sends, | |||
IWaveInfo const & | ic, | |||
PARALLELINFO * | pinfo | |||
) |
Dumps information of all arrays including the send and recv virtual ones.