Certainly the error message could be more useful. If it is possible to detect that the argument is an iterator then @parallel could do the collect itself though.
On Friday, August 21, 2015 at 6:19:24 AM UTC+10, John Brock wrote: > > This seems issue-worthy if the most recent nightly have the same problem. > It looks like Enumerate supports the length property, so the underlying > code for @parallel should be able to check the length of the enumerator and > figure out how many jobs to assign to each worker. > > And regardless of whether it makes sense for @parallel to support > enumerate, that error message is pretty opaque -- it doesn't make it > obvious to the programmer that parallel doesn't support enumerate, which is > a pretty natural thing to try. > > On Thursday, August 20, 2015 at 3:44:49 AM UTC-7, [email protected] wrote: >> >> >> >> On Thursday, August 20, 2015 at 4:50:49 AM UTC+10, Ismael VC wrote: >>> >>> Well that works but it's indeed odd, can you open a new issue for this? >>> >> >> Not really odd, @parallel needs to divide the set of values between >> multiple processes, so it needs the whole set of values. >> >> >>> >>> El miércoles, 19 de agosto de 2015, 13:48:28 (UTC-5), Ismael VC escribió: >>>> >>>> Enumerate is an iterator, you need to collect the items first: >>>> >>>> julia> @parallel for i in collect(enumerate(list)) >>>> println(i) >>>> end >>>> >>>> julia> From worker 2: (1,"a") >>>> From worker 2: (2,"b") >>>> From worker 3: (3,"c") >>>> >>>> >>>> El miércoles, 19 de agosto de 2015, 12:17:35 (UTC-5), Nils Gudat >>>> escribió: >>>>> >>>>> I just rewrote one of my parallel loops and was surprised by this: >>>>> >>>>> > list = ["a", "b", "c"] >>>>> >>>>> > for i in enumerate(list) >>>>> > println(i) >>>>> > end >>>>> >>>>> (1,"a") >>>>> (2,"b") >>>>> (3,"c") >>>>> >>>>> > addprocs(2) >>>>> >>>>> > @sync @parallel for i in enumerate(list) >>>>> > println(i) >>>>> > end >>>>> >>>>> ERROR: `getindex` has no method matching >>>>> getindex(::Enumerate{Array{ASCIIString,1}}, ::UnitRange{Int64}) >>>>> >>>>> Am I doing something wrong here? Is this expected behaviour? >>>>> >>>>
