Search in sources :

Example 6 with KahanObject

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;
}
Also used : KahanFunction(org.apache.sysml.runtime.functionobjects.KahanFunction) KahanObject(org.apache.sysml.runtime.instructions.cp.KahanObject)

Example 7 with KahanObject

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;
}
Also used : IJV(org.apache.sysml.runtime.matrix.data.IJV) KahanFunction(org.apache.sysml.runtime.functionobjects.KahanFunction) KahanObject(org.apache.sysml.runtime.instructions.cp.KahanObject)

Example 8 with KahanObject

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;
    }
}
Also used : KahanObject(org.apache.sysml.runtime.instructions.cp.KahanObject) KahanPlus(org.apache.sysml.runtime.functionobjects.KahanPlus)

Example 9 with KahanObject

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;
    }
}
Also used : KahanObject(org.apache.sysml.runtime.instructions.cp.KahanObject) KahanPlus(org.apache.sysml.runtime.functionobjects.KahanPlus)

Example 10 with KahanObject

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);
    }
}
Also used : KahanObject(org.apache.sysml.runtime.instructions.cp.KahanObject)

Aggregations

KahanObject (org.apache.sysml.runtime.instructions.cp.KahanObject)54 KahanPlus (org.apache.sysml.runtime.functionobjects.KahanPlus)25 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)15 KahanFunction (org.apache.sysml.runtime.functionobjects.KahanFunction)10 CM_COV_Object (org.apache.sysml.runtime.instructions.cp.CM_COV_Object)8 Builtin (org.apache.sysml.runtime.functionobjects.Builtin)7 CM (org.apache.sysml.runtime.functionobjects.CM)7 CMOperator (org.apache.sysml.runtime.matrix.operators.CMOperator)6 IOException (java.io.IOException)5 ReduceAll (org.apache.sysml.runtime.functionobjects.ReduceAll)5 WeightedCell (org.apache.sysml.runtime.matrix.data.WeightedCell)4 AggregateOperator (org.apache.sysml.runtime.matrix.operators.AggregateOperator)4 KahanPlusSq (org.apache.sysml.runtime.functionobjects.KahanPlusSq)3 ReduceCol (org.apache.sysml.runtime.functionobjects.ReduceCol)3 ValueFunction (org.apache.sysml.runtime.functionobjects.ValueFunction)3 ArrayList (java.util.ArrayList)2 ExecutorService (java.util.concurrent.ExecutorService)2 Future (java.util.concurrent.Future)2 Mean (org.apache.sysml.runtime.functionobjects.Mean)2 ReduceDiag (org.apache.sysml.runtime.functionobjects.ReduceDiag)2