Repository: systemml Updated Branches: refs/heads/master 0b51bb18c -> c27c488be
[SYSTEMML-1943] Configurable codegen optimizer (w/ default cost-based) This patch makes the (already pluggable) codegen optimizer configurable from outside of SystemML, which serves for testing purposes and as a fallback in case the default cost-based optimizer causes problems. Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/8ed25166 Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/8ed25166 Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/8ed25166 Branch: refs/heads/master Commit: 8ed251668f4d33bd5dbdf3c3acdc874f41a48f41 Parents: 0b51bb1 Author: Matthias Boehm <[email protected]> Authored: Sun Oct 1 15:50:05 2017 -0700 Committer: Matthias Boehm <[email protected]> Committed: Sun Oct 1 15:50:05 2017 -0700 ---------------------------------------------------------------------- conf/SystemML-config.xml.template | 3 +++ src/main/java/org/apache/sysml/conf/DMLConfig.java | 5 ++++- .../org/apache/sysml/hops/codegen/SpoofCompiler.java | 11 +++++++++-- src/main/java/org/apache/sysml/parser/DMLTranslator.java | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/8ed25166/conf/SystemML-config.xml.template ---------------------------------------------------------------------- diff --git a/conf/SystemML-config.xml.template b/conf/SystemML-config.xml.template index 6d5bf73..511e215 100644 --- a/conf/SystemML-config.xml.template +++ b/conf/SystemML-config.xml.template @@ -62,6 +62,9 @@ <!-- set the codegen java compiler (auto, janino, javac) --> <sysml.codegen.compiler>auto</sysml.codegen.compiler> + + <!-- set the codegen optimizer (fuse_all, fuse_no_redundancy, fuse_cost_based_v2) --> + <sysml.codegen.compiler>fuse_cost_based_v2</sysml.codegen.compiler> <!-- if codegen.enabled, enables source code caching of fused operators --> <sysml.codegen.plancache>true</sysml.codegen.plancache> http://git-wip-us.apache.org/repos/asf/systemml/blob/8ed25166/src/main/java/org/apache/sysml/conf/DMLConfig.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/conf/DMLConfig.java b/src/main/java/org/apache/sysml/conf/DMLConfig.java index 56f96e4..6a331a6 100644 --- a/src/main/java/org/apache/sysml/conf/DMLConfig.java +++ b/src/main/java/org/apache/sysml/conf/DMLConfig.java @@ -41,6 +41,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.sysml.hops.OptimizerUtils; import org.apache.sysml.hops.codegen.SpoofCompiler.CompilerType; +import org.apache.sysml.hops.codegen.SpoofCompiler.PlanSelector; import org.apache.sysml.lops.Compression; import org.apache.sysml.parser.ParseException; import org.apache.sysml.runtime.DMLRuntimeException; @@ -77,6 +78,7 @@ public class DMLConfig public static final String NATIVE_BLAS = "sysml.native.blas"; public static final String CODEGEN = "sysml.codegen.enabled"; //boolean public static final String CODEGEN_COMPILER = "sysml.codegen.compiler"; //see SpoofCompiler.CompilerType + public static final String CODEGEN_OPTIMIZER = "sysml.codegen.optimizer"; //see SpoofCompiler.PlanSelector public static final String CODEGEN_PLANCACHE = "sysml.codegen.plancache"; //boolean public static final String CODEGEN_LITERALS = "sysml.codegen.literals"; //1..heuristic, 2..always @@ -125,6 +127,7 @@ public class DMLConfig _defaultVals.put(COMPRESSED_LINALG, Compression.CompressConfig.AUTO.name() ); _defaultVals.put(CODEGEN, "false" ); _defaultVals.put(CODEGEN_COMPILER, CompilerType.AUTO.name() ); + _defaultVals.put(CODEGEN_COMPILER, PlanSelector.FUSE_COST_BASED_V2.name() ); _defaultVals.put(CODEGEN_PLANCACHE, "true" ); _defaultVals.put(CODEGEN_LITERALS, "1" ); _defaultVals.put(NATIVE_BLAS, "none" ); @@ -416,7 +419,7 @@ public class DMLConfig YARN_APPMASTER, YARN_APPMASTERMEM, YARN_MAPREDUCEMEM, CP_PARALLEL_OPS, CP_PARALLEL_IO, NATIVE_BLAS, COMPRESSED_LINALG, - CODEGEN, CODEGEN_COMPILER, CODEGEN_PLANCACHE, CODEGEN_LITERALS, + CODEGEN, CODEGEN_COMPILER, CODEGEN_OPTIMIZER, CODEGEN_PLANCACHE, CODEGEN_LITERALS, EXTRA_GPU_STATS, EXTRA_DNN_STATS, EXTRA_FINEGRAINED_STATS, STATS_MAX_WRAP_LEN, AVAILABLE_GPUS, SYNCHRONIZE_GPU, EAGER_CUDA_FREE }; http://git-wip-us.apache.org/repos/asf/systemml/blob/8ed25166/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 a4a68bb..a521918 100644 --- a/src/main/java/org/apache/sysml/hops/codegen/SpoofCompiler.java +++ b/src/main/java/org/apache/sysml/hops/codegen/SpoofCompiler.java @@ -108,13 +108,13 @@ public class SpoofCompiler //internal configuration flags public static boolean LDEBUG = false; public static CompilerType JAVA_COMPILER = CompilerType.JANINO; + public static PlanSelector PLAN_SEL_POLICY = PlanSelector.FUSE_COST_BASED_V2; 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; public static final int PLAN_CACHE_SIZE = 1024; //max 1K classes - public static final PlanSelector PLAN_SEL_POLICY = PlanSelector.FUSE_COST_BASED_V2; - + public enum CompilerType { AUTO, JAVAC, @@ -486,6 +486,13 @@ public class SpoofCompiler } } + public static void setConfiguredPlanSelector() { + DMLConfig conf = ConfigurationManager.getDMLConfig(); + String optimizer = conf.getTextValue(DMLConfig.CODEGEN_OPTIMIZER); + PlanSelector type = PlanSelector.valueOf(optimizer.toUpperCase()); + PLAN_SEL_POLICY = type; + } + public static void setExecTypeSpecificJavaCompiler() { DMLConfig conf = ConfigurationManager.getDMLConfig(); String compiler = conf.getTextValue(DMLConfig.CODEGEN_COMPILER); http://git-wip-us.apache.org/repos/asf/systemml/blob/8ed25166/src/main/java/org/apache/sysml/parser/DMLTranslator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/parser/DMLTranslator.java b/src/main/java/org/apache/sysml/parser/DMLTranslator.java index 40d0a1c..d669f73 100644 --- a/src/main/java/org/apache/sysml/parser/DMLTranslator.java +++ b/src/main/java/org/apache/sysml/parser/DMLTranslator.java @@ -297,6 +297,7 @@ public class DMLTranslator SpoofCompiler.PLAN_CACHE_POLICY = PlanCachePolicy.get( dmlconf.getBooleanValue(DMLConfig.CODEGEN_PLANCACHE), dmlconf.getIntValue(DMLConfig.CODEGEN_LITERALS)==2); + SpoofCompiler.setConfiguredPlanSelector(); SpoofCompiler.setExecTypeSpecificJavaCompiler(); if( SpoofCompiler.INTEGRATION==IntegrationType.HOPS ) codgenHopsDAG(dmlp);
