use of org.apache.sysml.runtime.instructions.Instruction in project incubator-systemml by apache.
the class Recompiler method recompileIfPredicate.
//helper functions for predicate recompile
private static void recompileIfPredicate(IfProgramBlock ipb, IfStatementBlock isb, LocalVariableMap vars, RecompileStatus status, long tid, boolean resetRecompile) throws DMLRuntimeException, HopsException, LopsException, IOException {
if (isb != null) {
Hop hops = isb.getPredicateHops();
if (hops != null) {
ArrayList<Instruction> tmp = recompileHopsDag(hops, vars, status, true, false, tid);
ipb.setPredicate(tmp);
if (ParForProgramBlock.RESET_RECOMPILATION_FLAGs && resetRecompile) {
Hop.resetRecompilationFlag(hops, ExecType.CP);
isb.updatePredicateRecompilationFlag();
}
//update predicate vars (potentially after constant folding, e.g., in parfor)
if (hops instanceof LiteralOp)
ipb.setPredicateResultVar(((LiteralOp) hops).getName().toLowerCase());
}
}
}
use of org.apache.sysml.runtime.instructions.Instruction in project incubator-systemml by apache.
the class Recompiler method recompileHopsDag2Forced.
/**
* C) Recompile basic program block hop DAG, but forced to CP.
*
* This happens always 'inplace', without statistics updates, and
* without dynamic rewrites.
*
* @param sb statement block
* @param hops list of high-level operators
* @param tid thread id
* @param et execution type
* @return list of instructions
* @throws DMLRuntimeException if DMLRuntimeException occurs
* @throws HopsException if HopsException occurs
* @throws LopsException if LopsException occurs
* @throws IOException if IOException occurs
*/
public static ArrayList<Instruction> recompileHopsDag2Forced(StatementBlock sb, ArrayList<Hop> hops, long tid, ExecType et) throws DMLRuntimeException, HopsException, LopsException, IOException {
ArrayList<Instruction> newInst = null;
//however, we create deep copies for most dags to allow for concurrent recompile
synchronized (hops) {
LOG.debug("\n**************** Optimizer (Recompile) *************\nMemory Budget = " + OptimizerUtils.toMB(OptimizerUtils.getLocalMemBudget()) + " MB");
// clear existing lops
Hop.resetVisitStatus(hops);
for (Hop hopRoot : hops) rClearLops(hopRoot);
// update exec type
Hop.resetVisitStatus(hops);
for (Hop hopRoot : hops) rSetExecType(hopRoot, et);
Hop.resetVisitStatus(hops);
// construct lops
Dag<Lop> dag = new Dag<Lop>();
for (Hop hopRoot : hops) {
Lop lops = hopRoot.constructLops();
lops.addToDag(dag);
}
// generate runtime instructions (incl piggybacking)
newInst = dag.getJobs(sb, ConfigurationManager.getDMLConfig());
}
// replace thread ids in new instructions
if (//only in parfor context
tid != 0)
newInst = ProgramConverter.createDeepCopyInstructionSet(newInst, tid, -1, null, null, null, false, false);
return newInst;
}
use of org.apache.sysml.runtime.instructions.Instruction in project incubator-systemml by apache.
the class Recompiler method recompileHopsDag2Forced.
/**
* D) Recompile predicate hop DAG (single root), but forced to CP.
*
* This happens always 'inplace', without statistics updates, and
* without dynamic rewrites.
*
* @param hops list of high-level operators
* @param tid thread id
* @param et execution type
* @return list of instructions
* @throws DMLRuntimeException if DMLRuntimeException occurs
* @throws HopsException if HopsException occurs
* @throws LopsException if LopsException occurs
* @throws IOException if IOException occurs
*/
public static ArrayList<Instruction> recompileHopsDag2Forced(Hop hops, long tid, ExecType et) throws DMLRuntimeException, HopsException, LopsException, IOException {
ArrayList<Instruction> newInst = null;
//need for synchronization as we do temp changes in shared hops/lops
synchronized (hops) {
LOG.debug("\n**************** Optimizer (Recompile) *************\nMemory Budget = " + OptimizerUtils.toMB(OptimizerUtils.getLocalMemBudget()) + " MB");
// clear existing lops
hops.resetVisitStatus();
rClearLops(hops);
// update exec type
hops.resetVisitStatus();
rSetExecType(hops, et);
hops.resetVisitStatus();
// construct lops
Dag<Lop> dag = new Dag<Lop>();
Lop lops = hops.constructLops();
lops.addToDag(dag);
// generate runtime instructions (incl piggybacking)
newInst = dag.getJobs(null, ConfigurationManager.getDMLConfig());
}
// replace thread ids in new instructions
if (//only in parfor context
tid != 0)
newInst = ProgramConverter.createDeepCopyInstructionSet(newInst, tid, -1, null, null, null, false, false);
return newInst;
}
use of org.apache.sysml.runtime.instructions.Instruction in project incubator-systemml by apache.
the class Recompiler method recompileHopsDagInstructions.
public static ArrayList<Instruction> recompileHopsDagInstructions(Hop hops) throws DMLRuntimeException, HopsException, LopsException, IOException {
ArrayList<Instruction> newInst = null;
//need for synchronization as we do temp changes in shared hops/lops
synchronized (hops) {
LOG.debug("\n**************** Optimizer (Recompile) *************\nMemory Budget = " + OptimizerUtils.toMB(OptimizerUtils.getLocalMemBudget()) + " MB");
// clear existing lops
hops.resetVisitStatus();
rClearLops(hops);
// construct lops
Dag<Lop> dag = new Dag<Lop>();
Lop lops = hops.constructLops();
lops.addToDag(dag);
// generate runtime instructions (incl piggybacking)
newInst = dag.getJobs(null, ConfigurationManager.getDMLConfig());
}
// explain recompiled instructions
if (DMLScript.EXPLAIN == ExplainType.RECOMPILE_HOPS)
LOG.info("EXPLAIN RECOMPILE \nPRED (line " + hops.getBeginLine() + "):\n" + Explain.explain(hops, 1));
if (DMLScript.EXPLAIN == ExplainType.RECOMPILE_RUNTIME)
LOG.info("EXPLAIN RECOMPILE \nPRED (line " + hops.getBeginLine() + "):\n" + Explain.explain(newInst, 1));
return newInst;
}
use of org.apache.sysml.runtime.instructions.Instruction in project incubator-systemml by apache.
the class Recompiler method recompileHopsDagInstructions.
public static ArrayList<Instruction> recompileHopsDagInstructions(StatementBlock sb, ArrayList<Hop> hops) throws HopsException, LopsException, DMLRuntimeException, IOException {
ArrayList<Instruction> newInst = null;
//however, we create deep copies for most dags to allow for concurrent recompile
synchronized (hops) {
LOG.debug("\n**************** Optimizer (Recompile) *************\nMemory Budget = " + OptimizerUtils.toMB(OptimizerUtils.getLocalMemBudget()) + " MB");
// clear existing lops
Hop.resetVisitStatus(hops);
for (Hop hopRoot : hops) rClearLops(hopRoot);
// construct lops
Dag<Lop> dag = new Dag<Lop>();
for (Hop hopRoot : hops) {
Lop lops = hopRoot.constructLops();
lops.addToDag(dag);
}
// generate runtime instructions (incl piggybacking)
newInst = dag.getJobs(sb, ConfigurationManager.getDMLConfig());
}
// explain recompiled hops / instructions
if (DMLScript.EXPLAIN == ExplainType.RECOMPILE_HOPS) {
LOG.info("EXPLAIN RECOMPILE \nGENERIC (lines " + sb.getBeginLine() + "-" + sb.getEndLine() + "):\n" + Explain.explainHops(hops, 1));
}
if (DMLScript.EXPLAIN == ExplainType.RECOMPILE_RUNTIME) {
LOG.info("EXPLAIN RECOMPILE \nGENERIC (lines " + sb.getBeginLine() + "-" + sb.getEndLine() + "):\n" + Explain.explain(newInst, 1));
}
return newInst;
}
Aggregations