Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Confusing spmd error

Subject: Confusing spmd error

From: Chuck37

Date: 9 Jan, 2013 03:49:15

Message: 1 of 5

I have a function that is giving me an error when called within spmd but I can't repeat it outside. e.g:

x = <something>;
spmd
 if labindex == 1
  y = <something>
  z = function(x,y);
 end
end

Gives me an error inside the function, but when I try to debug like this:

z = function(x,y{1})

It runs through just fine. This makes debugging very difficult. Anyone have any idea of what would cause it not to run exactly the same way in each case?

The error is nothing parallel related by the way, it's actually a singular matrix warning.

Subject: Confusing spmd error

From: Edric M Ellis

Date: 9 Jan, 2013 09:04:28

Message: 2 of 5

"Chuck37 " <chuck3737@yahooremovethis.com> writes:

> I have a function that is giving me an error when called within spmd
> but I can't repeat it outside. e.g:
>
> x = <something>;
> spmd
> if labindex == 1
> y = <something>
> z = function(x,y);
> end
> end
>
> Gives me an error inside the function, but when I try to debug like this:
>
> z = function(x,y{1})
>
> It runs through just fine. This makes debugging very difficult.
> Anyone have any idea of what would cause it not to run exactly the
> same way in each case?
>
> The error is nothing parallel related by the way, it's actually a
> singular matrix warning.

Hmm, that's very strange. Do you still get the warning if you simply do

x = <something>;
y = <something>;
z = function(x,y);

How about if you do

matlabpool open 1
spmd
  x = <something>;
  y = <something>;
  z = function(x,y);
end

matlabpool close
spmd
  x = <something>;
  y = <something>;
  z = function(x,y);
end

One other thing that has an outside chance of making a difference is
that matlabpool workers are run in single computational thread mode,
which means some algorithms will work slightly differently. You could
try launching your desktop matlab with the "-singleCompThread" switch to
see if that makes any difference.

Cheers,

Edric.

Subject: Confusing spmd error

From: Chuck37

Date: 9 Jan, 2013 14:59:08

Message: 3 of 5

Thanks, I'll give these idea a shot. It'll take a little doing since things are actually a little more complex than the example below.

From my print statement debugging so far, it appears that inside the function a structure is copied and somehow some of the values simply don't copy and have NaNs in their place. This is only the case inside spmd. I'll post back if I figure something out.

Edric M Ellis <eellis@mathworks.com> wrote in message <ytw6236zq03.fsf@uk-eellis0l.dhcp.mathworks.com>...
> "Chuck37 " <chuck3737@yahooremovethis.com> writes:
>
> > I have a function that is giving me an error when called within spmd
> > but I can't repeat it outside. e.g:
> >
> > x = <something>;
> > spmd
> > if labindex == 1
> > y = <something>
> > z = function(x,y);
> > end
> > end
> >
> > Gives me an error inside the function, but when I try to debug like this:
> >
> > z = function(x,y{1})
> >
> > It runs through just fine. This makes debugging very difficult.
> > Anyone have any idea of what would cause it not to run exactly the
> > same way in each case?
> >
> > The error is nothing parallel related by the way, it's actually a
> > singular matrix warning.
>
> Hmm, that's very strange. Do you still get the warning if you simply do
>
> x = <something>;
> y = <something>;
> z = function(x,y);
>
> How about if you do
>
> matlabpool open 1
> spmd
> x = <something>;
> y = <something>;
> z = function(x,y);
> end
>
> matlabpool close
> spmd
> x = <something>;
> y = <something>;
> z = function(x,y);
> end
>
> One other thing that has an outside chance of making a difference is
> that matlabpool workers are run in single computational thread mode,
> which means some algorithms will work slightly differently. You could
> try launching your desktop matlab with the "-singleCompThread" switch to
> see if that makes any difference.
>
> Cheers,
>
> Edric.

Subject: Confusing spmd error

From: Chuck37

Date: 9 Jan, 2013 17:34:07

Message: 4 of 5

I feel pretty stupid, but I was able to finally observe similar behavior outside SPMD. It seems that somehow the warnings are different inside and outside, so even though stuff was acting the same, the warnings were not displayed in the client.

Is there any way to debug on a worker? I thought maybe the interactive parallel mode would allow it, but it doesn't seem to be the case, or at least I couldn't figure it out.

Edric M Ellis <eellis@mathworks.com> wrote in message <ytw6236zq03.fsf@uk-eellis0l.dhcp.mathworks.com>...
> "Chuck37 " <chuck3737@yahooremovethis.com> writes:
>
> > I have a function that is giving me an error when called within spmd
> > but I can't repeat it outside. e.g:
> >
> > x = <something>;
> > spmd
> > if labindex == 1
> > y = <something>
> > z = function(x,y);
> > end
> > end
> >
> > Gives me an error inside the function, but when I try to debug like this:
> >
> > z = function(x,y{1})
> >
> > It runs through just fine. This makes debugging very difficult.
> > Anyone have any idea of what would cause it not to run exactly the
> > same way in each case?
> >
> > The error is nothing parallel related by the way, it's actually a
> > singular matrix warning.
>
> Hmm, that's very strange. Do you still get the warning if you simply do
>
> x = <something>;
> y = <something>;
> z = function(x,y);
>
> How about if you do
>
> matlabpool open 1
> spmd
> x = <something>;
> y = <something>;
> z = function(x,y);
> end
>
> matlabpool close
> spmd
> x = <something>;
> y = <something>;
> z = function(x,y);
> end
>
> One other thing that has an outside chance of making a difference is
> that matlabpool workers are run in single computational thread mode,
> which means some algorithms will work slightly differently. You could
> try launching your desktop matlab with the "-singleCompThread" switch to
> see if that makes any difference.
>
> Cheers,
>
> Edric.

Subject: Confusing spmd error

From: Edric M Ellis

Date: 10 Jan, 2013 09:18:48

Message: 5 of 5

"Chuck37 " <chuck3737@yahooremovethis.com> writes:

> Is there any way to debug on a worker? I thought maybe the
> interactive parallel mode would allow it, but it doesn't seem to be
> the case, or at least I couldn't figure it out.

I'm afraid not - the best bet is either to work out how to reproduce it
on the desktop, or use fprintf.

Cheers,

Edric.

Tags for this Thread

No tags are associated with this thread.

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.

Contact us