Is it possible to define custom shared type for multiprocessing?

I have a type looking like

struct TBModel

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.

1 Like