[SYSTEMML-2050] Fix print instruction scheduling (sort by line numbers)

This patch improves the new two-level instruction scheduling by
additionally sorting the partition of root nodes by line numbers, which
ensures that all prints appear in the order of their specification.
 

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

Branch: refs/heads/master
Commit: 47e50af3f48ed6b15574278dfb974640022e5619
Parents: e642469
Author: Matthias Boehm <[email protected]>
Authored: Tue Dec 12 16:16:04 2017 -0800
Committer: Matthias Boehm <[email protected]>
Committed: Tue Dec 12 18:56:04 2017 -0800

----------------------------------------------------------------------
 src/main/java/org/apache/sysml/lops/compile/Dag.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/47e50af3/src/main/java/org/apache/sysml/lops/compile/Dag.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/lops/compile/Dag.java 
b/src/main/java/org/apache/sysml/lops/compile/Dag.java
index 0326556..ab10363 100644
--- a/src/main/java/org/apache/sysml/lops/compile/Dag.java
+++ b/src/main/java/org/apache/sysml/lops/compile/Dag.java
@@ -3625,10 +3625,11 @@ public class Dag<N extends Lop>
        
        private ArrayList<Lop> doTopologicalSortTwoLevelOrder(ArrayList<Lop> v) 
{
                //partition nodes into leaf/inner nodes and dag root nodes,
-               //sort leaf/inner nodes by ID to force depth-first scheduling
+               //+ sort leaf/inner nodes by ID to force depth-first scheduling
+               //+ sort root nodes by line numbers to force ordering of prints 
                Lop[] nodearray = Stream.concat(
                        v.stream().filter(l -> 
!l.getOutputs().isEmpty()).sorted(Comparator.comparing(l -> l.getID())),
-                       v.stream().filter(l -> l.getOutputs().isEmpty()))
+                       v.stream().filter(l -> 
l.getOutputs().isEmpty()).sorted(Comparator.comparing(l -> l.getBeginLine())))
                        .toArray(Lop[]::new);
                
                return createIDMapping(nodearray);

Reply via email to