Search in sources :

Example 1 with RewriteInjectSparkLoopCheckpointing

use of org.apache.sysml.hops.rewrite.RewriteInjectSparkLoopCheckpointing in project incubator-systemml by apache.

the class OptimizerRuleBased method rewriteInjectSparkLoopCheckpointing.

// /////
// REWRITE inject spark loop checkpointing
// /
protected void rewriteInjectSparkLoopCheckpointing(OptNode n) {
    // get program blocks of root parfor
    Object[] progobj = OptTreeConverter.getAbstractPlanMapping().getMappedProg(n.getID());
    ParForStatementBlock pfsb = (ParForStatementBlock) progobj[0];
    ParForStatement fs = (ParForStatement) pfsb.getStatement(0);
    ParForProgramBlock pfpb = (ParForProgramBlock) progobj[1];
    boolean applied = false;
    try {
        // apply hop rewrite inject spark checkpoints (but without context awareness)
        RewriteInjectSparkLoopCheckpointing rewrite = new RewriteInjectSparkLoopCheckpointing(false);
        ProgramRewriter rewriter = new ProgramRewriter(rewrite);
        ProgramRewriteStatus state = new ProgramRewriteStatus();
        rewriter.rRewriteStatementBlockHopDAGs(pfsb, state);
        fs.setBody(rewriter.rRewriteStatementBlocks(fs.getBody(), state, true));
        // recompile if additional checkpoints introduced
        if (state.getInjectedCheckpoints()) {
            pfpb.setChildBlocks(ProgramRecompiler.generatePartitialRuntimeProgram(pfpb.getProgram(), fs.getBody()));
            applied = true;
        }
    } catch (Exception ex) {
        throw new DMLRuntimeException(ex);
    }
    LOG.debug(getOptMode() + " OPT: rewrite 'inject spark loop checkpointing' - result=" + applied);
}
Also used : ProgramRewriter(org.apache.sysml.hops.rewrite.ProgramRewriter) ParForStatementBlock(org.apache.sysml.parser.ParForStatementBlock) MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) RDDObject(org.apache.sysml.runtime.instructions.spark.data.RDDObject) ParForStatement(org.apache.sysml.parser.ParForStatement) ProgramRewriteStatus(org.apache.sysml.hops.rewrite.ProgramRewriteStatus) RewriteInjectSparkLoopCheckpointing(org.apache.sysml.hops.rewrite.RewriteInjectSparkLoopCheckpointing) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException) ParForProgramBlock(org.apache.sysml.runtime.controlprogram.ParForProgramBlock) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Example 2 with RewriteInjectSparkLoopCheckpointing

use of org.apache.sysml.hops.rewrite.RewriteInjectSparkLoopCheckpointing in project systemml by apache.

the class OptimizerRuleBased method rewriteInjectSparkLoopCheckpointing.

// /////
// REWRITE inject spark loop checkpointing
// /
protected void rewriteInjectSparkLoopCheckpointing(OptNode n) {
    // get program blocks of root parfor
    Object[] progobj = OptTreeConverter.getAbstractPlanMapping().getMappedProg(n.getID());
    ParForStatementBlock pfsb = (ParForStatementBlock) progobj[0];
    ParForStatement fs = (ParForStatement) pfsb.getStatement(0);
    ParForProgramBlock pfpb = (ParForProgramBlock) progobj[1];
    boolean applied = false;
    try {
        // apply hop rewrite inject spark checkpoints (but without context awareness)
        RewriteInjectSparkLoopCheckpointing rewrite = new RewriteInjectSparkLoopCheckpointing(false);
        ProgramRewriter rewriter = new ProgramRewriter(rewrite);
        ProgramRewriteStatus state = new ProgramRewriteStatus();
        rewriter.rRewriteStatementBlockHopDAGs(pfsb, state);
        fs.setBody(rewriter.rRewriteStatementBlocks(fs.getBody(), state, true));
        // recompile if additional checkpoints introduced
        if (state.getInjectedCheckpoints()) {
            pfpb.setChildBlocks(ProgramRecompiler.generatePartitialRuntimeProgram(pfpb.getProgram(), fs.getBody()));
            applied = true;
        }
    } catch (Exception ex) {
        throw new DMLRuntimeException(ex);
    }
    LOG.debug(getOptMode() + " OPT: rewrite 'inject spark loop checkpointing' - result=" + applied);
}
Also used : ProgramRewriter(org.apache.sysml.hops.rewrite.ProgramRewriter) ParForStatementBlock(org.apache.sysml.parser.ParForStatementBlock) MatrixObject(org.apache.sysml.runtime.controlprogram.caching.MatrixObject) RDDObject(org.apache.sysml.runtime.instructions.spark.data.RDDObject) ParForStatement(org.apache.sysml.parser.ParForStatement) ProgramRewriteStatus(org.apache.sysml.hops.rewrite.ProgramRewriteStatus) RewriteInjectSparkLoopCheckpointing(org.apache.sysml.hops.rewrite.RewriteInjectSparkLoopCheckpointing) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException) ParForProgramBlock(org.apache.sysml.runtime.controlprogram.ParForProgramBlock) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Aggregations

ProgramRewriteStatus (org.apache.sysml.hops.rewrite.ProgramRewriteStatus)2 ProgramRewriter (org.apache.sysml.hops.rewrite.ProgramRewriter)2 RewriteInjectSparkLoopCheckpointing (org.apache.sysml.hops.rewrite.RewriteInjectSparkLoopCheckpointing)2 ParForStatement (org.apache.sysml.parser.ParForStatement)2 ParForStatementBlock (org.apache.sysml.parser.ParForStatementBlock)2 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)2 ParForProgramBlock (org.apache.sysml.runtime.controlprogram.ParForProgramBlock)2 MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)2 RDDObject (org.apache.sysml.runtime.instructions.spark.data.RDDObject)2