[concurrency-interest] FJ usage question: Mutable procedures
David J. Biesack
David.Biesack at sas.com
Tue Aug 26 10:53:38 EDT 2008
Thanks, a raw RecursiveAction does the trick for me for now.
Note: there are two bugs in the examples http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/RecursiveAction.html
In the sumOfSquares example, the compute() method iterates while i < h :
for (int i = l; i < h; ++i) // perform leftmost base step
sum += array[i] * array[i];
Thus, the constructor call
Applyer a = new Applyer(array, 0, n-1, seqSize, null);
should not subtract one from n:
Applyer a = new Applyer(array, 0, n, seqSize, null);
Also, in Applyer in the javadoc
> Date: Tue, 26 Aug 2008 08:59:59 -0400
> From: Doug Lea <dl at cs.oswego.edu>
> CC: <concurrency-interest at cs.oswego.edu>
> David J. Biesack wrote:
> > ParallelDoubleArray has a summary() method; but it's not implemented in
> > terms of the public apply/Ops.DoubleProcedure API of
> > ParallelDoubleArray. I'd like to make that more general and define a
> > Ops.DoubleProcedure to compute extended summary statistics, or perform
> > other operations which require updating state within the ops/procedures.
> This is one of the basic tradeoffs made in ParallelArray:
> It knows how to translate fixed families of array operations
> into underlying fork/join processing. While we can and should
> keep adding to this family (as in supporting indexed procedures),
> there will always only be a finite set of functional/procedural
> forms that it understands.
> When you need to go beyond them, the best recourse is to
> step into the fun world of direct fork/join programming.
> Often, it is fairly straightforward, as in the examples
> (with more to come) in the RecursiveAction etc javadoc.
> ParallelArray includes a bunch of tweaks that improve
> performance over the basic templates (which it needs
> in part because it must act without any programmer
> supplied granularity information). The next update
> (real soon now) will include documented, exposed
> methods and classes that allow others to use them too,
> but most of these can be ignored in everyday programming.
David J. Biesack SAS Institute Inc.
(919) 531-7771 SAS Campus Drive
http://www.sas.com Cary, NC 27513
More information about the Concurrency-interest