PLUTO
al_hidden.h
Go to the documentation of this file.
1 /* ///////////////////////////////////////////////////////////////////// */
2 /*!
3  \file
4  \brief Internal include file for the ArrayLib.
5 
6  Internal include file for the ArrayLib.
7  If this is defined, each node has a copy of the indexes from all
8  other nodes. This is mainly useful to deal with non-uniform array
9  distributions.
10 
11  \author A. Malagoli (University of Chicago)
12  \author G. Muscianisi (g.muscianisi@cineca.it)
13 
14  \date Aug 29, 2012
15 */
16 /* ///////////////////////////////////////////////////////////////////// */
17 #ifndef __AL_HIDDEN
18 #define __AL_HIDDEN
19 
20 
21 #include <mpi.h>
22 
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <math.h>
27 
28 #include "al_defs.h"
29 
30 /* Include AL macros and definitions */
31 #include "al_codes.h"
32 
33 /* Include functions prototypes */
34 #include "al_proto.h"
35 
36 
37 /* Type definition for the SZ structure */
38 typedef struct szz{
39  int compiled; /* AL_TRUE if this is a compiled array */
40  MPI_Datatype type; /* The elementary data type of the array
41  e.g.: MPI_FLOAT, MPI_INT .. */
42  int type_size; /* Size of the elmentary data type */
43  int ndim; /* Number of array dimensions (max: 5) */
44  int rank; /* Rank of this portion of the array */
45  int size; /* Size of the communicator which the
46  array is associated with */
47  MPI_Comm comm; /* The communicator which the array is
48  associated with */
49  MPI_Comm cart_comm; /* The derived cartesian communicator */
50  MPI_Comm oned_comm[AL_MAX_DIM]; /* 1D communicators along directions */
51  /* (Useful for performing global operations along single directions */
52  long int buffsize; /* Size of the local buffer for the array */
53  int arrdim[AL_MAX_DIM]; /* Global dimensions of the array */
54  int larrdim[AL_MAX_DIM]; /* Local dimensions of the array
55  in this dimension WITHOUT ghost points */
56  int larrdim_gp[AL_MAX_DIM]; /* Local size of array in this direction
57  WITH ghost points (compare to larrdim)*/
58  int beg[AL_MAX_DIM]; /* Global address of beginning of array
59  in this dimension (C-convention) */
60  int end[AL_MAX_DIM]; /* Global address of ending of array
61  in this dimension (C-convention) */
62 
63  int *begs, *ends; /* These pointers can be used to
64  gather the information about the
65  distribution of the indexes across
66  all the nodes */
67 
68  int lbeg[AL_MAX_DIM]; /* Local address of beginning of array
69  in this dimension (C-convention) */
70  int lend[AL_MAX_DIM]; /* Local address of ending of array
71  in this dimension (C-convention) */
72  int bg[AL_MAX_DIM]; /* Size of ghost point at beginning of
73  array in this dimension */
74  int eg[AL_MAX_DIM]; /* Size of ghost point at beginning of
75  array in this dimension */
76  int offset[AL_MAX_DIM]; /* Local array offsets for local do loops */
77  int stride[AL_MAX_DIM]; /* We will replace offset with stride EVENTUALLY */
78  int isparallel[AL_MAX_DIM]; /* AL_TRUE if the array is distributed
79  along this dimension [Default: AL_TRUE]*/
80  int isperiodic[AL_MAX_DIM]; /* AL_TRUE if the array is periodic in
81  this dimension [Default: AL_TRUE] */
82  int isstaggered[AL_MAX_DIM]; /* AL_TRUE if the array is staggered in
83  this dimension [Default: AL_FALSE]*/
84  int left[AL_MAX_DIM]; /* Rank of left node in this dimension in the
85  cartesian communicator topology */
86  int right[AL_MAX_DIM]; /* Rank of right node in this dimension in the
87  cartesian communicator topology */
88  int lrank[AL_MAX_DIM]; /* Rank of this node along this dimension of
89  the cartesian nodes topology */
90  int lsize[AL_MAX_DIM]; /* Number of nodes along this dimension of
91  the cartesian nodes topology */
92  int sendb1[AL_MAX_DIM]; /* Send buffer pointer for the SendRecv operation */
94  int recvb1[AL_MAX_DIM]; /* Receive buffer pointers for the SendRecv operation */
96  int tag1[AL_MAX_DIM], tag2[AL_MAX_DIM]; /* Tags for SendRecv operation */
97  MPI_Datatype strided[AL_MAX_DIM]; /* Strided data type corresponding to
98  the ghost point buffer in this
99  dimension */
100  /* We add two separate strided data types in order to allow for
101  a different exchange of ghost points from Left to Right than
102  from Right to Left. This is needed when we exchange boundary
103  points in strided or overlapping data types */
104  MPI_Datatype type_lr[AL_MAX_DIM]; /* Strided data type for the
105  Left->Right exchange */
106  MPI_Datatype type_rl[AL_MAX_DIM]; /* Strided data type for the
107  Right->Left exchange */
108  int pio_offset; /* The offset for PIO */
109 
110  MPI_Datatype gsubarr; /* Global subarray for MPI-IO */
111  MPI_Datatype lsubarr; /* Local subarray for MPI-IO */
112 
113  MPI_Datatype gsubarr_stag[AL_MAX_DIM]; /* Global staggered subarrays for MPI-IO */
114  MPI_Datatype lsubarr_stag[AL_MAX_DIM]; /* Local staggered subarrays for MPI-IO */
115 
116  MPI_Offset io_offset; /* Offset used to store file pointer */
117  MPI_File ifp; /* Pointer to the file this array is to be
118  written using MPI-IO */
119 } SZ;
120 
121 
122 #endif /* End ifndef __AL_HIDDEN */
123 /*------------------------------------------------------------*/
124 
125 /* In order to make life easier with the Fortran interface,
126  we do not pass the pointers to the SZ structures directly,
127  but we rather allocate statically an array of pointers to
128  SZ structures, and pass an integer index that points to
129  an entry in this array */
130 /* SZ *sz_stack[AL_MAX_ARRAYS]; */
131 
132 
133 /*M
134  SZ - The descriptor structure for distributed arrays.
135 
136 .vb
137 
138  This structure contains all the information necessary
139  to handle information on distributed arrays. The structures
140  are not accessible directly by the user, but are modified
141  and queried by calling routines that are part of the AL
142  library.
143 
144 
145 Here is the type definition for the SZ structure:
146 
147 
148 typedef struct SZ_{
149  int compiled; AL_TRUE if this is a compiled array
150  int type; The elementary data type of the array
151  e.g.: MPI_FLOAT, MPI_INT ..
152  int ndim; Number of array dimensions (max: 5)
153  int rank; Rank of this portion of the array
154  int size; Size of the communicator which the
155  array is associated with
156  MPI_Comm comm; The communicator which the array is
157  associated with.
158  MPI_Comm cart_comm; The derived cartesian communicator
159  MPI_Comm oned_comm[AL_MAX_DIM]; 1D communicators along directions
160  (Useful for performing global operations
161  along single directions)
162  int buffsize;
163  int arrdim[AL_MAX_DIM]; Global dimensions of the array
164  int larrdim[AL_MAX_DIM]; Local dimensions of the array
165  in this dimension WITHOUT ghost points
166  int larrdim_gp[AL_MAX_DIM]; Local size of array in this direction
167  WITH ghost points (compare to larrdim)
168  int beg[AL_MAX_DIM]; Global address of beginning of array
169  in this dimension (C-convention)
170  int end[AL_MAX_DIM]; Global address of ending of array
171  in this dimension (C-convention)
172 
173  int *begs, *ends; These pointers can be used to
174  gather the information about the
175  distribution of the indexes across
176  all the nodes
177 
178  int lbeg[AL_MAX_DIM]; Local address of beginning of array
179  in this dimension (C-convention)
180  int lend[AL_MAX_DIM]; Local address of ending of array
181  in this dimension (C-convention)
182  int bg[AL_MAX_DIM]; Size of ghost point at beginning of
183  array in this dimension
184  int eg[AL_MAX_DIM]; Size of ghost point at beginning of
185  array in this dimension
186  int offset[AL_MAX_DIM]; Local array offsets for local do loops
187  int isparallel[AL_MAX_DIM]; AL_TRUE if the array is distributed
188  along this dimension [Default: AL_TRUE]
189  int isperiodic[AL_MAX_DIM]; AL_TRUE if the array is periodic in
190  this dimension [Default: AL_TRUE]
191  int isstaggered[AL_MAX_DIM];AL_TRUE if the array is staggered in
192  this dimension [Default: AL_FALSE]
193  int left[AL_MAX_DIM]; Rank of left node in this dimension in the
194  cartesian communicator topology
195  int right[AL_MAX_DIM]; Rank of right node in this dimension in the
196  cartesian communicator topology
197  int lrank[AL_MAX_DIM]; Rank of this node along this dimension of
198  the cartesian nodes topology
199  int lsize[AL_MAX_DIM]; Number of nodes along this dimension of
200  the cartesian nodes topology
201  int sendb1[AL_MAX_DIM]; Send buffer pointer for the SendRecv operation
202  int sendb2[AL_MAX_DIM];
203  int recvb1[AL_MAX_DIM]; Receive buffer pointers for the SendRecv operation
204  int recvb2[AL_MAX_DIM];
205  int tag1[AL_MAX_DIM], tag2[AL_MAX_DIM]; Tags for SendRecv operation
206 
207  MPI_Datatype strided[AL_MAX_DIM]; Strided data type corresponding to
208  the ghost point buffer in this
209  dimension
210 
211  MPI_Datatype type_lr[AL_MAX_DIM]; Strided data type for the
212  Left->Right exchange
213  MPI_Datatype type_rl[AL_MAX_DIM]; Strided data type for the
214  Right->Left exchange
215 
216  THESE ARE DEFINED ONLY IF MPI-IO IS COMPILED:
217 
218  MPI_Datatype gsubarr; Global subarray for MPI-IO
219  MPI_Datatype lsubarr; Local subarray for MPI-IO
220  MPI_Offset io_offset; Offset used to store file pointer
221  MPI_File ifp; Pointer to the file this array is to be
222  written using MPI-IO
223 
224 } SZ;
225 .ve
226 M*/
227 
int recvb2[AL_MAX_DIM]
Definition: al_hidden.h:95
int isperiodic[AL_MAX_DIM]
Definition: al_hidden.h:80
#define AL_MAX_DIM
Definition: al_codes.h:18
ArrayLib function prototypes header file.
int end[AL_MAX_DIM]
Definition: al_hidden.h:60
int lrank[AL_MAX_DIM]
Definition: al_hidden.h:88
int isparallel[AL_MAX_DIM]
Definition: al_hidden.h:78
int offset[AL_MAX_DIM]
Definition: al_hidden.h:76
int tag1[AL_MAX_DIM]
Definition: al_hidden.h:96
int right[AL_MAX_DIM]
Definition: al_hidden.h:86
int type_size
Definition: al_hidden.h:42
int * begs
Definition: al_hidden.h:63
MPI_Datatype gsubarr
Definition: al_hidden.h:110
MPI_Comm oned_comm[AL_MAX_DIM]
Definition: al_hidden.h:50
int recvb1[AL_MAX_DIM]
Definition: al_hidden.h:94
ArrayLib codes header file.
MPI_Comm cart_comm
Definition: al_hidden.h:49
int arrdim[AL_MAX_DIM]
Definition: al_hidden.h:53
int larrdim_gp[AL_MAX_DIM]
Definition: al_hidden.h:56
int sendb1[AL_MAX_DIM]
Definition: al_hidden.h:92
struct szz SZ
int larrdim[AL_MAX_DIM]
Definition: al_hidden.h:54
int rank
Definition: al_hidden.h:44
int * ends
Definition: al_hidden.h:63
MPI_Datatype type_rl[AL_MAX_DIM]
Definition: al_hidden.h:106
MPI_File ifp
Definition: al_hidden.h:117
int stride[AL_MAX_DIM]
Definition: al_hidden.h:77
int bg[AL_MAX_DIM]
Definition: al_hidden.h:72
MPI_Datatype lsubarr
Definition: al_hidden.h:111
int left[AL_MAX_DIM]
Definition: al_hidden.h:84
int beg[AL_MAX_DIM]
Definition: al_hidden.h:58
MPI_Datatype lsubarr_stag[AL_MAX_DIM]
Definition: al_hidden.h:114
int sendb2[AL_MAX_DIM]
Definition: al_hidden.h:93
int isstaggered[AL_MAX_DIM]
Definition: al_hidden.h:82
int eg[AL_MAX_DIM]
Definition: al_hidden.h:74
int lsize[AL_MAX_DIM]
Definition: al_hidden.h:90
MPI_Datatype strided[AL_MAX_DIM]
Definition: al_hidden.h:97
int size
Definition: al_hidden.h:45
int tag2[AL_MAX_DIM]
Definition: al_hidden.h:96
MPI_Comm comm
Definition: al_hidden.h:47
long int buffsize
Definition: al_hidden.h:52
MPI_Datatype type
Definition: al_hidden.h:40
MPI_Offset io_offset
Definition: al_hidden.h:116
ArrayLib function definitions header file.
Definition: al_hidden.h:38
MPI_Datatype gsubarr_stag[AL_MAX_DIM]
Definition: al_hidden.h:113
int pio_offset
Definition: al_hidden.h:108
int compiled
Definition: al_hidden.h:39
int lbeg[AL_MAX_DIM]
Definition: al_hidden.h:68
MPI_Datatype type_lr[AL_MAX_DIM]
Definition: al_hidden.h:104
int lend[AL_MAX_DIM]
Definition: al_hidden.h:70
int ndim
Definition: al_hidden.h:43