Is it possible to define custom shared type for multiprocessing?

#1

I have a type looking like

struct TBModel
    norbits::Int64
    lat::SMatrix{3,3,Float64,9}
    hoppings::Dict{SVector{3,Int64},Matrix{Float64}}
    overlaps::Dict{SVector{3,Int64},Matrix{Float64}}
    positions::Dict{SVector{3,Int64},SVector{3,Matrix{Float64}}}
end

Generally, a TBModel is huge (~4GB). My program initiates a TBModel and then calculate related quantities by multiprocessing.

Since the size of TBModel is large, I would like to avoid the situation where each process has its own copy of the instance. Since I only need to read (rather than write) a TBModel from the child processes, is it possible to share the data across all the processes just like SharedArray?

I am aware of multithreading functionality. However, many packages that I use are not thread-safe yet and I want to avoid such kind of pitfalls.

0 Likes