Hello,
I try to use reap and sow to accumulated values during a calculation. It is recommended because it is said to be faster than AppenTo. However, I would like to utilize all my cpu cores by using parallelsubmit on various reap expressions with nested for and sow. It seems that this does not work properly. Please take a look at the following example:
end = 5
Reap[
For[t = 0, t < end, t++,
Sow[t]
]
]
WaitAll[%]
returns: {Null, {{0, 1, 2, 3, 4}}} -> Good
end = 5
ParallelSubmit[
Reap[
For[t = 0, t < end, t++,
Sow[t]
]
]
]
WaitAll[%]
returns: {Null, {}} -> Bad
However, if I replace the end variable with its value like so:
ParallelSubmit[
Reap[
For[t = 0, t < 5, t++,
Sow[t]
]
]
]
WaitAll[%]
returns: {Null, {{0, 1, 2, 3, 4}}} -> Good
Why is that?