[#16518 changed this to an unimplemented feature.]
Trying to do a reduction on an instantiation of a reduction class results in a compiler segfault:
class PlusMinusReduceOp: ReduceScanOp {
type eltType;
var sum = true;
var value: eltType;
proc identity {
return 0: eltType;
}
proc accumulate(elm) {
if sum then value += elm;
else value -= elm;
}
proc accumulateOntoState(ref state, elm) {
if sum then state += elm;
else state -= elm;
}
proc combine(other: borrowed PlusMinusReduceOp) {
if sum then value += other.value;
else value -= other.value;
}
proc generate() return value;
proc clone() return new unmanaged PlusMinusReduceOp(eltType=eltType);
}
config const doSum = true;
var A = [1000, 200, 30, 4];
var plusMinus = new unmanaged PlusMinusReduceOp(eltType=int, sum=doSum);
var sum: int;
// forall reduce with instantiation works
forall elm in A with (plusMinus reduce sum) do
sum reduce= elm;
writeln(sum);
// Op reduce with type works (but you can't specify sum=<val>)
sum = PlusMinusReduceOp reduce A;
writeln(sum);
// Op reduce with instantiation segfaults
sum = plusMinus reduce A;
writeln(sum);
delete plusMinus;
[#16518 changed this to an unimplemented feature.]
Trying to do a reduction on an instantiation of a reduction class results in a compiler segfault:
Test:
test/reductions/sungeun/count.chpl