Tag Info

New answers tagged

1

I just cleaned up your code a little, added a Print command and lowered the maximum value of the iterators: ParallelDo[ a = Table[i + j, {i, 1.0, 100.0}, {j, 1.0, 100.0}]; Do[b = a.a; Print["Kernel ", $KernelID, ", iterator1 ", iterator1, ", iterator2 ", iterator2]; c = If[Tr[b] > 2000, b = a, Break[]], {iterator1, 1, 2} ], ...


2

As I commented earlier, with a notebook configured as in your question, I obtain your first answer with MMA V10 and your second answer with MMA V9. Evidently, Wolfram Inc identified the V9 behavior as a problem and fixed it in V10. Since the problem occurs for ToExpression run in ParallelTable, perhaps ToExpression[ParallelTable["b" <> ToString[j], ...


1

This isn't a perfect solution either, but it's an improvement on your solution 2: Use ParallelSubmit and WaitNext for parallelization. Documentation is here and here. With this method it is not necessary to collect all results to the main kernel first, and export them only afterwards. You'll be able to collect one result, save it, collect the next, save ...


3

Aisamu's solution is clean, and is what I'd recommend for a bigger project or if you do this a lot. But for a quick and dirty solution, the following works well: Parallelize[{expr1, expr2, expr4, ...}] expr1, expr2, etc. will be evaluated on separate kernels. Demonstration: Parallelize[{$KernelID, $KernelID, $KernelID}] (* {4, 3, 2} *)


4

As Yves said replace Print with List output. Here is an example using Sow and Reap along with Block and Mathematica 10 notation for Composition. (It would be better to avoid Print from the beginning but I am trying to make this an easy substitution for you.) myfun[x_, y_: 0] := Block[{ans, myplot, summary, Print = Sow@*Row@*List}, Print["The first ...


7

It's straightforward for simple cases! Just as @Yves Klett commented: f[a_, b_: 1] := (Pause[.3]; a + b) (* List of arguments to be passed for each job *) jobs = {{0}, {1}, {0, 3}, {2, 2}} Map[f @@ # &, jobs] // AbsoluteTiming (* {1.205, {1,2,3,4}} *) ParallelMap[f @@ # &, jobs] // AbsoluteTiming (* {0.309, {1,2,3,4}} *)



Top 50 recent answers are included