Search in sources :

Example 46 with ExecType

use of org.apache.sysml.lops.LopProperties.ExecType in project incubator-systemml by apache.

the class IndexingOp method optFindExecType.

@Override
protected ExecType optFindExecType() {
    checkAndSetForcedPlatform();
    ExecType REMOTE = OptimizerUtils.isSparkExecutionMode() ? ExecType.SPARK : ExecType.MR;
    if (_etypeForced != null) {
        _etype = _etypeForced;
    } else {
        if (OptimizerUtils.isMemoryBasedOptLevel()) {
            _etype = findExecTypeByMemEstimate();
        } else if (getInput().get(0).areDimsBelowThreshold()) {
            _etype = ExecType.CP;
        } else {
            _etype = REMOTE;
        }
        // check for valid CP dimensions and matrix size
        checkAndSetInvalidCPDimsAndSize();
    }
    // mark for recompile (forever)
    setRequiresRecompileIfNecessary();
    return _etype;
}
Also used : ExecType(org.apache.sysml.lops.LopProperties.ExecType)

Example 47 with ExecType

use of org.apache.sysml.lops.LopProperties.ExecType in project incubator-systemml by apache.

the class LeftIndexingOp method optFindExecType.

@Override
protected ExecType optFindExecType() {
    checkAndSetForcedPlatform();
    ExecType REMOTE = OptimizerUtils.isSparkExecutionMode() ? ExecType.SPARK : ExecType.MR;
    if (_etypeForced != null) {
        _etype = _etypeForced;
    } else {
        if (OptimizerUtils.isMemoryBasedOptLevel()) {
            _etype = findExecTypeByMemEstimate();
            checkAndModifyRecompilationStatus();
        } else if (getInput().get(0).areDimsBelowThreshold()) {
            _etype = ExecType.CP;
        } else {
            _etype = REMOTE;
        }
        // check for valid CP dimensions and matrix size
        checkAndSetInvalidCPDimsAndSize();
    }
    // mark for recompile (forever)
    setRequiresRecompileIfNecessary();
    return _etype;
}
Also used : ExecType(org.apache.sysml.lops.LopProperties.ExecType)

Example 48 with ExecType

use of org.apache.sysml.lops.LopProperties.ExecType in project incubator-systemml by apache.

the class LeftIndexingOp method constructLops.

