SharedArray with mixed types of elements? Alternative functions?

Hi Julia users,

I am doing parallel computation using @distributed. The returned results will be a multi-dimensional array with mixed types of elements, such as Int64, Float64 and Spring. I was trying to use SharedArray{Any}(...) but Any doesn’t work here.

Any function works similarly to SharedArray?

Thanks a lot.

I highly recommend using multithreading instead if it’s all on the same computer. Every array is “like” a shared array if you’re using multithreading (all threads can read/write, but just like a SharedArray beware of race conditions).

1 Like

Also, using a multidimensional Array with eltype Any strongly suggests that you should take a step back and consider using something like a vector of structs or something that better expresses your computation. The result of doing so will likely be a program that executes much more quickly. I think that rather than focusing on how to distribute do_one it is probably a really good idea to first post what do_one does (or a simplified version).

3 Likes