Search in sources :

Example 1 with CloseType

use of org.apache.sysml.hops.codegen.template.TemplateBase.CloseType in project incubator-systemml by apache.

the class SpoofCompiler method rExploreCPlans.

// //////////////////
// Codegen plan construction
private static void rExploreCPlans(Hop hop, CPlanMemoTable memo, boolean compileLiterals) {
    // top-down memoization of processed dag nodes
    if (memo.contains(hop.getHopID()) || memo.containsHop(hop))
        return;
    // recursive candidate exploration
    for (Hop c : hop.getInput()) rExploreCPlans(c, memo, compileLiterals);
    // open initial operator plans, if possible
    for (TemplateBase tpl : TemplateUtils.TEMPLATES) if (tpl.open(hop))
        memo.addAll(hop, enumPlans(hop, null, tpl, memo));
    // fuse and merge operator plans
    for (Hop c : hop.getInput()) for (TemplateBase tpl : memo.getDistinctTemplates(c.getHopID())) if (tpl.fuse(hop, c))
        memo.addAll(hop, enumPlans(hop, c, tpl, memo));
    // close operator plans, if required
    if (memo.contains(hop.getHopID())) {
        Iterator<MemoTableEntry> iter = memo.get(hop.getHopID()).iterator();
        while (iter.hasNext()) {
            MemoTableEntry me = iter.next();
            TemplateBase tpl = TemplateUtils.createTemplate(me.type);
            CloseType ccode = tpl.close(hop);
            if (ccode == CloseType.CLOSED_INVALID)
                iter.remove();
            me.ctype = ccode;
        }
    }
    // prune subsumed / redundant plans
    if (PRUNE_REDUNDANT_PLANS) {
        memo.pruneRedundant(hop.getHopID(), PLAN_SEL_POLICY.isHeuristic(), null);
    }
    // mark visited even if no plans found (e.g., unsupported ops)
    memo.addHop(hop);
}
Also used : CloseType(org.apache.sysml.hops.codegen.template.TemplateBase.CloseType) MemoTableEntry(org.apache.sysml.hops.codegen.template.CPlanMemoTable.MemoTableEntry) Hop(org.apache.sysml.hops.Hop) TemplateBase(org.apache.sysml.hops.codegen.template.TemplateBase)

Example 2 with CloseType

use of org.apache.sysml.hops.codegen.template.TemplateBase.CloseType in project systemml by apache.

the class SpoofCompiler method rExploreCPlans.

// //////////////////
// Codegen plan construction
private static void rExploreCPlans(Hop hop, CPlanMemoTable memo, boolean compileLiterals) {
    // top-down memoization of processed dag nodes
    if (memo.contains(hop.getHopID()) || memo.containsHop(hop))
        return;
    // recursive candidate exploration
    for (Hop c : hop.getInput()) rExploreCPlans(c, memo, compileLiterals);
    // open initial operator plans, if possible
    for (TemplateBase tpl : TemplateUtils.TEMPLATES) if (tpl.open(hop))
        memo.addAll(hop, enumPlans(hop, null, tpl, memo));
    // fuse and merge operator plans
    for (Hop c : hop.getInput()) for (TemplateBase tpl : memo.getDistinctTemplates(c.getHopID())) if (tpl.fuse(hop, c))
        memo.addAll(hop, enumPlans(hop, c, tpl, memo));
    // close operator plans, if required
    if (memo.contains(hop.getHopID())) {
        Iterator<MemoTableEntry> iter = memo.get(hop.getHopID()).iterator();
        while (iter.hasNext()) {
            MemoTableEntry me = iter.next();
            TemplateBase tpl = TemplateUtils.createTemplate(me.type);
            CloseType ccode = tpl.close(hop);
            if (ccode == CloseType.CLOSED_INVALID)
                iter.remove();
            me.ctype = ccode;
        }
    }
    // prune subsumed / redundant plans
    if (PRUNE_REDUNDANT_PLANS) {
        memo.pruneRedundant(hop.getHopID(), PLAN_SEL_POLICY.isHeuristic(), null);
    }
    // mark visited even if no plans found (e.g., unsupported ops)
    memo.addHop(hop);
}
Also used : CloseType(org.apache.sysml.hops.codegen.template.TemplateBase.CloseType) MemoTableEntry(org.apache.sysml.hops.codegen.template.CPlanMemoTable.MemoTableEntry) Hop(org.apache.sysml.hops.Hop) TemplateBase(org.apache.sysml.hops.codegen.template.TemplateBase)

Aggregations

Hop (org.apache.sysml.hops.Hop)2 MemoTableEntry (org.apache.sysml.hops.codegen.template.CPlanMemoTable.MemoTableEntry)2 TemplateBase (org.apache.sysml.hops.codegen.template.TemplateBase)2 CloseType (org.apache.sysml.hops.codegen.template.TemplateBase.CloseType)2