Basilisk CFD
Adaptive Cartesian mesh PDE framework
Loading...
Searching...
No Matches
tree-mpi.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Rcv
 
struct  RcvPid
 
struct  SndRcv
 
struct  MpiBoundary
 
struct  Remote
 

Macros

#define BOUNDARY_TAG(level)   (level)
 
#define COARSEN_TAG(level)   ((level) + 64)
 
#define REFINE_TAG()   (128)
 
#define MOVED_TAG()   (256)
 
#define is_remote(cell)   (cell.pid >= 0 && cell.pid != pid())
 
#define REMOTE()   ((Remote *)&val(remote,0))
 

Functions

void debug_mpi (FILE *fp1)
 
static void cache_level_init (CacheLevel *c)
 
static void rcv_append (Point point, Rcv *rcv)
 
void rcv_print (Rcv *rcv, FILE *fp, const char *prefix)
 
static void rcv_free_buf (Rcv *rcv)
 
static void rcv_destroy (Rcv *rcv)
 
static RcvPidrcv_pid_new (const char *name)
 
static Rcvrcv_pid_pointer (RcvPid *p, int pid)
 
static void rcv_pid_append (RcvPid *p, int pid, Point point)
 
static void rcv_pid_append_pids (RcvPid *p, Array *pids)
 
void rcv_pid_write (RcvPid *p, const char *name)
 
static void rcv_pid_print (RcvPid *p, FILE *fp, const char *prefix)
 
static void rcv_pid_destroy (RcvPid *p)
 
static void apply_bc (Rcv *rcv, scalar *list, scalar *listv, vector *listf, int l, MPI_Status s)
 
static void mpi_recv_check (void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status, const char *name)
 
static trace int mpi_waitany (int count, MPI_Request array_of_requests[], int *indx, MPI_Status *status)
 
static int list_lenb (scalar *list)
 
static int vectors_lenb (vector *list)
 
static void rcv_pid_receive (RcvPid *m, scalar *list, scalar *listv, vector *listf, int l)
 
static trace void rcv_pid_wait (RcvPid *m)
 
static void rcv_pid_send (RcvPid *m, scalar *list, scalar *listv, vector *listf, int l)
 
static void rcv_pid_sync (SndRcv *m, scalar *list, int l)
 
static void snd_rcv_destroy (SndRcv *m)
 
static void snd_rcv_init (SndRcv *m, const char *name)
 
static void mpi_boundary_destroy (Boundary *b)
 
static trace void mpi_boundary_level (const Boundary *b, scalar *list, int l)
 
static trace void mpi_boundary_restriction (const Boundary *b, scalar *list, int l)
 
void mpi_boundary_new ()
 
static FILEfopen_prefix (FILE *fp, const char *name, char *prefix)
 
static void snd_rcv_free (SndRcv *p)
 
static bool is_root (Point point)
 
static bool is_local_prolongation (Point point, Point p)
 
static void append_pid (Array *pids, int pid)
 
static int locals_pids (Point point, Array *pids)
 
static int root_pids (Point point, Array *pids)
 
static void rcv_pid_row (RcvPid *m, int l, int *row)
 
void check_snd_rcv_matrix (SndRcv *sndrcv, const char *name)
 
static bool has_local_child (Point point)
 
trace void mpi_boundary_update_buffers ()
 
trace void mpi_boundary_refine (scalar *list)
 
static void check_depth ()
 
trace void mpi_boundary_coarsen (int l, int too_fine)
 
static void flag_border_cells ()
 
static int balanced_pid (long index, long nt, int nproc)
 
trace void mpi_partitioning ()
 
void restore_mpi (FILE *fp, scalar *list1)
 
trace double z_indexing (scalar index, bool leaves)
 

Variables

int debug_iteration = -1
 
static Boundarympi_boundary = NULL
 

Macro Definition Documentation

◆ BOUNDARY_TAG

#define BOUNDARY_TAG (   level)    (level)

Definition at line 156 of file tree-mpi.h.

◆ COARSEN_TAG

#define COARSEN_TAG (   level)    ((level) + 64)

Definition at line 157 of file tree-mpi.h.

◆ is_remote

#define is_remote (   cell)    (cell.pid >= 0 && cell.pid != pid())

Definition at line 724 of file tree-mpi.h.

◆ MOVED_TAG

#define MOVED_TAG ( )    (256)

Definition at line 159 of file tree-mpi.h.

◆ REFINE_TAG

#define REFINE_TAG ( )    (128)

Definition at line 158 of file tree-mpi.h.

◆ REMOTE

#define REMOTE ( )    ((Remote *)&val(remote,0))

Definition at line 1129 of file tree-mpi.h.

Function Documentation

◆ append_pid()

static void append_pid ( Array pids,
int  pid 
)
static

Definition at line 726 of file tree-mpi.h.

References array_append(), i, int, p, and x.

Referenced by locals_pids(), mpi_boundary_update_buffers(), and root_pids().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_bc()

static void apply_bc ( Rcv rcv,
scalar list,
scalar listv,
vector listf,
int  l,
MPI_Status  s 
)
static

Definition at line 163 of file tree-mpi.h.

References allocated(), b, Rcv::buf, debug_mpi(), dimension, fflush(), foreach_cache_level(), free(), Rcv::halo, i, j, k, l, nodata, Rcv::pid, s, size, v, and x.

Referenced by rcv_pid_receive().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ balanced_pid()

static int balanced_pid ( long  index,
long  nt,
int  nproc 
)
static

Definition at line 1244 of file tree-mpi.h.

References index, max, min, nr, nt, and x.

Referenced by balance(), mpi_partitioning(), and restore_mpi().

Here is the caller graph for this function:

◆ cache_level_init()

static void cache_level_init ( CacheLevel c)
static

Definition at line 34 of file tree-mpi.h.

References c, and x.

Referenced by rcv_append(), and rcv_pid_pointer().

Here is the caller graph for this function:

◆ check_depth()

static void check_depth ( )
static

Definition at line 1090 of file tree-mpi.h.

References assert, depth, foreach_cell_all(), fp, i, j, l, L0, Layer::len, level, Layer::m, max, Layer::nc, tree, x, X0, and Y0.

Referenced by mpi_boundary_coarsen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_snd_rcv_matrix()

void check_snd_rcv_matrix ( SndRcv sndrcv,
const char name 
)

Definition at line 787 of file tree-mpi.h.

References debug_mpi(), depth, fflush(), free(), i, j, k, l, matrix_free(), matrix_new(), npe, qmalloc, rcv_pid_row(), and x.

Referenced by mpi_boundary_update_buffers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ debug_mpi()

void debug_mpi ( FILE fp1)

Definition at line 540 of file tree-mpi.h.

References _i, assert, cell(), depth, fopen_prefix(), foreach_halo, fp, i, is_refined, l, leaf, level, Rcv::maxdepth, mpi, mpi_boundary, n, RcvPid::npid, Rcv::pid, RcvPid::rcv, rcv_pid_print(), x, y, and z.

Referenced by apply_bc(), check_snd_rcv_matrix(), mpi_boundary_update_buffers(), and mpi_recv_check().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flag_border_cells()

static void flag_border_cells ( )
static

Definition at line 1200 of file tree-mpi.h.

References _i, border, cell(), flags, GHOSTS, is_refined_check(), level, and x.

Referenced by balance(), mpi_partitioning(), and restore_mpi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fopen_prefix()

static FILE * fopen_prefix ( FILE fp,
const char name,
char prefix 
)
static

Definition at line 523 of file tree-mpi.h.

References debug_iteration, fname, fp, and x.

Referenced by debug_mpi().

Here is the caller graph for this function:

◆ has_local_child()

static bool has_local_child ( Point  point)
static

Definition at line 851 of file tree-mpi.h.

References cell(), and x.

Referenced by mpi_boundary_update_buffers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_local_prolongation()

static bool is_local_prolongation ( Point  point,
Point  p 
)
static

Definition at line 708 of file tree-mpi.h.