@Override
public Lop constructLops() {
    // return already created lops
    if (getLops() != null)
        return getLops();
    try {
        ExecType et = optFindExecType();
        if (et == ExecType.MR) {
            // the right matrix is reindexed
            Lop top = getInput().get(2).constructLops();
            Lop bottom = getInput().get(3).constructLops();
            Lop left = getInput().get(4).constructLops();
            Lop right = getInput().get(5).constructLops();
            // right hand matrix
            Lop nrow = new UnaryCP(getInput().get(0).constructLops(), OperationTypes.NROW, DataType.SCALAR, ValueType.INT);
            Lop ncol = new UnaryCP(getInput().get(0).constructLops(), OperationTypes.NCOL, DataType.SCALAR, ValueType.INT);
            Lop rightInput = null;
            if (isRightHandSideScalar()) {
                // insert cast to matrix if necessary (for reuse MR runtime)
                rightInput = new UnaryCP(getInput().get(1).constructLops(), OperationTypes.CAST_AS_MATRIX, DataType.MATRIX, ValueType.DOUBLE);
                rightInput.getOutputParameters().setDimensions(1L, 1L, ConfigurationManager.getBlocksize(), ConfigurationManager.getBlocksize(), -1L);
            } else
                rightInput = getInput().get(1).constructLops();
            RightIndex reindex = new RightIndex(rightInput, top, bottom, left, right, nrow, ncol, getDataType(), getValueType(), et, true);
            reindex.getOutputParameters().setDimensions(getInput().get(0).getDim1(), getInput().get(0).getDim2(), getRowsInBlock(), getColsInBlock(), getNnz());
            setLineNumbers(reindex);
            Group group1 = new Group(reindex, Group.OperationTypes.Sort, DataType.MATRIX, getValueType());
            group1.getOutputParameters().setDimensions(getInput().get(0).getDim1(), getInput().get(0).getDim2(), getRowsInBlock(), getColsInBlock(), getNnz());
            setLineNumbers(group1);
            // the left matrix is zeroed out
            ZeroOut zeroout = new ZeroOut(getInput().get(0).constructLops(), top, bottom, left, right, getInput().get(0).getDim1(), getInput().get(0).getDim2(), getDataType(), getValueType(), et);
            zeroout.getOutputParameters().setDimensions(getInput().get(0).getDim1(), getInput().get(0).getDim2(), getRowsInBlock(), getColsInBlock(), getNnz());
            setLineNumbers(zeroout);
            Group group2 = new Group(zeroout, Group.OperationTypes.Sort, DataType.MATRIX, getValueType());
            group2.getOutputParameters().setDimensions(getInput().get(0).getDim1(), getInput().get(0).getDim2(), getRowsInBlock(), getColsInBlock(), getNnz());
            setLineNumbers(group2);
            Binary binary = new Binary(group1, group2, HopsOpOp2LopsB.get(Hop.OpOp2.PLUS), getDataType(), getValueType(), et);
            binary.getOutputParameters().setDimensions(getInput().get(0).getDim1(), getInput().get(0).getDim2(), getRowsInBlock(), getColsInBlock(), getNnz());
            setLineNumbers(binary);
            setLops(binary);
        } else if (et == ExecType.SPARK) {
            Hop left = getInput().get(0);
            Hop right = getInput().get(1);
            LeftIndexingMethod method = getOptMethodLeftIndexingMethod(left.getDim1(), left.getDim2(), left.getRowsInBlock(), left.getColsInBlock(), left.getNnz(), right.getDim1(), right.getDim2(), right.getNnz(), right.getDataType());
            // insert cast to matrix if necessary (for reuse broadcast runtime)
            Lop rightInput = right.constructLops();
            if (isRightHandSideScalar()) {
                rightInput = new UnaryCP(rightInput, (left.getDataType() == DataType.MATRIX ? OperationTypes.CAST_AS_MATRIX : OperationTypes.CAST_AS_FRAME), left.getDataType(), right.getValueType());
                long bsize = ConfigurationManager.getBlocksize();
                rightInput.getOutputParameters().setDimensions(1, 1, bsize, bsize, -1);
            }
            LeftIndex leftIndexLop = new LeftIndex(left.constructLops(), rightInput, getInput().get(2).constructLops(), getInput().get(3).constructLops(), getInput().get(4).constructLops(), getInput().get(5).constructLops(), getDataType(), getValueType(), et, getSpLixCacheType(method));
            setOutputDimensions(leftIndexLop);
            setLineNumbers(leftIndexLop);
            setLops(leftIndexLop);
        } else {
            LeftIndex left = new LeftIndex(getInput().get(0).constructLops(), getInput().get(1).constructLops(), getInput().get(2).constructLops(), getInput().get(3).constructLops(), getInput().get(4).constructLops(), getInput().get(5).constructLops(), getDataType(), getValueType(), et);
            setOutputDimensions(left);
            setLineNumbers(left);
            setLops(left);
        }
    } catch (Exception e) {
        throw new HopsException(this.printErrorLocation() + "In LeftIndexingOp Hop, error in constructing Lops ", e);
    }
    // add reblock/checkpoint lops if necessary
    constructAndSetLopsDataFlowProperties();
    return getLops();
}
Also used : Group(org.apache.sysml.lops.Group) ZeroOut(org.apache.sysml.lops.ZeroOut) RightIndex(org.apache.sysml.lops.RightIndex) LeftIndex(org.apache.sysml.lops.LeftIndex) ExecType(org.apache.sysml.lops.LopProperties.ExecType) Binary(org.apache.sysml.lops.Binary) Lop(org.apache.sysml.lops.Lop) UnaryCP(org.apache.sysml.lops.UnaryCP)

