Using SharedArray with structs


#1

I wanted to use @distributed for and SharedArray{MyStruct,1}. However, I get the error:

ArgumentError("type of SharedArray elements must be bits types, got Modia.Instantiation.Instance")

Is there any other way of returning structs from distributed for or other parallelization mechanisms?


#2

Seems to be expecting primitive types.
My quick-and-dirty fix would be to make 1 array per field of your struct then map the constructor to the resulting matrices.

map(MyStruct, array1, array2, ..., arrayN)
# alternative
pmap(MyStruct, array1, array2, ..., arrayN)

Then again this is just a silly hack without knowing any of your particular needs.
As a disclaimer I’m still learning julia, but solving these kind of problems is a great way to improve.