use of org.apache.sysml.runtime.instructions.cp.KahanObject in project incubator-systemml by apache.
the class SpoofCellwise method executeDenseRowAggSum.
private long executeDenseRowAggSum(double[] a, SideInput[] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) throws DMLRuntimeException {
KahanFunction kplus = (KahanFunction) getAggFunction();
KahanObject kbuff = new KahanObject(0, 0);
long lnnz = 0;
for (int i = rl, ix = rl * n; i < ru; i++) {
kbuff.set(0, 0);
for (int j = 0; j < n; j++, ix++) {
double aval = (a != null) ? a[ix] : 0;
if (aval != 0 || !sparseSafe)
kplus.execute2(kbuff, genexec(aval, b, scalars, m, n, i, j));
}
lnnz += ((c[i] = kbuff._sum) != 0) ? 1 : 0;
}
return lnnz;
}
use of org.apache.sysml.runtime.instructions.cp.KahanObject in project incubator-systemml by apache.
the class SpoofCellwise method executeCompressedAggSum.
private double executeCompressedAggSum(CompressedMatrixBlock a, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) throws DMLRuntimeException {
KahanFunction kplus = (KahanFunction) getAggFunction();
KahanObject kbuff = new KahanObject(0, 0);
Iterator<IJV> iter = a.getIterator(rl, ru, !sparseSafe);
while (iter.hasNext()) {
IJV cell = iter.next();
double val = genexec(cell.getV(), b, scalars, m, n, cell.getI(), cell.getJ());
kplus.execute2(kbuff, val);
}
return kbuff._sum;
}
use of org.apache.sysml.runtime.instructions.cp.KahanObject in project incubator-systemml by apache.
the class ColGroupDDC1 method computeRowSums.
@Override
protected void computeRowSums(MatrixBlock result, KahanFunction kplus, int rl, int ru) {
KahanObject kbuff = new KahanObject(0, 0);
KahanPlus kplus2 = KahanPlus.getKahanPlusFnObject();
double[] c = result.getDenseBlock();
//pre-aggregate nnz per value tuple
double[] vals = sumAllValues(kplus, kbuff, false);
//for correctness in case of sqk+)
for (int i = rl; i < ru; i++) {
kbuff.set(c[2 * i], c[2 * i + 1]);
kplus2.execute2(kbuff, vals[_data[i] & 0xFF]);
c[2 * i] = kbuff._sum;
c[2 * i + 1] = kbuff._correction;
}
}
use of org.apache.sysml.runtime.instructions.cp.KahanObject in project incubator-systemml by apache.
the class ColGroupDDC2 method computeRowSums.
@Override
protected void computeRowSums(MatrixBlock result, KahanFunction kplus, int rl, int ru) {
KahanObject kbuff = new KahanObject(0, 0);
KahanPlus kplus2 = KahanPlus.getKahanPlusFnObject();
double[] c = result.getDenseBlock();
//pre-aggregate nnz per value tuple
double[] vals = sumAllValues(kplus, kbuff, false);
//for correctness in case of sqk+)
for (int i = rl; i < ru; i++) {
kbuff.set(c[2 * i], c[2 * i + 1]);
kplus2.execute2(kbuff, vals[_data[i]]);
c[2 * i] = kbuff._sum;
c[2 * i + 1] = kbuff._correction;
}
}
use of org.apache.sysml.runtime.instructions.cp.KahanObject in project incubator-systemml by apache.
the class ColGroupDDC2 method computeSum.
@Override
protected void computeSum(MatrixBlock result, KahanFunction kplus) {
final int ncol = getNumCols();
final int numVals = getNumValues();
if (numVals < MAX_TMP_VALS) {
//iterative over codes and count per code
int[] counts = getCounts();
//post-scaling of pre-aggregate with distinct values
KahanObject kbuff = new KahanObject(result.quickGetValue(0, 0), result.quickGetValue(0, 1));
for (int k = 0, valOff = 0; k < numVals; k++, valOff += ncol) {
int cntk = counts[k];
for (int j = 0; j < ncol; j++) kplus.execute3(kbuff, _values[valOff + j], cntk);
}
result.quickSetValue(0, 0, kbuff._sum);
result.quickSetValue(0, 1, kbuff._correction);
} else //general case
{
super.computeSum(result, kplus);
}
}
Aggregations