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 2017/09/28 07:20:47 UTC

systemml git commit: [MINOR] Tuning multi-threaded codegen ops (sparse-safe par thresholds)

Repository: systemml
Updated Branches:
  refs/heads/master e391e114e -> b5ef21fdc


[MINOR] Tuning multi-threaded codegen ops (sparse-safe par thresholds)

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

Branch: refs/heads/master
Commit: b5ef21fdcad73852d878ac519a0959092393af20
Parents: e391e11
Author: Matthias Boehm <mb...@gmail.com>
Authored: Wed Sep 27 23:49:39 2017 -0700
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Wed Sep 27 23:49:39 2017 -0700

----------------------------------------------------------------------
 .../sysml/runtime/codegen/SpoofCellwise.java    | 20 ++++++++++++--------
 .../runtime/codegen/SpoofMultiAggregate.java    |  4 +++-
 .../sysml/runtime/codegen/SpoofOperator.java    |  5 +++++
 .../sysml/runtime/codegen/SpoofRowwise.java     |  2 +-
 4 files changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/b5ef21fd/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
index 5f937f6..59308d4 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
@@ -116,10 +116,6 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		if( inputs==null || inputs.size() < 1  )
 			throw new RuntimeException("Invalid input arguments.");
 		
-		if( getTotalInputNnz(inputs) < PAR_NUMCELL_THRESHOLD ) {
-			k = 1; //serial execution
-		}
-		
 		//input preparation
 		MatrixBlock a = inputs.get(0);
 		SideInput[] b = prepInputMatrices(inputs);
@@ -131,6 +127,12 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		boolean sparseSafe = isSparseSafe() || (b.length == 0
 				&& genexec( 0, b, scalars, m, n, 0, 0 ) == 0);
 		
+		long inputSize = sparseSafe ? 
+			getTotalInputNnz(inputs) : getTotalInputSize(inputs);
+		if( inputSize < PAR_NUMCELL_THRESHOLD ) {
+			k = 1; //serial execution
+		}
+		
 		double ret = 0;
 		if( k <= 1 ) //SINGLE-THREADED
 		{
@@ -199,10 +201,6 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		if( inputs==null || inputs.size() < 1 || out==null )
 			throw new RuntimeException("Invalid input arguments.");
 		
-		if( getTotalInputNnz(inputs) < PAR_NUMCELL_THRESHOLD ) {
-			k = 1; //serial execution
-		}
-		
 		//input preparation
 		MatrixBlock a = inputs.get(0);
 		SideInput[] b = prepInputMatrices(inputs);
@@ -214,6 +212,12 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		boolean sparseSafe = isSparseSafe() || (b.length == 0
 				&& genexec( 0, b, scalars, m, n, 0, 0 ) == 0);
 		
+		long inputSize = sparseSafe ? 
+			getTotalInputNnz(inputs) : getTotalInputSize(inputs);
+		if( inputSize < PAR_NUMCELL_THRESHOLD ) {
+			k = 1; //serial execution
+		}
+		
 		//result allocation and preparations
 		boolean sparseOut = _type == CellType.NO_AGG
 			&& sparseSafe && a.isInSparseFormat();

http://git-wip-us.apache.org/repos/asf/systemml/blob/b5ef21fd/src/main/java/org/apache/sysml/runtime/codegen/SpoofMultiAggregate.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofMultiAggregate.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofMultiAggregate.java
index 4aa91bb..3f45d62 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofMultiAggregate.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofMultiAggregate.java
@@ -85,7 +85,9 @@ public abstract class SpoofMultiAggregate extends SpoofOperator implements Seria
 		if( inputs==null || inputs.size() < 1  )
 			throw new RuntimeException("Invalid input arguments.");
 		
-		if( getTotalInputNnz(inputs) < PAR_NUMCELL_THRESHOLD ) {
+		long inputSize = isSparseSafe() ?
+			getTotalInputNnz(inputs) : getTotalInputSize(inputs);
+		if( inputSize < PAR_NUMCELL_THRESHOLD ) {
 			k = 1; //serial execution
 		}
 	

http://git-wip-us.apache.org/repos/asf/systemml/blob/b5ef21fd/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java
index 156c5ff..bec488b 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java
@@ -156,6 +156,11 @@ public abstract class SpoofOperator implements Serializable
 		return inputs.stream().mapToLong(in -> in.getNonZeros()).sum();
 	}
 	
+	public static long getTotalInputSize(ArrayList<MatrixBlock> inputs) {
+		return inputs.stream().mapToLong(
+			in -> (long)in.getNumRows() * in.getNumColumns()).sum();
+	}
+	
 	//abstraction for safely accessing sideways matrices without the need 
 	//to allocate empty matrices as dense, see prepInputMatrices
 	

http://git-wip-us.apache.org/repos/asf/systemml/blob/b5ef21fd/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java
index 2464b15..8b12e7e 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java
@@ -170,7 +170,7 @@ public abstract class SpoofRowwise extends SpoofOperator
 	{
 		//redirect to serial execution
 		if( k <= 1 || (_type.isColumnAgg() && !LibMatrixMult.checkParColumnAgg(inputs.get(0), k, false))
-			|| getTotalInputNnz(inputs) < PAR_NUMCELL_THRESHOLD ) {
+			|| getTotalInputSize(inputs) < PAR_NUMCELL_THRESHOLD ) {
 			return execute(inputs, scalarObjects, out);
 		}