[SYSTEMML-2070] Refactoring codegen tests, incl new stepwise tests

This patch refactors the existing codegen testsuite by splitting it into
two testsuite for expressions and algorithms. Furthermore, this also
includes new tests for stepwise linregDS and GLM, which are otherwise
not included in SystemML's testsuite.


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

Branch: refs/heads/master
Commit: 98595c52f59d5007cf0c46d9476a5a11b0bfe775
Parents: 523f82f
Author: Matthias Boehm <[email protected]>
Authored: Sat Jan 13 16:22:10 2018 -0800
Committer: Matthias Boehm <[email protected]>
Committed: Sat Jan 13 17:52:43 2018 -0800

----------------------------------------------------------------------
 .../functions/codegen/AlgorithmARIMA.java       |   52 -
 .../functions/codegen/AlgorithmAutoEncoder.java |  180 ---
 .../functions/codegen/AlgorithmGLM.java         |  266 -----
 .../functions/codegen/AlgorithmKMeans.java      |  196 ----
 .../functions/codegen/AlgorithmL2SVM.java       |  168 ---
 .../functions/codegen/AlgorithmLinregCG.java    |  246 ----
 .../functions/codegen/AlgorithmMDABivar.java    |   52 -
 .../functions/codegen/AlgorithmMLogreg.java     |  286 -----
 .../functions/codegen/AlgorithmMSVM.java        |  166 ---
 .../functions/codegen/AlgorithmPNMF.java        |  152 ---
 .../functions/codegenalg/AlgorithmARIMA.java    |   52 +
 .../codegenalg/AlgorithmAutoEncoder.java        |  180 +++
 .../functions/codegenalg/AlgorithmGLM.java      |  266 +++++
 .../functions/codegenalg/AlgorithmKMeans.java   |  196 ++++
 .../functions/codegenalg/AlgorithmL2SVM.java    |  168 +++
 .../functions/codegenalg/AlgorithmLinregCG.java |  246 ++++
 .../functions/codegenalg/AlgorithmMDABivar.java |   52 +
 .../functions/codegenalg/AlgorithmMLogreg.java  |  286 +++++
 .../functions/codegenalg/AlgorithmMSVM.java     |  166 +++
 .../functions/codegenalg/AlgorithmPNMF.java     |  152 +++
 .../codegenalg/AlgorithmStepwiseRegression.java |  208 ++++
 .../scripts/functions/codegen/Algorithm_GLM.R   | 1081 ------------------
 .../scripts/functions/codegen/Algorithm_L2SVM.R |  108 --
 .../functions/codegen/Algorithm_LinregCG.R      |  159 ---
 .../functions/codegen/Algorithm_MLogreg.R       |  280 -----
 .../scripts/functions/codegen/Algorithm_MSVM.R  |  133 ---
 .../scripts/functions/codegen/Algorithm_PNMF.R  |   43 -
 .../functions/codegenalg/Algorithm_GLM.R        | 1081 ++++++++++++++++++
 .../functions/codegenalg/Algorithm_L2SVM.R      |  108 ++
 .../functions/codegenalg/Algorithm_LinregCG.R   |  159 +++
 .../functions/codegenalg/Algorithm_MLogreg.R    |  280 +++++
 .../functions/codegenalg/Algorithm_MSVM.R       |  133 +++
 .../functions/codegenalg/Algorithm_PNMF.R       |   43 +
 .../codegenalg/SystemML-config-codegen.xml      |   27 +
 .../functions/codegen/ZPackageSuite.java        |   10 -
 .../functions/codegenalg/ZPackageSuite.java     |   45 +
 36 files changed, 3848 insertions(+), 3578 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmARIMA.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmARIMA.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmARIMA.java