References dimension, dp, scalar::i, Point::i, is_refined, neighbor(), p, point, x, y, and z.

Referenced by locals_pids(), and mpi_boundary_update_buffers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_root()

static bool is_root ( Point  point)
static

Definition at line 698 of file tree-mpi.h.

References cell(), is_refined, and x.

Referenced by mpi_boundary_update_buffers(), and restore_mpi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ list_lenb()

static int list_lenb ( scalar list)
static

Definition at line 299 of file tree-mpi.h.

References s, and x.

Referenced by rcv_pid_receive(), and rcv_pid_send().

Here is the caller graph for this function:

◆ locals_pids()

static int locals_pids ( Point  point,
Array pids 
)
static

Definition at line 734 of file tree-mpi.h.

References append_pid(), cell(), int, is_local_prolongation(), is_refined, is_remote, p, point, and x.

Referenced by mpi_boundary_update_buffers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mpi_boundary_coarsen()

trace void mpi_boundary_coarsen ( int  l,
int  too_fine 
)

Definition at line 1132 of file tree-mpi.h.

◆ mpi_boundary_destroy()

static void mpi_boundary_destroy ( Boundary b)
static

Definition at line 482 of file tree-mpi.h.

References array_free(), b, free(), m(), and snd_rcv_destroy().

Referenced by mpi_boundary_new().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mpi_boundary_level()

static trace void mpi_boundary_level ( const Boundary b,
scalar list,
int  l 
)
static

Definition at line 494 of file tree-mpi.h.

References b, l, list, m(), and rcv_pid_sync().

Referenced by mpi_boundary_coarsen(), and mpi_boundary_new().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mpi_boundary_new()

void mpi_boundary_new ( )

Definition at line 508 of file tree-mpi.h.

References add_boundary(), array_new(), _Boundary::destroy, _Boundary::level, mpi, mpi_boundary, mpi_boundary_destroy(), mpi_boundary_level(), mpi_boundary_restriction(), qcalloc, _Boundary::restriction, and snd_rcv_init().

Referenced by init_grid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mpi_boundary_refine()

trace void mpi_boundary_refine ( scalar list)

Definition at line 1020 of file tree-mpi.h.

Referenced by mpi_boundary_refine().

Here is the caller graph for this function:

◆ mpi_boundary_restriction()

static trace void mpi_boundary_restriction ( const Boundary b,
scalar list,
int  l 
)
static

Definition at line 502 of file tree-mpi.h.

References b, l, list, m(), and rcv_pid_sync().

Referenced by mpi_boundary_new().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mpi_boundary_update_buffers()

trace void mpi_boundary_update_buffers ( )

Definition at line 860 of file tree-mpi.h.

References _i, append_pid(), cell(), check_snd_rcv_matrix(), coarsen_cell(), debug_mpi(), depth, free(), has_local_child(), i, is_local_prolongation(), is_refined, is_remote, is_root(), l, level, locals_pids(), m(), mpi_boundary, n, npe, p, point, SndRcv::rcv, rcv_pid_append(), rcv_pid_append_pids(), restriction, root_pids(), SndRcv::snd, snd_rcv_free(), t, tree_check(), user, and x.

Referenced by balance(), mpi_boundary_update(), and mpi_partitioning().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mpi_partitioning()

trace void mpi_partitioning ( )

Definition at line 1255 of file tree-mpi.h.

References balanced_pid(), cell(), flag_border_cells(), foreach_cell_post(), i, mpi_boundary_update_buffers(), npe, nt, tree, and x.

Here is the call graph for this function:

◆ mpi_recv_check()

static void mpi_recv_check ( void buf,
int  count,
MPI_Datatype  datatype,
int  source,
int  tag,
MPI_Comm  comm,
MPI_Status status,
const char name 
)
static

Definition at line 236 of file tree-mpi.h.

References assert, buf, debug_mpi(), fflush(), source, t, tag, and x.

Referenced by mpi_boundary_refine(), rcv_pid_receive(), and receive_tree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mpi_waitany()

