Bazman
Bazman

Reputation: 2150

Differences between error handling between parallel tool box and regular matlab

On a recent post I was told that there are differences between the way parallel toolbox handles warnings and the way regular matlab deoes it. I felt that poster hand gone someway to answering my question so I marked it as answered. But I still have some additional questions (hope this doesn't contitute double posting).

Error only triggers when I don't use parfor?

I just wondered if someone can explain to me what these differences are? Also what is meant by parfor being sandboxed?

Is it still possible to use try catch type structures with the parallel tool box or using some other mechanism to chain the same thing?

To be clear when I run using parfor warning messages are still produced telling me the matix is illconditioned but it doesn't seem to be being picked up as an error despite me adding the lines

warnState(1) = warning('error', 'MATLAB:singularMatrix'); 
warnState(2) = warning('error', 'MATLAB:illConditionedMatrix'); 

However, when I run using a regular for loop it is picked up as an error.

So the parallel tool box is producing the warnings correctly its just not translating them into errors via the code above so they can be used in a try catch structure.

Kind Regards

Hugh

Upvotes: 1

Views: 445

Answers (1)

Edric
Edric

Reputation: 25140

I think the problem in your original code is that you changed the warnings to errors on the MATLAB client only. To make that change on the workers, you need to do

spmd
    warnState(1) = warning('error', 'MATLAB:singularMatrix'); 
    warnState(2) = warning('error', 'MATLAB:illConditionedMatrix'); 
end

There's also the pctRunOnAll function to run things everywhere.

Also, I don't know what the OP meant about matlabpool workers being 'sandboxed'. The differences between your MATLAB client and the workers are:

  1. The workers always run in single threaded mode; and
  2. The workers run with no display (although they can produce off-screen graphics and save to file)

Upvotes: 2

Related Questions