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/14 05:05:37 UTC

systemml git commit: [SYSTEMML-1509] Enable codegen runtime integration by default

Repository: systemml
Updated Branches:
  refs/heads/master 14b4d5487 -> 0b698a42a


[SYSTEMML-1509] Enable codegen runtime integration by default

This patch switches the code generator integration (during initial
compilation) from HOPs to runtime plans, which leaves the original HOP
DAGs unchanged (by only modifying the generated runtime plans) to
preserve the full operation semantics for dynamic recompilation. An
example, where this has major performance impact is GLM and similar
scripts (e.g., w/ complex function call patterns) that heavily rely on
dynamic recompilation. In GLM, the HOP codegen integration destroyed the
core pattern t(X) %*% (w * (X %*% ssX_p_CG)) by fusing only t(X) %*% (w
* tmp) because the size of w was unknown. During dynamic recompilation
the remaining parts cannot be fused any more because the contained
operations are unknown (other than dimension propagation and fusion
type). The codegen integration into dynamic recompilation remains
unchanged and hence does not induce additional overheads.

Additionally, this patch also makes some minor fixes for the handling of
recompilation status and empty inputs in outer product operators.


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

Branch: refs/heads/master
Commit: 0b698a42a5466cd42cb9e8c5513bd7015050fb88
Parents: 14b4d54
Author: Matthias Boehm <mb...@gmail.com>
Authored: Tue Jun 13 21:08:21 2017 -0700
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Tue Jun 13 21:59:17 2017 -0700

----------------------------------------------------------------------
 .../sysml/hops/codegen/SpoofCompiler.java       |  6 +++---
 .../sysml/hops/recompile/RecompileStatus.java   | 22 +++++++++++++-------
 .../apache/sysml/hops/recompile/Recompiler.java |  6 ++++--
 .../runtime/codegen/SpoofOuterProduct.java      | 14 ++++++-------
 4 files changed, 28 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/0b698a42/src/main/java/org/apache/sysml/hops/codegen/SpoofCompiler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/SpoofCompiler.java b/src/main/java/org/apache/sysml/hops/codegen/SpoofCompiler.java
index 857c187..a58e28d 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/SpoofCompiler.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/SpoofCompiler.java
@@ -100,7 +100,7 @@ public class SpoofCompiler
 	//internal configuration flags
 	public static boolean LDEBUG                      = false;
 	public static CompilerType JAVA_COMPILER          = CompilerType.JANINO; 
-	public static IntegrationType INTEGRATION         = IntegrationType.HOPS;
+	public static IntegrationType INTEGRATION         = IntegrationType.RUNTIME;
 	public static final boolean RECOMPILE_CODEGEN     = true;
 	public static final boolean PRUNE_REDUNDANT_PLANS = true;
 	public static PlanCachePolicy PLAN_CACHE_POLICY   = PlanCachePolicy.CSLH;
@@ -293,7 +293,7 @@ public class SpoofCompiler
 	{
 		//create copy of hop dag, call codegen, and generate instructions
 		return Recompiler.recompileHopsDag(sb, roots, 
-			new LocalVariableMap(), new RecompileStatus(), false, false, 0);
+			new LocalVariableMap(), new RecompileStatus(true), false, false, 0);
 	}
 	
 	public static ArrayList<Instruction> generateCodeFromHopDAGsToInst(Hop root) 
@@ -301,7 +301,7 @@ public class SpoofCompiler
 	{
 		//create copy of hop dag, call codegen, and generate instructions
 		return Recompiler.recompileHopsDag(root, 
-			new LocalVariableMap(), new RecompileStatus(), false, false, 0);
+			new LocalVariableMap(), new RecompileStatus(true), false, false, 0);
 	}
 	
 	

