I suspect MATLAB is classifying x2 as a reduction variable. However, the documentation notes:
"The classification rules for variables, including reduction variables, are purely syntactic. They cannot determine whether the f you have supplied is truly associative or not. Associativity is assumed, but if you violate this, different executions of the loop might result in different answers." http://www.mathworks.com/help/distcomp/advanced-topics.html On Thursday, March 6, 2014 7:45:40 AM UTC-6, Billou Bielour wrote: > > Matlab's parfor will probably work on the case above, I don't know exactly > how they do it, but it's pretty smart usually. > > x2 = []; > n = 10; > parfor i = 1:n > x2 = [x2, i]; > end > x2 > > I have to say the Julia doc is not super clear, it says: > > "Notice that the reduction operator can be omitted if it is not needed. > However, this code will not initialize all of a, since each process will > have a separate copy if it. Parallel for loops like these must be avoided. > Fortunately, distributed arrays can be used to get around this limitation, > as we will see in the next section." > > But it doesn't really comes back to this example in the distributed array > section. > > On Wednesday, March 5, 2014 9:17:45 PM UTC+1, Jake Bolewski wrote: >> >> Hi Jason, >> >> I don't really understand what you are trying to do but the problem is >> that the array a is not read-only in this context. >> From the manual: Using “outside” variables in parallel loops is >> perfectly reasonable if the variables are read-only. >> >> See the parallel section of the manual: >> http://julia.readthedocs.org/en/latest/manual/parallel-computing/ >> >> The way you are using a is not amenable to parallelization as you have a >> clear data dependency for each iteration. >> >> Best, >> Jake >> >> On Wednesday, March 5, 2014 2:51:11 PM UTC-5, Jason Solack wrote: >>> >>> i'm sorry, yes i did! >>> >>> On Wednesday, March 5, 2014 2:49:11 PM UTC-5, Jake Bolewski wrote: >>>> >>>> Is j = 1000000 a typo (did you mean 1:1000000)? >>>> >>>> >>>> On Wednesday, March 5, 2014 2:41:51 PM UTC-5, Jason Solack wrote: >>>>> >>>>> i'm trying to check out how Julia handles parallel for loops and i'm >>>>> getting some errors >>>>> >>>>> i'm not sure if it's because i'm working with a single array and i >>>>> can't append to this in parallel, so i thought i'd ask >>>>> >>>>> nprocs() >>>>> addprocs(6) >>>>> >>>>> tic() >>>>> onPass = 1 >>>>> a = Array(Int64, 0) >>>>> @parallel for i = 1:100000, j=10000 >>>>> a = [a, i*j] >>>>> onPass = onPass + 1 >>>>> if onPass % 10000 == 0 >>>>> println("on pass ", onPass) >>>>> end >>>>> end >>>>> toc() >>>>> >>>>> is this not possible in parallel? >>>>> >>>>> Thank you again for all your answers! >>>>> >>>>> jason >>>>> >>>>
