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:
problem with parallel matlab

Subject: problem with parallel matlab

From: MICHAEL

Date: 19 May, 2010 14:36:04

Message: 1 of 4

for i=1:size(APLocation,1)
    point=APLocation(i,:);
    parfor j=1:length (RXpoint)
        rssi(i,j) = LOSS(point,RXpoint(:,j)'); %%rssi having the signal strength from all AP's
    end
end

when i'm running the following code, i get the same value for each element of rssi (serially i get different results)


where is my problem?

Subject: problem with parallel matlab

From: Jeremy Greenwald

Date: 19 May, 2010 14:55:10

Message: 2 of 4

Creating some fake data and and implementing a simple LOSS function, I do
not see a different between the serial and parallel execution. Does LOSS
use any persistent or global variables?



function [ rssi rssi2 ] = foo



APLocation = rand(10);

RXpoint = rand(10) * 5;



for i=1:size(APLocation,1)

    point=APLocation(i,:);

    parfor j=1:length (RXpoint)

        rssi(i,j) = LOSS(point,RXpoint(:,j)');

    end

end



for i=1:size(APLocation,1)

    point=APLocation(i,:);

    for j=1:length (RXpoint)

        rssi2(i,j) = LOSS(point,RXpoint(:,j)');

    end

end



end



function rv = LOSS( a,b )

rv = sum( a+b );

end


"michael" <bezenchu@gmail.com> wrote in message
news:ht0t0k$fce$1@fred.mathworks.com...
> for i=1:size(APLocation,1)
> point=APLocation(i,:);
> parfor j=1:length (RXpoint)
> rssi(i,j) = LOSS(point,RXpoint(:,j)'); %%rssi having the signal
> strength from all AP's
> end
> end
>
> when i'm running the following code, i get the same value for each element
> of rssi (serially i get different results)
>
>
> where is my problem?
>

Subject: problem with parallel matlab

From: MICHAEL

Date: 19 May, 2010 15:09:05

Message: 3 of 4

yes

LOSS uses some global variables but they doesn't change in LOSS.
they have constant value and i use them only to simplify my program.

"Jeremy Greenwald" <jgreenwa@mathworks.com> wrote in message <ht0u4f$d5$1@fred.mathworks.com>...
> Creating some fake data and and implementing a simple LOSS function, I do
> not see a different between the serial and parallel execution. Does LOSS
> use any persistent or global variables?
>
>
>
> function [ rssi rssi2 ] = foo
>
>
>
> APLocation = rand(10);
>
> RXpoint = rand(10) * 5;
>
>
>
> for i=1:size(APLocation,1)
>
> point=APLocation(i,:);
>
> parfor j=1:length (RXpoint)
>
> rssi(i,j) = LOSS(point,RXpoint(:,j)');
>
> end
>
> end
>
>
>
> for i=1:size(APLocation,1)
>
> point=APLocation(i,:);
>
> for j=1:length (RXpoint)
>
> rssi2(i,j) = LOSS(point,RXpoint(:,j)');
>
> end
>
> end
>
>
>
> end
>
>
>
> function rv = LOSS( a,b )
>
> rv = sum( a+b );
>
> end
>
>
> "michael" <bezenchu@gmail.com> wrote in message
> news:ht0t0k$fce$1@fred.mathworks.com...
> > for i=1:size(APLocation,1)
> > point=APLocation(i,:);
> > parfor j=1:length (RXpoint)
> > rssi(i,j) = LOSS(point,RXpoint(:,j)'); %%rssi having the signal
> > strength from all AP's
> > end
> > end
> >
> > when i'm running the following code, i get the same value for each element
> > of rssi (serially i get different results)
> >
> >
> > where is my problem?
> >
>

Subject: problem with parallel matlab

From: Jeremy Greenwald

Date: 19 May, 2010 17:06:01

Message: 4 of 4

It may be that the global variables used by LOSS are not initialized on the
workers. Can you verify that the values of the global variables are set on
the workers?
"michael" <bezenchu@gmail.com> wrote in message
news:ht0uuh$p08$1@fred.mathworks.com...
> yes
>
> LOSS uses some global variables but they doesn't change in LOSS.
> they have constant value and i use them only to simplify my program.
>
> "Jeremy Greenwald" <jgreenwa@mathworks.com> wrote in message
> <ht0u4f$d5$1@fred.mathworks.com>...
>> Creating some fake data and and implementing a simple LOSS function, I do
>> not see a different between the serial and parallel execution. Does LOSS
>> use any persistent or global variables?
>>
>>
>>
>> function [ rssi rssi2 ] = foo
>>
>>
>>
>> APLocation = rand(10);
>>
>> RXpoint = rand(10) * 5;
>>
>>
>>
>> for i=1:size(APLocation,1)
>>
>> point=APLocation(i,:);
>>
>> parfor j=1:length (RXpoint)
>>
>> rssi(i,j) = LOSS(point,RXpoint(:,j)');
>>
>> end
>>
>> end
>>
>>
>>
>> for i=1:size(APLocation,1)
>>
>> point=APLocation(i,:);
>>
>> for j=1:length (RXpoint)
>>
>> rssi2(i,j) = LOSS(point,RXpoint(:,j)');
>>
>> end
>>
>> end
>>
>>
>>
>> end
>>
>>
>>
>> function rv = LOSS( a,b )
>>
>> rv = sum( a+b );
>>
>> end
>>
>>
>> "michael" <bezenchu@gmail.com> wrote in message
>> news:ht0t0k$fce$1@fred.mathworks.com...
>> > for i=1:size(APLocation,1)
>> > point=APLocation(i,:);
>> > parfor j=1:length (RXpoint)
>> > rssi(i,j) = LOSS(point,RXpoint(:,j)'); %%rssi having the signal
>> > strength from all AP's
>> > end
>> > end
>> >
>> > when i'm running the following code, i get the same value for each
>> > element of rssi (serially i get different results)
>> >
>> >
>> > where is my problem?
>> >
>>
>

Tags for 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