Search in sources :

Example 46 with Timing

use of org.apache.sysml.runtime.controlprogram.parfor.stat.Timing in project incubator-systemml by apache.

the class GraphBuilder method constructGlobalDataFlowGraph.

public static GDFGraph constructGlobalDataFlowGraph(Program prog, Summary summary) throws DMLRuntimeException, HopsException {
    Timing time = new Timing(true);
    HashMap<String, GDFNode> roots = new HashMap<String, GDFNode>();
    for (ProgramBlock pb : prog.getProgramBlocks()) constructGDFGraph(pb, roots);
    //create GDF graph root nodes 
    ArrayList<GDFNode> ret = new ArrayList<GDFNode>();
    for (GDFNode root : roots.values()) if (!(root instanceof GDFCrossBlockNode))
        ret.add(root);
    //create GDF graph
    GDFGraph graph = new GDFGraph(prog, ret);
    summary.setTimeGDFGraph(time.stop());
    return graph;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ForProgramBlock(org.apache.sysml.runtime.controlprogram.ForProgramBlock) IfProgramBlock(org.apache.sysml.runtime.controlprogram.IfProgramBlock) FunctionProgramBlock(org.apache.sysml.runtime.controlprogram.FunctionProgramBlock) ProgramBlock(org.apache.sysml.runtime.controlprogram.ProgramBlock) WhileProgramBlock(org.apache.sysml.runtime.controlprogram.WhileProgramBlock) Timing(org.apache.sysml.runtime.controlprogram.parfor.stat.Timing)

Example 47 with Timing

use of org.apache.sysml.runtime.controlprogram.parfor.stat.Timing in project incubator-systemml by apache.

the class CompressedMatrixBlock method aggregateBinaryOperations.

@Override
public MatrixValue aggregateBinaryOperations(MatrixValue mv1, MatrixValue mv2, MatrixValue result, AggregateBinaryOperator op) throws DMLRuntimeException {
    //call uncompressed matrix mult if necessary
    if (!isCompressed()) {
        return super.aggregateBinaryOperations(mv1, mv2, result, op);
    }
    //multi-threaded mm of single uncompressed colgroup
    if (isSingleUncompressedGroup()) {
        MatrixBlock tmp = ((ColGroupUncompressed) _colGroups.get(0)).getData();
        return tmp.aggregateBinaryOperations(this == mv1 ? tmp : mv1, this == mv2 ? tmp : mv2, result, op);
    }
    Timing time = LOG.isDebugEnabled() ? new Timing(true) : null;
    //setup meta data (dimensions, sparsity)
    int rl = mv1.getNumRows();
    int cl = mv2.getNumColumns();
    //create output matrix block
    MatrixBlock ret = (MatrixBlock) result;
    if (ret == null)
        ret = new MatrixBlock(rl, cl, false, rl * cl);
    else
        ret.reset(rl, cl, false, rl * cl);
    //compute matrix mult
    if (mv1.getNumRows() > 1 && mv2.getNumColumns() == 1) {
        //MV right
        CompressedMatrixBlock cmb = (CompressedMatrixBlock) mv1;
        MatrixBlock mb = (MatrixBlock) mv2;
        if (op.getNumThreads() > 1)
            cmb.rightMultByVector(mb, ret, op.getNumThreads());
        else
            cmb.rightMultByVector(mb, ret);
    } else if (mv1.getNumRows() == 1 && mv2.getNumColumns() > 1) {
        //MV left
        MatrixBlock mb = (MatrixBlock) mv1;
        if (op.getNumThreads() > 1)
            leftMultByVectorTranspose(_colGroups, mb, ret, false, op.getNumThreads());
        else
            leftMultByVectorTranspose(_colGroups, mb, ret, false, true);
    } else {
        //we want to have an eager fail if this happens
        throw new DMLRuntimeException("Unsupported matrix-matrix multiplication over compressed matrix block.");
    }
    if (LOG.isDebugEnabled())
        LOG.debug("Compressed MM in " + time.stop());
    return ret;
}
Also used : MatrixBlock(org.apache.sysml.runtime.matrix.data.MatrixBlock) Timing(org.apache.sysml.runtime.controlprogram.parfor.stat.Timing) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 48 with Timing

use of org.apache.sysml.runtime.controlprogram.parfor.stat.Timing in project incubator-systemml by apache.

the class SystemTMulticlassSVMScoreTest method execDMLScriptviaJMLC.

/**
	 * 
	 * @param X
	 * @return
	 * @throws DMLException
	 * @throws IOException
	 */
private ArrayList<double[][]> execDMLScriptviaJMLC(ArrayList<double[][]> X) throws IOException {
    Timing time = new Timing(true);
    ArrayList<double[][]> ret = new ArrayList<double[][]>();
    //establish connection to SystemML
    Connection conn = new Connection();
    try {
        // For now, JMLC pipeline only allows dml
        boolean parsePyDML = false;
        //read and precompile script
        String script = conn.readScript(SCRIPT_DIR + TEST_DIR + TEST_NAME + ".dml");
        PreparedScript pstmt = conn.prepareScript(script, new String[] { "X", "W" }, new String[] { "predicted_y" }, parsePyDML);
        //read model
        String modelData = conn.readScript(SCRIPT_DIR + TEST_DIR + MODEL_FILE);
        double[][] W = conn.convertToDoubleMatrix(modelData, rows, cols);
        //execute script multiple times
        for (int i = 0; i < nRuns; i++) {
            //bind input parameters
            pstmt.setMatrix("W", W);
            pstmt.setMatrix("X", X.get(i));
            //execute script
            ResultVariables rs = pstmt.executeScript();
            //get output parameter
            double[][] Y = rs.getMatrix("predicted_y");
            //keep result for comparison
            ret.add(Y);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new IOException(ex);
    } finally {
        if (conn != null)
            conn.close();
    }
    System.out.println("JMLC scoring w/ " + nRuns + " runs in " + time.stop() + "ms.");
    return ret;
}
Also used : PreparedScript(org.apache.sysml.api.jmlc.PreparedScript) ResultVariables(org.apache.sysml.api.jmlc.ResultVariables) ArrayList(java.util.ArrayList) Connection(org.apache.sysml.api.jmlc.Connection) Timing(org.apache.sysml.runtime.controlprogram.parfor.stat.Timing) IOException(java.io.IOException) IOException(java.io.IOException) DMLException(org.apache.sysml.api.DMLException)

Example 49 with Timing

use of org.apache.sysml.runtime.controlprogram.parfor.stat.Timing in project incubator-systemml by apache.

the class CostEstimationWrapper method getTimeEstimate.

public static double getTimeEstimate(Program rtprog, ExecutionContext ec) {
    Timing time = new Timing(true);
    HashMap<String, VarStats> stats = new HashMap<>();
    LocalVariableMap vars = (ec != null) ? ec.getVariables() : new LocalVariableMap();
    double costs = _costEstim.getTimeEstimate(rtprog, vars, stats);
    LOG.debug("Finished estimation in " + time.stop() + "ms.");
    return costs;
}
Also used : HashMap(java.util.HashMap) LocalVariableMap(org.apache.sysml.runtime.controlprogram.LocalVariableMap) Timing(org.apache.sysml.runtime.controlprogram.parfor.stat.Timing)

Example 50 with Timing

use of org.apache.sysml.runtime.controlprogram.parfor.stat.Timing in project incubator-systemml by apache.

the class FrameEncodeTest method execDMLScriptviaJMLC.

private static ArrayList<String[][]> execDMLScriptviaJMLC(String testname, String[][] F1, boolean modelReuse) throws IOException {
    Timing time = new Timing(true);
    ArrayList<String[][]> ret = new ArrayList<String[][]>();
    // establish connection to SystemML
    Connection conn = new Connection();
    try {
        // prepare input arguments
        HashMap<String, String> args = new HashMap<String, String>();
        args.put("$TRANSFORM_SPEC", "{ \"ids\": true ,\"recode\": [ 1, 2, 3] }");
        // read and precompile script
        String script = conn.readScript(SCRIPT_DIR + TEST_DIR + testname + ".dml");
        PreparedScript pstmt = conn.prepareScript(script, args, new String[] { "F1", "M" }, new String[] { "F2" }, false);
        if (modelReuse)
            pstmt.setFrame("F1", F1, true);
        // execute script multiple times
        for (int i = 0; i < nRuns; i++) {
            // bind input parameters
            if (!modelReuse)
                pstmt.setFrame("F1", F1);
            // execute script
            ResultVariables rs = pstmt.executeScript();
            // get output parameter
            String[][] Y = rs.getFrame("F2");
            // keep result for comparison
            ret.add(Y);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new IOException(ex);
    } finally {
        IOUtilFunctions.closeSilently(conn);
    }
    System.out.println("JMLC scoring w/ " + nRuns + " runs in " + time.stop() + "ms.");
    return ret;
}
Also used : PreparedScript(org.apache.sysml.api.jmlc.PreparedScript) HashMap(java.util.HashMap) ResultVariables(org.apache.sysml.api.jmlc.ResultVariables) ArrayList(java.util.ArrayList) Connection(org.apache.sysml.api.jmlc.Connection) IOException(java.io.IOException) IOException(java.io.IOException) Timing(org.apache.sysml.runtime.controlprogram.parfor.stat.Timing)

Aggregations

Timing (org.apache.sysml.runtime.controlprogram.parfor.stat.Timing)78 IOException (java.io.IOException)31 ArrayList (java.util.ArrayList)29 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)25 HashMap (java.util.HashMap)24 Connection (org.apache.sysml.api.jmlc.Connection)17 PreparedScript (org.apache.sysml.api.jmlc.PreparedScript)17 ResultVariables (org.apache.sysml.api.jmlc.ResultVariables)17 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)17 MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)14 ParForStatementBlock (org.apache.sysml.parser.ParForStatementBlock)10 TaskPartitioner (org.apache.sysml.runtime.controlprogram.parfor.TaskPartitioner)10 ParForBody (org.apache.sysml.runtime.controlprogram.parfor.ParForBody)8 RemoteParForJobReturn (org.apache.sysml.runtime.controlprogram.parfor.RemoteParForJobReturn)8 LocalVariableMap (org.apache.sysml.runtime.controlprogram.LocalVariableMap)7 ProgramBlock (org.apache.sysml.runtime.controlprogram.ProgramBlock)7 ExecutorService (java.util.concurrent.ExecutorService)6 Future (java.util.concurrent.Future)6 LocalTaskQueue (org.apache.sysml.runtime.controlprogram.parfor.LocalTaskQueue)6 Task (org.apache.sysml.runtime.controlprogram.parfor.Task)6