http://git-wip-us.apache.org/repos/asf/systemml/blob/0b698a42/src/main/java/org/apache/sysml/hops/recompile/RecompileStatus.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/recompile/RecompileStatus.java b/src/main/java/org/apache/sysml/hops/recompile/RecompileStatus.java
index 68b5d8e..c16244f 100644
--- a/src/main/java/org/apache/sysml/hops/recompile/RecompileStatus.java
+++ b/src/main/java/org/apache/sysml/hops/recompile/RecompileStatus.java
@@ -25,24 +25,30 @@ import org.apache.sysml.runtime.matrix.MatrixCharacteristics;
 
 public class RecompileStatus 
 {
+	private final HashMap<String, MatrixCharacteristics> _lastTWrites; 
+	private final boolean _initialCodegen;
 	
-	private HashMap<String, MatrixCharacteristics> _lastTWrites = null; 
+	public RecompileStatus() {
+		this(false);
+	}
 	
-	public RecompileStatus()
-	{
+	public RecompileStatus(boolean initialCodegen) {
 		_lastTWrites = new HashMap<String,MatrixCharacteristics>();
+		_initialCodegen = initialCodegen;
 	}
 	
-	public HashMap<String, MatrixCharacteristics> getTWriteStats()
-	{
+	public HashMap<String, MatrixCharacteristics> getTWriteStats() {
 		return _lastTWrites;
 	}
+	
+	public boolean isInitialCodegen() {
+		return _initialCodegen;
+	}
 
 	@Override
-	public Object clone()
-	{
+	public Object clone() {
 		RecompileStatus ret = new RecompileStatus();
-		ret._lastTWrites.putAll(this._lastTWrites);
+		ret._lastTWrites.putAll(_lastTWrites);
 		return ret;
 	}
 }

http://git-wip-us.apache.org/repos/asf/systemml/blob/0b698a42/src/main/java/org/apache/sysml/hops/recompile/Recompiler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/recompile/Recompiler.java b/src/main/java/org/apache/sysml/hops/recompile/Recompiler.java
index 25efecf..f156182 100644
--- a/src/main/java/org/apache/sysml/hops/recompile/Recompiler.java
+++ b/src/main/java/org/apache/sysml/hops/recompile/Recompiler.java
@@ -222,7 +222,8 @@ public class Recompiler
 			if( ConfigurationManager.getDMLConfig().getBooleanValue(DMLConfig.CODEGEN) 
 					&& SpoofCompiler.RECOMPILE_CODEGEN ) {
 				Hop.resetVisitStatus(hops);
-				hops = SpoofCompiler.optimize(hops, true);
+				hops = SpoofCompiler.optimize(hops, 
+					(status==null || !status.isInitialCodegen()));
 			}
 			
 			// construct lops			
@@ -330,7 +331,8 @@ public class Recompiler
 			if( ConfigurationManager.getDMLConfig().getBooleanValue(DMLConfig.CODEGEN) 
 					&& SpoofCompiler.RECOMPILE_CODEGEN ) {
 				hops.resetVisitStatus();
-				hops = SpoofCompiler.optimize(hops, false);
+				hops = SpoofCompiler.optimize(hops,
+					(status==null || !status.isInitialCodegen()));
 			}
 			
 			// construct lops			

http://git-wip-us.apache.org/repos/asf/systemml/blob/0b698a42/src/main/java/org/apache/sysml/runtime/codegen/SpoofOuterProduct.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofOuterProduct.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofOuterProduct.java
index 9d0203e..c66d065 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofOuterProduct.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofOuterProduct.java
@@ -152,11 +152,11 @@ public abstract class SpoofOuterProduct extends SpoofOperator
 			throw new RuntimeException("Invalid input arguments.");
 		
 		//check empty result
-		if(   (_outerProductType == OutProdType.LEFT_OUTER_PRODUCT && inputs.get(1).isEmptyBlock(false)) //U is empty
-				   || (_outerProductType == OutProdType.RIGHT_OUTER_PRODUCT &&  inputs.get(2).isEmptyBlock(false)) //V is empty
-				   || (_outerProductType == OutProdType.CELLWISE_OUTER_PRODUCT && inputs.get(0).isEmptyBlock(false))) {  //X is empty
-					out.examSparsity(); //turn empty dense into sparse
-					return; 
+		if( (_outerProductType == OutProdType.LEFT_OUTER_PRODUCT && inputs.get(1).isEmptyBlock(false)) //U is empty
+			|| (_outerProductType == OutProdType.RIGHT_OUTER_PRODUCT &&  inputs.get(2).isEmptyBlock(false)) //V is empty
+			|| inputs.get(0).isEmptyBlock(false) ) {  //X is empty
+			out.examSparsity(); //turn empty dense into sparse
+			return; 
 		}
 		
 		//input preparation and result allocation (Allocate the output that is set by Sigma2CPInstruction) 
@@ -232,8 +232,8 @@ public abstract class SpoofOuterProduct extends SpoofOperator
 		
 		//check empty result
 		if( (_outerProductType == OutProdType.LEFT_OUTER_PRODUCT && inputs.get(1).isEmptyBlock(false)) //U is empty
-			|| (_outerProductType == OutProdType.RIGHT_OUTER_PRODUCT &&  inputs.get(2).isEmptyBlock(false)) //V is empty
-			|| (_outerProductType == OutProdType.CELLWISE_OUTER_PRODUCT && inputs.get(0).isEmptyBlock(false))) {  //X is empty
+			|| (_outerProductType == OutProdType.RIGHT_OUTER_PRODUCT && inputs.get(2).isEmptyBlock(false)) //V is empty
+			|| inputs.get(0).isEmptyBlock(false) ) {  //X is empty
 			out.examSparsity(); //turn empty dense into sparse
 			return; 
 		}