Repository: incubator-systemml Updated Branches: refs/heads/master 933824ea9 -> f12759d75
[SYSTEMML-1458] Fix memoization and cse on codegen cplan construction Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/35476195 Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/35476195 Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/35476195 Branch: refs/heads/master Commit: 35476195fb8caab5da1e63350b82df3e2b44cf8a Parents: 933824e Author: Matthias Boehm <[email protected]> Authored: Mon Apr 3 15:51:43 2017 -0700 Committer: Matthias Boehm <[email protected]> Committed: Mon Apr 3 15:51:43 2017 -0700 ---------------------------------------------------------------------- .../org/apache/sysml/hops/codegen/template/TemplateCell.java | 4 ++++ .../apache/sysml/hops/codegen/template/TemplateOuterProduct.java | 4 ++++ .../org/apache/sysml/hops/codegen/template/TemplateRowAgg.java | 4 ++++ 3 files changed, 12 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/35476195/src/main/java/org/apache/sysml/hops/codegen/template/TemplateCell.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateCell.java b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateCell.java index 447f6d6..58df56f 100644 --- a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateCell.java +++ b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateCell.java @@ -136,6 +136,10 @@ public class TemplateCell extends TemplateBase private void rConstructCplan(Hop hop, CPlanMemoTable memo, HashMap<Long, CNode> tmp, HashSet<Hop> inHops, boolean compileLiterals) { + //memoization for common subexpression elimination and to avoid redundant work + if( tmp.containsKey(hop.getHopID()) ) + return; + //recursively process required childs MemoTableEntry me = memo.getBest(hop.getHopID(), TemplateType.CellTpl); for( int i=0; i<hop.getInput().size(); i++ ) { http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/35476195/src/main/java/org/apache/sysml/hops/codegen/template/TemplateOuterProduct.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateOuterProduct.java b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateOuterProduct.java index a1d2174..1a2d802 100644 --- a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateOuterProduct.java +++ b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateOuterProduct.java @@ -133,6 +133,10 @@ public class TemplateOuterProduct extends TemplateBase { private void rConstructCplan(Hop hop, CPlanMemoTable memo, HashMap<Long, CNode> tmp, HashSet<Hop> inHops, HashMap<String, Hop> inHops2, boolean compileLiterals) { + //memoization for common subexpression elimination and to avoid redundant work + if( tmp.containsKey(hop.getHopID()) ) + return; + //recursively process required childs MemoTableEntry me = memo.getBest(hop.getHopID(), TemplateType.OuterProdTpl); for( int i=0; i<hop.getInput().size(); i++ ) { http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/35476195/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRowAgg.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRowAgg.java b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRowAgg.java index 2883893..63f7cc6 100644 --- a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRowAgg.java +++ b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRowAgg.java @@ -135,6 +135,10 @@ public class TemplateRowAgg extends TemplateBase private void rConstructCplan(Hop hop, CPlanMemoTable memo, HashMap<Long, CNode> tmp, HashSet<Hop> inHops, HashMap<String, Hop> inHops2, boolean compileLiterals) { + //memoization for common subexpression elimination and to avoid redundant work + if( tmp.containsKey(hop.getHopID()) ) + return; + //recursively process required childs MemoTableEntry me = memo.getBest(hop.getHopID(), TemplateType.RowAggTpl); for( int i=0; i<hop.getInput().size(); i++ ) {
