Search in sources :

Example 1 with PTaskPartitioner

use of org.apache.sysml.runtime.controlprogram.ParForProgramBlock.PTaskPartitioner in project incubator-systemml by apache.

the class OptimizerRuleBased method hasLargeTotalResults.

/**
	 * Heuristically compute total result sizes, if larger than local mem budget assumed to be large.
	 * 
	 * @param pn internal representation of a plan alternative for program blocks and instructions
	 * @param resultVars list of result variables
	 * @param vars local variable map
	 * @param checkSize ?
	 * @return true if result sizes larger than local memory budget
	 * @throws DMLRuntimeException if DMLRuntimeException occurs
	 */
protected boolean hasLargeTotalResults(OptNode pn, ArrayList<String> resultVars, LocalVariableMap vars, boolean checkSize) throws DMLRuntimeException {
    double totalSize = 0;
    //get num tasks according to task partitioning 
    PTaskPartitioner tp = PTaskPartitioner.valueOf(pn.getParam(ParamType.TASK_PARTITIONER));
    int k = pn.getK();
    long W = estimateNumTasks(tp, _N, k);
    for (String var : resultVars) {
        //Potential unknowns: for local result var of child parfor (but we're only interested in top level)
        //Potential scalars: for disabled dependency analysis and unbounded scoping			
        Data dat = vars.get(var);
        if (dat != null && dat instanceof MatrixObject) {
            MatrixObject mo = (MatrixObject) vars.get(var);
            long rows = mo.getNumRows();
            long cols = mo.getNumColumns();
            long nnz = mo.getNnz();
            if (//w/ compare
            nnz > 0) {
                totalSize += W * OptimizerUtils.estimateSizeExactSparsity(rows, cols, 1.0);
            } else //in total at most as dimensions (due to disjoint results)
            {
                totalSize += OptimizerUtils.estimateSizeExactSparsity(rows, cols, 1.0);
            }
        }
    }
    //heuristic:  large if >= local mem budget 
    return (totalSize >= _lm);
}
Also used : PTaskPartitioner(org.apache.sysml.runtime.controlprogram.ParForProgramBlock.PTaskPartitioner) MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) Data(org.apache.sysml.runtime.instructions.cp.Data) MatrixFormatMetaData(org.apache.sysml.runtime.matrix.MatrixFormatMetaData)

Example 2 with PTaskPartitioner

use of org.apache.sysml.runtime.controlprogram.ParForProgramBlock.PTaskPartitioner in project incubator-systemml by apache.

the class OptimizerRuleBased method hasLargeTotalResults.

/**
 * Heuristically compute total result sizes, if larger than local mem budget assumed to be large.
 *
 * @param pn internal representation of a plan alternative for program blocks and instructions
 * @param resultVars list of result variables
 * @param vars local variable map
 * @param checkSize ?
 * @return true if result sizes larger than local memory budget
 */
protected boolean hasLargeTotalResults(OptNode pn, ArrayList<ResultVar> resultVars, LocalVariableMap vars, boolean checkSize) {
    double totalSize = 0;
    // get num tasks according to task partitioning
    PTaskPartitioner tp = PTaskPartitioner.valueOf(pn.getParam(ParamType.TASK_PARTITIONER));
    int k = pn.getK();
    long W = estimateNumTasks(tp, _N, k);
    for (ResultVar var : resultVars) {
        // Potential unknowns: for local result var of child parfor (but we're only interested in top level)
        // Potential scalars: for disabled dependency analysis and unbounded scoping
        Data dat = vars.get(var._name);
        if (dat != null && dat instanceof MatrixObject) {
            MatrixObject mo = (MatrixObject) dat;
            long rows = mo.getNumRows();
            long cols = mo.getNumColumns();
            long nnz = mo.getNnz();
            if (// w/ compare
            nnz > 0) {
                totalSize += W * OptimizerUtils.estimateSizeExactSparsity(rows, cols, 1.0);
            } else // in total at most as dimensions (due to disjoint results)
            {
                totalSize += OptimizerUtils.estimateSizeExactSparsity(rows, cols, 1.0);
            }
        }
    }
    // heuristic:  large if >= local mem budget
    return (totalSize >= _lm);
}
Also used : PTaskPartitioner(org.apache.sysml.runtime.controlprogram.ParForProgramBlock.PTaskPartitioner) MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) ResultVar(org.apache.sysml.parser.ParForStatementBlock.ResultVar) Data(org.apache.sysml.runtime.instructions.cp.Data)

Example 3 with PTaskPartitioner

use of org.apache.sysml.runtime.controlprogram.ParForProgramBlock.PTaskPartitioner in project systemml by apache.

the class OptimizerRuleBased method hasLargeTotalResults.

/**
 * Heuristically compute total result sizes, if larger than local mem budget assumed to be large.
 *
 * @param pn internal representation of a plan alternative for program blocks and instructions
 * @param resultVars list of result variables
 * @param vars local variable map
 * @param checkSize ?
 * @return true if result sizes larger than local memory budget
 */
protected boolean hasLargeTotalResults(OptNode pn, ArrayList<ResultVar> resultVars, LocalVariableMap vars, boolean checkSize) {
    double totalSize = 0;
    // get num tasks according to task partitioning
    PTaskPartitioner tp = PTaskPartitioner.valueOf(pn.getParam(ParamType.TASK_PARTITIONER));
    int k = pn.getK();
    long W = estimateNumTasks(tp, _N, k);
    for (ResultVar var : resultVars) {
        // Potential unknowns: for local result var of child parfor (but we're only interested in top level)
        // Potential scalars: for disabled dependency analysis and unbounded scoping
        Data dat = vars.get(var._name);
        if (dat != null && dat instanceof MatrixObject) {
            MatrixObject mo = (MatrixObject) dat;
            long rows = mo.getNumRows();
            long cols = mo.getNumColumns();
            long nnz = mo.getNnz();
            if (// w/ compare
            nnz > 0) {
                totalSize += W * OptimizerUtils.estimateSizeExactSparsity(rows, cols, 1.0);
            } else // in total at most as dimensions (due to disjoint results)
            {
                totalSize += OptimizerUtils.estimateSizeExactSparsity(rows, cols, 1.0);
            }
        }
    }
    // heuristic:  large if >= local mem budget
    return (totalSize >= _lm);
}
Also used : PTaskPartitioner(org.apache.sysml.runtime.controlprogram.ParForProgramBlock.PTaskPartitioner) MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) ResultVar(org.apache.sysml.parser.ParForStatementBlock.ResultVar) Data(org.apache.sysml.runtime.instructions.cp.Data)

Aggregations

PTaskPartitioner (org.apache.sysml.runtime.controlprogram.ParForProgramBlock.PTaskPartitioner)3 MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)3 Data (org.apache.sysml.runtime.instructions.cp.Data)3 ResultVar (org.apache.sysml.parser.ParForStatementBlock.ResultVar)2 MatrixFormatMetaData (org.apache.sysml.runtime.matrix.MatrixFormatMetaData)1