From: Fahim Chandurwala on 18 Jul 2010 20:44 Greetings: I am trying to convert a normal for loop into a parfor loop. The problem I have is that two of the global variables that are declared outside the parfor loop are, however, set in the parfor loop. Is there a way around this problem? How is it that global variable can be set in for loop and not in parfor? Heres the concept program with the gory details removed: global a, b; n=10 parfor ii=1:n [a,b]=some_function(x,y); end
From: neil on 19 Jul 2010 00:24 "Fahim Chandurwala" <fchandur(a)gmail.com> wrote in message <i2074k$eog$1(a)fred.mathworks.com>... > Greetings: > I am trying to convert a normal for loop into a parfor loop. The problem I have is that two of the global variables that are declared outside the parfor loop are, however, set in the parfor loop. Is there a way around this problem? > How is it that global variable can be set in for loop and not in parfor? > Heres the concept program with the gory details removed: > global a, b; > n=10 > parfor ii=1:n > [a,b]=some_function(x,y); > end You can access globals but not create them in parfor loops. your function some_function, if using globals will create them in the body of the function. http://www.mathworks.com/access/helpdesk/help/toolbox/distcomp/bq__cs7-1.html http://blogs.mathworks.com/loren/2009/10/02/using-parfor-loops-getting-up-and-running/ I'm pretty sure globals in parfor loops is a bad idea. since it will be difficult to control what the value of the global is when. I would stay away from it if I was you.
|
Pages: 1 Prev: Knot vector by averaging technique Next: Question about nonlinear programming fmincon |