static trace int mpi_waitany ( int  count,
MPI_Request  array_of_requests[],
int indx,
MPI_Status status 
)
static

Definition at line 293 of file tree-mpi.h.

References x.

Referenced by rcv_pid_receive().

Here is the caller graph for this function:

◆ rcv_append()

static void rcv_append ( Point  point,
Rcv rcv 
)
static

Definition at line 40 of file tree-mpi.h.

References cache_level_append(), cache_level_init(), Rcv::depth, Rcv::halo, j, level, Rcv::maxdepth, point, and x.

Referenced by rcv_pid_append().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_destroy()

static void rcv_destroy ( Rcv rcv)
static

Definition at line 72 of file tree-mpi.h.

References Rcv::depth, free(), Rcv::halo, i, CacheLevel::n, CacheLevel::p, and rcv_free_buf().

Referenced by rcv_pid_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_free_buf()

static void rcv_free_buf ( Rcv rcv)
static

Definition at line 61 of file tree-mpi.h.

References Rcv::buf, free(), Rcv::r, and x.

Referenced by rcv_destroy(), and rcv_pid_wait().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_append()

static void rcv_pid_append ( RcvPid p,
int  pid,
Point  point 
)
static

Definition at line 109 of file tree-mpi.h.

References p, point, rcv_append(), and rcv_pid_pointer().

Referenced by mpi_boundary_update_buffers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_append_pids()

static void rcv_pid_append_pids ( RcvPid p,
Array pids 
)
static

Definition at line 114 of file tree-mpi.h.

References a, array_append(), i, int, j, p, and x.

Referenced by mpi_boundary_update_buffers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_destroy()

static void rcv_pid_destroy ( RcvPid p)
static

Definition at line 145 of file tree-mpi.h.

References free(), i, p, and rcv_destroy().

Referenced by snd_rcv_destroy(), and snd_rcv_free().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_new()

static RcvPid * rcv_pid_new ( const char name)
static

Definition at line 81 of file tree-mpi.h.

References RcvPid::name, qcalloc, and strdup().

Referenced by snd_rcv_free(), and snd_rcv_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_pointer()

static Rcv * rcv_pid_pointer ( RcvPid p,
int  pid 
)
static

Definition at line 88 of file tree-mpi.h.

References assert, Rcv::buf, cache_level_init(), Rcv::depth, Rcv::halo, i, Rcv::maxdepth, npe, p, Rcv::pid, qmalloc, and x.

Referenced by rcv_pid_append().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_print()

static void rcv_pid_print ( RcvPid p,
FILE fp,
const char prefix 
)
static

Definition at line 139 of file tree-mpi.h.

References fp, i, p, rcv_print(), and x.

Referenced by debug_mpi().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_receive()

static void rcv_pid_receive ( RcvPid m,
scalar list,
scalar listv,
vector listf,
int  l 
)
static

Definition at line 313 of file tree-mpi.h.

References apply_bc(), assert, BOUNDARY_TAG, Rcv::buf, depth, dimension, fflush(), Rcv::halo, i, l, list, list_lenb(), m(), mpi_recv_check(), mpi_waitany(), CacheLevel::n, nr, Rcv::pid, s, vectors_lenb(), and x.

Referenced by rcv_pid_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_row()

static void rcv_pid_row ( RcvPid m,
int  l,
int row 
)
static

Definition at line 776 of file tree-mpi.h.

References depth, Rcv::halo, i, l, m(), CacheLevel::n, npe, Rcv::pid, and x.

Referenced by check_snd_rcv_matrix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_send()

static void rcv_pid_send ( RcvPid m,
scalar list,
scalar listv,
vector listf,
int  l 
)
static

Definition at line 375 of file tree-mpi.h.

References allocated(), assert, b, BOUNDARY_TAG, Rcv::buf, depth, dimension, fflush(), foreach_cache_level(), Rcv::halo, i, j, k, l, list, list_lenb(), m(), CacheLevel::n, nodata, Rcv::pid, Rcv::r, s, v, vectors_lenb(), and x.

Referenced by rcv_pid_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_sync()

