This is a Julia API for Devito. it provides a Julia API's for a sub-set of Devito,
supporting Grid's, Function's, TimeFunction's and SparseTimeFunction's for both their
serial and domain decomposed MPI variants.
In addition it provides a Julia array interface for convenient and fast (copy-free) access to the Devito numpy arrays. For example,
using Devito
configuration!("language", "openmpi")
configuration!("mpi", false)
configuration() # show the Devito configuration
g = Grid(shape=(10,20,30))
f = Devito.Function(name="f", grid=g, space_order=8)
d = data(f)
d_with_halo = data_with_halo(f)
d_with_inhalo = data_with_inhalo(f)In the above code listing:
dis a view of the underlying numpy array that excludes Devito's exterior and interior halo paddingd_with_halois a view that includes Devito's exterior halo padding, but excludes its interior halo paddingd_with_inhalois a view that includes Divito's exterior and interior halo padding
If we are running with MPi turned on, then the data, data_with_halo and data_with_inhalo methods return
a view to an MPI domain distributed array. This array can be gathered to the rank 0 MPI rank with the convert
method:
using Devito
configuration!("language", "openmpi")
configuration!("mpi", true)
g = Grid(shape=(10,20,30))
f = Devito.Function(name="f", grid=g, space_order=8)
d = data(f)
p = parent(d) # array local to this MPI rank
_d = convert(Array, d) # _d is an Array on MPI rank 0 gathered from `d` which is decomposed accross all MPI ranksPlease see the examples folder in this package for more details.
- The Julia arrays returned by the
data,data_with_haloanddata_with_inhalomethods are in the expected Julia/Fortran column major order (i.e. the first dimension is fast). However, the tuples and arrays passed to the Devito Function, TimeFunction and SparseTimeFunction methods are given in Python/C row major order. This can cause some confusion at first. Consider the following example:
using Devito
g = Grid(shape=(10,11,12)) # 10 size of the slow dimension, and 12 is the size of the fast dimension.
f = Devito.Function(name="f", grid=g, space_order=8)
d = data(g) # size(d) is (12,11,10) where, as before, 10 is the size of the slow dimension, and 12 is the size of the fast dimensionIf this caused too much confusion, we can, in the future, intercept the shape argument and reverse the direction of the tuple.