On Wednesday 04 December 2013 14:07:15 Brad Chamberlain wrote: > Hi Peter -- > > I agree with Michael's comments. To understand your results better, I > wanted to ask how you are controlling running on one core vs. two cores.
Brad, I used --dataParTasksPerLocale=1 to force single thread and otherwise observed two active threads (as expected). > On Wed, 4 Dec 2013, Michael Ferguson wrote: ... > > Second, your forall loop does not compute the same number ... > > There is a race condition. > > The problem is that the forall loop runs the iterations > > in some number of tasks, so that it is likely that at some point > > the updates to sum happen in two threads at once. The visible effect > > would be that you'd "lose updates" since you'd see something Michael, Thanks, being really new to Chapel I guess I for a moment thought that the atomic property for sum would be dynamically done for me, heh. Attempting to fix this I went looking for an example forall with proper syncronization. The first one I found was: http://chapel.cray.com/tutorials.html -> http://faculty.knox.edu/dbunde/teaching/chapel/ -> 2.1. Forall and Coforall -> var sum : int = 0; forall i in 1..1000000 { sum += i; } writeln(sum); Which by the looks of it contains the same mistake I did... Reading the Forall part of the otherwise great "Productive Programming in Chapel: a Next-Generation Language for General, Locality-Aware Parallelism, University of Bergen Tutorial, April 10th, 2013." (also from http://chapel.cray.com/tutorials.html) didn't yield any clues or references to atomic or sync variables. I proceeded to read the language spec that came with my 1.8.0 chapel and found information on sync variables and modified my forall to: config const N = 10; var sum$ : sync real = 0.0; forall i in 1..N by -1 do sum$ += 1.0/(i*i); writeln(sqrt(sum$*6)); For completeness this took the execution time for the forall example to 190s/130s (default/--fast). /Peter -- -= Peter Kjellström -= National Supercomputer Centre
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ Sponsored by Intel(R) XDK Develop, test and display web and hybrid apps with a single code base. Download it for free now! http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________ Chapel-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/chapel-users
