Making a struct definition available on the cluster

question

#1

So I’m new to Julia - and I’ve been experimenting with the Distributed package - I wrote an example program to illustrate some of the concepts. Using remote channels, I can create primitive remote channel type, but how can I create a user-defined Remote Channel Type? For example, if I define a simple struct:

struct Ctrl
n::Int64
q::Bool
end

How can I make a remote Channel of type Channel{Ctrl}. When I attempt to do so, the struct reference isn’t defined in the worker procs.


#2

Define the struct everywhere according to

@everywhere struct Ctrl
    n::Int64
    q::Bool
end

This defines the struct on all workers that are running while the struct is defined, so start your workers before defining the struct like above.

PS: also, don’t forget to quote your code


#3

Thanks - I failed to realize that @everywhere was not a directive and rather required to be issued after the workers were created - duh!

Here’s the repo of the code if anyone’s interested: