You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by mb...@apache.org on 2018/10/13 18:19:18 UTC

systemml git commit: [SYSTEMML-2486] Performance density map and layered graph estimators

Repository: systemml
Updated Branches:
  refs/heads/master ef1945d70 -> fc6f89128


[SYSTEMML-2486] Performance density map and layered graph estimators

This patch improves the runtime performance of the density map and
layered graph estimators by (1) forcing block sizes of power of two for
the density map to facilitate div shifting, and (2) reducing the default
number of rounds from 128 to 32 for the layered graph.


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

Branch: refs/heads/master
Commit: fc6f89128e6a5e1541bfaf5cb52dfdee49403a0c
Parents: ef1945d
Author: Matthias Boehm <mb...@gmail.com>
Authored: Sat Oct 13 20:15:49 2018 +0200
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Sat Oct 13 20:15:59 2018 +0200

----------------------------------------------------------------------
 .../org/apache/sysml/hops/estim/EstimatorDensityMap.java    | 9 +++++++++
 .../org/apache/sysml/hops/estim/EstimatorLayeredGraph.java  | 2 +-
 .../test/integration/functions/estim/OuterProductTest.java  | 8 ++++----
 .../test/integration/functions/estim/SelfProductTest.java   | 8 ++++----
 .../functions/estim/SquaredProductChainTest.java            | 8 ++++----
 .../integration/functions/estim/SquaredProductTest.java     | 8 ++++----
 6 files changed, 26 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/fc6f8912/src/main/java/org/apache/sysml/hops/estim/EstimatorDensityMap.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/estim/EstimatorDensityMap.java b/src/main/java/org/apache/sysml/hops/estim/EstimatorDensityMap.java
index 3206ab6..27e6dcf 100644
--- a/src/main/java/org/apache/sysml/hops/estim/EstimatorDensityMap.java
+++ b/src/main/java/org/apache/sysml/hops/estim/EstimatorDensityMap.java
@@ -193,6 +193,8 @@ public class EstimatorDensityMap extends SparsityEstimator
 			_b = b;
 			_map = init(in);
 			_scaled = false;
+			if( !isPow2(_b) )
+				throw new RuntimeException("Invalid block size: "+_b);
 		}
 		
 		public DensityMap(MatrixBlock map, int rlenOrig, int clenOrig, int b, boolean scaled) {
@@ -201,6 +203,8 @@ public class EstimatorDensityMap extends SparsityEstimator
 			_b = b;
 			_map = map;
 			_scaled = scaled;
+			if( !isPow2(_b) )
+				throw new RuntimeException("Invalid block size: "+_b);
 		}
 		
 		public int getNumRows() {
@@ -313,5 +317,10 @@ public class EstimatorDensityMap extends SparsityEstimator
 			out.recomputeNonZeros();
 			return out;
 		}
