Parfor not printing

I am running a small script with parfort. The script starts with the following line:

parfor i=1:length(vX) fprintf('%d/%d\n',i,length(X)); ... 

Therefore, apparently, I should immediately print printouts. When I start it with a pool of two workers opened by matlabpool(2) , I see a printout of no . When I close the workers while keeping the parfor loop, I see printouts, but only when I press ctrl-c. When I change parfor to regular for , I see the result. Note that I never saw the loop work to the end, as it is quite long, but the printout is the second line of the script and should happen immediately if there is no buffering problem that I do not know about in matlab. What's happening?

+4
source share
2 answers

I suspect the delay is due to the overhead of setting up a parfor loop.

In my experience, it may take several to 15 seconds to initialize a loop. This is especially true when the code in my loop uses variables with large memory footprints, since the variables must be copied for workers.

Copying data between employees is carried out over the network, and the main monitor of network activity should show this activity. It will be useful for me to determine how much of my parfor comes to initializing the workers.

I use fprintf all the time in my parfor loops; however, I try to be creative about the generated output, since loop iterations are not sequential.

If all you need is a progress indicator: http://www.mathworks.com/matlabcentral/fileexchange/32101-progress-monitor-progress-bar-that-works-with-parfor

+3
source

I had the same problem, and for several months I tried to find a solution. But in the end, I just resorted to using

 disp(['text ',num2str(variable)); 
0
source

All Articles