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/06/22 06:07:30 UTC

[1/2] systemml git commit: [SYSTEMML-1730] Fix correctness codegen vector primitives (abs, sm-div)

Repository: systemml
Updated Branches:
  refs/heads/master 4de8d684f -> f516e4bdc


[SYSTEMML-1730] Fix correctness codegen vector primitives (abs, sm-div)

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

Branch: refs/heads/master
Commit: ea805c863cacba4a4b8ac5c02d4fbf9154a93277
Parents: 4de8d68
Author: Matthias Boehm <mb...@gmail.com>
Authored: Wed Jun 21 22:29:17 2017 -0700
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Wed Jun 21 22:29:17 2017 -0700

----------------------------------------------------------------------
 .../runtime/codegen/LibSpoofPrimitives.java      | 13 ++++++-------
 .../sysml/runtime/matrix/data/LibMatrixMult.java | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/ea805c86/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java b/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java
index 8e2b4b6..d9f20ef 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java
@@ -228,7 +228,7 @@ public class LibSpoofPrimitives
 	public static double[] vectDivWrite(double bval, double[] a, int ai, int len) {
 		double[] c = allocVector(len, false);
 		for( int j = 0; j < len; j++, ai++)
-			c[j] = bval / a[ai] / bval;
+			c[j] = bval / a[ai];
 		return c;
 	}
 	
@@ -327,12 +327,11 @@ public class LibSpoofPrimitives
 	//custom vector plus
 	
 	public static void vectPlusAdd(double[] a, double bval, double[] c, int ai, int ci, int len) {
-		for( int j = ai; j < ai+len; j++, ci++)
-			c[ci] +=  a[j] + bval;
+		LibMatrixMult.vectAdd(a, bval, c, ai, ci, len);
 	}
 	
 	public static void vectPlusAdd(double bval, double[] a, double[] c, int ai, int ci, int len) {
-		vectPlusAdd(a, bval, c, ai, ci, len);
+		LibMatrixMult.vectAdd(a, bval, c, ai, ci, len);
 	}
 
 	public static void vectPlusAdd(double[] a, double bval, double[] c, int[] aix, int ai, int ci, int len) {
@@ -610,20 +609,20 @@ public class LibSpoofPrimitives
 
 	public static void vectAbsAdd(double[] a, double[] c, int[] aix, int ai, int ci, int len) {
 		for( int j = ai; j < ai+len; j++ )
-			c[ci + aix[j]] += Math.log(a[j]);
+			c[ci + aix[j]] += Math.abs(a[j]);
 	}
 	
 	public static double[] vectAbsWrite(double[] a, int ai, int len) {
 		double[] c = allocVector(len, false);
 		for( int j = 0; j < len; j++, ai++)
-			c[j] = Math.log(a[ai]);
+			c[j] = Math.abs(a[ai]);
 		return c;
 	}
 
 	public static double[] vectAbsWrite(double[] a, int[] aix, int ai, int len) {
 		double[] c = allocVector(len, true);
 		for( int j = ai; j < ai+len; j++ )
-			c[aix[j]] = Math.log(a[j]);
+			c[aix[j]] = Math.abs(a[j]);
 		return c;
 	}
 	

http://git-wip-us.apache.org/repos/asf/systemml/blob/ea805c86/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
index f0f2196..0ed0090 100644
--- a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
+++ b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
@@ -3198,6 +3198,25 @@ public class LibMatrixMult
 	}
 
 	//note: public for use by codegen for consistency
+	public static void vectAdd( double[] a, double bval, double[] c, int ai, int ci, final int len ) {
+		final int bn = len%8;
+		//rest, not aligned to 8-blocks
+		for( int j = 0; j < bn; j++, ai++, ci++)
+			c[ ci ] += a[ ai ];
+		//unrolled 8-block  (for better ILP)
+		for( int j = bn; j < len; j+=8, ai+=8, ci+=8) {
+			c[ ci+0 ] += a[ ai+0 ] + bval;
+			c[ ci+1 ] += a[ ai+1 ] + bval;
+			c[ ci+2 ] += a[ ai+2 ] + bval;
+			c[ ci+3 ] += a[ ai+3 ] + bval;
+			c[ ci+4 ] += a[ ai+4 ] + bval;
+			c[ ci+5 ] += a[ ai+5 ] + bval;
+			c[ ci+6 ] += a[ ai+6 ] + bval;
+			c[ ci+7 ] += a[ ai+7 ] + bval;
+		}
+	}
+	
+	//note: public for use by codegen for consistency
 	public static void vectAdd( double[] a, double[] c, int ai, int ci, final int len )
 	{
 		final int bn = len%8;


[2/2] systemml git commit: [SYSTEMML-1624] Fix correctness matrix-scalar pow (sparse-safeness)

Posted by mb...@apache.org.
[SYSTEMML-1624] Fix correctness matrix-scalar pow (sparse-safeness)

This patch a correctness issue of right matrix-scalar pow operations and
the special case pow(X,0). This right scalar operator was marked
statically sparse-safe although it should be conditionally sparse-safe
if the given constant is not equal 0.


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

Branch: refs/heads/master
Commit: f516e4bdc9af606d2112564901ebb2e27467569d
Parents: ea805c8
Author: Matthias Boehm <mb...@gmail.com>
Authored: Wed Jun 21 23:07:52 2017 -0700
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Wed Jun 21 23:07:52 2017 -0700

----------------------------------------------------------------------
 .../runtime/matrix/operators/RightScalarOperator.java     | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/f516e4bd/src/main/java/org/apache/sysml/runtime/matrix/operators/RightScalarOperator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/matrix/operators/RightScalarOperator.java b/src/main/java/org/apache/sysml/runtime/matrix/operators/RightScalarOperator.java
index 9e87bcd..5a75c32 100644
--- a/src/main/java/org/apache/sysml/runtime/matrix/operators/RightScalarOperator.java
+++ b/src/main/java/org/apache/sysml/runtime/matrix/operators/RightScalarOperator.java
@@ -52,18 +52,12 @@ public class RightScalarOperator extends ScalarOperator
 			|| (fn instanceof GreaterThanEquals && _constant>0)
 			|| (fn instanceof LessThan && _constant<=0)
 			|| (fn instanceof LessThanEquals && _constant<0)
-			|| (fn instanceof Divide && _constant!=0));
+			|| (fn instanceof Divide && _constant!=0)
+			|| (fn instanceof Power && _constant!=0));
 	}
 	
 	@Override
 	public double executeScalar(double in) throws DMLRuntimeException {
 		return fn.execute(in, _constant);
 	}
-	
-	@Override
-	protected boolean isSparseSafeStatic() {
-		//add power as only rhs op sparse safe (1^0=1 but 0^1=0).
-		return (super.isSparseSafeStatic() 
-			|| fn instanceof Power);
-	}
 }