+		
+		private boolean isPow2(int value) {
+			double tmp = (Math.log(value) / Math.log(2));
+			return Math.floor(tmp) == Math.ceil(tmp);
+		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/systemml/blob/fc6f8912/src/main/java/org/apache/sysml/hops/estim/EstimatorLayeredGraph.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/estim/EstimatorLayeredGraph.java b/src/main/java/org/apache/sysml/hops/estim/EstimatorLayeredGraph.java
index 6130143..fa8adaa 100644
--- a/src/main/java/org/apache/sysml/hops/estim/EstimatorLayeredGraph.java
+++ b/src/main/java/org/apache/sysml/hops/estim/EstimatorLayeredGraph.java
@@ -41,7 +41,7 @@ import java.util.stream.Collectors;
  */
 public class EstimatorLayeredGraph extends SparsityEstimator {
 
-	private static final int ROUNDS = 128;
+	private static final int ROUNDS = 32;
 	private final int _rounds;
 	
 	public EstimatorLayeredGraph() {

http://git-wip-us.apache.org/repos/asf/systemml/blob/fc6f8912/src/test/java/org/apache/sysml/test/integration/functions/estim/OuterProductTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/sysml/test/integration/functions/estim/OuterProductTest.java b/src/test/java/org/apache/sysml/test/integration/functions/estim/OuterProductTest.java
index 70facf7..70ea63b 100644
--- a/src/test/java/org/apache/sysml/test/integration/functions/estim/OuterProductTest.java
+++ b/src/test/java/org/apache/sysml/test/integration/functions/estim/OuterProductTest.java
@@ -80,13 +80,13 @@ public class OuterProductTest extends AutomatedTestBase
 	}
 	
 	@Test
-	public void testDensityMap7Case1() {
-		runSparsityEstimateTest(new EstimatorDensityMap(7), m, k, n, case1);
+	public void testDensityMap8Case1() {
+		runSparsityEstimateTest(new EstimatorDensityMap(8), m, k, n, case1);
 	}
 	
 	@Test
-	public void testDensityMap7Case2() {
-		runSparsityEstimateTest(new EstimatorDensityMap(7), m, k, n, case2);
+	public void testDensityMap8Case2() {
+		runSparsityEstimateTest(new EstimatorDensityMap(8), m, k, n, case2);
 	}
 	
 	@Test

http://git-wip-us.apache.org/repos/asf/systemml/blob/fc6f8912/src/test/java/org/apache/sysml/test/integration/functions/estim/SelfProductTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/sysml/test/integration/functions/estim/SelfProductTest.java b/src/test/java/org/apache/sysml/test/integration/functions/estim/SelfProductTest.java
index 1d96e49..702514e 100644
--- a/src/test/java/org/apache/sysml/test/integration/functions/estim/SelfProductTest.java
+++ b/src/test/java/org/apache/sysml/test/integration/functions/estim/SelfProductTest.java
@@ -71,13 +71,13 @@ public class SelfProductTest extends AutomatedTestBase
 	}
 	
 	@Test
-	public void testDensityMap7Case1() {
-		runSparsityEstimateTest(new EstimatorDensityMap(7), m, sparsity1);
+	public void testDensityMap8Case1() {
+		runSparsityEstimateTest(new EstimatorDensityMap(8), m, sparsity1);
 	}
 	
 	@Test
-	public void testDensityMap7Case2() {
-		runSparsityEstimateTest(new EstimatorDensityMap(7), m, sparsity2);
+	public void testDensityMap8Case2() {
+		runSparsityEstimateTest(new EstimatorDensityMap(8), m, sparsity2);
 	}
 	
 	@Test

http://git-wip-us.apache.org/repos/asf/systemml/blob/fc6f8912/src/test/java/org/apache/sysml/test/integration/functions/estim/SquaredProductChainTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/sysml/test/integration/functions/estim/SquaredProductChainTest.java b/src/test/java/org/apache/sysml/test/integration/functions/estim/SquaredProductChainTest.java
index df2f3b4..7d97150 100644
--- a/src/test/java/org/apache/sysml/test/integration/functions/estim/SquaredProductChainTest.java
+++ b/src/test/java/org/apache/sysml/test/integration/functions/estim/SquaredProductChainTest.java
@@ -88,13 +88,13 @@ public class SquaredProductChainTest extends AutomatedTestBase
 	}
 	
 	@Test
-	public void testDensityMap7Case1() {
-		runSparsityEstimateTest(new EstimatorDensityMap(7), m, k, n, n2, case1);
+	public void testDensityMap8Case1() {
+		runSparsityEstimateTest(new EstimatorDensityMap(8), m, k, n, n2, case1);
 	}
 	
 	@Test
-	public void testDensityMap7Case2() {
-		runSparsityEstimateTest(new EstimatorDensityMap(7), m, k, n, n2, case2);
+	public void testDensityMap8Case2() {
+		runSparsityEstimateTest(new EstimatorDensityMap(8), m, k, n, n2, case2);
 	}
 	
 	@Test

http://git-wip-us.apache.org/repos/asf/systemml/blob/fc6f8912/src/test/java/org/apache/sysml/test/integration/functions/estim/SquaredProductTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/sysml/test/integration/functions/estim/SquaredProductTest.java b/src/test/java/org/apache/sysml/test/integration/functions/estim/SquaredProductTest.java
index 77c0b1d..51eb5d6 100644
--- a/src/test/java/org/apache/sysml/test/integration/functions/estim/SquaredProductTest.java
+++ b/src/test/java/org/apache/sysml/test/integration/functions/estim/SquaredProductTest.java
@@ -86,13 +86,13 @@ public class SquaredProductTest extends AutomatedTestBase
 	}
 	
 	@Test
-	public void testDensityMap7Case1() {
-		runSparsityEstimateTest(new EstimatorDensityMap(7), m, k, n, case1);
+	public void testDensityMap8Case1() {
+		runSparsityEstimateTest(new EstimatorDensityMap(8), m, k, n, case1);
 	}
 	
 	@Test
-	public void testDensityMap7Case2() {
-		runSparsityEstimateTest(new EstimatorDensityMap(7), m, k, n, case2);
+	public void testDensityMap8Case2() {
+		runSparsityEstimateTest(new EstimatorDensityMap(8), m, k, n, case2);
 	}
 	
 	@Test