Search in sources :

Example 41 with ExecType

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

the class DataGenOp 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 (this.areDimsBelowThreshold() || this.isVector())
            _etype = ExecType.CP;
        else
            _etype = REMOTE;
        // check for valid CP dimensions and matrix size
        checkAndSetInvalidCPDimsAndSize();
    }
    // mark for recompile (forever)
    setRequiresRecompileIfNecessary();
    // similarly, sample is currently not supported in MR either
    if (_op == DataGenMethod.SINIT)
        _etype = ExecType.CP;
    // workaround until sample supported in MR
    if (_op == DataGenMethod.SAMPLE && _etype == ExecType.MR)
        _etype = ExecType.CP;
    return _etype;
}
Also used : ExecType(org.apache.sysml.lops.LopProperties.ExecType)

Example 42 with ExecType

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

the class DataOp method optFindExecType.

@Override
protected ExecType optFindExecType() {
    // MB: find exec type has two meanings here: (1) for write it means the actual
    // exec type, while (2) for read it affects the recompilation decision as needed
    // for example for sum(X) where the memory consumption is solely determined by the DataOp
    ExecType letype = (OptimizerUtils.isMemoryBasedOptLevel()) ? findExecTypeByMemEstimate() : null;
    ExecType REMOTE = OptimizerUtils.isSparkExecutionMode() ? ExecType.SPARK : ExecType.MR;
    // NOTE: independent of etype executed in MR (piggybacked) if input to persistent write is MR
    if (_dataop == DataOpTypes.PERSISTENTWRITE || _dataop == DataOpTypes.TRANSIENTWRITE) {
        checkAndSetForcedPlatform();
        // additional check for write only
        if (getDataType() == DataType.SCALAR || (getDataType() == DataType.FRAME && REMOTE == ExecType.MR))
            _etypeForced = ExecType.CP;
        if (_etypeForced != null) {
            _etype = _etypeForced;
        } else {
            if (OptimizerUtils.isMemoryBasedOptLevel()) {
                _etype = letype;
            } 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();
    } else // READ
    {
        // mark for recompile (forever)
        if (ConfigurationManager.isDynamicRecompilation() && !dimsKnown(true) && letype == REMOTE && (_recompileRead || _requiresCheckpoint)) {
            setRequiresRecompile();
        }
        _etype = letype;
    }
    return _etype;
}
Also used : ExecType(org.apache.sysml.lops.LopProperties.ExecType)

Example 43 with ExecType

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

the class FunctionOp method constructLops.

@Override
public Lop constructLops() {
    // return already created lops
    if (getLops() != null)
        return getLops();
    ExecType et = optFindExecType();
    // construct input lops (recursive)
    ArrayList<Lop> tmp = new ArrayList<>();
    for (Hop in : getInput()) tmp.add(in.constructLops());
    // construct function call
    Lop fcall = _singleOutFun ? new FunctionCallCPSingle(tmp, _fnamespace, _fname, et) : new FunctionCallCP(tmp, _fnamespace, _fname, _outputs, _outputHops, et);
    setLineNumbers(fcall);
    setLops(fcall);
    return getLops();
}
Also used : FunctionCallCPSingle(org.apache.sysml.lops.FunctionCallCPSingle) FunctionCallCP(org.apache.sysml.lops.FunctionCallCP) ArrayList(java.util.ArrayList) ExecType(org.apache.sysml.lops.LopProperties.ExecType) Lop(org.apache.sysml.lops.Lop)

Example 44 with ExecType

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

the class Hop method constructAndSetCheckpointLopIfRequired.

private void constructAndSetCheckpointLopIfRequired() {
    // determine execution type
    ExecType et = ExecType.CP;
    if (OptimizerUtils.isSparkExecutionMode() && getDataType() != DataType.SCALAR) {
        // (2) avoid unnecessary creation of spark context (incl executors)
        if ((OptimizerUtils.isHybridExecutionMode() && hasValidCPDimsAndSize() && !OptimizerUtils.exceedsCachingThreshold(getDim2(), _outputMemEstimate)) || _etypeForced == ExecType.CP) {
            et = ExecType.CP;
        } else // default case
        {
            et = ExecType.SPARK;
        }
    }
    // add checkpoint lop to output if required
    if (_requiresCheckpoint && et != ExecType.CP) {
        try {
            // investigate need for serialized storage of large sparse matrices
            // (compile- instead of runtime-level for better debugging)
            boolean serializedStorage = false;
            if (getDataType() == DataType.MATRIX && dimsKnown(true)) {
                double matrixPSize = OptimizerUtils.estimatePartitionedSizeExactSparsity(_dim1, _dim2, _rows_in_block, _cols_in_block, _nnz);
                double dataCache = SparkExecutionContext.getDataMemoryBudget(true, true);
                serializedStorage = MatrixBlock.evalSparseFormatInMemory(_dim1, _dim2, _nnz) && // sparse in-memory does not fit in agg mem
                matrixPSize > dataCache && (OptimizerUtils.getSparsity(_dim1, _dim2, _nnz) < MatrixBlock.ULTRA_SPARSITY_TURN_POINT || // ultra-sparse or sparse w/o csr
                !Checkpoint.CHECKPOINT_SPARSE_CSR);
            } else if (!dimsKnown(true)) {
                setRequiresRecompile();
            }
            // construct checkpoint w/ right storage level
            Lop input = getLops();
            Lop chkpoint = new Checkpoint(input, getDataType(), getValueType(), serializedStorage ? Checkpoint.getSerializeStorageLevelString() : Checkpoint.getDefaultStorageLevelString());
            setOutputDimensions(chkpoint);
            setLineNumbers(chkpoint);
            setLops(chkpoint);
        } catch (LopsException ex) {
            throw new HopsException(ex);
        }
    }
}
Also used : Checkpoint(org.apache.sysml.lops.Checkpoint) LopsException(org.apache.sysml.lops.LopsException) ExecType(org.apache.sysml.lops.LopProperties.ExecType) Lop(org.apache.sysml.lops.Lop)

Example 45 with ExecType

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

the class Hop method constructAndSetReblockLopIfRequired.

private void constructAndSetReblockLopIfRequired() {
    // determine execution type
    ExecType et = ExecType.CP;
    if (DMLScript.rtplatform != RUNTIME_PLATFORM.SINGLE_NODE && !(getDataType() == DataType.SCALAR)) {
        et = OptimizerUtils.isSparkExecutionMode() ? ExecType.SPARK : ExecType.MR;
    }
    // add reblock lop to output if required
    if (_requiresReblock && et != ExecType.CP) {
        Lop input = getLops();
        Lop reblock = null;
        try {
            if (// CSV
            this instanceof DataOp && ((DataOp) this).getDataOpType() == DataOpTypes.PERSISTENTREAD && ((DataOp) this).getInputFormatType() == FileFormatTypes.CSV) {
                reblock = new CSVReBlock(input, getRowsInBlock(), getColsInBlock(), getDataType(), getValueType(), et);
            } else // TEXT / MM / BINARYBLOCK / BINARYCELL
            {
                reblock = new ReBlock(input, getRowsInBlock(), getColsInBlock(), getDataType(), getValueType(), _outputEmptyBlocks, et);
            }
        } catch (LopsException ex) {
            throw new HopsException(ex);
        }
        setOutputDimensions(reblock);
        setLineNumbers(reblock);
        setLops(reblock);
    }
}
Also used : LopsException(org.apache.sysml.lops.LopsException) ReBlock(org.apache.sysml.lops.ReBlock) CSVReBlock(org.apache.sysml.lops.CSVReBlock) ExecType(org.apache.sysml.lops.LopProperties.ExecType) Lop(org.apache.sysml.lops.Lop) CSVReBlock(org.apache.sysml.lops.CSVReBlock)

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