Search in sources :

Example 86 with Lop

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;
}
Also used : MultiThreadedHop(org.apache.sysml.hops.Hop.MultiThreadedHop) Transform(org.apache.sysml.lops.Transform) Lop(org.apache.sysml.lops.Lop)

Example 87 with Lop

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();
}
Also used : MultipleCP(org.apache.sysml.lops.MultipleCP) Lop(org.apache.sysml.lops.Lop) LopsException(org.apache.sysml.lops.LopsException)

Example 88 with Lop

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);
}
Also used : MultiThreadedHop(org.apache.sysml.hops.Hop.MultiThreadedHop) Binary(org.apache.sysml.lops.Binary) Lop(org.apache.sysml.lops.Lop)

Example 89 with Lop

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;
}
Also used : Hop(org.apache.sysml.hops.Hop) Dag(org.apache.sysml.lops.compile.Dag) 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) Lop(org.apache.sysml.lops.Lop)

Example 90 with Lop

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;
}
Also used : Dag(org.apache.sysml.lops.compile.Dag) 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) Lop(org.apache.sysml.lops.Lop)

Aggregations

Lop (org.apache.sysml.lops.Lop)92 MultiThreadedHop (org.apache.sysml.hops.Hop.MultiThreadedHop)34 ExecType (org.apache.sysml.lops.LopProperties.ExecType)27 Group (org.apache.sysml.lops.Group)23 ArrayList (java.util.ArrayList)18 Aggregate (org.apache.sysml.lops.Aggregate)16 LopsException (org.apache.sysml.lops.LopsException)16 DataPartition (org.apache.sysml.lops.DataPartition)15 Instruction (org.apache.sysml.runtime.instructions.Instruction)15 Data (org.apache.sysml.lops.Data)12 MRJobInstruction (org.apache.sysml.runtime.instructions.MRJobInstruction)12 Dag (org.apache.sysml.lops.compile.Dag)10 Transform (org.apache.sysml.lops.Transform)8 Unary (org.apache.sysml.lops.Unary)8 HashMap (java.util.HashMap)7 Hop (org.apache.sysml.hops.Hop)7 UnaryCP (org.apache.sysml.lops.UnaryCP)7 FunctionCallCPInstruction (org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction)7 RandInstruction (org.apache.sysml.runtime.instructions.mr.RandInstruction)7 SeqInstruction (org.apache.sysml.runtime.instructions.mr.SeqInstruction)7