MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: ProgressIndicator in ParallelTable problem, redux

  • To: mathgroup at
  • Subject: [mg131772] Re: ProgressIndicator in ParallelTable problem, redux
  • From: Szabolcs HorvÃt <szhorvat at>
  • Date: Wed, 2 Oct 2013 05:53:36 -0400 (EDT)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • References: <l2e7rs$ff5$>

Not exactly an answer to your question, but you'll find some discussion 
of similar issues here:

The reason why your example doesn't work with parallel calculations is 
that the front end (which renders the UI elements) only communicates 
with the main kernel to do dynamic updating.  It does not have a 
connection to the parallel kernels (subkernels).  I do not know if it is 
possible to connect it directly to the subkernels.  It can definitely 
talk to more than one main kernel.

If not, you're stuck with shared variable approaches (with all the 
performance implications).

On 2013-10-1 6:23 , psycho_dad wrote:
> Hi all,
> I have the following problem with ProgressIndicator and ParallelTable. Assume we have a function f (see below for a simple toy model) that performs a "long" calculation and carries its own ProgressIndicator to show how far it has progressed. It works OK if I run it once or in a Table (it runs serially of course), but if I run it inside a ParallelTable with N Kernels, the N progress bars remain "dead", while the calculation goes on OK.
> To be more clear, what I want is to run the function f[] in Parallel with N Kernels, with each instance having its own progress bar updating dynamically. So, there should be N progress bars updating dynamically as the calculations go on.
> In my real code f[] is too complicated but roughly it does a MCMC (plus some other stuff), so each instance would correspond to a different chain.
> The toy model f[] is shown below and it just sums numbers k^2 from 0 to "end" (+ a time-delay):
> f[end_] := DynamicModule[{n},(
>     n = 0;
>     Print[ProgressIndicator[Dynamic[n],{0,end}]];
>     Sum[Pause[.15];n=k;(k^2),{k,0,end,1}])]
> For example, the following gives the result along with a dynamic progress bar:
> f[10]
> ... while this runs f[10] 5 times serially (in the real case this would produce 5 different MCMC chains):
> Table[f[10],{j,1,5}]//AbsoluteTiming
> Now the parallel case:
> LaunchKernels[5];
> DistributeDefinitions[f];
> ParallelTable[f[10],{j,1,5},DistributedContexts:>Automatic]//AbsoluteTiming
> If you run the last part you will notice that while it returns the expected result (roughly 5 times as fast), the progress bars don't update as they should. Any idea how to fix this?
> This is not an issue of sharing the variables between Kernels with SetSharedVariable, like in
> as obviously each instance should have its own version. BTW, the latter is a slightly related question I had asked some time ago, hence the redux in the title.
> Thanks for any help in advance!
> Cheers

  • Prev by Date: Re: Output display by slide
  • Next by Date: Error in slope and intercept
  • Previous by thread: ProgressIndicator in ParallelTable problem, redux
  • Next by thread: Re: ProgressIndicator in ParallelTable problem, redux