use of org.apache.sysml.lops.Lop in project incubator-systemml by apache.
the class ReorgOp method constructCPOrSparkSortLop.
private static Lop constructCPOrSparkSortLop(Hop input, Hop by, Hop desc, Hop ixret, ExecType et, boolean bSortIndInMem) throws HopsException, LopsException {
Transform transform1 = new Transform(input.constructLops(), HopsTransf2Lops.get(ReOrgOp.SORT), input.getDataType(), input.getValueType(), et, bSortIndInMem);
for (Hop c : new Hop[] { by, desc, ixret }) {
Lop ltmp = c.constructLops();
transform1.addInput(ltmp);
ltmp.addOutput(transform1);
}
//force order of added lops
transform1.setLevel();
return transform1;
}
use of org.apache.sysml.lops.Lop in project incubator-systemml by apache.
the class MultipleOp method constructLops.
/**
* Construct the corresponding Lops for this Hop
*/
@Override
public Lop constructLops() throws HopsException, LopsException {
// reuse existing lop
if (getLops() != null)
return getLops();
try {
ArrayList<Hop> inHops = getInput();
Lop[] inLops = new Lop[inHops.size()];
for (int i = 0; i < inHops.size(); i++) {
Hop inHop = inHops.get(i);
Lop inLop = inHop.constructLops();
inLops[i] = inLop;
}
MultipleCP.OperationType opType = MultipleOperandOperationHopTypeToLopType.get(multipleOperandOperation);
if (opType == null) {
throw new HopsException("Unknown MultipleCP Lop operation type for MultipleOperandOperation Hop type '" + multipleOperandOperation + "'");
}
MultipleCP multipleCPLop = new MultipleCP(opType, getDataType(), getValueType(), inLops);
setOutputDimensions(multipleCPLop);
setLineNumbers(multipleCPLop);
setLops(multipleCPLop);
} catch (Exception e) {
throw new HopsException(this.printErrorLocation() + "error constructing Lops for MultipleOp Hop -- \n ", e);
}
// add reblock/checkpoint lops if necessary
constructAndSetLopsDataFlowProperties();
return getLops();
}
use of org.apache.sysml.lops.Lop in project incubator-systemml by apache.
the class AggBinaryOp method constructCPLopsMM.
private void constructCPLopsMM() throws HopsException, LopsException {
Lop matmultCP = null;
if (DMLScript.USE_ACCELERATOR && (DMLScript.FORCE_ACCELERATOR || getMemEstimate() < OptimizerUtils.GPU_MEMORY_BUDGET)) {
Hop h1 = getInput().get(0);
Hop h2 = getInput().get(1);
Lop left;
Lop right;
boolean isLeftTransposed;
boolean isRightTransposed;
if (HopRewriteUtils.isTransposeOperation(h1)) {
isLeftTransposed = true;
left = h1.getInput().get(0).constructLops();
} else {
isLeftTransposed = false;
left = h1.constructLops();
}
if (HopRewriteUtils.isTransposeOperation(h2)) {
isRightTransposed = true;
right = h2.getInput().get(0).constructLops();
} else {
isRightTransposed = false;
right = h2.constructLops();
}
matmultCP = new Binary(left, right, Binary.OperationTypes.MATMULT, getDataType(), getValueType(), ExecType.GPU, isLeftTransposed, isRightTransposed);
setOutputDimensions(matmultCP);
setNnz(-1);
} else {
if (isLeftTransposeRewriteApplicable(true, false)) {
matmultCP = constructCPLopsMMWithLeftTransposeRewrite();
} else {
int k = OptimizerUtils.getConstrainedNumThreads(_maxNumThreads);
matmultCP = new Binary(getInput().get(0).constructLops(), getInput().get(1).constructLops(), Binary.OperationTypes.MATMULT, getDataType(), getValueType(), ExecType.CP, k);
}
setOutputDimensions(matmultCP);
}
setLineNumbers(matmultCP);
setLops(matmultCP);
}
use of org.apache.sysml.lops.Lop 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.lops.Lop 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;
}
Aggregations