# Why can't I parallelize this code

I have a simple routine (I thought it was simple), that I cannot parallize. It goes like this

Clear[ParallelSow, Arep, Brep, xrep];
SetSharedFunction[ParallelSow];
ParallelSow[expr_] := Sow[expr];

Data = Reap[ParallelDo[
Arep = (-1 + 2 RandomInteger[]) Exp[-14 RandomReal[] ];
Brep = (-1 + 2 RandomInteger[]) Exp[-14 RandomReal[] ];
xrep = (-1 + 2 RandomInteger[]) Exp[-14 RandomReal[] ];
cosmo = {A + B, B - A} /. {A -> Arep, B -> Brep, x -> xrep};
If[Brep^2 + 4 Arep < 0, Continue[]];
If[! (-1 <= (1/2)*(Brep + Sqrt[Brep^2 + 4*Arep]) <=
1 || -1 <= (1/2)*(Brep - Sqrt[Brep^2 + 4*Arep]) <= 1),
Continue[], , Print["Error 1"]];
If[0.943 < cosmo[] < 0.981 && cosmo[] < 0.15,
ParallelSow[{Arep, Brep, xrep, cosmo}]
, Null, Print["Error 2"]]
, 100000]][][]


And in the end I get a

ParallelDo::nopar1: <<1>> cannot be parallelized; proceeding with sequential evaluation. >>


Where <<1>> refers to the expression above.

I looked into the documentation and googled it. I have no idea what is in my code I cannot parallelize...

• Please show a complete minimal example. Look at sscce.org for guidance. – Szabolcs Oct 13 '16 at 11:36
• Done, sorry about that. – romanovzky Oct 13 '16 at 11:42

The syntax for ParallelDo is incorrect for your version of Mathematica. There should be an error message that makes this clear:
Use ParallelDo[..., {n}] instead of ParallelDo[..., n]
• I don't like this new syntax that omits the {...}, it causes ambiguities which lead to misunderstandings. If I had reliable WiFi, I'd link to the question, but right now my network barely works. – Szabolcs Oct 13 '16 at 11:48