Skip to content

Importing SharedArrays module work without @everywhere? #37060

@trathi05

Description

@trathi05

I expected that we need @everywhere macro before importing SharedArrays module, i.e., @everywhere using SharedArrays, but the code below seems to be working perfectly fine with or without @everywhere.
Secondly, I also expected that the variable y below needs to be defined @everywhere, i.e.,@everywhere y=5 for it to be recognized by all processes, but it worked fine without it.

using Distributed
addprocs(4)
using SharedArrays #I expected that we need @everywhere using SharedArrays

x = SharedArray{Int}(10)
y = 5 #this is available to all processes even without adding @everywhere macro
@distributed for i = 1:10
    x[i] = i + y
end

Note: If I append @everywhere in the above two cases, the code still works fine.
I am not sure if this is a bug, but I expected the approach without @everywhere to throw an error. Is it because SharedArrays.jl is in stdlib? I suppose we should have more consistent way of importing ShareadArrays module or declaring a variable in this case?

I am using Julia version 1.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    parallelismParallel or distributed computation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions