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;
}
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);
}
}
}
}
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();
}
}
}
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;
}
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;
}
}
Aggregations