I am wondering what the best approach is to distribute arrays that are part of a struct with MPI.
Example of such a struct (partly):
@get_units @with_kw struct SBM{T,N,M}
Δt::T | "s"
maxlayers::Int | "-"
n::Int | "-"
nlayers::Vector{Int} | "-"
n_unsatlayers::Vector{Int} | "-"
riverfrac::Vector{T} | "-"
θₛ::Vector{T} | "-"
θᵣ::Vector{T} | "-"
...
An instance of this struct is updated each time step with:
function update(sbm::SBM)
for i = 1:sbm.n
...
I understand that with MPI.Send
and MPI.Recv
arrays can be distributed, and this is faster than passing a struct (requires serialization).
What would be a good approach here, to distribute arrays that are part of a struct, without the use of serialization?
Do I need to initialize the struct on all ranks then? I guess normally you would initialize (and for example read parameter values from files) on the root rank and then distribute.
Or would it better to use Distributed.jl in this case?