Example 49 with ExecType

use of org.apache.sysml.lops.LopProperties.ExecType in project incubator-systemml by apache.

the class NaryOp method optFindExecType.

@Override
protected ExecType optFindExecType() {
    checkAndSetForcedPlatform();
    ExecType REMOTE = OptimizerUtils.isSparkExecutionMode() ? ExecType.SPARK : ExecType.MR;
    // forced / memory-based / threshold-based decision
    if (_etypeForced != null) {
        _etype = _etypeForced;
    } else {
        if (OptimizerUtils.isMemoryBasedOptLevel())
            _etype = findExecTypeByMemEstimate();
        else // Choose CP, if the input dimensions are below threshold or if the input is a vector
        if (areDimsBelowThreshold())
            _etype = ExecType.CP;
        else
            _etype = REMOTE;
        // check for valid CP dimensions and matrix size
        checkAndSetInvalidCPDimsAndSize();
    }
    // mark for recompile (forever)
    setRequiresRecompileIfNecessary();
    // ensure cp exec type for single-node operations
    if (_op == OpOpN.PRINTF || _op == OpOpN.EVAL)
        _etype = ExecType.CP;
    return _etype;
}
Also used : ExecType(org.apache.sysml.lops.LopProperties.ExecType)

Example 50 with ExecType

use of org.apache.sysml.lops.LopProperties.ExecType in project incubator-systemml by apache.

the class QuaternaryOp method optFindExecType.

@Override
protected ExecType optFindExecType() {
    checkAndSetForcedPlatform();
    ExecType REMOTE = OptimizerUtils.isSparkExecutionMode() ? ExecType.SPARK : ExecType.MR;
    if (_etypeForced != null) {
        _etype = _etypeForced;
    } else {
        if (OptimizerUtils.isMemoryBasedOptLevel()) {
            _etype = findExecTypeByMemEstimate();
        } else if ((getInput().get(0).areDimsBelowThreshold() && getInput().get(1).areDimsBelowThreshold() && getInput().get(2).areDimsBelowThreshold() && getInput().get(3).areDimsBelowThreshold()))
            _etype = ExecType.CP;
        else
            _etype = REMOTE;
        // check for valid CP dimensions and matrix size
        checkAndSetInvalidCPDimsAndSize();
    }
    // mark for recompile (forever)
    setRequiresRecompileIfNecessary();
    return _etype;
}
Also used : ExecType(org.apache.sysml.lops.LopProperties.ExecType)

Aggregations

ExecType (org.apache.sysml.lops.LopProperties.ExecType)64 Lop (org.apache.sysml.lops.Lop)26 MultiThreadedHop (org.apache.sysml.hops.Hop.MultiThreadedHop)13 Group (org.apache.sysml.lops.Group)13 Aggregate (org.apache.sysml.lops.Aggregate)10 UnaryCP (org.apache.sysml.lops.UnaryCP)7 DataPartition (org.apache.sysml.lops.DataPartition)6 SortKeys (org.apache.sysml.lops.SortKeys)6 CombineUnary (org.apache.sysml.lops.CombineUnary)5 PickByCount (org.apache.sysml.lops.PickByCount)5 ArrayList (java.util.ArrayList)4 CombineBinary (org.apache.sysml.lops.CombineBinary)4 LopsException (org.apache.sysml.lops.LopsException)4 HashMap (java.util.HashMap)3 Data (org.apache.sysml.lops.Data)3 PartialAggregate (org.apache.sysml.lops.PartialAggregate)3 SparkAggType (org.apache.sysml.hops.AggBinaryOp.SparkAggType)2 DataOp (org.apache.sysml.hops.DataOp)2 Hop (org.apache.sysml.hops.Hop)2 OperationTypes (org.apache.sysml.lops.Aggregate.OperationTypes)2