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/02/11 02:59:22 UTC

[1/4] systemml git commit: [HOTFIX] Fix initialization of compressed matrix blocks (dim check)

Repository: systemml
Updated Branches:
  refs/heads/master 401b79657 -> 744df8139


[HOTFIX] Fix initialization of compressed matrix blocks (dim check)

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

Branch: refs/heads/master
Commit: 6e932951a8a24cb184c2ba0968c63ab4e96425b8
Parents: 401b796
Author: Matthias Boehm <mb...@gmail.com>
Authored: Sat Feb 10 13:06:34 2018 -0800
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Sat Feb 10 13:06:34 2018 -0800

----------------------------------------------------------------------
 .../org/apache/sysml/runtime/compress/CompressedMatrixBlock.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/6e932951/src/main/java/org/apache/sysml/runtime/compress/CompressedMatrixBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/compress/CompressedMatrixBlock.java b/src/main/java/org/apache/sysml/runtime/compress/CompressedMatrixBlock.java
index e5f8827..4867749 100644
--- a/src/main/java/org/apache/sysml/runtime/compress/CompressedMatrixBlock.java
+++ b/src/main/java/org/apache/sysml/runtime/compress/CompressedMatrixBlock.java
@@ -128,7 +128,7 @@ public class CompressedMatrixBlock extends MatrixBlock implements Externalizable
 	protected boolean _sharedDDC1Dict = false;
 	
 	public CompressedMatrixBlock() {
-		super(-1, -1, true);
+		super(0, 0, true);
 	}
 	
 	/**


[3/4] systemml git commit: [SYSTEMML-2145] Fix codegen row tmpl compiler/runtime for kmeans

Posted by mb...@apache.org.
[SYSTEMML-2145] Fix codegen row tmpl compiler/runtime for kmeans

This patch fixes two issues - caused by recent changes of the codegen
framework - that led to failures for large-scale kmeans runs.
Specifically, this includes (1) a fix to retain dense output formats for
incremental aggregation in spark codegen operations, and (2) a compiler
modification regarding constant output sizes.

Furthermore, this also includes a harding for sparse-unsafe row
operations over empty inputs.


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

Branch: refs/heads/master
Commit: d7e4c7c5fec81842b3c96fdd1a6c3f2ea7d0fa00
Parents: 056e48d
Author: Matthias Boehm <mb...@gmail.com>
Authored: Sat Feb 10 18:25:28 2018 -0800
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Sat Feb 10 18:25:28 2018 -0800

----------------------------------------------------------------------
 .../sysml/hops/codegen/template/TemplateRow.java     |  7 +++++--
 .../apache/sysml/runtime/codegen/SpoofRowwise.java   | 15 ++++++++++++---
 .../instructions/spark/SpoofSPInstruction.java       |  4 +++-
 3 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/d7e4c7c5/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRow.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRow.java b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRow.java
index 7cb67d0..f405516 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRow.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRow.java
@@ -53,6 +53,7 @@ import org.apache.sysml.hops.Hop.OpOp1;
 import org.apache.sysml.hops.Hop.OpOp2;
 import org.apache.sysml.hops.Hop.OpOpN;
 import org.apache.sysml.parser.Expression.DataType;
+import org.apache.sysml.runtime.codegen.SpoofRowwise.RowType;
 import org.apache.sysml.runtime.matrix.data.LibMatrixMult;
 import org.apache.sysml.runtime.matrix.data.Pair;
 
@@ -218,8 +219,10 @@ public class TemplateRow extends TemplateBase
 		CNodeRow tpl = new CNodeRow(inputs, output);
 		tpl.setRowType(TemplateUtils.getRowType(hop, 
 			inHops2.get("X"), inHops2.get("B1")));
-		if( tpl.getRowType().isConstDim2(hop.getDim2()) )
-			tpl.setConstDim2(hop.getDim2());
+		long n2 = tpl.getRowType()==RowType.COL_AGG_B1 ?
+			hop.getDim1() : hop.getDim2();
+		if( tpl.getRowType().isConstDim2(n2) )
+			tpl.setConstDim2(n2);
 		tpl.setNumVectorIntermediates(TemplateUtils
 			.determineMinVectorIntermediates(output));
 		tpl.getOutput().resetVisitStatus();

http://git-wip-us.apache.org/repos/asf/systemml/blob/d7e4c7c5/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 acc2e8d..b026b46 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java
@@ -169,7 +169,8 @@ public abstract class SpoofRowwise extends SpoofOperator
 			out = LibMatrixReorg.transpose(out, new MatrixBlock(
 				out.getNumColumns(), out.getNumRows(), false));
 		}
-		out.examSparsity();
+		if( !aggIncr )
+			out.examSparsity();
 		return out;
 	}
 	
@@ -289,8 +290,12 @@ public abstract class SpoofRowwise extends SpoofOperator
 	}
 	
 	private void executeDense(DenseBlock a, SideInput[] b, double[] scalars, DenseBlock c, int n, int rl, int ru) {
-		if( a == null )
+		//forward empty block to sparse
+		if( a == null ) {
+			executeSparse(null, b, scalars, c, n, rl, ru);
 			return;
+		}
+		
 		SideInput[] lb = createSparseSideInputs(b, true);
 		for( int i=rl; i<ru; i++ ) {
 			genexec(a.values(i), a.pos(i), lb, scalars,
@@ -314,8 +319,12 @@ public abstract class SpoofRowwise extends SpoofOperator
 	}
 	
 	private void executeCompressed(CompressedMatrixBlock a, SideInput[] b, double[] scalars, DenseBlock c, int n, int rl, int ru) {
-		if( a.isEmptyBlock(false) )
+		//forward empty block to sparse
+		if( a.isEmptyBlock(false) ) {
+			executeSparse(null, b, scalars, c, n, rl, ru);
 			return;
+		}
+		
 		SideInput[] lb = createSparseSideInputs(b, true);
 		Iterator<double[]> iter = a.getDenseRowIterator(rl, ru);
 		for( int i=rl; iter.hasNext(); i++ ) {

http://git-wip-us.apache.org/repos/asf/systemml/blob/d7e4c7c5/src/main/java/org/apache/sysml/runtime/instructions/spark/SpoofSPInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/spark/SpoofSPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/spark/SpoofSPInstruction.java
index 4022201..82b34df 100644
--- a/src/main/java/org/apache/sysml/runtime/instructions/spark/SpoofSPInstruction.java
+++ b/src/main/java/org/apache/sysml/runtime/instructions/spark/SpoofSPInstruction.java
@@ -477,8 +477,10 @@ public class SpoofSPInstruction extends SPInstruction {
 			
 			//cleanup and final result preparations
 			LibSpoofPrimitives.cleanupThreadLocalMemory();
-			if( aggIncr )
+			if( aggIncr ) {
+				blkOut.examSparsity(); //deferred format change
 				ret.add(new Tuple2<>(new MatrixIndexes(1,1), blkOut));
+			}
 			
 			return ret.iterator();
 		}


[4/4] systemml git commit: [SYSTEMML-2143] Fix missing sprop/sigmoid codegen support in row templ

Posted by mb...@apache.org.
[SYSTEMML-2143] Fix missing sprop/sigmoid codegen support in row templ

This patch adds codegen support for sprop (sample proportion) and
sigmoid in codegen row templates, which requires sparse and dense vector
primitives. So far we only supported scalar sprop and sigmoid in outer,
cell and magg templates.


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

Branch: refs/heads/master
Commit: 744df8139cbacaa5b65323768c099ae87121af3c
Parents: d7e4c7c
Author: Matthias Boehm <mb...@gmail.com>
Authored: Sat Feb 10 18:58:57 2018 -0800
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Sat Feb 10 18:58:57 2018 -0800

----------------------------------------------------------------------
 .../sysml/hops/codegen/cplan/CNodeUnary.java    | 37 ++++++++------
 .../hops/codegen/template/TemplateRow.java      |  4 +-
 .../runtime/codegen/LibSpoofPrimitives.java     | 52 ++++++++++++++++++++
 .../functions/codegen/RowAggTmplTest.java       | 34 ++++++++++++-
 .../scripts/functions/codegen/rowAggPattern37.R | 32 ++++++++++++
 .../functions/codegen/rowAggPattern37.dml       | 27 ++++++++++
 .../scripts/functions/codegen/rowAggPattern38.R | 32 ++++++++++++
 .../functions/codegen/rowAggPattern38.dml       | 27 ++++++++++
 8 files changed, 227 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/744df813/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeUnary.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeUnary.java b/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeUnary.java
index 83ddd28..a1401c3 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeUnary.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeUnary.java
@@ -36,6 +36,7 @@ public class CNodeUnary extends CNode
 		VECT_SIN, VECT_COS, VECT_TAN, VECT_ASIN, VECT_ACOS, VECT_ATAN, 
 		VECT_SINH, VECT_COSH, VECT_TANH,
 		VECT_CUMSUM, VECT_CUMMIN, VECT_CUMMAX,
+		VECT_SPROP, VECT_SIGMOID,
 		EXP, POW2, MULT2, SQRT, LOG, LOG_NZ,
 		ABS, ROUND, CEIL, FLOOR, SIGN, 
 		SIN, COS, TAN, ASIN, ACOS, ATAN, SINH, COSH, TANH,
@@ -81,7 +82,9 @@ public class CNodeUnary extends CNode
 				case VECT_TANH:
 				case VECT_CUMSUM:
 				case VECT_CUMMIN:
-				case VECT_CUMMAX:{
+				case VECT_CUMMAX:
+				case VECT_SPROP:
+				case VECT_SIGMOID: {
 					String vectName = getVectorPrimitiveName();
 					return sparse ? "    double[] %TMP% = LibSpoofPrimitives.vect"+vectName+"Write(%IN1v%, %IN1i%, %POS1%, alen, len);\n" : 
 									"    double[] %TMP% = LibSpoofPrimitives.vect"+vectName+"Write(%IN1%, %POS1%, %LEN%);\n";
@@ -89,20 +92,20 @@ public class CNodeUnary extends CNode
 					
 				case EXP:
 					return "    double %TMP% = FastMath.exp(%IN1%);\n";
-			    case LOOKUP_R:
-			    	return sparse ?
-			    		"    double %TMP% = getValue(%IN1v%, %IN1i%, ai, alen, 0);\n" :
-			    		"    double %TMP% = getValue(%IN1%, rix);\n";
-			    case LOOKUP_C:
-			    	return "    double %TMP% = getValue(%IN1%, n, 0, cix);\n";
-			    case LOOKUP_RC:
-			    	return "    double %TMP% = getValue(%IN1%, n, rix, cix);\n";	
+				case LOOKUP_R:
+					return sparse ?
+						"    double %TMP% = getValue(%IN1v%, %IN1i%, ai, alen, 0);\n" :
+						"    double %TMP% = getValue(%IN1%, rix);\n";
+				case LOOKUP_C:
+					return "    double %TMP% = getValue(%IN1%, n, 0, cix);\n";
+				case LOOKUP_RC:
+					return "    double %TMP% = getValue(%IN1%, n, rix, cix);\n";
 				case LOOKUP0:
-					return "    double %TMP% = %IN1%[0];\n" ;
+					return "    double %TMP% = %IN1%[0];\n";
 				case POW2:
-					return "    double %TMP% = %IN1% * %IN1%;\n" ;
+					return "    double %TMP% = %IN1% * %IN1%;\n";
 				case MULT2:
-					return "    double %TMP% = %IN1% + %IN1%;\n" ;
+					return "    double %TMP% = %IN1% + %IN1%;\n";
 				case ABS:
 					return "    double %TMP% = Math.abs(%IN1%);\n";
 				case SIN:
@@ -155,8 +158,8 @@ public class CNodeUnary extends CNode
 				|| this == VECT_SIN || this == VECT_COS || this == VECT_TAN
 				|| this == VECT_ASIN || this == VECT_ACOS || this == VECT_ATAN
 				|| this == VECT_SINH || this == VECT_COSH || this == VECT_TANH
-				|| this == VECT_CUMSUM || this == VECT_CUMMIN
-				|| this == VECT_CUMMAX;
+				|| this == VECT_CUMSUM || this == VECT_CUMMIN || this == VECT_CUMMAX
+				|| this == VECT_SPROP || this == VECT_SIGMOID;
 		}
 		public UnaryType getVectorAddPrimitive() {
 			return UnaryType.valueOf("VECT_"+getVectorPrimitiveName().toUpperCase()+"_ADD");
@@ -267,7 +270,9 @@ public class CNodeUnary extends CNode
 			case VECT_CUMSUM:
 			case VECT_CUMMIN:
 			case VECT_CUMMAX:
-			case VECT_SIGN: return "u(v"+_type.name().toLowerCase()+")";
+			case VECT_SIGN:
+			case VECT_SIGMOID:
+			case VECT_SPROP:return "u(v"+_type.name().toLowerCase()+")";
 			case LOOKUP_R:  return "u(ixr)";
 			case LOOKUP_C:  return "u(ixc)";
 			case LOOKUP_RC: return "u(ixrc)";
@@ -302,6 +307,8 @@ public class CNodeUnary extends CNode
 			case VECT_CUMSUM:
 			case VECT_CUMMIN:
 			case VECT_CUMMAX:
+			case VECT_SPROP:
+			case VECT_SIGMOID:
 				_rows = _inputs.get(0)._rows;
 				_cols = _inputs.get(0)._cols;
 				_dataType= DataType.MATRIX;

http://git-wip-us.apache.org/repos/asf/systemml/blob/744df813/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRow.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRow.java b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRow.java
index f405516..d133cc4 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRow.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/template/TemplateRow.java
@@ -63,7 +63,7 @@ public class TemplateRow extends TemplateBase
 	private static final Hop.OpOp1[] SUPPORTED_VECT_UNARY = new OpOp1[]{
 			OpOp1.EXP, OpOp1.SQRT, OpOp1.LOG, OpOp1.ABS, OpOp1.ROUND, OpOp1.CEIL, OpOp1.FLOOR, OpOp1.SIGN,
 			OpOp1.SIN, OpOp1.COS, OpOp1.TAN, OpOp1.ASIN, OpOp1.ACOS, OpOp1.ATAN, OpOp1.SINH, OpOp1.COSH, OpOp1.TANH,
-			OpOp1.CUMSUM, OpOp1.CUMMIN, OpOp1.CUMMAX};
+			OpOp1.CUMSUM, OpOp1.CUMMIN, OpOp1.CUMMAX, OpOp1.SPROP, OpOp1.SIGMOID};
 	private static final Hop.OpOp2[] SUPPORTED_VECT_BINARY = new OpOp2[]{
 			OpOp2.MULT, OpOp2.DIV, OpOp2.MINUS, OpOp2.PLUS, OpOp2.POW, OpOp2.MIN, OpOp2.MAX, OpOp2.XOR,
 			OpOp2.EQUAL, OpOp2.NOTEQUAL, OpOp2.LESS, OpOp2.LESSEQUAL, OpOp2.GREATER, OpOp2.GREATEREQUAL};
@@ -272,7 +272,7 @@ public class TemplateRow extends TemplateBase
 				if( cdata1 instanceof CNodeBinary && ((CNodeBinary)cdata1).getType().isVectorScalarPrimitive() )
 					out = new CNodeBinary(cdata1.getInput().get(0), cdata1.getInput().get(1),
 							((CNodeBinary)cdata1).getType().getVectorAddPrimitive());
-				else	
+				else
 					out = cdata1;
 			}
 			else if( ((AggUnaryOp)hop).getDirection() == Direction.RowCol && ((AggUnaryOp)hop).getOp() == AggOp.SUM ) {

http://git-wip-us.apache.org/repos/asf/systemml/blob/744df813/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 473d849..2f1a4a3 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/LibSpoofPrimitives.java
@@ -1504,6 +1504,58 @@ public class LibSpoofPrimitives
 			c[aix[j]] = Math.sqrt(a[j]);
 		return c;
 	}
+
+	//custom sprop
+	
+	public static void vectSpropAdd(double[] a, double[] c, int ai, int ci, int len) {
+		for( int j = ai; j < ai+len; j++, ci++)
+			c[ci] += a[j] * (1 - a[j]);
+	}
+
+	public static void vectSpropAdd(double[] a, double[] c, int[] aix, int ai, int ci, int alen, int len) {
+		for( int j = ai; j < ai+alen; j++ )
+			c[ci + aix[j]] += a[j] * (1 - a[j]);
+	}
+	
+	public static double[] vectSpropWrite(double[] a, int ai, int len) {
+		double[] c = allocVector(len, false);
+		for( int j = 0; j < len; j++, ai++)
+			c[j] = a[j] * (1 - a[j]);
+		return c;
+	}
+
+	public static double[] vectSpropWrite(double[] a, int[] aix, int ai, int alen, int len) {
+		double[] c = allocVector(len, true);
+		for( int j = ai; j < ai+alen; j++ )
+			c[aix[j]] = a[j] * (1 - a[j]);
+		return c;
+	}
+	
+	//custom sigmoid
+	
+	public static void vectSigmoidAdd(double[] a, double[] c, int ai, int ci, int len) {
+		for( int j = ai; j < ai+len; j++, ci++)
+			c[ci] +=  1 / (1 + FastMath.exp(-a[j]));
+	}
+
+	public static void vectSigmoidAdd(double[] a, double[] c, int[] aix, int ai, int ci, int alen, int len) {
+		for( int j = ai; j < ai+alen; j++ )
+			c[ci + aix[j]] += 1 / (1 + FastMath.exp(-a[j]));
+	}
+	
+	public static double[] vectSigmoidWrite(double[] a, int ai, int len) {
+		double[] c = allocVector(len, false);
+		for( int j = 0; j < len; j++, ai++)
+			c[j] = 1 / (1 + FastMath.exp(-a[j]));
+		return c;
+	}
+
+	public static double[] vectSigmoidWrite(double[] a, int[] aix, int ai, int alen, int len) {
+		double[] c = allocVector(len, true, 0.5); //sigmoid(0) = 0.5
+		for( int j = ai; j < ai+alen; j++ )
+			c[aix[j]] = 1 / (1 + FastMath.exp(-a[j]));
+		return c;
+	}
 	
 	//custom vector equal
 	

http://git-wip-us.apache.org/repos/asf/systemml/blob/744df813/src/test/java/org/apache/sysml/test/integration/functions/codegen/RowAggTmplTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/sysml/test/integration/functions/codegen/RowAggTmplTest.java b/src/test/java/org/apache/sysml/test/integration/functions/codegen/RowAggTmplTest.java
index 129178d..bd75c5b 100644
--- a/src/test/java/org/apache/sysml/test/integration/functions/codegen/RowAggTmplTest.java
+++ b/src/test/java/org/apache/sysml/test/integration/functions/codegen/RowAggTmplTest.java
@@ -73,6 +73,8 @@ public class RowAggTmplTest extends AutomatedTestBase
 	private static final String TEST_NAME34 = TEST_NAME+"34"; //X / rowSums(X!=0)
 	private static final String TEST_NAME35 = TEST_NAME+"35"; //cbind(X/rowSums(X), Y, Z)
 	private static final String TEST_NAME36 = TEST_NAME+"36"; //xor operation
+	private static final String TEST_NAME37 = TEST_NAME+"37"; //sprop(X/rowSums)
+	private static final String TEST_NAME38 = TEST_NAME+"38"; //sigmoid(X/rowSums)
 	
 	private static final String TEST_DIR = "functions/codegen/";
 	private static final String TEST_CLASS_DIR = TEST_DIR + RowAggTmplTest.class.getSimpleName() + "/";
@@ -84,7 +86,7 @@ public class RowAggTmplTest extends AutomatedTestBase
 	@Override
 	public void setUp() {
 		TestUtils.clearAssertionInformation();
-		for(int i=1; i<=36; i++)
+		for(int i=1; i<=38; i++)
 			addTestConfiguration( TEST_NAME+i, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME+i, new String[] { String.valueOf(i) }) );
 	}
 	
@@ -628,6 +630,36 @@ public class RowAggTmplTest extends AutomatedTestBase
 		testCodegenIntegration( TEST_NAME36, false, ExecType.SPARK );
 	}
 	
+	@Test
+	public void testCodegenRowAggRewrite37CP() {
+		testCodegenIntegration( TEST_NAME37, true, ExecType.CP );
+	}
+
+	@Test
+	public void testCodegenRowAgg37CP() {
+		testCodegenIntegration( TEST_NAME37, false, ExecType.CP );
+	}
+
+	@Test
+	public void testCodegenRowAgg37SP() {
+		testCodegenIntegration( TEST_NAME37, false, ExecType.SPARK );
+	}
+	
+	@Test
+	public void testCodegenRowAggRewrite38CP() {
+		testCodegenIntegration( TEST_NAME38, true, ExecType.CP );
+	}
+
+	@Test
+	public void testCodegenRowAgg38CP() {
+		testCodegenIntegration( TEST_NAME38, false, ExecType.CP );
+	}
+
+	@Test
+	public void testCodegenRowAgg38SP() {
+		testCodegenIntegration( TEST_NAME38, false, ExecType.SPARK );
+	}
+	
 	private void testCodegenIntegration( String testname, boolean rewrites, ExecType instType )
 	{
 		boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;

http://git-wip-us.apache.org/repos/asf/systemml/blob/744df813/src/test/scripts/functions/codegen/rowAggPattern37.R
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern37.R b/src/test/scripts/functions/codegen/rowAggPattern37.R
new file mode 100644
index 0000000..7cf0047
--- /dev/null
+++ b/src/test/scripts/functions/codegen/rowAggPattern37.R
@@ -0,0 +1,32 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+args<-commandArgs(TRUE)
+options(digits=22)
+library("Matrix")
+library("matrixStats")
+
+X = matrix(seq(1, 6000)/600, 300, 20, byrow=TRUE);
+
+Y = X/(rowSums(X)%*%matrix(1,1,ncol(X)))
+S = Y * (Y-1);
+
+writeMM(as(S, "CsparseMatrix"), paste(args[2], "S", sep=""));

http://git-wip-us.apache.org/repos/asf/systemml/blob/744df813/src/test/scripts/functions/codegen/rowAggPattern37.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern37.dml b/src/test/scripts/functions/codegen/rowAggPattern37.dml
new file mode 100644
index 0000000..fd6be93
--- /dev/null
+++ b/src/test/scripts/functions/codegen/rowAggPattern37.dml
@@ -0,0 +1,27 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+X = matrix(seq(1, 6000)/600, 300, 20);
+
+Y = X/rowSums(X)
+S = Y * (Y-1);
+
+write(S, $1);

http://git-wip-us.apache.org/repos/asf/systemml/blob/744df813/src/test/scripts/functions/codegen/rowAggPattern38.R
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern38.R b/src/test/scripts/functions/codegen/rowAggPattern38.R
new file mode 100644
index 0000000..fccf1a6
--- /dev/null
+++ b/src/test/scripts/functions/codegen/rowAggPattern38.R
@@ -0,0 +1,32 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+args<-commandArgs(TRUE)
+options(digits=22)
+library("Matrix")
+library("matrixStats")
+
+X = matrix(seq(1, 6000)/600, 300, 20, byrow=TRUE);
+
+Y = X/(rowSums(X)%*%matrix(1,1,ncol(X)))
+S = 1 / (1 + exp(-Y));
+
+writeMM(as(S, "CsparseMatrix"), paste(args[2], "S", sep=""));

http://git-wip-us.apache.org/repos/asf/systemml/blob/744df813/src/test/scripts/functions/codegen/rowAggPattern38.dml
----------------------------------------------------------------------
diff --git a/src/test/scripts/functions/codegen/rowAggPattern38.dml b/src/test/scripts/functions/codegen/rowAggPattern38.dml
new file mode 100644
index 0000000..b6d46c2
--- /dev/null
+++ b/src/test/scripts/functions/codegen/rowAggPattern38.dml
@@ -0,0 +1,27 @@
+#-------------------------------------------------------------
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#-------------------------------------------------------------
+
+X = matrix(seq(1, 6000)/600, 300, 20);
+
+Y = X/rowSums(X)
+S = 1 / (1 + exp(-Y));
+
+write(S, $1);


[2/4] systemml git commit: [SYSTEMML-2144] Disable codegen for config w/ forced gpu operations

Posted by mb...@apache.org.
[SYSTEMML-2144] Disable codegen for config w/ forced gpu operations

Until the codegen framework supports the generation of GPU operations,
we globally disable code generation in case of forced GPU acceleration.

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

Branch: refs/heads/master
Commit: 056e48d0cdd984c722797e71f2a4aec041c19690
Parents: 6e93295
Author: Matthias Boehm <mb...@gmail.com>
Authored: Sat Feb 10 13:51:06 2018 -0800
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Sat Feb 10 13:51:06 2018 -0800

----------------------------------------------------------------------
 .../java/org/apache/sysml/conf/ConfigurationManager.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/056e48d0/src/main/java/org/apache/sysml/conf/ConfigurationManager.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/conf/ConfigurationManager.java b/src/main/java/org/apache/sysml/conf/ConfigurationManager.java
index 0ddc78a..bbba53f 100644
--- a/src/main/java/org/apache/sysml/conf/ConfigurationManager.java
+++ b/src/main/java/org/apache/sysml/conf/ConfigurationManager.java
@@ -20,6 +20,7 @@
 package org.apache.sysml.conf;
 
 import org.apache.hadoop.mapred.JobConf;
+import org.apache.sysml.api.DMLScript;
 import org.apache.sysml.conf.CompilerConfig.ConfigType;
 import org.apache.sysml.runtime.matrix.mapred.MRConfigurationNames;
 import org.apache.sysml.runtime.matrix.mapred.MRJobConfiguration;
@@ -190,11 +191,14 @@ public class ConfigurationManager
 	}
 	
 	public static boolean isCodegenEnabled() {
-		return getDMLConfig().getBooleanValue(DMLConfig.CODEGEN)
-			|| getCompilerConfigFlag(ConfigType.CODEGEN_ENABLED);
+		return (getDMLConfig().getBooleanValue(DMLConfig.CODEGEN)
+			|| getCompilerConfigFlag(ConfigType.CODEGEN_ENABLED))
+			&& !DMLScript.USE_ACCELERATOR;
+		//note: until codegen is supported for the GPU backend, we globally
+		//disable codegen if operations are forced to the GPU to avoid
+		//a counter-productive impact on performance.
 	}
 	
-	
 	///////////////////////////////////////
 	// Thread-local classes