Search in sources :

Example 1 with KahanFunction

use of org.apache.sysml.runtime.functionobjects.KahanFunction in project incubator-systemml by apache.

the class SpoofCellwise method executeDenseAggSum.

private double executeDenseAggSum(double[] 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);
    for (int i = rl, ix = rl * n; i < ru; i++) 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));
    }
    return kbuff._sum;
}
Also used : KahanFunction(org.apache.sysml.runtime.functionobjects.KahanFunction) KahanObject(org.apache.sysml.runtime.instructions.cp.KahanObject)

Example 2 with KahanFunction

use of org.apache.sysml.runtime.functionobjects.KahanFunction 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 3 with KahanFunction

use of org.apache.sysml.runtime.functionobjects.KahanFunction in project incubator-systemml by apache.

the class SpoofCellwise method executeDenseAggSum.

private double executeDenseAggSum(DenseBlock a, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) {
    KahanFunction kplus = (KahanFunction) getAggFunction();
    KahanObject kbuff = new KahanObject(0, 0);
    if (a == null && !sparseSafe) {
        for (int i = rl; i < ru; i++) for (int j = 0; j < n; j++) kplus.execute2(kbuff, genexec(0, b, scalars, m, n, i, j));
    } else if (a != null) {
        for (int i = rl; i < ru; i++) {
            double[] avals = a.values(i);
            int aix = a.pos(i);
            for (int j = 0; j < n; j++) {
                double aval = avals[aix + j];
                if (aval != 0 || !sparseSafe)
                    kplus.execute2(kbuff, genexec(aval, b, scalars, m, n, i, j));
            }
        }
    }
    return kbuff._sum;
}
Also used : KahanFunction(org.apache.sysml.runtime.functionobjects.KahanFunction) KahanObject(org.apache.sysml.runtime.instructions.cp.KahanObject)

Example 4 with KahanFunction

use of org.apache.sysml.runtime.functionobjects.KahanFunction in project incubator-systemml by apache.

the class SpoofCellwise method executeCompressedColAggSum.

private long executeCompressedColAggSum(CompressedMatrixBlock a, SideInput[] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) {
    KahanFunction kplus = (KahanFunction) getAggFunction();
    KahanObject kbuff = new KahanObject(0, 0);
    double[] corr = new double[n];
    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());
        kbuff.set(c[cell.getJ()], corr[cell.getJ()]);
        kplus.execute2(kbuff, val);
        c[cell.getJ()] = kbuff._sum;
        corr[cell.getJ()] = kbuff._correction;
    }
    return -1;
}
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 5 with KahanFunction

use of org.apache.sysml.runtime.functionobjects.KahanFunction in project incubator-systemml by apache.

the class SpoofCellwise method executeDenseRowAggSum.

private long executeDenseRowAggSum(DenseBlock a, SideInput[] b, double[] scalars, DenseBlock c, int m, int n, boolean sparseSafe, int rl, int ru) {
    // note: output always single block
    double[] lc = c.valuesAt(0);
    KahanFunction kplus = (KahanFunction) getAggFunction();
    KahanObject kbuff = new KahanObject(0, 0);
    long lnnz = 0;
    if (a == null && !sparseSafe) {
        for (int i = rl; i < ru; i++) {
            kbuff.set(0, 0);
            for (int j = 0; j < n; j++) kplus.execute2(kbuff, genexec(0, b, scalars, m, n, i, j));
            lnnz += ((lc[i] = kbuff._sum) != 0) ? 1 : 0;
        }
    } else if (a != null) {
        for (int i = rl; i < ru; i++) {
            kbuff.set(0, 0);
            double[] avals = a.values(i);
            int aix = a.pos(i);
            for (int j = 0; j < n; j++) {
                double aval = avals[aix + j];
                if (aval != 0 || !sparseSafe)
                    kplus.execute2(kbuff, genexec(aval, b, scalars, m, n, i, j));
            }
            lnnz += ((lc[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)

Aggregations

KahanFunction (org.apache.sysml.runtime.functionobjects.KahanFunction)32 KahanObject (org.apache.sysml.runtime.instructions.cp.KahanObject)28 KahanPlus (org.apache.sysml.runtime.functionobjects.KahanPlus)10 ValueFunction (org.apache.sysml.runtime.functionobjects.ValueFunction)10 ArrayList (java.util.ArrayList)6 ExecutorService (java.util.concurrent.ExecutorService)6 Future (java.util.concurrent.Future)6 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)6 IJV (org.apache.sysml.runtime.matrix.data.IJV)6 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)6 CompressedMatrixBlock (org.apache.sysml.runtime.compress.CompressedMatrixBlock)4 Builtin (org.apache.sysml.runtime.functionobjects.Builtin)4 KahanPlusSq (org.apache.sysml.runtime.functionobjects.KahanPlusSq)4 ReduceAll (org.apache.sysml.runtime.functionobjects.ReduceAll)4 ReduceCol (org.apache.sysml.runtime.functionobjects.ReduceCol)4 IOException (java.io.IOException)2 ColGroup (org.apache.sysml.runtime.compress.ColGroup)2 ColGroupValue (org.apache.sysml.runtime.compress.ColGroupValue)2 Timing (org.apache.sysml.runtime.controlprogram.parfor.stat.Timing)2 BuiltinCode (org.apache.sysml.runtime.functionobjects.Builtin.BuiltinCode)2