Preallocating large matrices in all cores is slower than allocating every time

As I demonstrated in my first comment, it wasn’t working the way you expected. Distributed.jl tries to send the globals like matrices to remote workers, if the globals are mentioned in @distributed body. The function getmatrices is a way to workaround this problem; i.e., it let us not mention the globals in @distributed.

It’s hard to tell what went wrong without an MWE.

See also: Please read: make it easier to help you

1 Like