Skip to content

Commit 56c95ef

Browse files
Update the halo documentation to cover the new exchange interfaces
1 parent df6a588 commit 56c95ef

File tree

1 file changed

+66
-3
lines changed

1 file changed

+66
-3
lines changed

docs/source/pages/api_halo.rst

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,18 @@ Here the first parameter var, a 3D input array, contains the normal pencil-distr
1212

1313
As with the rest of the 2DECOMP&FFT library, a more general form of the routine is available (implemented using Fortran optional parameters):
1414

15-
``call update_halo(var, var_halo, level, opt_decomp, opt_global)``
15+
``call update_halo(var, var_halo, level, opt_decomp, opt_global, opt_pencil)``
1616

17-
This supports halo-cell communications among pencils with arbitrary global sizes, as described by `opt_decomp`, the decomposition object. The last optional parameter `opt_global` is required (to be set to .true.) if global coordinate is used to define the pencils, i.e. the input array var is defined using the start/end variables rather than size variables. This ensures the coordinate systems used by `var` and `var_halo` are consistent.
17+
This supports halo-cell communications among pencils with arbitrary global sizes, as described by
18+
`opt_decomp`, the decomposition object.
19+
The optional parameter `opt_global` is required (to be set to .true.) if global coordinate is used
20+
to define the pencils, i.e. the input array var is defined using the start/end variables rather than
21+
size variables.
22+
This ensures the coordinate systems used by `var` and `var_halo` are consistent.
23+
The optional parameter `opt_pencil` allows the user to specify which pencil they are operating in
24+
(`1=X,2=Y,3=Z`), our recommendation is to do so, the current interface makes this parameter optional
25+
to continue supporting the previous implementation which would try to determin the orientation
26+
automatically, however this may not be reliable.
1827

1928
To demonstrate the use of this API, here is an example that computes spatial derivatives:
2029

@@ -49,4 +58,58 @@ The extra parameter periodic_bc is a 1D array containing 3 logical values that s
4958

5059
Like the rest of 2DECOMP&FFT, the halo-cell support API is implemented in a black-box fashion. The library internally handles the communications between neighbouring blocks using standard MPI non-blocking point-to-point communications.
5160

52-
61+
-----------------------
62+
Halo-exchange interface
63+
-----------------------
64+
65+
The high-level halo interface described above makes it easy to add halo support to existing codes.
66+
However, by handling the memory allocation for you, it is difficult to adopt in a code that is
67+
already written to handle its halos when porting to the 2DECOMP&FFT library.
68+
As described above, the `update_halo` interface operates in two phases:
69+
1) a new array, extended with halo entries is allocated
70+
2) local data is copied into the local region of this array and used to communicate halo values to
71+
neighbouring processes
72+
73+
To facilitate the use of 2DECOMP&FFT by existing stencil codes we have exposed the data exchange
74+
(step 2) as a new interface `exchange_halo`.
75+
There are two behaviours of the interface based on the optional parameters `opt_depth` and
76+
`opt_levels`
77+
78+
::
79+
call halo_exchange(arr, ipencil, opt_depth, opt_levels)
80+
81+
where `arr` is the working array, `ipencil=1,2,3` indicates the pencil orientation and the optional
82+
values `opt_depth` and `opt_levels` take scalar and array integer values to indicate the halo
83+
depths.
84+
The former sets the halo depth in the two perpendicular directions to the current pencil orientation
85+
and the latter allows an arbitrary depth of halo to be set
86+
in each axis of the current orientation.
87+
The working array is expected to be prepopulated with local data and of size
88+
`(nx+2*ih,ny+2*jh,nz+2*kh)`, where `ih,jh,kh` are the halo depths in each direction.
89+
To illustrate the use of `exchange_halo` the two calls
90+
91+
::
92+
call halo_exchange(vh, 1, opt_depth=1)
93+
call halo_exchange(wh, 1, opt_levels=[0, 1, 1])
94+
95+
are equivalent and will exchange halo data to depth 1 in the Y and Z axes for data in the X pencil.
96+
97+
To aid users in creating suitably-sized arrays the allocation subroutines have been extended with
98+
optional halo parameters `opt_depth` and `opt_levels` whose meaning matches the above.
99+
When supplied with non-zero values 2DECOMP&FFT will allocate a halo-padded array to the requested
100+
depth.
101+
102+
When a code is heavily dependent on halo exchanges, it may be repetitive to specify the halo depths
103+
at each exchange.
104+
In such cases, the user can specify a default depth for a given decomposition by setting
105+
106+
::
107+
decomp_info%xlevel = [ihx, jhx, khx]
108+
decomp_info%ylevel = [ihy, jhy, khy]
109+
decomp_info%zlevel = [ihz, jhz, khz]
110+
111+
if `opt_depth/opt_levels` is not specified in the allocation, or halo exchange routines, then this
112+
value will be used (note that by default these are all set to `[0,0,0]`).
113+
114+
We would like to acknowledge the work of S.Owens in the ARCHER2 eCSE05-03 project
115+
(https://www.archer2.ac.uk/ecse/reports/eCSE05-03/) who initially developed these interfaces.

0 commit comments

Comments
 (0)