Repository: systemml
Updated Branches:
  refs/heads/master 180c4f281 -> 8fbeca142


[SYSTEMML-2480] Fix codegen register allocation special cases

This patch fixes special cases of codegen register allocation which
(1) computed an incorrect initial count due to missing suport for Nary
operations, and (2) incorrectly reported valid configurations for probes
of count 1 and 0 because the sequence generator does not support these
small cycles.


Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/b3b50c00
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/b3b50c00
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/b3b50c00

Branch: refs/heads/master
Commit: b3b50c0047b95143719411b3937d9f5ab42c7397
Parents: 180c4f2
Author: Matthias Boehm <[email protected]>
Authored: Thu Aug 2 19:45:37 2018 -0700
Committer: Matthias Boehm <[email protected]>
Committed: Thu Aug 2 22:54:03 2018 -0700

----------------------------------------------------------------------
 .../apache/sysml/hops/codegen/template/TemplateUtils.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/b3b50c00/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java
----------------------------------------------------------------------
diff --git 
a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java 
b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java
index f2ad7e6..8b6db37 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateUtils.java
@@ -47,6 +47,7 @@ import org.apache.sysml.hops.codegen.cplan.CNode;
 import org.apache.sysml.hops.codegen.cplan.CNodeBinary;
 import org.apache.sysml.hops.codegen.cplan.CNodeBinary.BinType;
 import org.apache.sysml.hops.codegen.cplan.CNodeData;
+import org.apache.sysml.hops.codegen.cplan.CNodeNary;
 import org.apache.sysml.hops.codegen.cplan.CNodeTernary;
 import org.apache.sysml.hops.codegen.cplan.CNodeUnary;
 import org.apache.sysml.hops.codegen.cplan.CNodeUnary.UnaryType;
@@ -409,7 +410,9 @@ public class TemplateUtils
        public static boolean isUnaryOperatorPipeline(CNode node) {
                if( node.isVisited() ) {
                        //second reference to vector intermediate invalidates a 
unary pipeline
-                       return !(node instanceof CNodeBinary && 
((CNodeBinary)node).getType().isVectorPrimitive());
+                       return !((node instanceof CNodeBinary && 
((CNodeBinary)node).getType().isVectorPrimitive())
+                               || (node instanceof CNodeTernary && 
((CNodeTernary)node).getType().isVectorPrimitive())
+                               || (node instanceof CNodeNary && 
((CNodeNary)node).getType().isVectorPrimitive()));
                }
                boolean ret = true;
                for( CNode input : node.getInput() )
@@ -452,7 +455,9 @@ public class TemplateUtils
                                && 
((CNodeUnary)node).getType().isVectorScalarPrimitive()) ? 1 : 0;
                int cntTn = (node instanceof CNodeTernary
                                && 
((CNodeTernary)node).getType().isVectorPrimitive()) ? 1 : 0;
-               return ret + cntBin + cntUn + cntTn;
+               int cntNn = (node instanceof CNodeNary 
+                               && 
((CNodeNary)node).getType().isVectorPrimitive()) ? 1 : 0;
+               return ret + cntBin + cntUn + cntTn + cntNn;
        }
        
        public static int getMaxLiveVectorIntermediates(CNode node, CNode main, 
Map<Long, Set<Long>> parents, Set<Pair<Long, Long>> stack) {
@@ -479,6 +484,7 @@ public class TemplateUtils
        }
        
        public static boolean isValidNumVectorIntermediates(CNode node, CNode 
main, Map<Long, Set<Long>> parents, Map<Long, Pair<Long, MutableInt>> inUse, 
Set<Long> inUse2, int count) {
+               if( count <= 1 ) return false;
                IDSequence buff = new IDSequence(true, count-1); //zero based
                inUse.clear(); inUse2.clear();
                node.resetVisitStatus();

Reply via email to