ASCOT5
Loading...
Searching...
No Matches
Functions
mpi_interface.c File Reference

MPI interface. More...

#include <stddef.h>
#include <stdlib.h>
#include "ascot5.h"
#include "diag.h"
#include "mpi_interface.h"
#include "particle.h"
#include "simulate.h"

Go to the source code of this file.

Functions

void mpi_interface_init (int argc, char **argv, int *mpi_rank, int *mpi_size, int *mpi_root)
 Initialize MPI.
 
void mpi_interface_finalize ()
 Finalize MPI.
 
void mpi_interface_barrier ()
 Wait until all processes have reached this routine.
 
void mpi_my_particles (int *start_index, int *n, int n_tot, int mpi_rank, int mpi_size)
 Divide markers to mpi processes.
 
void mpi_gather_particlestate (particle_state *ps, particle_state **ps_gather, int *n_gather, int n_tot, int mpi_rank, int mpi_size, int mpi_root)
 Gather all particle states to the root process.
 
void mpi_gather_diag (diag_offload_data *data, real *offload_array, int ntotal, int mpi_rank, int mpi_size, int mpi_root)
 Gather all diagnostics to the root process.
 

Detailed Description

MPI interface.

This module provides interfaces for communication with MPI.

Definition in file mpi_interface.c.

Function Documentation

◆ mpi_interface_init()

void mpi_interface_init ( int argc,
char ** argv,
int * mpi_rank,
int * mpi_size,
int * mpi_root )

Initialize MPI.

This function initializes MPI and sets the mpi_rank and mpi_size accordingly. If compiled without MPI, mpirank is set to zero and mpi_size is set to one.

Parameters
argccount of the command line arguments
argvpointers to the command line arguments
mpi_rankpointer to the determined rank of this MPI process
mpi_sizepointer to the determined number of MPI processes
mpi_rootpointer to the determined rank of the root MPI process

Definition at line 30 of file mpi_interface.c.

◆ mpi_interface_finalize()

void mpi_interface_finalize ( )

Finalize MPI.

This function finalizes the MPI environment, to be called at the end of execution.

Definition at line 58 of file mpi_interface.c.

◆ mpi_interface_barrier()

void mpi_interface_barrier ( )

Wait until all processes have reached this routine.

Wrapper for the MPI_Barrier.

Definition at line 69 of file mpi_interface.c.

◆ mpi_my_particles()

void mpi_my_particles ( int * start_index,
int * n,
int n_tot,
int mpi_rank,
int mpi_size )

Divide markers to mpi processes.

This function divides ntotal markers evenly and returns the starting index and number of markers to be simulated for each process.

Parameters
start_indexpointer to variable for starting index in input markers
npointer to variable for number of markers for this process
n_totnumber of markers in the simulation
mpi_rankrank of this MPI process
mpi_sizetotal number of MPI processes

Definition at line 87 of file mpi_interface.c.

◆ mpi_gather_particlestate()

void mpi_gather_particlestate ( particle_state * ps,
particle_state ** ps_gather,
int * n_gather,
int n_tot,
int mpi_rank,
int mpi_size,
int mpi_root )

Gather all particle states to the root process.

This function gathers the particle states from each process to an array in the root process. In condor-style execution only particle states for current process are stored. An allocated array for gathered particle states is stored in psgathered and number of states in ngathered.

Todo
Could be done more cleanly with custom datatypes
Parameters
pspointer to array particle states for this process
ps_gatherpointer to pointer to array where markers are gathered
n_gatherpointer to variable for number of gathered markers
n_tottotal number of markers in the simulation
mpi_rankrank of this MPI process
mpi_sizetotal number of MPI processes
mpi_rootrank of the root process

Definition at line 117 of file mpi_interface.c.

◆ mpi_gather_diag()

void mpi_gather_diag ( diag_offload_data * data,
real * offload_array,
int ntotal,
int mpi_rank,
int mpi_size,
int mpi_root )

Gather all diagnostics to the root process.

This function gathers the distributions and orbits to the root process. Distributions are summed and orbit data is appended to the root process diagnostics array.

Parameters
datadiagnostics offload data
offload_arraypointer to diagnostics offload array
ntotaltotal number of markers in the simulation
mpi_rankrank of this MPI process
mpi_sizetotal number of MPI processes
mpi_rootrank of the root process

Definition at line 295 of file mpi_interface.c.