Search in sources :

Example 71 with IJV

use of org.apache.sysml.runtime.matrix.data.IJV in project 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 72 with IJV

use of org.apache.sysml.runtime.matrix.data.IJV in project systemml by apache.

the class SpoofCellwise method executeCompressedNoAgg.

private long executeCompressedNoAgg(CompressedMatrixBlock a, SideInput[] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) {
    double[] c = (out.getDenseBlock() != null) ? out.getDenseBlockValues() : null;
    SparseBlock csblock = out.getSparseBlock();
    // whenever k/2 * BITMAP_BLOCK_SZ > m (i.e., it does not limit parallelism)
    if (out.isInSparseFormat() && rl % BitmapEncoder.BITMAP_BLOCK_SZ == 0 && ru % BitmapEncoder.BITMAP_BLOCK_SZ == 0) {
        int[] rnnz = a.countNonZerosPerRow(rl, ru);
        for (int i = rl; i < ru; i++) csblock.allocate(i, rnnz[i - rl]);
    }
    long lnnz = 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());
        if (out.isInSparseFormat()) {
            csblock.allocate(cell.getI());
            csblock.append(cell.getI(), cell.getJ(), val);
        } else
            c[cell.getI() * n + cell.getJ()] = val;
        lnnz += (val != 0) ? 1 : 0;
    }
    return lnnz;
}
Also used : IJV(org.apache.sysml.runtime.matrix.data.IJV) SparseBlock(org.apache.sysml.runtime.matrix.data.SparseBlock)

Example 73 with IJV

use of org.apache.sysml.runtime.matrix.data.IJV in project systemml by apache.

the class SpoofCellwise method executeCompressedColAggMxx.

private long executeCompressedColAggMxx(CompressedMatrixBlock a, SideInput[] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) {
    Arrays.fill(c, rl, ru, (_aggOp == AggOp.MIN) ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY);
    ValueFunction vfun = getAggFunction();
    long lnnz = 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());
        c[cell.getI()] = vfun.execute(c[cell.getI()], val);
    }
    for (int i = rl; i < ru; i++) lnnz += (c[i] != 0) ? 1 : 0;
    return lnnz;
}
Also used : ValueFunction(org.apache.sysml.runtime.functionobjects.ValueFunction) IJV(org.apache.sysml.runtime.matrix.data.IJV)

Example 74 with IJV

use of org.apache.sysml.runtime.matrix.data.IJV in project systemml by apache.

the class SpoofMultiAggregate method executeCompressed.

private void executeCompressed(CompressedMatrixBlock a, SideInput[] b, double[] scalars, double[] c, int m, int n, int rl, int ru) {
    // core compressed aggregation operation
    Iterator<IJV> iter = a.getIterator(rl, ru, true);
    while (iter.hasNext()) {
        IJV cell = iter.next();
        genexec(cell.getV(), b, scalars, c, m, n, cell.getI(), cell.getJ());
    }
}
Also used : IJV(org.apache.sysml.runtime.matrix.data.IJV)

Example 75 with IJV

use of org.apache.sysml.runtime.matrix.data.IJV in project systemml by apache.

the class SpoofOuterProduct method executeCellwiseCompressed.

private void executeCellwiseCompressed(CompressedMatrixBlock a, DenseBlock u, DenseBlock v, SideInput[] b, double[] scalars, MatrixBlock out, int m, int n, int k, OutProdType type, int rl, int ru, int cl, int cu) {
    // NOTE: we don't create sparse side inputs w/ row-major cursors because
    // compressed data is access in a column-major order
    double[] c = (out.getDenseBlock() != null) ? out.getDenseBlockValues() : null;
    SparseBlock csblock = out.getSparseBlock();
    Iterator<IJV> iter = a.getIterator(rl, ru, false);
    while (iter.hasNext()) {
        IJV cell = iter.next();
        double[] uvals = u.values(cell.getI());
        double[] vvals = v.values(cell.getJ());
        int uix = u.pos(cell.getI());
        int vix = v.pos(cell.getJ());
        if (type == OutProdType.CELLWISE_OUTER_PRODUCT) {
            if (out.isInSparseFormat()) {
                csblock.allocate(cell.getI());
                csblock.append(cell.getI(), cell.getJ(), genexecCellwise(cell.getV(), uvals, uix, vvals, vix, b, scalars, m, n, k, cell.getI(), cell.getJ()));
            } else {
                c[cell.getI() * n + cell.getJ()] = genexecCellwise(cell.getV(), uvals, uix, vvals, vix, b, scalars, m, n, k, cell.getI(), cell.getJ());
            }
        } else {
            c[0] += genexecCellwise(cell.getV(), uvals, uix, vvals, vix, b, scalars, m, n, k, cell.getI(), cell.getJ());
        }
    }
}
Also used : IJV(org.apache.sysml.runtime.matrix.data.IJV) SparseBlock(org.apache.sysml.runtime.matrix.data.SparseBlock)

Aggregations

IJV (org.apache.sysml.runtime.matrix.data.IJV)80 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)22 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)12 SparseBlock (org.apache.sysml.runtime.matrix.data.SparseBlock)11 BufferedWriter (java.io.BufferedWriter)10 OutputStreamWriter (java.io.OutputStreamWriter)10 FileSystem (org.apache.hadoop.fs.FileSystem)10 SequenceFile (org.apache.hadoop.io.SequenceFile)10 File (java.io.File)8 IOException (java.io.IOException)8 Path (org.apache.hadoop.fs.Path)8 JobConf (org.apache.hadoop.mapred.JobConf)8 MatrixCell (org.apache.sysml.runtime.matrix.data.MatrixCell)7 MatrixIndexes (org.apache.sysml.runtime.matrix.data.MatrixIndexes)7 ArrayList (java.util.ArrayList)6 Iterator (java.util.Iterator)6 KahanFunction (org.apache.sysml.runtime.functionobjects.KahanFunction)6 ValueFunction (org.apache.sysml.runtime.functionobjects.ValueFunction)6 KahanObject (org.apache.sysml.runtime.instructions.cp.KahanObject)6 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)6