Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: parfor, can not be classified help
Replies: 7   Last Post: Jun 28, 2012 9:19 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,531
Registered: 12/7/04
Re: parfor, can not be classified help
Posted: Jun 28, 2012 9:19 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"PRIYANGA " <p.priyanga19@gmail.com> wrote in message
news:jsgr13$981$1@newscl01ah.mathworks.com...
> "Paul Matthews" wrote in message <io21gc$isj$1@fred.mathworks.com>...
>> Hi,
>> I'm new to the Parallel Computing toolbox and am having trouble
>> converting some of my code to be compliant to support variable
>> classification within my 'parfor' loop. Could someone help explain what
>> is wrong with this simplified example?
>>
>> Pop(40,10) = zeros;
>> [pop_size, pop_cols] = size(Pop);
>>
>> parfor a = 1 : pop_size
>> Child = rand(1,pop_cols);
>> Pop(a, :) = Child();
>> Pop(a, pop_cols) = inf; %This line causes Pop not to be able to be
>> classified
>> end


http://www.mathworks.com/help/toolbox/distcomp/brdqtjj-1.html#bq_of7_-1

Is Pop the loop variable? No, that's a.
Is Pop a sliced variable? Does it satisfy the four requirements given on
that page? It does not, so it is not a sliced variable. In particular it
fails the "Fixed Index Listing" requirement; in one place you index into it
with a and : and in another you index into it with a and pop_cols.
Similarly Pop is not a broadcast, reduction, or temporary variable.

You can do what you want by modifying the temporary Child variable
(replacing its last element with Inf) and then deleting the third line
inside the PARFOR. That should cause Pop to satisfy the four requirements
for a sliced variable.

parfor a = 1 : pop_size
Child = rand(1,pop_cols);
Child(end) = Inf;
Pop(a, :) = Child();
end

Note I haven't tested this, but I believe it should work.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.