Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9665

Accessing results in ParallelDo

From Themis Matsoukas <tmatsoukas@me.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Accessing results in ParallelDo
Date 2012-04-16 10:11 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jmgr98$plo$1@smc.vnet.net> (permalink)

Show all headers | View raw


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 comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Accessing results in ParallelDo Themis Matsoukas <tmatsoukas@me.com> - 2012-04-16 10:11 +0000

csiph-web