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 2016/03/25 21:40:09 UTC

[5/5] incubator-systemml git commit: [SYSTEMML-396] Fix multi-threaded cumulative aggregates (sparse, init)

[SYSTEMML-396] Fix multi-threaded cumulative aggregates (sparse, init)

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

Branch: refs/heads/master
Commit: d40081527fad512e08adb05c4490a4f35c050f8f
Parents: b2aec7a
Author: Matthias Boehm <mb...@us.ibm.com>
Authored: Fri Mar 25 13:37:25 2016 -0700
Committer: Matthias Boehm <mb...@us.ibm.com>
Committed: Fri Mar 25 13:39:27 2016 -0700

----------------------------------------------------------------------
 .../sysml/runtime/instructions/InstructionUtils.java     |  6 +++---
 .../apache/sysml/runtime/matrix/data/LibMatrixAgg.java   | 11 ++++++-----
 2 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/d4008152/src/main/java/org/apache/sysml/runtime/instructions/InstructionUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/InstructionUtils.java b/src/main/java/org/apache/sysml/runtime/instructions/InstructionUtils.java
index ae0fd30..675a7a0 100644
--- a/src/main/java/org/apache/sysml/runtime/instructions/InstructionUtils.java
+++ b/src/main/java/org/apache/sysml/runtime/instructions/InstructionUtils.java
@@ -538,11 +538,11 @@ public class InstructionUtils
 		if( f.getBuiltinFunctionCode()==BuiltinFunctionCode.CUMSUM ) 
 			return parseBasicAggregateUnaryOperator("uack+") ;
 		else if( f.getBuiltinFunctionCode()==BuiltinFunctionCode.CUMPROD ) 
-			return parseCumulativeAggregateUnaryOperator("uac*") ;
+			return parseBasicAggregateUnaryOperator("uac*") ;
 		else if( f.getBuiltinFunctionCode()==BuiltinFunctionCode.CUMMIN ) 
-			return parseCumulativeAggregateUnaryOperator("uacmin") ;
+			return parseBasicAggregateUnaryOperator("uacmin") ;
 		else if( f.getBuiltinFunctionCode()==BuiltinFunctionCode.CUMMAX ) 
-			return parseCumulativeAggregateUnaryOperator("uacmax" ) ;
+			return parseBasicAggregateUnaryOperator("uacmax" ) ;
 		
 		throw new RuntimeException("Unsupported cumulative aggregate unary operator: "+f.getBuiltinFunctionCode());
 	}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/d4008152/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixAgg.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixAgg.java b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixAgg.java
index e965b7e..d48a004 100644
--- a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixAgg.java
+++ b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixAgg.java
@@ -339,9 +339,11 @@ public class LibMatrixAgg
 	public static MatrixBlock cumaggregateUnaryMatrix(MatrixBlock in, MatrixBlock out, UnaryOperator uop, int k) 
 		throws DMLRuntimeException
 	{
-		//fall back to sequential version if necessary
+		AggregateUnaryOperator uaop = InstructionUtils.parseBasicCumulativeAggregateUnaryOperator(uop);
+		
+		//fall back to sequential if necessary or agg not supported
 		if(    k <= 1 || (long)in.rlen*in.clen < PAR_NUMCELL_THRESHOLD || in.rlen <= k
-			|| out.clen*8*k > PAR_INTERMEDIATE_SIZE_THRESHOLD ) {
+			|| out.clen*8*k > PAR_INTERMEDIATE_SIZE_THRESHOLD || uaop == null ) {
 			return cumaggregateUnaryMatrix(in, out, uop);
 		}
 		
@@ -370,7 +372,6 @@ public class LibMatrixAgg
 			int blklen = (int)(Math.ceil((double)m/k));
 			
 			//step 1: compute aggregates per row partition
-			AggregateUnaryOperator uaop = InstructionUtils.parseBasicCumulativeAggregateUnaryOperator(uop);
 			AggType uaoptype = getAggType(uaop);
 			ArrayList<PartialAggTask> tasks = new ArrayList<PartialAggTask>();
 			for( int i=0; i<k & i*blklen<m; i++ )
@@ -392,7 +393,7 @@ public class LibMatrixAgg
 			//step 3: compute final cumulative aggregate
 			ArrayList<CumAggTask> tasks2 = new ArrayList<CumAggTask>();
 			for( int i=0; i<k & i*blklen<m; i++ ) {
-				double[] agg = (i==0)? new double[n2] : 
+				double[] agg = (i==0)? null : 
 					DataConverter.convertToDoubleVector(tmp2.sliceOperations(i-1, i-1, 0, n2-1, new MatrixBlock()));
 				tasks2.add( new CumAggTask(in, agg, out, aggtype, uop, i*blklen, Math.min((i+1)*blklen, m)) );
 			}
@@ -2554,7 +2555,7 @@ public class LibMatrixAgg
 		int[] cnt = new int[ n ]; 
 
 		//compute column aggregates min/max
-		for( int i=0, ix=0; i<m; i++, ix+=n )
+		for( int i=rl, ix=rl*n; i<ru; i++, ix+=n )
 		{
 			if( !a.isEmpty(i) ) {
 				int apos = a.pos(i);