static void rcv_pid_sync ( SndRcv m,
scalar list,
int  l 
)
static

Definition at line 444 of file tree-mpi.h.

References free(), l, list_add(), m(), rcv_pid_receive(), rcv_pid_send(), rcv_pid_wait(), restriction_vertex(), s, vectors_add(), and x.

Referenced by mpi_boundary_level(), and mpi_boundary_restriction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_wait()

static trace void rcv_pid_wait ( RcvPid m)
static

Definition at line 368 of file tree-mpi.h.

References i, m(), and rcv_free_buf().

Referenced by rcv_pid_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcv_pid_write()

void rcv_pid_write ( RcvPid p,
const char name 
)

Definition at line 127 of file tree-mpi.h.

References fname, fp, i, p, Rcv::pid, rcv_print(), and x.

Here is the call graph for this function:

◆ rcv_print()

void rcv_print ( Rcv rcv,
FILE fp,
const char prefix 
)

Definition at line 53 of file tree-mpi.h.

References Rcv::depth, foreach_cache_level(), fp, Rcv::halo, l, level, CacheLevel::n, Rcv::pid, x, y, and z.

Referenced by rcv_pid_print(), and rcv_pid_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ restore_mpi()

void restore_mpi ( FILE fp,
scalar list1 
)

Definition at line 1297 of file tree-mpi.h.

References _i, balanced_pid(), cell(), cm, flag_border_cells(), flags, fm, foreach_cell_post(), fp, free(), scalar::i, index, is_root(), leaf, level, list, list_append(), list_concat(), list_len(), mpi_boundary_update(), npe, nt, NewPid::pid, point, refine_cell(), s, size, user, val(), and x.

Here is the call graph for this function:

◆ root_pids()

static int root_pids ( Point  point,
Array pids 
)
static

Definition at line 762 of file tree-mpi.h.

References append_pid(), cell(), int, is_remote, and x.

Referenced by mpi_boundary_update_buffers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ snd_rcv_destroy()

static void snd_rcv_destroy ( SndRcv m)
static

Definition at line 465 of file tree-mpi.h.

References m(), and rcv_pid_destroy().

Referenced by mpi_boundary_destroy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ snd_rcv_free()

static void snd_rcv_free ( SndRcv p)
static

Definition at line 687 of file tree-mpi.h.

References p, rcv_pid_destroy(), rcv_pid_new(), and x.

Referenced by mpi_boundary_update_buffers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ snd_rcv_init()

static void snd_rcv_init ( SndRcv m,
const char name 
)
static

Definition at line 471 of file tree-mpi.h.

References m(), rcv_pid_new(), s, and x.

Referenced by mpi_boundary_new().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vectors_lenb()

static int vectors_lenb ( vector list)
static

Definition at line 306 of file tree-mpi.h.

References v, and x.

Referenced by rcv_pid_receive(), and rcv_pid_send().

Here is the caller graph for this function:

◆ z_indexing()

trace double z_indexing ( scalar  index,
bool  leaves 
)

<em>z_indexing()</em>: fills <em>index</em> with the Z-ordering index.

If leaves is true only leaves are indexed, otherwise all active cells are indexed.

On the master process (pid() == 0), the function returns the (global) maximum index (and -1 on all other processes).

On a single processor, we would just need something like (for leaves)

double i = 0;
for (int _i = 0; _i < _N; _i++) /* foreach */
index[] = i++;

In parallel, this is a bit more difficult.

We first compute the size of each subtree.

The maximum index value is the size of the entire tree (i.e. the value of size in the root cell on the master process) minus one.

fixme: doc

Definition at line 1443 of file tree-mpi.h.

References _i, boundary_iterate, cell(), depth, i, index, l, leaves, level, restriction, size, subtree_size(), and x.

Here is the call graph for this function:

Variable Documentation

◆ debug_iteration

int debug_iteration = -1

Definition at line 4 of file tree-mpi.h.

Referenced by fopen_prefix().

◆ mpi_boundary

Boundary* mpi_boundary = NULL
static