First steps into parallel computing!

You should start with the Threads.@threads macro, this is most like your last example, but it does it automatically:

Threads.@threads for i in 1:length(angle)
    Results[i, 1] = angle[i]*pi\180
    Results[i, 2] = cos(angle[i])
    Results[i, 3] = sin(angle[i])
    ... Etc
end

Threads is your first go-to when you have a single computer with multiple cores and want to loop over a large number of items in parallel (as the above example), it is the easiest to use when you already have a for loop and there are no race conditions.

You can use the Distributed.jl package to do the same thing with multiple processes, but this has a higher communication overhead as the multiple processes do not share memory.

For a more detailed look at multi threading - Multi-threading Julia Docs

1 Like