deleted file mode 100644
index 248eb82..0000000
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmARIMA.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.sysml.test.integration.functions.codegen;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.io.File;
-
-import org.apache.sysml.test.integration.applications.ArimaTest;
-
-@RunWith(value = Parameterized.class)
-public class AlgorithmARIMA extends ArimaTest 
-{
-       private final static String LOCAL_TEST_DIR = "functions/codegen/";
-       private final static String TEST_CONF = "SystemML-config-codegen.xml";
-       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
LOCAL_TEST_DIR, TEST_CONF);
-       
-       public AlgorithmARIMA(int m, int p, int d, int q, int P, int D, int Q, 
int s, int include_mean, int useJacobi) {
-               super(m, p, d, q, P, D, Q, s, include_mean, useJacobi);
-               TEST_CLASS_DIR = TEST_DIR + 
AlgorithmARIMA.class.getSimpleName() + "/";
-       }
-
-       @Test
-       public void testArimaDml() {
-               testArima(ScriptType.DML);
-       }
-       
-       @Override
-       protected File getConfigTemplateFile() {
-               System.out.println("This test case overrides default 
configuration with " + TEST_CONF_FILE.getPath());
-               return TEST_CONF_FILE;
-       }
-}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmAutoEncoder.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmAutoEncoder.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmAutoEncoder.java
deleted file mode 100644
index 70f5324..0000000
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmAutoEncoder.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.sysml.test.integration.functions.codegen;
-
-import java.io.File;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.sysml.api.DMLScript;
-import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
-import org.apache.sysml.hops.OptimizerUtils;
-import org.apache.sysml.lops.LopProperties.ExecType;
-import org.apache.sysml.test.integration.AutomatedTestBase;
-import org.apache.sysml.test.integration.TestConfiguration;
-import org.apache.sysml.test.utils.TestUtils;
-
-public class AlgorithmAutoEncoder extends AutomatedTestBase 
-{
-       private final static String TEST_NAME1 = "Algorithm_AutoEncoder";
-       private final static String TEST_DIR = "functions/codegen/";
-       private final static String TEST_CLASS_DIR = TEST_DIR + 
AlgorithmAutoEncoder.class.getSimpleName() + "/";
-       private final static String TEST_CONF = "SystemML-config-codegen.xml";
-       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
-       
-       private final static int rows = 2468;
-       private final static int cols = 784;
-       
-       private final static double sparsity1 = 0.7; //dense
-       private final static double sparsity2 = 0.1; //sparse
-       
-       private final static int H1 = 500;
-       private final static int H2 = 2;
-       private final static double epochs = 2; 
-       
-       @Override
-       public void setUp() {
-               TestUtils.clearAssertionInformation();
-               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "w" })); 
-       }
-
-       @Test
-       public void testAutoEncoder256DenseCP() {
-               runGLMTest(256, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testAutoEncoder256DenseRewritesCP() {
-               runGLMTest(256, false, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testAutoEncoder256SparseCP() {
-               runGLMTest(256, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testAutoEncoder256SparseRewritesCP() {
-               runGLMTest(256, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testAutoEncoder512DenseCP() {
-               runGLMTest(512, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testAutoEncoder512DenseRewritesCP() {
-               runGLMTest(512, false, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testAutoEncoder512SparseCP() {
-               runGLMTest(512, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testAutoEncoder512SparseRewritesCP() {
-               runGLMTest(512, true, true, ExecType.CP);
-       }
-       
-       //Note: limited cases for SPARK, as lazy evaluation 
-       //causes very long execution time for this algorithm
-       
-       @Test
-       public void testAutoEncoder256DenseRewritesSpark() {
-               runGLMTest(256, false, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testAutoEncoder256SparseRewritesSpark() {
-               runGLMTest(256, true, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testAutoEncoder512DenseRewritesSpark() {
-               runGLMTest(512, false, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testAutoEncoder512SparseRewritesSpark() {
-               runGLMTest(512, true, true, ExecType.SPARK);
-       }
-       
-       private void runGLMTest(int batchsize, boolean sparse, boolean 
rewrites, ExecType instType)
-       {
-               boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
-               RUNTIME_PLATFORM platformOld = rtplatform;
-               switch( instType ){
-                       case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break;
-                       case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break;
-                       default: rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK; 
break;
-               }
-       
-               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
-               if( rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == 
RUNTIME_PLATFORM.HYBRID_SPARK )
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
-
-               try
-               {
-                       String TEST_NAME = TEST_NAME1;
-                       TestConfiguration config = 
getTestConfiguration(TEST_NAME);
-                       loadTestConfiguration(config);
-                       
-                       fullDMLScriptName = 
"scripts/staging/autoencoder-2layer.dml";
-                       programArgs = new String[]{ "-explain", "-stats", 
"-nvargs", "X="+input("X"),
-                               "H1="+H1, "H2="+H2, "EPOCH="+epochs, 
"BATCH="+batchsize, 
-                               "W1_out="+output("W1"), "b1_out="+output("b1"),
-                               "W2_out="+output("W2"), "b2_out="+output("b2"),
-                               "W3_out="+output("W3"), "b3_out="+output("b3"),
-                               "W4_out="+output("W4"), "b4_out="+output("b4")};
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
rewrites;
-                       
-                       //generate actual datasets
-                       double[][] X = getRandomMatrix(rows, cols, 0, 1, 
sparse?sparsity2:sparsity1, 714);
-                       writeInputMatrixWithMTD("X", X, true);
-                       
-                       //run script
-                       runTest(true, false, null, -1); 
-                       //TODO R script
-                       
-                       
Assert.assertTrue(heavyHittersContainsSubString("spoof") 
-                               || heavyHittersContainsSubString("sp_spoof"));
-               }
-               finally {
-                       rtplatform = platformOld;
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlag;
-                       OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
-                       OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
-               }
-       }
-
-       /**
-        * 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;
-       }
-}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmGLM.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmGLM.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmGLM.java
deleted file mode 100644
index 00dd593..0000000
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmGLM.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.sysml.test.integration.functions.codegen;
-
-import java.io.File;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.sysml.api.DMLScript;
-import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
-import org.apache.sysml.hops.OptimizerUtils;
-import org.apache.sysml.lops.LopProperties.ExecType;
-import org.apache.sysml.test.integration.AutomatedTestBase;
-import org.apache.sysml.test.integration.TestConfiguration;
-import org.apache.sysml.test.utils.TestUtils;
-
-public class AlgorithmGLM extends AutomatedTestBase 
-{      
-       private final static String TEST_NAME1 = "Algorithm_GLM";
-       private final static String TEST_DIR = "functions/codegen/";
-       private final static String TEST_CLASS_DIR = TEST_DIR + 
AlgorithmGLM.class.getSimpleName() + "/";
-       private final static String TEST_CONF = "SystemML-config-codegen.xml";
-       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
-       
-       //private final static double eps = 1e-5;
-       
-       private final static int rows = 2468;
-       private final static int cols = 1007;
-               
-       private final static double sparsity1 = 0.7; //dense
-       private final static double sparsity2 = 0.1; //sparse
-       
-       private final static int intercept = 0;
-       private final static double epsilon = 0.000000001;
-       private final static double maxiter = 5; //inner/outer
-       
-       public enum GLMType {
-               POISSON_LOG,
-               GAMMA_LOG,
-               BINOMIAL_PROBIT,
-       }
-       
-       @Override
-       public void setUp() {
-               TestUtils.clearAssertionInformation();
-               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "w" })); 
-       }
-
-       @Test
-       public void testGLMPoissonDenseRewritesCP() {
-               runGLMTest(GLMType.POISSON_LOG, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMPoissonSparseRewritesCP() {
-               runGLMTest(GLMType.POISSON_LOG, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMPoissonDenseCP() {
-               runGLMTest(GLMType.POISSON_LOG, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMPoissonSparseCP() {
-               runGLMTest(GLMType.POISSON_LOG, false, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMGammaDenseRewritesCP() {
-               runGLMTest(GLMType.GAMMA_LOG, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMGammaSparseRewritesCP() {
-               runGLMTest(GLMType.GAMMA_LOG, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMGammaDenseCP() {
-               runGLMTest(GLMType.GAMMA_LOG, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMGammaSparseCP() {
-               runGLMTest(GLMType.GAMMA_LOG, false, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMBinomialDenseRewritesCP() {
-               runGLMTest(GLMType.BINOMIAL_PROBIT, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMBinomialSparseRewritesCP() {
-               runGLMTest(GLMType.BINOMIAL_PROBIT, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMBinomialDenseCP() {
-               runGLMTest(GLMType.BINOMIAL_PROBIT, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMBinomialSparseCP() {
-               runGLMTest(GLMType.BINOMIAL_PROBIT, false, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testGLMPoissonDenseRewritesSP() {
-               runGLMTest(GLMType.POISSON_LOG, true, false, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMPoissonSparseRewritesSP() {
-               runGLMTest(GLMType.POISSON_LOG, true, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMPoissonDenseSP() {
-               runGLMTest(GLMType.POISSON_LOG, false, false, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMPoissonSparseSP() {
-               runGLMTest(GLMType.POISSON_LOG, false, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMGammaDenseRewritesSP() {
-               runGLMTest(GLMType.GAMMA_LOG, true, false, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMGammaSparseRewritesSP() {
-               runGLMTest(GLMType.GAMMA_LOG, true, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMGammaDenseSP() {
-               runGLMTest(GLMType.GAMMA_LOG, false, false, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMGammaSparseSP() {
-               runGLMTest(GLMType.GAMMA_LOG, false, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMBinomialDenseRewritesSP() {
-               runGLMTest(GLMType.BINOMIAL_PROBIT, true, false, 
ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMBinomialSparseRewritesSP() {
-               runGLMTest(GLMType.BINOMIAL_PROBIT, true, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMBinomialDenseSP() {
-               runGLMTest(GLMType.BINOMIAL_PROBIT, false, false, 
ExecType.SPARK);
-       }
-       
-       @Test
-       public void testGLMBinomialSparseSP() {
-               runGLMTest(GLMType.BINOMIAL_PROBIT, false, true, 
ExecType.SPARK);
-       }
-       
-       private void runGLMTest( GLMType type, boolean rewrites, boolean 
sparse, ExecType instType)
-       {
-               boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
-               RUNTIME_PLATFORM platformOld = rtplatform;
-               switch( instType ){
-                       case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break;
-                       case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break;
-                       default: rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK; 
break;
-               }
-       
-               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
-               if( rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == 
RUNTIME_PLATFORM.HYBRID_SPARK )
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
-
-               try
-               {
-                       String TEST_NAME = TEST_NAME1;
-                       TestConfiguration config = 
getTestConfiguration(TEST_NAME);
-                       loadTestConfiguration(config);
-                       
-                       String[] addArgs = new String[4];
-                       String param4Name = "lpow=";
-                       switch(type) {
-                               case POISSON_LOG: //dfam, vpow, link, lpow
-                                       addArgs[0] = "1"; addArgs[1] = "1.0"; 
addArgs[2] = "1"; addArgs[3] = "0.0";
-                                       break;
-                               case GAMMA_LOG:   //dfam, vpow, link, lpow
-                                       addArgs[0] = "1"; addArgs[1] = "2.0"; 
addArgs[2] = "1"; addArgs[3] = "0.0";
-                                       break;
-                               case BINOMIAL_PROBIT: //dfam, vpow, link, yneg 
-                                       addArgs[0] = "2"; addArgs[1] = "0.0"; 
addArgs[2] = "3"; addArgs[3] = "0";
-                                       param4Name = "yneg=";
-                                       break;
-                       }
-                       
-                       fullDMLScriptName = "scripts/algorithms/GLM.dml";
-                       programArgs = new String[]{ "-explain", "-stats", 
"-nvargs", "X="+input("X"), "Y="+input("Y"),
-                               "icpt="+String.valueOf(intercept), 
"tol="+String.valueOf(epsilon), "moi="+String.valueOf(maxiter), 
-                               "dfam="+addArgs[0], "vpow="+addArgs[1], 
"link="+addArgs[2], param4Name+addArgs[3], "B="+output("w")};
-
-                       rCmd = getRCmd(inputDir(), 
String.valueOf(intercept),String.valueOf(epsilon),
-                               String.valueOf(maxiter), addArgs[0], 
addArgs[1], addArgs[2], addArgs[3], expectedDir());
-
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
rewrites;
-                       
-                       //generate actual datasets
-                       double[][] X = getRandomMatrix(rows, cols, 0, 1, 
sparse?sparsity2:sparsity1, 714);
-                       writeInputMatrixWithMTD("X", X, true);
-                       double[][] y = TestUtils.round(getRandomMatrix(rows, 1, 
0, 1, 1.0, 136));
-                       writeInputMatrixWithMTD("Y", y, true);
-                       
-                       runTest(true, false, null, -1); 
-                       //TODO fix R glm script
-                       //runRScript(true); 
-                       
-                       //compare matrices 
-                       //HashMap<CellIndex, Double> dmlfile = 
readDMLMatrixFromHDFS("w");
-                       //HashMap<CellIndex, Double> rfile  = 
readRMatrixFromFS("w");
-                       //TestUtils.compareMatrices(dmlfile, rfile, eps, 
"Stat-DML", "Stat-R");
-                       
Assert.assertTrue(heavyHittersContainsSubString("spoof") || 
heavyHittersContainsSubString("sp_spoof"));
-               }
-               finally {
-                       rtplatform = platformOld;
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlag;
-                       OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
-                       OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
-               }
-       }
-
-       /**
-        * 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;
-       }
-}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmKMeans.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmKMeans.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmKMeans.java
deleted file mode 100644
index 705ee65..0000000
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmKMeans.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.sysml.test.integration.functions.codegen;
-
-import java.io.File;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.sysml.api.DMLScript;
-import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
-import org.apache.sysml.hops.OptimizerUtils;
-import org.apache.sysml.lops.LopProperties.ExecType;
-import org.apache.sysml.test.integration.AutomatedTestBase;
-import org.apache.sysml.test.integration.TestConfiguration;
-import org.apache.sysml.test.utils.TestUtils;
-
-public class AlgorithmKMeans extends AutomatedTestBase 
-{      
-       private final static String TEST_NAME1 = "Algorithm_KMeans";
-       private final static String TEST_DIR = "functions/codegen/";
-       private final static String TEST_CLASS_DIR = TEST_DIR + 
AlgorithmKMeans.class.getSimpleName() + "/";
-       private final static String TEST_CONF = "SystemML-config-codegen.xml";
-       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
-       
-       //private final static double eps = 1e-5;
-       
-       private final static int rows = 3972;
-       private final static int cols = 972;
-               
-       private final static double sparsity1 = 0.7; //dense
-       private final static double sparsity2 = 0.1; //sparse
-       
-       private final static double epsilon = 0.000000001;
-       private final static double maxiter = 10;
-       
-       @Override
-       public void setUp() {
-               TestUtils.clearAssertionInformation();
-               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "C" })); 
-       }
-
-       @Test
-       public void testKMeansDenseBinSingleRewritesCP() {
-               runKMeansTest(TEST_NAME1, true, false, 2, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansSparseBinSingleRewritesCP() {
-               runKMeansTest(TEST_NAME1, true, true, 2, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansDenseBinSingleCP() {
-               runKMeansTest(TEST_NAME1, false, false, 2, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansSparseBinSingleCP() {
-               runKMeansTest(TEST_NAME1, false, true, 2, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansDenseBinMultiRewritesCP() {
-               runKMeansTest(TEST_NAME1, true, false, 2, 10, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansSparseBinMultiRewritesCP() {
-               runKMeansTest(TEST_NAME1, true, true, 2, 10, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansDenseBinMultiCP() {
-               runKMeansTest(TEST_NAME1, false, false, 2, 10, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansSparseBinMultiCP() {
-               runKMeansTest(TEST_NAME1, false, true, 2, 10, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansDenseMulSingleRewritesCP() {
-               runKMeansTest(TEST_NAME1, true, false, 20, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansSparseMulSingleRewritesCP() {
-               runKMeansTest(TEST_NAME1, true, true, 20, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansDenseMulSingleCP() {
-               runKMeansTest(TEST_NAME1, false, false, 20, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansSparseMulSingleCP() {
-               runKMeansTest(TEST_NAME1, false, true, 20, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansDenseMulMultiRewritesCP() {
-               runKMeansTest(TEST_NAME1, true, false, 20, 10, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansSparseMulMultiRewritesCP() {
-               runKMeansTest(TEST_NAME1, true, true, 20, 10, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansDenseMulMultiCP() {
-               runKMeansTest(TEST_NAME1, false, false, 20, 10, ExecType.CP);
-       }
-       
-       @Test
-       public void testKMeansSparseMulMultiCP() {
-               runKMeansTest(TEST_NAME1, false, true, 20, 10, ExecType.CP);
-       }
-       
-       private void runKMeansTest( String testname, boolean rewrites, boolean 
sparse, int centroids, int runs, ExecType instType)
-       {
-               boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
-               RUNTIME_PLATFORM platformOld = rtplatform;
-               switch( instType ){
-                       case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break;
-                       case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break;
-                       default: rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK; 
break;
-               }
-       
-               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
-               if( rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == 
RUNTIME_PLATFORM.HYBRID_SPARK )
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
-
-               try
-               {
-                       String TEST_NAME = testname;
-                       TestConfiguration config = 
getTestConfiguration(TEST_NAME);
-                       loadTestConfiguration(config);
-                       
-                       fullDMLScriptName = "scripts/algorithms/Kmeans.dml";
-                       programArgs = new String[]{ "-explain", "-stats",
-                               "-nvargs", "X="+input("X"), 
"k="+String.valueOf(centroids), "runs="+String.valueOf(runs), 
-                               "tol="+String.valueOf(epsilon), 
"maxi="+String.valueOf(maxiter), "C="+output("C")};
-
-                       //rCmd = getRCmd(inputDir(), 
String.valueOf(intercept),String.valueOf(epsilon),
-                       //      String.valueOf(maxiter), expectedDir());
-
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
rewrites;
-                       
-                       //generate actual datasets
-                       double[][] X = getRandomMatrix(rows, cols, 0, 1, 
sparse?sparsity2:sparsity1, 714);
-                       writeInputMatrixWithMTD("X", X, true);
-                       
-                       runTest(true, false, null, -1); 
-                       
-                       
Assert.assertTrue(heavyHittersContainsSubString("spoof") || 
heavyHittersContainsSubString("sp_spoof"));
-               }
-               finally {
-                       rtplatform = platformOld;
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlag;
-                       OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
-                       OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
-               }
-       }
-
-       /**
-        * 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;
-       }
-}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmL2SVM.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmL2SVM.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmL2SVM.java
deleted file mode 100644
index 788c73d..0000000
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmL2SVM.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.sysml.test.integration.functions.codegen;
-
-import java.io.File;
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.sysml.api.DMLScript;
-import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
-import org.apache.sysml.hops.OptimizerUtils;
-import org.apache.sysml.lops.LopProperties.ExecType;
-import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex;
-import org.apache.sysml.test.integration.AutomatedTestBase;
-import org.apache.sysml.test.integration.TestConfiguration;
-import org.apache.sysml.test.utils.TestUtils;
-
-public class AlgorithmL2SVM extends AutomatedTestBase 
-{      
-       private final static String TEST_NAME1 = "Algorithm_L2SVM";
-       private final static String TEST_DIR = "functions/codegen/";
-       private final static String TEST_CLASS_DIR = TEST_DIR + 
AlgorithmL2SVM.class.getSimpleName() + "/";
-       private final static String TEST_CONF = "SystemML-config-codegen.xml";
-       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
-       
-       private final static double eps = 1e-5;
-       
-       private final static int rows = 3468;
-       private final static int cols1 = 1007;
-       private final static int cols2 = 987;
-       
-       private final static double sparsity1 = 0.7; //dense
-       private final static double sparsity2 = 0.1; //sparse
-       
-       private final static int intercept = 0;
-       private final static double epsilon = 0.000000001;
-       private final static double maxiter = 10;
-       
-       @Override
-       public void setUp() {
-               TestUtils.clearAssertionInformation();
-               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "w" })); 
-       }
-
-       @Test
-       public void testL2SVMDenseRewritesCP() {
-               runL2SVMTest(TEST_NAME1, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testL2SVMSparseRewritesCP() {
-               runL2SVMTest(TEST_NAME1, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testL2SVMDenseCP() {
-               runL2SVMTest(TEST_NAME1, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testL2SVMSparseCP() {
-               runL2SVMTest(TEST_NAME1, false, true, ExecType.CP);
-       }
-
-       @Test
-       public void testL2SVMDenseRewritesSP() {
-               runL2SVMTest(TEST_NAME1, true, false, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testL2SVMSparseRewritesSP() {
-               runL2SVMTest(TEST_NAME1, true, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testL2SVMDenseSP() {
-               runL2SVMTest(TEST_NAME1, false, false, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testL2SVMSparseSP() {
-               runL2SVMTest(TEST_NAME1, false, true, ExecType.SPARK);
-       }
-       
-       private void runL2SVMTest( String testname, boolean rewrites, boolean 
sparse, ExecType instType)
-       {
-               boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
-               RUNTIME_PLATFORM platformOld = rtplatform;
-               switch( instType ){
-                       case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break;
-                       case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break;
-                       default: rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK; 
break;
-               }
-       
-               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
-               if( rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == 
RUNTIME_PLATFORM.HYBRID_SPARK )
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
-
-               try
-               {
-                       String TEST_NAME = testname;
-                       TestConfiguration config = 
getTestConfiguration(TEST_NAME);
-                       loadTestConfiguration(config);
-                       
-                       fullDMLScriptName = "scripts/algorithms/l2-svm.dml";
-                       programArgs = new String[]{ "-explain", "-stats", 
"-nvargs", "X="+input("X"), "Y="+input("Y"),
-                               "icpt="+String.valueOf(intercept), 
"tol="+String.valueOf(epsilon), "reg=0.001",
-                               "maxiter="+String.valueOf(maxiter), 
"model="+output("w"), "Log= "};
-
-                       rCmd = getRCmd(inputDir(), 
String.valueOf(intercept),String.valueOf(epsilon),
-                               String.valueOf(maxiter), expectedDir());
-
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
rewrites;
-                       
-                       //generate actual datasets
-                       int cols = (instType==ExecType.SPARK) ? cols2 : cols1;
-                       double[][] X = getRandomMatrix(rows, cols, 0, 1, 
sparse?sparsity2:sparsity1, 714);
-                       writeInputMatrixWithMTD("X", X, true);
-                       double[][] y = TestUtils.round(getRandomMatrix(rows, 1, 
0, 1, 1.0, 136));
-                       writeInputMatrixWithMTD("Y", y, true);
-                       
-                       runTest(true, false, null, -1); 
-                       runRScript(true); 
-                       
-                       //compare matrices 
-                       HashMap<CellIndex, Double> dmlfile = 
readDMLMatrixFromHDFS("w");
-                       HashMap<CellIndex, Double> rfile  = 
readRMatrixFromFS("w");
-                       TestUtils.compareMatrices(dmlfile, rfile, eps, 
"Stat-DML", "Stat-R");
-                       
Assert.assertTrue(heavyHittersContainsSubString("spoof") || 
heavyHittersContainsSubString("sp_spoof"));
-               }
-               finally {
-                       rtplatform = platformOld;
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlag;
-                       OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
-                       OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
-               }
-       }
-
-       /**
-        * 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;
-       }
-}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmLinregCG.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmLinregCG.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmLinregCG.java
deleted file mode 100644
index 149b28e..0000000
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmLinregCG.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.sysml.test.integration.functions.codegen;
-
-import java.io.File;
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.sysml.api.DMLScript;
-import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
-import org.apache.sysml.hops.OptimizerUtils;
-import org.apache.sysml.lops.LopProperties.ExecType;
-import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex;
-import org.apache.sysml.test.integration.AutomatedTestBase;
-import org.apache.sysml.test.integration.TestConfiguration;
-import org.apache.sysml.test.utils.TestUtils;
-
-public class AlgorithmLinregCG extends AutomatedTestBase 
-{      
-       private final static String TEST_NAME1 = "Algorithm_LinregCG";
-       private final static String TEST_DIR = "functions/codegen/";
-       private final static String TEST_CLASS_DIR = TEST_DIR + 
AlgorithmLinregCG.class.getSimpleName() + "/";
-       private final static String TEST_CONF = "SystemML-config-codegen.xml";
-       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
-       
-       private final static double eps = 1e-1;
-       
-       private final static int rows = 2468;
-       private final static int cols = 507;
-               
-       private final static double sparsity1 = 0.7; //dense
-       private final static double sparsity2 = 0.1; //sparse
-       
-       private final static double epsilon = 0.000000001;
-       private final static double maxiter = 10;
-       
-       @Override
-       public void setUp() {
-               TestUtils.clearAssertionInformation();
-               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "w" })); 
-       }
-
-       @Test
-       public void testLinregCG0DenseRewritesCP() {
-               runLinregCGTest(TEST_NAME1, true, false, 0, ExecType.CP);
-       }
-       
-       @Test
-       public void testLinregCG0SparseRewritesCP() {
-               runLinregCGTest(TEST_NAME1, true, true, 0, ExecType.CP);
-       }
-       
-       @Test
-       public void testLinregCG0DenseCP() {
-               runLinregCGTest(TEST_NAME1, false, false, 0, ExecType.CP);
-       }
-       
-       @Test
-       public void testLinregCG0SparseCP() {
-               runLinregCGTest(TEST_NAME1, false, true, 0, ExecType.CP);
-       }
-
-       @Test
-       public void testLinregCG0DenseRewritesSP() {
-               runLinregCGTest(TEST_NAME1, true, false, 0, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG0SparseRewritesSP() {
-               runLinregCGTest(TEST_NAME1, true, true, 0, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG0DenseSP() {
-               runLinregCGTest(TEST_NAME1, false, false, 0, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG0SparseSP() {
-               runLinregCGTest(TEST_NAME1, false, true, 0, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG1DenseRewritesCP() {
-               runLinregCGTest(TEST_NAME1, true, false, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testLinregCG1SparseRewritesCP() {
-               runLinregCGTest(TEST_NAME1, true, true, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testLinregCG1DenseCP() {
-               runLinregCGTest(TEST_NAME1, false, false, 1, ExecType.CP);
-       }
-       
-       @Test
-       public void testLinregCG1SparseCP() {
-               runLinregCGTest(TEST_NAME1, false, true, 1, ExecType.CP);
-       }
-
-       @Test
-       public void testLinregCG1DenseRewritesSP() {
-               runLinregCGTest(TEST_NAME1, true, false, 1, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG1SparseRewritesSP() {
-               runLinregCGTest(TEST_NAME1, true, true, 1, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG1DenseSP() {
-               runLinregCGTest(TEST_NAME1, false, false, 1, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG1SparseSP() {
-               runLinregCGTest(TEST_NAME1, false, true, 1, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG2DenseRewritesCP() {
-               runLinregCGTest(TEST_NAME1, true, false, 2, ExecType.CP);
-       }
-       
-       @Test
-       public void testLinregCG2SparseRewritesCP() {
-               runLinregCGTest(TEST_NAME1, true, true, 2, ExecType.CP);
-       }
-       
-       @Test
-       public void testLinregCG2DenseCP() {
-               runLinregCGTest(TEST_NAME1, false, false, 2, ExecType.CP);
-       }
-       
-       @Test
-       public void testLinregCG2SparseCP() {
-               runLinregCGTest(TEST_NAME1, false, true, 2, ExecType.CP);
-       }
-
-       @Test
-       public void testLinregCG2DenseRewritesSP() {
-               runLinregCGTest(TEST_NAME1, true, false, 2, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG2SparseRewritesSP() {
-               runLinregCGTest(TEST_NAME1, true, true, 2, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG2DenseSP() {
-               runLinregCGTest(TEST_NAME1, false, false, 2, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testLinregCG2SparseSP() {
-               runLinregCGTest(TEST_NAME1, false, true, 2, ExecType.SPARK);
-       }
-       
-       private void runLinregCGTest( String testname, boolean rewrites, 
boolean sparse, int intercept, ExecType instType)
-       {
-               boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
-               RUNTIME_PLATFORM platformOld = rtplatform;
-               switch( instType ){
-                       case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break;
-                       case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break;
-                       default: rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK; 
break;
-               }
-       
-               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
-               if( rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == 
RUNTIME_PLATFORM.HYBRID_SPARK )
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
-
-               try
-               {
-                       String TEST_NAME = testname;
-                       TestConfiguration config = 
getTestConfiguration(TEST_NAME);
-                       loadTestConfiguration(config);
-                       
-                       fullDMLScriptName = 
"scripts/algorithms/LinearRegCG.dml";
-                       programArgs = new String[]{ "-explain", "-stats", 
"-nvargs", "X="+input("X"), "Y="+input("y"),
-                               "icpt="+String.valueOf(intercept), 
"tol="+String.valueOf(epsilon),
-                               "maxi="+String.valueOf(maxiter), "reg=0.001", 
"B="+output("w")};
-
-                       rCmd = getRCmd(inputDir(), 
String.valueOf(intercept),String.valueOf(epsilon),
-                               String.valueOf(maxiter), "0.001", 
expectedDir());
-       
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
rewrites;
-                       
-                       //generate actual datasets
-                       double[][] X = getRandomMatrix(rows, cols, 0, 1, 
sparse?sparsity2:sparsity1, 7);
-                       writeInputMatrixWithMTD("X", X, true);
-                       double[][] y = getRandomMatrix(rows, 1, 0, 10, 1.0, 3);
-                       writeInputMatrixWithMTD("y", y, true);
-                       
-                       runTest(true, false, null, -1); 
-                       runRScript(true); 
-                       
-                       //compare matrices 
-                       HashMap<CellIndex, Double> dmlfile = 
readDMLMatrixFromHDFS("w");
-                       HashMap<CellIndex, Double> rfile  = 
readRMatrixFromFS("w");
-                       TestUtils.compareMatrices(dmlfile, rfile, eps, 
"Stat-DML", "Stat-R");
-                       
Assert.assertTrue(heavyHittersContainsSubString("spoofRA") 
-                                       || 
heavyHittersContainsSubString("sp_spoofRA"));
-               }
-               finally {
-                       rtplatform = platformOld;
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlag;
-                       OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
-                       OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
-               }
-       }
-
-       /**
-        * 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;
-       }
-}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMDABivar.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMDABivar.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMDABivar.java
deleted file mode 100644
index 9477234..0000000
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMDABivar.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.sysml.test.integration.functions.codegen;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.io.File;
-
-import org.apache.sysml.test.integration.applications.MDABivariateStatsTest;
-
-@RunWith(value = Parameterized.class)
-public class AlgorithmMDABivar extends MDABivariateStatsTest 
-{
-       private final static String LOCAL_TEST_DIR = "functions/codegen/";
-       private final static String TEST_CONF = "SystemML-config-codegen.xml";
-       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
LOCAL_TEST_DIR, TEST_CONF);
-       
-       public AlgorithmMDABivar(int n, int m, int li, int lml) {
-               super(n, m, li, lml);
-               TEST_CLASS_DIR = TEST_DIR + 
AlgorithmMDABivar.class.getSimpleName() + "/";
-       }
-
-       @Test
-       public void testMDABivariateStatsDml() {
-               testMDABivariateStats(ScriptType.DML);
-       }
-       
-       @Override
-       protected File getConfigTemplateFile() {
-               System.out.println("This test case overrides default 
configuration with " + TEST_CONF_FILE.getPath());
-               return TEST_CONF_FILE;
-       }
-}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMLogreg.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMLogreg.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMLogreg.java
deleted file mode 100644
index 9c908b6..0000000
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMLogreg.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.sysml.test.integration.functions.codegen;
-
-import java.io.File;
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.sysml.api.DMLScript;
-import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
-import org.apache.sysml.hops.OptimizerUtils;
-import org.apache.sysml.lops.LopProperties.ExecType;
-import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex;
-import org.apache.sysml.test.integration.AutomatedTestBase;
-import org.apache.sysml.test.integration.TestConfiguration;
-import org.apache.sysml.test.utils.TestUtils;
-
-public class AlgorithmMLogreg extends AutomatedTestBase 
-{
-       private final static String TEST_NAME1 = "Algorithm_MLogreg";
-       private final static String TEST_DIR = "functions/codegen/";
-       private final static String TEST_CLASS_DIR = TEST_DIR + 
AlgorithmMLogreg.class.getSimpleName() + "/";
-       private final static String TEST_CONF = "SystemML-config-codegen.xml";
-       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
-       
-       private final static double eps = 1e-5;
-       
-       private final static int rows = 2468;
-       private final static int cols = 227;
-               
-       private final static double sparsity1 = 0.7; //dense
-       private final static double sparsity2 = 0.1; //sparse
-       
-       private final static double epsilon = 0.000000001;
-       private final static double maxiter = 10;
-       
-       @Override
-       public void setUp() {
-               TestUtils.clearAssertionInformation();
-               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "w" })); 
-       }
-
-       @Test
-       public void testMlogregBin0DenseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 2, 0, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregBin0SparseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 2, 0, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregBin0DenseCP() {
-               runMlogregTest(TEST_NAME1, 2, 0, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregBin0SparseCP() {
-               runMlogregTest(TEST_NAME1, 2, 0, false, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul0DenseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 5, 0, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul0SparseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 5, 0, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul0DenseCP() {
-               runMlogregTest(TEST_NAME1, 5, 0, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul0SparseCP() {
-               runMlogregTest(TEST_NAME1, 5, 0, false, true, ExecType.CP);
-       }
-
-       @Test
-       public void testMlogregBin0DenseRewritesSP() {
-               runMlogregTest(TEST_NAME1, 2, 0, true, false, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testMlogregBin0SparseRewritesSP() {
-               runMlogregTest(TEST_NAME1, 2, 0, true, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testMlogregBin0DenseSP() {
-               runMlogregTest(TEST_NAME1, 2, 0, false, false, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testMlogregBin0SparseSP() {
-               runMlogregTest(TEST_NAME1, 2, 0, false, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testMlogregMul0DenseRewritesSP() {
-               runMlogregTest(TEST_NAME1, 5, 0, true, false, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testMlogregMul0SparseRewritesSP() {
-               runMlogregTest(TEST_NAME1, 5, 0, true, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testMlogregMul0DenseSP() {
-               runMlogregTest(TEST_NAME1, 5, 0, false, false, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testMlogregMul0SparseSP() {
-               runMlogregTest(TEST_NAME1, 5, 0, false, true, ExecType.SPARK);
-       }
-       
-       @Test
-       public void testMlogregBin1DenseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 2, 1, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregBin1SparseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 2, 1, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregBin1DenseCP() {
-               runMlogregTest(TEST_NAME1, 2, 1, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregBin1SparseCP() {
-               runMlogregTest(TEST_NAME1, 2, 1, false, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul1DenseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 5, 1, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul1SparseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 5, 1, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul1DenseCP() {
-               runMlogregTest(TEST_NAME1, 5, 1, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul1SparseCP() {
-               runMlogregTest(TEST_NAME1, 5, 1, false, true, ExecType.CP);
-       }
-
-       @Test
-       public void testMlogregBin2DenseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 2, 2, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregBin2SparseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 2, 2, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregBin2DenseCP() {
-               runMlogregTest(TEST_NAME1, 2, 2, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregBin2SparseCP() {
-               runMlogregTest(TEST_NAME1, 2, 2, false, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul2DenseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 5, 2, true, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul2SparseRewritesCP() {
-               runMlogregTest(TEST_NAME1, 5, 2, true, true, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul2DenseCP() {
-               runMlogregTest(TEST_NAME1, 5, 2, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testMlogregMul2SparseCP() {
-               runMlogregTest(TEST_NAME1, 5, 2, false, true, ExecType.CP);
-       }
-       
-       private void runMlogregTest( String testname, int classes, int 
intercept, boolean rewrites, boolean sparse, ExecType instType)
-       {
-               boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
-               RUNTIME_PLATFORM platformOld = rtplatform;
-               switch( instType ){
-                       case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break;
-                       case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break;
-                       default: rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK; 
break;
-               }
-       
-               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
-               if( rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == 
RUNTIME_PLATFORM.HYBRID_SPARK )
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
-
-               try
-               {
-                       String TEST_NAME = testname;
-                       TestConfiguration config = 
getTestConfiguration(TEST_NAME);
-                       loadTestConfiguration(config);
-                       
-                       fullDMLScriptName = 
"scripts/algorithms/MultiLogReg.dml";
-                       programArgs = new String[]{ "-explain", "-stats", 
"-nvargs", "X="+input("X"), "Y="+input("Y"),
-                               "icpt="+String.valueOf(intercept), 
"tol="+String.valueOf(epsilon),
-                               "moi="+String.valueOf(maxiter), "reg=0.001", 
"B="+output("w")};
-
-                       rCmd = getRCmd(inputDir(), 
String.valueOf(intercept),String.valueOf(epsilon),
-                               String.valueOf(maxiter), expectedDir());
-
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
rewrites;
-                       
-                       //generate actual datasets
-                       double[][] X = getRandomMatrix(rows, cols, 0, 1, 
sparse?sparsity2:sparsity1, 2384);
-                       writeInputMatrixWithMTD("X", X, true);
-                       double[][] y = TestUtils.round(getRandomMatrix(rows, 1, 
0.51, classes+0.49, 1.0, 9283));
-                       writeInputMatrixWithMTD("Y", y, true);
-                       
-                       runTest(true, false, null, -1); 
-                       runRScript(true); 
-                       
-                       //compare matrices 
-                       HashMap<CellIndex, Double> dmlfile = 
readDMLMatrixFromHDFS("w");
-                       HashMap<CellIndex, Double> rfile  = 
readRMatrixFromFS("w");
-                       TestUtils.compareMatrices(dmlfile, rfile, eps, 
"Stat-DML", "Stat-R");
-                       Assert.assertTrue(heavyHittersContainsSubString("spoof")
-                               || heavyHittersContainsSubString("sp_spoof"));
-               }
-               finally {
-                       rtplatform = platformOld;
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlag;
-                       OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
-                       OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
-               }
-       }
-
-       /**
-        * 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;
-       }
-}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMSVM.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMSVM.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMSVM.java
deleted file mode 100644
index 2a5de13..0000000
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmMSVM.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.sysml.test.integration.functions.codegen;
-
-import java.io.File;
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.sysml.api.DMLScript;
-import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
-import org.apache.sysml.hops.OptimizerUtils;
-import org.apache.sysml.lops.LopProperties.ExecType;
-import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex;
-import org.apache.sysml.test.integration.AutomatedTestBase;
-import org.apache.sysml.test.integration.TestConfiguration;
-import org.apache.sysml.test.utils.TestUtils;
-
-public class AlgorithmMSVM extends AutomatedTestBase 
-{      
-       private final static String TEST_NAME1 = "Algorithm_MSVM";
-       private final static String TEST_DIR = "functions/codegen/";
-       private final static String TEST_CLASS_DIR = TEST_DIR + 
AlgorithmMSVM.class.getSimpleName() + "/";
-       private final static String TEST_CONF = "SystemML-config-codegen.xml";
-       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
-       
-       private final static double eps = 1e-5;
-       
-       private final static int rows = 1468;
-       private final static int cols = 1007;
-               
-       private final static double sparsity1 = 0.7; //dense
-       private final static double sparsity2 = 0.1; //sparse
-       
-       private final static int intercept = 0;
-       private final static double epsilon = 0.000000001;
-       private final static double maxiter = 10;
-       
-       @Override
-       public void setUp() {
-               TestUtils.clearAssertionInformation();
-               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "w" })); 
-       }
-
-       @Test
-       public void testMSVMDenseBinRewritesCP() {
-               runMSVMTest(TEST_NAME1, true, false, 2, ExecType.CP);
-       }
-       
-       @Test
-       public void testMSVMSparseBinRewritesCP() {
-               runMSVMTest(TEST_NAME1, true, true, 2, ExecType.CP);
-       }
-       
-       @Test
-       public void testMSVMDenseBinCP() {
-               runMSVMTest(TEST_NAME1, false, false, 2, ExecType.CP);
-       }
-       
-       @Test
-       public void testMSVMSparseBinCP() {
-               runMSVMTest(TEST_NAME1, false, true, 2, ExecType.CP);
-       }
-       
-       @Test
-       public void testMSVMDenseMulRewritesCP() {
-               runMSVMTest(TEST_NAME1, true, false, 4, ExecType.CP);
-       }
-       
-       @Test
-       public void testMSVMSparseMulRewritesCP() {
-               runMSVMTest(TEST_NAME1, true, true, 4, ExecType.CP);
-       }
-       
-       @Test
-       public void testMSVMDenseMulCP() {
-               runMSVMTest(TEST_NAME1, false, false, 4, ExecType.CP);
-       }
-       
-       @Test
-       public void testMSVMSparseMulCP() {
-               runMSVMTest(TEST_NAME1, false, true, 4, ExecType.CP);
-       }
-       
-       private void runMSVMTest( String testname, boolean rewrites, boolean 
sparse, int numClasses, ExecType instType)
-       {
-               boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
-               RUNTIME_PLATFORM platformOld = rtplatform;
-               switch( instType ){
-                       case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break;
-                       case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break;
-                       default: rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK; 
break;
-               }
-       
-               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
-               if( rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == 
RUNTIME_PLATFORM.HYBRID_SPARK )
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
-
-               try
-               {
-                       String TEST_NAME = testname;
-                       TestConfiguration config = 
getTestConfiguration(TEST_NAME);
-                       loadTestConfiguration(config);
-                       
-                       fullDMLScriptName = "scripts/algorithms/m-svm.dml";
-                       programArgs = new String[]{ "-explain", "-stats", 
"-nvargs", "X="+input("X"), "Y="+input("Y"),
-                                       "icpt="+String.valueOf(intercept), 
"tol="+String.valueOf(epsilon), "reg=0.001",
-                                       "maxiter="+String.valueOf(maxiter), 
"model="+output("w"), "Log= "};
-
-                       rCmd = getRCmd(inputDir(), 
String.valueOf(intercept),String.valueOf(epsilon),
-                               String.valueOf(maxiter), expectedDir());
-
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
rewrites;
-                       
-                       //generate actual datasets
-                       double[][] X = getRandomMatrix(rows, cols, 0, 1, 
sparse?sparsity2:sparsity1, 714);
-                       writeInputMatrixWithMTD("X", X, true);
-                       double[][] y = TestUtils.round(getRandomMatrix(rows, 1, 
1, numClasses, 1.0, 136));
-                       writeInputMatrixWithMTD("Y", y, true);
-                       
-                       runTest(true, false, null, -1); 
-                       runRScript(true); 
-                       
-                       //compare matrices 
-                       HashMap<CellIndex, Double> dmlfile = 
readDMLMatrixFromHDFS("w");
-                       HashMap<CellIndex, Double> rfile  = 
readRMatrixFromFS("w");
-                       TestUtils.compareMatrices(dmlfile, rfile, eps, 
"Stat-DML", "Stat-R");
-                       
Assert.assertTrue(heavyHittersContainsSubString("spoof") || 
heavyHittersContainsSubString("sp_spoof"));
-               }
-               finally {
-                       rtplatform = platformOld;
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlag;
-                       OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
-                       OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
-               }
-       }
-
-       /**
-        * 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;
-       }
-}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmPNMF.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmPNMF.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmPNMF.java
deleted file mode 100644
index 826428e..0000000
--- 
a/src/test/java/org/apache/sysml/test/integration/functions/codegen/AlgorithmPNMF.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.sysml.test.integration.functions.codegen;
-
-import java.io.File;
-import java.util.HashMap;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.apache.sysml.api.DMLScript;
-import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
-import org.apache.sysml.hops.OptimizerUtils;
-import org.apache.sysml.lops.LopProperties.ExecType;
-import org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex;
-import org.apache.sysml.test.integration.AutomatedTestBase;
-import org.apache.sysml.test.integration.TestConfiguration;
-import org.apache.sysml.test.utils.TestUtils;
-
-public class AlgorithmPNMF extends AutomatedTestBase 
-{      
-       private final static String TEST_NAME1 = "Algorithm_PNMF";
-       private final static String TEST_DIR = "functions/codegen/";
-       private final static String TEST_CLASS_DIR = TEST_DIR + 
AlgorithmPNMF.class.getSimpleName() + "/";
-       private final static String TEST_CONF = "SystemML-config-codegen.xml";
-       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
-       
-       private final static double eps = 1e-5;
-       
-       private final static int rows = 1468;
-       private final static int cols = 1207;
-       private final static int rank = 20;
-               
-       private final static double sparsity1 = 0.7; //dense
-       private final static double sparsity2 = 0.1; //sparse
-       
-       private final static double epsilon = 0.000000001;
-       private final static double maxiter = 10;
-       
-       @Override
-       public void setUp() {
-               TestUtils.clearAssertionInformation();
-               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "w" })); 
-       }
-
-       @Test
-       public void testPNMFDenseCP() {
-               runPNMFTest(TEST_NAME1, false, false, ExecType.CP);
-       }
-       
-       @Test
-       public void testPNMFSparseCP() {
-               runPNMFTest(TEST_NAME1, false, true, ExecType.CP);
-       }
-       
-       //TODO requires proper handling of blocksize constraints
-       //@Test
-       //public void testPNMFDenseSP() {
-       //      runPNMFTest(TEST_NAME1, false, false, ExecType.SPARK);
-       //}
-       
-       //@Test
-       //public void testPNMFSparseSP() {
-       //      runPNMFTest(TEST_NAME1, false, true, ExecType.SPARK);
-       //}
-
-       private void runPNMFTest( String testname, boolean rewrites, boolean 
sparse, ExecType instType)
-       {
-               boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
-               RUNTIME_PLATFORM platformOld = rtplatform;
-               switch( instType ){
-                       case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break;
-                       case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break;
-                       default: rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK; 
break;
-               }
-       
-               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
-               if( rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == 
RUNTIME_PLATFORM.HYBRID_SPARK )
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
-
-               try
-               {
-                       String TEST_NAME = testname;
-                       TestConfiguration config = 
getTestConfiguration(TEST_NAME);
-                       loadTestConfiguration(config);
-                       
-                       fullDMLScriptName = "scripts/staging/PNMF.dml";
-                       programArgs = new String[]{ "-explain", "-stats", 
"-args", input("X"), 
-                               input("W"), input("H"), String.valueOf(rank), 
String.valueOf(epsilon), 
-                               String.valueOf(maxiter), output("W"), 
output("H")};
-
-                       rCmd = getRCmd(inputDir(), String.valueOf(rank), 
String.valueOf(epsilon), 
-                               String.valueOf(maxiter), expectedDir());
-
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
rewrites;
-                       
-                       //generate actual datasets
-                       double[][] X = getRandomMatrix(rows, cols, 0, 1, 
sparse?sparsity2:sparsity1, 234);
-                       writeInputMatrixWithMTD("X", X, true);
-                       double[][] W = getRandomMatrix(rows, rank, 0, 0.025, 
1.0, 3);
-                       writeInputMatrixWithMTD("W", W, true);
-                       double[][] H = getRandomMatrix(rank, cols, 0, 0.025, 
1.0, 7);
-                       writeInputMatrixWithMTD("H", H, true);
-                       
-                       runTest(true, false, null, -1); 
-                       runRScript(true); 
-                       
-                       //compare matrices 
-                       HashMap<CellIndex, Double> dmlW = 
readDMLMatrixFromHDFS("W");
-                       HashMap<CellIndex, Double> dmlH = 
readDMLMatrixFromHDFS("H");
-                       HashMap<CellIndex, Double> rW = readRMatrixFromFS("W");
-                       HashMap<CellIndex, Double> rH = readRMatrixFromFS("H");
-                       TestUtils.compareMatrices(dmlW, rW, eps, "Stat-DML", 
"Stat-R");
-                       TestUtils.compareMatrices(dmlH, rH, eps, "Stat-DML", 
"Stat-R");
-                       
Assert.assertTrue(heavyHittersContainsSubString("spoof") || 
heavyHittersContainsSubString("sp_spoof"));
-               }
-               finally {
-                       rtplatform = platformOld;
-                       DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
-                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlag;
-                       OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
-                       OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
-               }
-       }
-
-       /**
-        * 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;
-       }
-}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmARIMA.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmARIMA.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmARIMA.java
new file mode 100644
index 0000000..6a7edcd
--- /dev/null
+++ 
b/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmARIMA.java
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+package org.apache.sysml.test.integration.functions.codegenalg;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.File;
+
+import org.apache.sysml.test.integration.applications.ArimaTest;
+
+@RunWith(value = Parameterized.class)
+public class AlgorithmARIMA extends ArimaTest 
+{
+       private final static String LOCAL_TEST_DIR = "functions/codegenalg/";
+       private final static String TEST_CONF = "SystemML-config-codegen.xml";
+       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
LOCAL_TEST_DIR, TEST_CONF);
+       
+       public AlgorithmARIMA(int m, int p, int d, int q, int P, int D, int Q, 
int s, int include_mean, int useJacobi) {
+               super(m, p, d, q, P, D, Q, s, include_mean, useJacobi);
+               TEST_CLASS_DIR = TEST_DIR + 
AlgorithmARIMA.class.getSimpleName() + "/";
+       }
+
+       @Test
+       public void testArimaDml() {
+               testArima(ScriptType.DML);
+       }
+       
+       @Override
+       protected File getConfigTemplateFile() {
+               System.out.println("This test case overrides default 
configuration with " + TEST_CONF_FILE.getPath());
+               return TEST_CONF_FILE;
+       }
+}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmAutoEncoder.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmAutoEncoder.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmAutoEncoder.java
new file mode 100644
index 0000000..04c81c9
--- /dev/null
+++ 
b/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmAutoEncoder.java
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+
+package org.apache.sysml.test.integration.functions.codegenalg;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.apache.sysml.api.DMLScript;
+import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
+import org.apache.sysml.hops.OptimizerUtils;
+import org.apache.sysml.lops.LopProperties.ExecType;
+import org.apache.sysml.test.integration.AutomatedTestBase;
+import org.apache.sysml.test.integration.TestConfiguration;
+import org.apache.sysml.test.utils.TestUtils;
+
+public class AlgorithmAutoEncoder extends AutomatedTestBase 
+{
+       private final static String TEST_NAME1 = "Algorithm_AutoEncoder";
+       private final static String TEST_DIR = "functions/codegenalg/";
+       private final static String TEST_CLASS_DIR = TEST_DIR + 
AlgorithmAutoEncoder.class.getSimpleName() + "/";
+       private final static String TEST_CONF = "SystemML-config-codegen.xml";
+       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
+       
+       private final static int rows = 2468;
+       private final static int cols = 784;
+       
+       private final static double sparsity1 = 0.7; //dense
+       private final static double sparsity2 = 0.1; //sparse
+       
+       private final static int H1 = 500;
+       private final static int H2 = 2;
+       private final static double epochs = 2; 
+       
+       @Override
+       public void setUp() {
+               TestUtils.clearAssertionInformation();
+               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "w" })); 
+       }
+
+       @Test
+       public void testAutoEncoder256DenseCP() {
+               runGLMTest(256, false, false, ExecType.CP);
+       }
+       
+       @Test
+       public void testAutoEncoder256DenseRewritesCP() {
+               runGLMTest(256, false, true, ExecType.CP);
+       }
+       
+       @Test
+       public void testAutoEncoder256SparseCP() {
+               runGLMTest(256, true, false, ExecType.CP);
+       }
+       
+       @Test
+       public void testAutoEncoder256SparseRewritesCP() {
+               runGLMTest(256, true, true, ExecType.CP);
+       }
+       
+       @Test
+       public void testAutoEncoder512DenseCP() {
+               runGLMTest(512, false, false, ExecType.CP);
+       }
+       
+       @Test
+       public void testAutoEncoder512DenseRewritesCP() {
+               runGLMTest(512, false, true, ExecType.CP);
+       }
+       
+       @Test
+       public void testAutoEncoder512SparseCP() {
+               runGLMTest(512, true, false, ExecType.CP);
+       }
+       
+       @Test
+       public void testAutoEncoder512SparseRewritesCP() {
+               runGLMTest(512, true, true, ExecType.CP);
+       }
+       
+       //Note: limited cases for SPARK, as lazy evaluation 
+       //causes very long execution time for this algorithm
+       
+       @Test
+       public void testAutoEncoder256DenseRewritesSpark() {
+               runGLMTest(256, false, true, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testAutoEncoder256SparseRewritesSpark() {
+               runGLMTest(256, true, true, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testAutoEncoder512DenseRewritesSpark() {
+               runGLMTest(512, false, true, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testAutoEncoder512SparseRewritesSpark() {
+               runGLMTest(512, true, true, ExecType.SPARK);
+       }
+       
+       private void runGLMTest(int batchsize, boolean sparse, boolean 
rewrites, ExecType instType)
+       {
+               boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
+               RUNTIME_PLATFORM platformOld = rtplatform;
+               switch( instType ){
+                       case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break;
+                       case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break;
+                       default: rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK; 
break;
+               }
+       
+               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
+               if( rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == 
RUNTIME_PLATFORM.HYBRID_SPARK )
+                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
+
+               try
+               {
+                       String TEST_NAME = TEST_NAME1;
+                       TestConfiguration config = 
getTestConfiguration(TEST_NAME);
+                       loadTestConfiguration(config);
+                       
+                       fullDMLScriptName = 
"scripts/staging/autoencoder-2layer.dml";
+                       programArgs = new String[]{ "-explain", "-stats", 
"-nvargs", "X="+input("X"),
+                               "H1="+H1, "H2="+H2, "EPOCH="+epochs, 
"BATCH="+batchsize, 
+                               "W1_out="+output("W1"), "b1_out="+output("b1"),
+                               "W2_out="+output("W2"), "b2_out="+output("b2"),
+                               "W3_out="+output("W3"), "b3_out="+output("b3"),
+                               "W4_out="+output("W4"), "b4_out="+output("b4")};
+                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
rewrites;
+                       
+                       //generate actual datasets
+                       double[][] X = getRandomMatrix(rows, cols, 0, 1, 
sparse?sparsity2:sparsity1, 714);
+                       writeInputMatrixWithMTD("X", X, true);
+                       
+                       //run script
+                       runTest(true, false, null, -1); 
+                       //TODO R script
+                       
+                       
Assert.assertTrue(heavyHittersContainsSubString("spoof") 
+                               || heavyHittersContainsSubString("sp_spoof"));
+               }
+               finally {
+                       rtplatform = platformOld;
+                       DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
+                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlag;
+                       OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
+                       OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
+               }
+       }
+
+       /**
+        * 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;
+       }
+}

http://git-wip-us.apache.org/repos/asf/systemml/blob/98595c52/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmGLM.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmGLM.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmGLM.java
new file mode 100644
index 0000000..603e146
--- /dev/null
+++ 
b/src/test/java/org/apache/sysml/test/integration/functions/codegenalg/AlgorithmGLM.java
@@ -0,0 +1,266 @@
+/*
+ * 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.
+ */
+
+package org.apache.sysml.test.integration.functions.codegenalg;
+
+import java.io.File;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.apache.sysml.api.DMLScript;
+import org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM;
+import org.apache.sysml.hops.OptimizerUtils;
+import org.apache.sysml.lops.LopProperties.ExecType;
+import org.apache.sysml.test.integration.AutomatedTestBase;
+import org.apache.sysml.test.integration.TestConfiguration;
+import org.apache.sysml.test.utils.TestUtils;
+
+public class AlgorithmGLM extends AutomatedTestBase 
+{      
+       private final static String TEST_NAME1 = "Algorithm_GLM";
+       private final static String TEST_DIR = "functions/codegenalg/";
+       private final static String TEST_CLASS_DIR = TEST_DIR + 
AlgorithmGLM.class.getSimpleName() + "/";
+       private final static String TEST_CONF = "SystemML-config-codegen.xml";
+       private final static File   TEST_CONF_FILE = new File(SCRIPT_DIR + 
TEST_DIR, TEST_CONF);
+       
+       //private final static double eps = 1e-5;
+       
+       private final static int rows = 2468;
+       private final static int cols = 1007;
+               
+       private final static double sparsity1 = 0.7; //dense
+       private final static double sparsity2 = 0.1; //sparse
+       
+       private final static int intercept = 0;
+       private final static double epsilon = 0.000000001;
+       private final static double maxiter = 5; //inner/outer
+       
+       public enum GLMType {
+               POISSON_LOG,
+               GAMMA_LOG,
+               BINOMIAL_PROBIT,
+       }
+       
+       @Override
+       public void setUp() {
+               TestUtils.clearAssertionInformation();
+               addTestConfiguration(TEST_NAME1, new 
TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "w" })); 
+       }
+
+       @Test
+       public void testGLMPoissonDenseRewritesCP() {
+               runGLMTest(GLMType.POISSON_LOG, true, false, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMPoissonSparseRewritesCP() {
+               runGLMTest(GLMType.POISSON_LOG, true, true, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMPoissonDenseCP() {
+               runGLMTest(GLMType.POISSON_LOG, false, false, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMPoissonSparseCP() {
+               runGLMTest(GLMType.POISSON_LOG, false, true, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMGammaDenseRewritesCP() {
+               runGLMTest(GLMType.GAMMA_LOG, true, false, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMGammaSparseRewritesCP() {
+               runGLMTest(GLMType.GAMMA_LOG, true, true, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMGammaDenseCP() {
+               runGLMTest(GLMType.GAMMA_LOG, false, false, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMGammaSparseCP() {
+               runGLMTest(GLMType.GAMMA_LOG, false, true, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMBinomialDenseRewritesCP() {
+               runGLMTest(GLMType.BINOMIAL_PROBIT, true, false, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMBinomialSparseRewritesCP() {
+               runGLMTest(GLMType.BINOMIAL_PROBIT, true, true, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMBinomialDenseCP() {
+               runGLMTest(GLMType.BINOMIAL_PROBIT, false, false, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMBinomialSparseCP() {
+               runGLMTest(GLMType.BINOMIAL_PROBIT, false, true, ExecType.CP);
+       }
+       
+       @Test
+       public void testGLMPoissonDenseRewritesSP() {
+               runGLMTest(GLMType.POISSON_LOG, true, false, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMPoissonSparseRewritesSP() {
+               runGLMTest(GLMType.POISSON_LOG, true, true, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMPoissonDenseSP() {
+               runGLMTest(GLMType.POISSON_LOG, false, false, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMPoissonSparseSP() {
+               runGLMTest(GLMType.POISSON_LOG, false, true, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMGammaDenseRewritesSP() {
+               runGLMTest(GLMType.GAMMA_LOG, true, false, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMGammaSparseRewritesSP() {
+               runGLMTest(GLMType.GAMMA_LOG, true, true, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMGammaDenseSP() {
+               runGLMTest(GLMType.GAMMA_LOG, false, false, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMGammaSparseSP() {
+               runGLMTest(GLMType.GAMMA_LOG, false, true, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMBinomialDenseRewritesSP() {
+               runGLMTest(GLMType.BINOMIAL_PROBIT, true, false, 
ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMBinomialSparseRewritesSP() {
+               runGLMTest(GLMType.BINOMIAL_PROBIT, true, true, ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMBinomialDenseSP() {
+               runGLMTest(GLMType.BINOMIAL_PROBIT, false, false, 
ExecType.SPARK);
+       }
+       
+       @Test
+       public void testGLMBinomialSparseSP() {
+               runGLMTest(GLMType.BINOMIAL_PROBIT, false, true, 
ExecType.SPARK);
+       }
+       
+       private void runGLMTest( GLMType type, boolean rewrites, boolean 
sparse, ExecType instType)
+       {
+               boolean oldFlag = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
+               RUNTIME_PLATFORM platformOld = rtplatform;
+               switch( instType ){
+                       case MR: rtplatform = RUNTIME_PLATFORM.HADOOP; break;
+                       case SPARK: rtplatform = RUNTIME_PLATFORM.SPARK; break;
+                       default: rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK; 
break;
+               }
+       
+               boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
+               if( rtplatform == RUNTIME_PLATFORM.SPARK || rtplatform == 
RUNTIME_PLATFORM.HYBRID_SPARK )
+                       DMLScript.USE_LOCAL_SPARK_CONFIG = true;
+
+               try
+               {
+                       String TEST_NAME = TEST_NAME1;
+                       TestConfiguration config = 
getTestConfiguration(TEST_NAME);
+                       loadTestConfiguration(config);
+                       
+                       String[] addArgs = new String[4];
+                       String param4Name = "lpow=";
+                       switch(type) {
+                               case POISSON_LOG: //dfam, vpow, link, lpow
+                                       addArgs[0] = "1"; addArgs[1] = "1.0"; 
addArgs[2] = "1"; addArgs[3] = "0.0";
+                                       break;
+                               case GAMMA_LOG:   //dfam, vpow, link, lpow
+                                       addArgs[0] = "1"; addArgs[1] = "2.0"; 
addArgs[2] = "1"; addArgs[3] = "0.0";
+                                       break;
+                               case BINOMIAL_PROBIT: //dfam, vpow, link, yneg 
+                                       addArgs[0] = "2"; addArgs[1] = "0.0"; 
addArgs[2] = "3"; addArgs[3] = "0";
+                                       param4Name = "yneg=";
+                                       break;
+                       }
+                       
+                       fullDMLScriptName = "scripts/algorithms/GLM.dml";
+                       programArgs = new String[]{ "-explain", "-stats", 
"-nvargs", "X="+input("X"), "Y="+input("Y"),
+                               "icpt="+String.valueOf(intercept), 
"tol="+String.valueOf(epsilon), "moi="+String.valueOf(maxiter), 
+                               "dfam="+addArgs[0], "vpow="+addArgs[1], 
"link="+addArgs[2], param4Name+addArgs[3], "B="+output("w")};
+
+                       rCmd = getRCmd(inputDir(), 
String.valueOf(intercept),String.valueOf(epsilon),
+                               String.valueOf(maxiter), addArgs[0], 
addArgs[1], addArgs[2], addArgs[3], expectedDir());
+
+                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = 
rewrites;
+                       
+                       //generate actual datasets
+                       double[][] X = getRandomMatrix(rows, cols, 0, 1, 
sparse?sparsity2:sparsity1, 714);
+                       writeInputMatrixWithMTD("X", X, true);
+                       double[][] y = TestUtils.round(getRandomMatrix(rows, 1, 
0, 1, 1.0, 136));
+                       writeInputMatrixWithMTD("Y", y, true);
+                       
+                       runTest(true, false, null, -1); 
+                       //TODO fix R glm script
+                       //runRScript(true); 
+                       
+                       //compare matrices 
+                       //HashMap<CellIndex, Double> dmlfile = 
readDMLMatrixFromHDFS("w");
+                       //HashMap<CellIndex, Double> rfile  = 
readRMatrixFromFS("w");
+                       //TestUtils.compareMatrices(dmlfile, rfile, eps, 
"Stat-DML", "Stat-R");
+                       
Assert.assertTrue(heavyHittersContainsSubString("spoof") || 
heavyHittersContainsSubString("sp_spoof"));
+               }
+               finally {
+                       rtplatform = platformOld;
+                       DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
+                       OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlag;
+                       OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
+                       OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
+               }
+       }
+
+       /**
+        * 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;
+       }
+}

Reply via email to