November 2017
Beginner
316 pages
6h 40m
English
Alright, we all know by now that we can run loops in Julia pretty easily using the for and end blocks. However, the loops are what we run to compute the data sequentially and not asynchronously. To solve this situation, Julia provides a handy macro named @parallel, which takes in an expression, which is, in turn, a for loop. To see how it works compared with the normal for loops, take a look at the following code snippet:
# running on a single process, i.e when workers are just 1. julia> workers() 1-element Array{Int64,1}: 1 # simple for loop, works perfectly julia> for i in 1:5 println(i) end 1 2 3 4 5 # parallel for loop running on sigle worker doesn't give a # synchronised output julia> @parallel for i in 1:5 ...Read now
Unlock full access