Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: parfor, can not be classified help
Posted:
Jun 28, 2012 9:19 AM
|
|
"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
|
|
|
|