Posts

Julia @distributed: subsequent code run before all workers finish

Image
1 I have been headbutting on a wall for a few days around this code: using Distributed using SharedArrays # Dimension size M=10; N=100; z_ijw = zeros(Float64,M,N,M) z_ijw_tmp = SharedArrayFloat64(M*M*N) i2s = CartesianIndices(z_ijw) @distributed for iall=1:(M*M*N) # get index i=i2s[iall][1] j=i2s[iall][2] w=i2s[iall][3] # Assign function value z_ijw_tmp[iall]=sqrt(i+j+w) # Any random function would do end # Print the last element of the array println(z_ijw_tmp[end]) println(z_ijw_tmp[end]) println(z_ijw_tmp[end]) The first printed out number is always 0, the second number is either 0 or 10.95... (sqrt of 120, which is correct). The 3rd is either 0 or 10.95 (if the 2nd is 0) So it appears that the print code (@mainthread?) is allowed to run before all the workers finish. Is there anyway for the print code to run properly the first time (without a wait command) Without multiple println, I thought it was a problem with scope and spend a few days reading about it @.@ ...

Grim Reaper (Billy & Mandy) vs. Him (Powerpuff Girls)

Image
Wiki Characters Creators Teams Volumes Issues Publishers Locations Concepts Things Story Arcs Movies Series Episodes New Comics Forums Gen. Discussion Bug Reporting Delete/Combine Pages Artist Show-Off Off-Topic Contests Battles Fan-Fic RPG Comic Book Preview API Developers Editing & Tools Podcast Quests Community Top Users Activity Feed User Lists Community Promos Archives News Reviews Videos Podcasts Previews Login / Sign Up All Wiki     Arcs     Characters     Companies     Concepts     Issues     Locations     Movies     People     Teams     Things     Volumes     Series     Episodes Editorial     Videos     Ar...