Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: X10 2.4
-
Component/s: XRX Runtime
-
Labels:None
-
Number of attachments :
Description
It would be really slick to define DistArray's reduce function as shown below:
public final def reduce[U](op:(U,T)=>U, unit:U):U {
val reducer = new Reducible[U,T]() {
public def zero():U = unit;
public operator this(a:U,b:T):U = op(a,b);
};
val result = finish(reducer) {
for (where in dist.places()) {
async at (where) {
var localRes:U = unit;
val imc = raw();
for ([i] in 0..(imc.length()-1)) {
localRes = op(localRes, imc(i));
}
offer(localRes);
};
}
};
return result;
}
Unfortunately we only have Reducible[U], not Reducible[U,T].
Would be really nice to extend Reducible (and the CF runtime) to support (T,U)=>U reductions.
For now, I have to revert to the less scalable version that doesn't exploit collecting finish ![]()
actually, the code block doesn't quite work as written, but there's a minor variation on it that uses CF to do the local reduction as well that would work nicely.