Is ParallelMap and Parallelize@Map expected to work with Sow and Reap construct.
This is a rather brief toy code to find all Primes just to force the use of Sow/Reap inside Map
Reap[Map[ If[PrimeQ@#, Sow@#] &, Range[10] ]][[2]] and the output is, as expected
{{2, 3, 5, 7}} But when I do
Reap[Parallelize@Map[ If[PrimeQ@#, Sow@#] &, Range[1000] ]][[2]] I got the output
{} And the same was the output when I ran
Reap[ ParallelMap[ If[PrimeQ@#, Sow@#] &, Range[10] ] ][[2]] 2 questions :
1) How is this explainable ?
2) If this is the case, how do I efficiently I spawn parallel jobs which accumulate something ?