# Make Struct available on all workers

**URL:** <https://discourse.julialang.org/t/make-struct-available-on-all-workers/49869>\
**Category:** General Usage\
**Tags:** question, parallel, distributed\
**Created:** [November 9, 2020, 9:19pm UTC](https://discourse.julialang.org/t/make-struct-available-on-all-workers/49869 "2020-11-09T21:19:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![oskar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oskar/32/12494_2.png) [@oskar](https://discourse.julialang.org/u/oskar)\
**Post date:** [November 9, 2020, 9:19pm UTC](https://discourse.julialang.org/t/make-struct-available-on-all-workers/49869/1 "2020-11-09T21:19:05Z")

</div>

I am using `Distributed.jl` and `DistributedArrays.jl` to write code that runs in parallel and I want to make a certain struct available to all processes, because they all need to (only) read from it several times every time I call a function remotely.

I.e. I have

```julia
using DistributedArrays
struct A
    [...]
end
struct B
    [...]
end
struct MyType
    a::A
    Db::DArray{B,1,Array{B,1}}
end
function f(a::A, Db::DArray{B,1,Array{B,1}})
    do_something_to_b(a, Db[:L])
end
a = A([...]); b1 = B([...]); b2 = B([...])
M = MyType(a, distribute([b1,b2]))
for i in 1:N
    SPMD.spmd(f, M.a, M.Db, pids=workers())
end

```

This way it works, however, I suppose that `a` is copied to all the workers `N` times, instead of just once.  
How can I make it more efficient?
