What's the most effective function in julia to do a task inside a loop?

Good day everyone,

basically I have this:

@sync @parallel for i in 1:100;
     V[i] = i
end

And I really have no problems at all. I'm working with julia 0.6.4 and I've noticed that the function @parallel doesn't exist in the new releases. So my question is: there's a more efficient way to run in parallel that simple task? maybe in other versions of Julia. The function @distributed does the same?

Thanks.

Upvotes: 1

Views: 95

Answers (1)

mbauman
mbauman

Reputation: 31342

If you're updating code from 0.6 to 1.0, step through 0.7 first. It's literally exactly the same as 1.0, but with friendly warnings that tell you how to update your code! And yes, in this case, it'll tell you to use @distributed instead of @parallel and to load the Distributed standard library.

julia> @sync @parallel for i in 1:100;
            V[i] = i
       end
WARNING: Base.@parallel is deprecated: it has been moved to the standard library package `Distributed`.
Add `using Distributed` to your imports.
 in module Main
┌ Warning: `@parallel` is deprecated, use `@distributed` instead.
│   caller = eval(::Module, ::Any) at boot.jl:319
└ @ Core ./boot.jl:319

This was simply a rename, and a rename for a good reason: there are many forms of parallelism and the "most effective" form of parallelism for you will depend upon what task you're doing (in particular its runtime and IO) and the hardware you have available.

Upvotes: 1

Related Questions