This is an automated email from the ASF dual-hosted git repository.

arnabp20 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/systemds.git


The following commit(s) were added to refs/heads/master by this push:
     new aa09b5c  [SYSTEMDS-2813] Add lineage specific flags to SystemDS-config
aa09b5c is described below

commit aa09b5c3d3b5d221426fd06871b6690e1297ee9e
Author: arnabp <[email protected]>
AuthorDate: Fri Jan 29 17:37:55 2021 +0100

    [SYSTEMDS-2813] Add lineage specific flags to SystemDS-config
    
    This patch adds two lineage specific configurations, enable/disable
    cache spilling and enable/disable compiler assisted dynamic
    rewrites. Both are true by default. These flags help in
    automating microbenchmarks.
---
 conf/SystemDS-config.xml.template                        |  8 +++++++-
 src/main/java/org/apache/sysds/conf/DMLConfig.java       |  6 +++++-
 .../rewrite/RewriteAlgebraicSimplificationDynamic.java   |  5 ++++-
 .../apache/sysds/runtime/lineage/LineageCacheConfig.java | 14 +++++++++-----
 .../sysds/test/functions/lineage/CacheEvictionTest.java  | 16 +++++++++++++---
 .../functions/lineage/SystemDS-config-eviction.xml       |  8 +++++++-
 6 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/conf/SystemDS-config.xml.template 
b/conf/SystemDS-config.xml.template
index 171cfb3..3f5c1db 100644
--- a/conf/SystemDS-config.xml.template
+++ b/conf/SystemDS-config.xml.template
@@ -93,4 +93,10 @@
     
     <!-- Allocator to use to allocate GPU device memory. Supported values are 
cuda, unified_memory (default: cuda) -->
     <sysds.gpu.memory.allocator>cuda</sysds.gpu.memory.allocator>
-</root>
\ No newline at end of file
+
+    <!-- enables disk spilling for lineage cache -->
+    <sysds.lineage.cachespill>true</sysds.lineage.cachespill>
+
+    <!-- enables compiler assisted partial rewrites (e.g. Append-TSMM) -->
+    <sysds.lineage.compilerassisted>true</sysds.lineage.compilerassisted>
+</root>
diff --git a/src/main/java/org/apache/sysds/conf/DMLConfig.java 
b/src/main/java/org/apache/sysds/conf/DMLConfig.java
index aaf4988..fdedc14 100644
--- a/src/main/java/org/apache/sysds/conf/DMLConfig.java
+++ b/src/main/java/org/apache/sysds/conf/DMLConfig.java
@@ -88,6 +88,8 @@ public class DMLConfig
        public static final String EAGER_CUDA_FREE      = 
"sysds.gpu.eager.cudaFree"; // boolean: whether to perform eager CUDA free on 
rmvar
        public static final String GPU_EVICTION_POLICY  = 
"sysds.gpu.eviction.policy"; // string: can be lru, lfu, min_evict
        public static final String LOCAL_SPARK_NUM_THREADS = 
"sysds.local.spark.number.threads";
+       public static final String LINEAGECACHESPILL    = 
"sysds.lineage.cachespill"; // boolean: whether to spill cache entries to disk
+       public static final String COMPILERASSISTED_RW  = 
"sysds.lineage.compilerassisted"; // boolean: whether to apply compiler 
assisted rewrites
        
        // Fraction of available memory to use. The available memory is 
computer when the GPUContext is created
        // to handle the tradeoff on calling cudaMemGetInfo too often.
@@ -137,6 +139,8 @@ public class DMLConfig
                _defaultVals.put(CODEGEN_LITERALS,       "1" );
                _defaultVals.put(NATIVE_BLAS,            "none" );
                _defaultVals.put(NATIVE_BLAS_DIR,        "none" );
+               _defaultVals.put(LINEAGECACHESPILL,      "true" );
+               _defaultVals.put(COMPILERASSISTED_RW,    "true" );
                _defaultVals.put(PRINT_GPU_MEMORY_INFO,  "false" );
                _defaultVals.put(EVICTION_SHADOW_BUFFERSIZE,  "0.0" );
                _defaultVals.put(STATS_MAX_WRAP_LEN,     "30" );
@@ -396,7 +400,7 @@ public class DMLConfig
                        COMPRESSED_LINALG, COMPRESSED_LOSSY, 
COMPRESSED_VALID_COMPRESSIONS, COMPRESSED_OVERLAPPING,
                        COMPRESSED_SAMPLING_RATIO, COMPRESSED_COCODE, 
COMPRESSED_TRANSPOSE,
                        CODEGEN, CODEGEN_API, CODEGEN_COMPILER, 
CODEGEN_OPTIMIZER, CODEGEN_PLANCACHE, CODEGEN_LITERALS,
-                       STATS_MAX_WRAP_LEN, PRINT_GPU_MEMORY_INFO,
+                       STATS_MAX_WRAP_LEN, LINEAGECACHESPILL, 
COMPILERASSISTED_RW, PRINT_GPU_MEMORY_INFO,
                        AVAILABLE_GPUS, SYNCHRONIZE_GPU, EAGER_CUDA_FREE, 
FLOATING_POINT_PRECISION, GPU_EVICTION_POLICY, 
                        LOCAL_SPARK_NUM_THREADS, EVICTION_SHADOW_BUFFERSIZE, 
GPU_MEMORY_ALLOCATOR, GPU_MEMORY_UTILIZATION_FACTOR,
                        USE_SSL_FEDERATED_COMMUNICATION, 
DEFAULT_FEDERATED_INITIALIZATION_TIMEOUT
diff --git 
a/src/main/java/org/apache/sysds/hops/rewrite/RewriteAlgebraicSimplificationDynamic.java
 
b/src/main/java/org/apache/sysds/hops/rewrite/RewriteAlgebraicSimplificationDynamic.java
index 191c35d..77efaf2 100644
--- 
a/src/main/java/org/apache/sysds/hops/rewrite/RewriteAlgebraicSimplificationDynamic.java
+++ 
b/src/main/java/org/apache/sysds/hops/rewrite/RewriteAlgebraicSimplificationDynamic.java
@@ -55,6 +55,8 @@ import org.apache.sysds.lops.MapMultChain.ChainType;
 import org.apache.sysds.parser.DataExpression;
 import org.apache.sysds.common.Types.DataType;
 import org.apache.sysds.common.Types.ValueType;
+import org.apache.sysds.conf.ConfigurationManager;
+import org.apache.sysds.conf.DMLConfig;
 
 /**
  * Rule: Algebraic Simplifications. Simplifies binary expressions
@@ -154,7 +156,8 @@ public class RewriteAlgebraicSimplificationDynamic extends 
HopRewriteRule
                        hi = removeUnnecessaryReorgOperation(hop, hi, i); 
//e.g., matrix(X) -> X, if dims(in)==dims(out); r(X)->X, if 1x1 dims
                        hi = removeUnnecessaryOuterProduct(hop, hi, i);   
//e.g., X*(Y%*%matrix(1,...) -> X*Y, if Y col vector
                        hi = removeUnnecessaryIfElseOperation(hop, hi, 
i);//e.g., ifelse(E, A, B) -> A, if E==TRUE or nnz(E)==length(E)
-                       hi = removeUnnecessaryAppendTSMM(hop, hi, i);     
//e.g., X = t(rbind(A,B,C)) %*% rbind(A,B,C) -> t(A)%*%A + t(B)%*%B + t(C)%*%C
+                       
if(ConfigurationManager.getDMLConfig().getBooleanValue(DMLConfig.COMPILERASSISTED_RW))
+                               hi = removeUnnecessaryAppendTSMM(hop, hi, i);   
  //e.g., X = t(rbind(A,B,C)) %*% rbind(A,B,C) -> t(A)%*%A + t(B)%*%B + t(C)%*%C
                        if(OptimizerUtils.ALLOW_OPERATOR_FUSION)
                                hi = fuseDatagenAndReorgOperation(hop, hi, i);  
  //e.g., t(rand(rows=10,cols=1)) -> rand(rows=1,cols=10), if one dim=1
                        hi = simplifyColwiseAggregate(hop, hi, i);        
//e.g., colsums(X) -> sum(X) or X, if col/row vector
diff --git 
a/src/main/java/org/apache/sysds/runtime/lineage/LineageCacheConfig.java 
b/src/main/java/org/apache/sysds/runtime/lineage/LineageCacheConfig.java
index 96604d2..be7bd0f 100644
--- a/src/main/java/org/apache/sysds/runtime/lineage/LineageCacheConfig.java
+++ b/src/main/java/org/apache/sysds/runtime/lineage/LineageCacheConfig.java
@@ -21,6 +21,8 @@ package org.apache.sysds.runtime.lineage;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.sysds.api.DMLScript;
+import org.apache.sysds.conf.ConfigurationManager;
+import org.apache.sysds.conf.DMLConfig;
 import org.apache.sysds.runtime.controlprogram.caching.MatrixObject;
 import org.apache.sysds.runtime.controlprogram.context.ExecutionContext;
 import org.apache.sysds.runtime.instructions.Instruction;
@@ -77,7 +79,7 @@ public class LineageCacheConfig
 
        //-------------DISK SPILLING RELATED CONFIGURATIONS--------------//
 
-       private static boolean _allowSpill = false;
+       //private static boolean _allowSpill = false;
        // Minimum reliable spilling estimate in milliseconds.
        public static final double MIN_SPILL_TIME_ESTIMATE = 10;
        // Minimum reliable data size for spilling estimate in MB.
@@ -170,7 +172,7 @@ public class LineageCacheConfig
        static {
                //setup static configuration parameters
                REUSE_OPCODES = OPCODES;
-               setSpill(true); 
+               //setSpill(true); 
                setCachePolicy(LineageCachePolicy.COSTNSIZE);
                setCompAssRW(true);
        }
@@ -308,13 +310,15 @@ public class LineageCacheConfig
                return (WEIGHTS[2] > 0);
        }
 
-       public static void setSpill(boolean toSpill) {
+       /*public static void setSpill(boolean toSpill) {
                _allowSpill = toSpill;
                // NOTE: _allowSpill only enables/disables disk spilling, but 
has 
                // no control over eviction order of cached items.
-       }
+       }*/
        
        public static boolean isSetSpill() {
-               return _allowSpill;
+               // Check if cachespill set in SystemDS-config (default true)
+               DMLConfig conf = ConfigurationManager.getDMLConfig();
+               return conf.getBooleanValue(DMLConfig.LINEAGECACHESPILL);
        }
 }
diff --git 
a/src/test/java/org/apache/sysds/test/functions/lineage/CacheEvictionTest.java 
b/src/test/java/org/apache/sysds/test/functions/lineage/CacheEvictionTest.java
index fa9bae6..93c1f05 100644
--- 
a/src/test/java/org/apache/sysds/test/functions/lineage/CacheEvictionTest.java
+++ 
b/src/test/java/org/apache/sysds/test/functions/lineage/CacheEvictionTest.java
@@ -20,6 +20,7 @@
 
 package org.apache.sysds.test.functions.lineage;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -27,7 +28,6 @@ import java.util.List;
 import org.apache.sysds.hops.OptimizerUtils;
 import org.apache.sysds.hops.recompile.Recompiler;
 import org.apache.sysds.runtime.lineage.Lineage;
-import org.apache.sysds.runtime.lineage.LineageCacheConfig;
 import org.apache.sysds.runtime.lineage.LineageCacheConfig.ReuseCacheType;
 import org.apache.sysds.runtime.lineage.LineageCacheStatistics;
 import org.apache.sysds.runtime.matrix.data.MatrixValue;
@@ -44,6 +44,8 @@ public class CacheEvictionTest extends LineageBase {
        protected static final String TEST_NAME1 = "CacheEviction2";
 
        protected String TEST_CLASS_DIR = TEST_DIR + 
CacheEvictionTest.class.getSimpleName() + "/";
+       private final static String TEST_CONF = "SystemDS-config-eviction.xml";
+       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
        
        @Override
        public void setUp() {
@@ -82,7 +84,6 @@ public class CacheEvictionTest extends LineageBase {
                        getAndLoadTestConfiguration(testname);
                        fullDMLScriptName = getScript();
                        Lineage.resetInternalState();
-                       LineageCacheConfig.setSpill(false); //disable spilling
                        
                        // LRU based eviction
                        List<String> proArgs = new ArrayList<>();
@@ -126,8 +127,17 @@ public class CacheEvictionTest extends LineageBase {
                finally {
                        OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
old_simplification;
                        OptimizerUtils.ALLOW_SUM_PRODUCT_REWRITES = 
old_sum_product;
-                       LineageCacheConfig.setSpill(true);
                        Recompiler.reinitRecompiler();
                }
        }
+       /**
+        * Override default configuration with custom test configuration to 
ensure
+        * scratch space and local temporary directory locations are also 
updated.
+        */
+       @Override
+       protected File getConfigTemplateFile() {
+               // Instrumentation in this test's output log to show custom 
configuration file used for template.
+               System.out.println("This test case overrides default 
configuration with " + TEST_CONF_FILE.getPath());
+               return TEST_CONF_FILE;
+       }
 }
diff --git a/conf/SystemDS-config.xml.template 
b/src/test/scripts/functions/lineage/SystemDS-config-eviction.xml
similarity index 94%
copy from conf/SystemDS-config.xml.template
copy to src/test/scripts/functions/lineage/SystemDS-config-eviction.xml
index 171cfb3..7234de9 100644
--- a/conf/SystemDS-config.xml.template
+++ b/src/test/scripts/functions/lineage/SystemDS-config-eviction.xml
@@ -93,4 +93,10 @@
     
     <!-- Allocator to use to allocate GPU device memory. Supported values are 
cuda, unified_memory (default: cuda) -->
     <sysds.gpu.memory.allocator>cuda</sysds.gpu.memory.allocator>
-</root>
\ No newline at end of file
+
+    <!-- enables disk spilling for lineage cache -->
+    <sysds.lineage.cachespill>false</sysds.lineage.cachespill>
+
+    <!-- enables compiler assisted partial rewrites (e.g. Append-TSMM) -->
+    <sysds.lineage.compilerassisted>true</sysds.lineage.compilerassisted>
+</root>

Reply via email to