Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9665 > unrolled thread
| Started by | Themis Matsoukas <tmatsoukas@me.com> |
|---|---|
| First post | 2012-04-16 10:11 +0000 |
| Last post | 2012-04-16 10:11 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Accessing results in ParallelDo Themis Matsoukas <tmatsoukas@me.com> - 2012-04-16 10:11 +0000
| From | Themis Matsoukas <tmatsoukas@me.com> |
|---|---|
| Date | 2012-04-16 10:11 +0000 |
| Subject | Accessing results in ParallelDo |
| Message-ID | <jmgr98$plo$1@smc.vnet.net> |
I have been experimenting with parallel computing on Mathematica 8 on a two core MacBook Pro but I can't figure how to access to the results calculated in ParallelDo. Here is a a simple loop that builds a list b by appending random numbers. This runs fine and prints list b as it is generated in each of the two kernels. However, when I ask for b at the end of the loop I get b={}.
ClearAll["Global`*"];
CloseKernels[];
LaunchKernels[];
NoP = 4;
b = {};
ParallelDo[
b = Append[b, RandomInteger[{1, NoP}]];
Print["b = ", b],
{i, 1, 4}
];
Print["Final result: b=", b]
b = {4} <---kernel 2 (my annotation)
b = {3} <---kernel 1
b = {4,2} <---kernel 2
b = {3,3} <---kernel 1
Final result: b={}
My question is, how do I pass the results of ParallelDo into a variable outside the loop?
Thanks
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web