Thread Subject: output to command window during parfor loop

Subject: output to command window during parfor loop

From: Andrew

Date: 17 Jun, 2009 16:53:02

Message: 1 of 3

I am writing a basic parfor loop which consists of outputting to the screen using disp(). The general structure of my code is as follows:

matlabpool open local 4
parfor loop = 1:n
    disp(sprintf('Processing data module #%.0f out of #%.0f', loop, n));
    doDataProcessing(loop);
end
matlabpool close

I am having a problem where the messages created by disp() do not get outputted to the command window during the execution of the parfor loop. Instead, all the disp messages are outputted all at once after the parfor loop completes or if I stop execution midway. Is there a command I can use to flush out the buffered output text or force the text from the worker to the client so that the client can display it while the parfor loop is running?

Thanks

Subject: output to command window during parfor loop

From: Edric M Ellis

Date: 18 Jun, 2009 07:09:20

Message: 2 of 3

"Andrew " <wang@arlut.utexas.edu> writes:

> I am writing a basic parfor loop which consists of outputting to the screen
> using disp(). The general structure of my code is as follows:
>
> matlabpool open local 4
> parfor loop = 1:n
> disp(sprintf('Processing data module #%.0f out of #%.0f', loop, n));
> doDataProcessing(loop);
> end
> matlabpool close
>
> I am having a problem where the messages created by disp() do not get
> outputted to the command window during the execution of the parfor
> loop. Instead, all the disp messages are outputted all at once after the
> parfor loop completes or if I stop execution midway.

Hi,

We enhanced the PARFOR output in R2008b to print the output progressively, so if
you can upgrade to that release (or R2009a), things should work as you expect.

Cheers,

Edric.

Subject: output to command window during parfor loop

From: Mason Freed

Date: 29 Jun, 2009 23:22:02

Message: 3 of 3

Edric M Ellis <eellis@mathworks.com> wrote in message <ytwr5xinhlr.fsf@uk-eellis-deb4-64.mathworks.co.uk>...
> "Andrew " <wang@arlut.utexas.edu> writes:
>
> > I am writing a basic parfor loop which consists of outputting to the screen
> > using disp(). The general structure of my code is as follows:
> >
> > matlabpool open local 4
> > parfor loop = 1:n
> > disp(sprintf('Processing data module #%.0f out of #%.0f', loop, n));
> > doDataProcessing(loop);
> > end
> > matlabpool close
> >
> > I am having a problem where the messages created by disp() do not get
> > outputted to the command window during the execution of the parfor
> > loop. Instead, all the disp messages are outputted all at once after the
> > parfor loop completes or if I stop execution midway.
>
> Hi,
>
> We enhanced the PARFOR output in R2008b to print the output progressively, so if
> you can upgrade to that release (or R2009a), things should work as you expect.

Hello,

It seems that the output displays only after a carriage return is displayed. I.e. fprintf('foo'); doesn't display anything until all iterations are complete. But fprintf('foo\n'); does display. Is there any way to get around that limitation?

Also, is there ANY way to display a GUI progress indicator? As far as I can tell, it is impossible to update any kind of UI object from within the parfor loop, which means the user just has to sit and wait without any visual indication of progress. Is that correct? Any way to get around this limitation?

Thanks,
Mason

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
parfor Daniele 4 Sep, 2009 06:14:41
display Mason Freed 29 Jun, 2009 19:24:08
parfor Mason Freed 29 Jun, 2009 19:24:08
disp Andrew 17 Jun, 2009 13:55:44
output Andrew 17 Jun, 2009 13:55:40
parfor Andrew 17 Jun, 2009 13:55:35
rssFeed for this Thread

Contact us at files@mathworks.com