{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/10773","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/10773/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/10773/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/10773/events","html_url":"https://github.com/JuliaLang/julia/issues/10773","id":67173418,"number":10773,"title":"Unexpected behaviour of `SharedArray` in single core usage","user":{"login":"nilshg","id":7264491,"avatar_url":"https://avatars.githubusercontent.com/u/7264491?v=3","gravatar_id":"","url":"https://api.github.com/users/nilshg","html_url":"https://github.com/nilshg","followers_url":"https://api.github.com/users/nilshg/followers","following_url":"https://api.github.com/users/nilshg/following{/other_user}","gists_url":"https://api.github.com/users/nilshg/gists{/gist_id}","starred_url":"https://api.github.com/users/nilshg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilshg/subscriptions","organizations_url":"https://api.github.com/users/nilshg/orgs","repos_url":"https://api.github.com/users/nilshg/repos","events_url":"https://api.github.com/users/nilshg/events{/privacy}","received_events_url":"https://api.github.com/users/nilshg/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/parallel","name":"parallel","color":"f7e102"},{"url":"https://api.github.com/repos/JuliaLang/julia/labels/windows","name":"windows","color":"0b02e1"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-08T16:56:29Z","updated_at":"2015-04-14T13:16:52Z","closed_at":null,"body":"See this [discussion in the Julia users group](https://groups.google.com/forum/#!topic/julia-users/jnPbCbbcD6Q):\r\n\r\nWhen running a `@sync @parallel` loop which writes its results into different `SharedArray`s on just one core, some of the returned arrays will contain information of other arrays being assigned to. This does not happen when the code is run on mutiple cores. I'm copying my original example from the users group below; in this example the return array `r2` will contain the results of `r3`, while the three arrays calculated in parallel contain the expected results:\r\n\r\n````\r\nx1 = linspace(1, 3, 3)\r\nx2 = linspace(1, 3, 3)\r\nx3 = linspace(1, 3, 3)\r\n\r\nfunction getresults(x1::Array, x2::Array, x3::Array)\r\n  result1 = SharedArray(Float64, (3,3,3))\r\n  result2 = similar(result1)\r\n  result3 = similar(result1)\r\n\r\n  @sync @parallel for a=1:3\r\n    for b=1:3\r\n      for c=1:3\r\n        result1[a,b,c] = x1[a]*x2[b]*x3[c]\r\n        result2[a,b,c] = sqrt(x1[a]*x2[b]*x3[c])\r\n        result3[a,b,c] = (x1[a]*x2[b]*x3[c])^2\r\n      end\r\n    end\r\n  end\r\n  return sdata(result1), sdata(result2), sdata(result3)\r\nend\r\n\r\n# Compute function using 1 core\r\n(r1,r2,r3) = getresults(x1, x2, x3)\r\n\r\n# Add remaining cores as workers, compute again\r\nnprocs()==CPU_CORES || addprocs(CPU_CORES-1)\r\n(r1_par,r2_par,r3_par) = getresults(x1, x2, x3)\r\n````"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/92821680","html_url":"https://github.com/JuliaLang/julia/issues/10773#issuecomment-92821680","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/10773","id":92821680,"user":{"login":"tkelman","id":5934628,"avatar_url":"https://avatars.githubusercontent.com/u/5934628?v=3","gravatar_id":"","url":"https://api.github.com/users/tkelman","html_url":"https://github.com/tkelman","followers_url":"https://api.github.com/users/tkelman/followers","following_url":"https://api.github.com/users/tkelman/following{/other_user}","gists_url":"https://api.github.com/users/tkelman/gists{/gist_id}","starred_url":"https://api.github.com/users/tkelman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkelman/subscriptions","organizations_url":"https://api.github.com/users/tkelman/orgs","repos_url":"https://api.github.com/users/tkelman/repos","events_url":"https://api.github.com/users/tkelman/events{/privacy}","received_events_url":"https://api.github.com/users/tkelman/received_events","type":"User","site_admin":false},"created_at":"2015-04-14T13:16:52Z","updated_at":"2015-04-14T13:16:52Z","body":"Thanks Tracy. Would be helpful if someone who has a Windows machine and a bit of time can try tracking down the OS API calls that underlie the SharedArray operations and figure out more precisely what causes this."}}