Search in sources :

Example 56 with Hop

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

the class Recompiler method rDeepCopyHopsDag.

private static Hop rDeepCopyHopsDag(Hop hop, HashMap<Long, Hop> memo) throws CloneNotSupportedException {
    Hop ret = memo.get(hop.getHopID());
    // create clone if required
    if (ret == null) {
        ret = (Hop) hop.clone();
        // create new childs and modify references
        for (Hop in : hop.getInput()) {
            Hop tmp = rDeepCopyHopsDag(in, memo);
            ret.getInput().add(tmp);
            tmp.getParent().add(ret);
        }
        memo.put(hop.getHopID(), ret);
    }
    return ret;
}
Also used : Hop(org.apache.sysml.hops.Hop)

Example 57 with Hop

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

the class Recompiler method recompileForPredicates.

private static void recompileForPredicates(ForProgramBlock fpb, ForStatementBlock fsb, LocalVariableMap vars, RecompileStatus status, long tid, ResetType resetRecompile) {
    if (fsb != null) {
        Hop fromHops = fsb.getFromHops();
        Hop toHops = fsb.getToHops();
        Hop incrHops = fsb.getIncrementHops();
        // handle recompilation flags
        if (ParForProgramBlock.RESET_RECOMPILATION_FLAGs && resetRecompile.isReset()) {
            if (fromHops != null) {
                ArrayList<Instruction> tmp = recompileHopsDag(fromHops, vars, status, true, false, tid);
                fpb.setFromInstructions(tmp);
                Hop.resetRecompilationFlag(fromHops, ExecType.CP, resetRecompile);
            }
            if (toHops != null) {
                ArrayList<Instruction> tmp = recompileHopsDag(toHops, vars, status, true, false, tid);
                fpb.setToInstructions(tmp);
                Hop.resetRecompilationFlag(toHops, ExecType.CP, resetRecompile);
            }
            if (incrHops != null) {
                ArrayList<Instruction> tmp = recompileHopsDag(incrHops, vars, status, true, false, tid);
                fpb.setIncrementInstructions(tmp);
                Hop.resetRecompilationFlag(incrHops, ExecType.CP, resetRecompile);
            }
            fsb.updatePredicateRecompilationFlags();
        } else // no reset of recompilation flags
        {
            if (fromHops != null) {
                ArrayList<Instruction> tmp = recompileHopsDag(fromHops, vars, status, true, false, tid);
                fpb.setFromInstructions(tmp);
            }
            if (toHops != null) {
                ArrayList<Instruction> tmp = recompileHopsDag(toHops, vars, status, true, false, tid);
                fpb.setToInstructions(tmp);
            }
            if (incrHops != null) {
                ArrayList<Instruction> tmp = recompileHopsDag(incrHops, vars, status, true, false, tid);
                fpb.setIncrementInstructions(tmp);
            }
        }
    }
}
Also used : Hop(org.apache.sysml.hops.Hop) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) Instruction(org.apache.sysml.runtime.instructions.Instruction) FunctionCallCPInstruction(org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction) SeqInstruction(org.apache.sysml.runtime.instructions.mr.SeqInstruction) RandInstruction(org.apache.sysml.runtime.instructions.mr.RandInstruction)

Example 58 with Hop

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

the class Recompiler method recompileWhilePredicate.

private static void recompileWhilePredicate(WhileProgramBlock wpb, WhileStatementBlock wsb, LocalVariableMap vars, RecompileStatus status, long tid, ResetType resetRecompile) {
    if (wsb == null)
        return;
    Hop hops = wsb.getPredicateHops();
    if (hops != null) {
        ArrayList<Instruction> tmp = recompileHopsDag(hops, vars, status, true, false, tid);
        wpb.setPredicate(tmp);
        if (ParForProgramBlock.RESET_RECOMPILATION_FLAGs && resetRecompile.isReset()) {
            Hop.resetRecompilationFlag(hops, ExecType.CP, resetRecompile);
            wsb.updatePredicateRecompilationFlag();
        }
    }
}
Also used : Hop(org.apache.sysml.hops.Hop) MRJobInstruction(org.apache.sysml.runtime.instructions.MRJobInstruction) Instruction(org.apache.sysml.runtime.instructions.Instruction) FunctionCallCPInstruction(org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction) SeqInstruction(org.apache.sysml.runtime.instructions.mr.SeqInstruction) RandInstruction(org.apache.sysml.runtime.instructions.mr.RandInstruction)

Example 59 with Hop

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

the class Recompiler method deepCopyHopsDag.

/**
 * Deep copy of hops dags for parallel recompilation.
 *
 * @param hops high-level operator
 * @return high-level operator
 */
public static Hop deepCopyHopsDag(Hop hops) {
    Hop ret = null;
    try {
        // orig ID, new clone
        HashMap<Long, Hop> memo = new HashMap<>();
        ret = rDeepCopyHopsDag(hops, memo);
    } catch (Exception ex) {
        throw new HopsException(ex);
    }
    return ret;
}
Also used : HashMap(java.util.HashMap) Hop(org.apache.sysml.hops.Hop) HopsException(org.apache.sysml.hops.HopsException) HopsException(org.apache.sysml.hops.HopsException) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException) IOException(java.io.IOException)

Example 60 with Hop

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

the class HopDagValidator method validateHopDag.

public static void validateHopDag(ArrayList<Hop> roots, HopRewriteRule rule) {
    if (roots == null)
        return;
    try {
        Hop.resetVisitStatus(roots);
        ValidatorState state = new ValidatorState();
        for (Hop hop : roots) rValidateHop(hop, state);
    } catch (HopsException ex) {
        try {
            LOG.error("Invalid HOP DAG after rewrite " + rule.getClass().getName() + ": \n" + Explain.explainHops(roots), ex);
        } catch (DMLRuntimeException e) {
        }
        throw ex;
    }
}
Also used : Hop(org.apache.sysml.hops.Hop) HopsException(org.apache.sysml.hops.HopsException) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Aggregations

Hop (org.apache.sysml.hops.Hop)307 LiteralOp (org.apache.sysml.hops.LiteralOp)94 AggBinaryOp (org.apache.sysml.hops.AggBinaryOp)65 BinaryOp (org.apache.sysml.hops.BinaryOp)63 ArrayList (java.util.ArrayList)61 AggUnaryOp (org.apache.sysml.hops.AggUnaryOp)61 HashMap (java.util.HashMap)44 DataOp (org.apache.sysml.hops.DataOp)41 UnaryOp (org.apache.sysml.hops.UnaryOp)41 HashSet (java.util.HashSet)39 ReorgOp (org.apache.sysml.hops.ReorgOp)32 MemoTableEntry (org.apache.sysml.hops.codegen.template.CPlanMemoTable.MemoTableEntry)28 StatementBlock (org.apache.sysml.parser.StatementBlock)28 IndexingOp (org.apache.sysml.hops.IndexingOp)24 ForStatementBlock (org.apache.sysml.parser.ForStatementBlock)23 WhileStatementBlock (org.apache.sysml.parser.WhileStatementBlock)23 IfStatementBlock (org.apache.sysml.parser.IfStatementBlock)22 DataGenOp (org.apache.sysml.hops.DataGenOp)21 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)21 HopsException (org.apache.sysml.hops.HopsException)18