use of org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM in project incubator-systemml by apache.
the class CholeskyTest method runTestCholesky.
private void runTestCholesky(int rows, int cols, RUNTIME_PLATFORM rt) {
RUNTIME_PLATFORM rtold = rtplatform;
rtplatform = rt;
boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
if (rtplatform == RUNTIME_PLATFORM.SPARK)
DMLScript.USE_LOCAL_SPARK_CONFIG = true;
try {
getAndLoadTestConfiguration(TEST_NAME);
String HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = HOME + TEST_NAME + ".dml";
programArgs = new String[] { "-args", input("A"), output("D") };
double[][] A = getRandomMatrix(rows, cols, 0, 1, sparsity, 10);
MatrixCharacteristics mc = new MatrixCharacteristics(rows, cols, -1, -1, -1);
writeInputMatrixWithMTD("A", A, false, mc);
// run tests and compare results
runTest(true, false, null, -1);
Assert.assertEquals(0, readDMLMatrixFromHDFS("D").get(new CellIndex(1, 1)), 1e-5);
} finally {
DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
rtplatform = rtold;
}
}
use of org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM in project incubator-systemml by apache.
the class EigenFactorizeTest method runTestEigenFactorize.
private void runTestEigenFactorize(int rows, RUNTIME_PLATFORM rt) {
RUNTIME_PLATFORM rtold = rtplatform;
rtplatform = rt;
boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
if (rtplatform == RUNTIME_PLATFORM.SPARK)
DMLScript.USE_LOCAL_SPARK_CONFIG = true;
try {
getAndLoadTestConfiguration(TEST_NAME1);
String HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = HOME + TEST_NAME1 + ".dml";
programArgs = new String[] { "-args", input("A"), Integer.toString(numEigenValuesToEvaluate), output("D") };
double[][] A = getRandomMatrix(rows, rows, 0, 1, sparsity, 10);
MatrixCharacteristics mc = new MatrixCharacteristics(rows, rows, -1, -1, -1);
writeInputMatrixWithMTD("A", A, false, mc);
// Expected matrix = 1x1 zero matrix
double[][] D = new double[numEigenValuesToEvaluate][1];
for (int i = 0; i < numEigenValuesToEvaluate; i++) {
D[i][0] = 0.0;
}
writeExpectedMatrix("D", D);
boolean exceptionExpected = false;
runTest(true, exceptionExpected, null, -1);
compareResults(1e-8);
} finally {
DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
rtplatform = rtold;
}
}
use of org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM in project incubator-systemml by apache.
the class FullCumminTest method runColAggregateOperationTest.
/**
* @param sparseM1
* @param sparseM2
* @param instType
*/
private void runColAggregateOperationTest(InputType type, boolean sparse, ExecType instType, boolean rewrites) {
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;
break;
}
boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
if (rtplatform == RUNTIME_PLATFORM.SPARK)
DMLScript.USE_LOCAL_SPARK_CONFIG = true;
// rewrites
boolean oldFlagRewrites = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = rewrites;
try {
int cols = (type == InputType.COL_VECTOR) ? 1 : colsMatrix;
int rows = (type == InputType.ROW_VECTOR) ? 1 : rowsMatrix;
double sparsity = (sparse) ? spSparse : spDense;
String TEST_CACHE_DIR = "";
if (TEST_CACHE_ENABLED) {
TEST_CACHE_DIR = type.ordinal() + "_" + sparsity + "/";
}
TestConfiguration config = getTestConfiguration(TEST_NAME);
loadTestConfiguration(config, TEST_CACHE_DIR);
// This is for running the junit test the new way, i.e., construct the arguments directly
String HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = HOME + TEST_NAME + ".dml";
programArgs = new String[] { "-explain", "-args", input("A"), output("B") };
fullRScriptName = HOME + TEST_NAME + ".R";
rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
// generate actual dataset
double[][] A = getRandomMatrix(rows, cols, -0.05, 1, sparsity, 7);
writeInputMatrixWithMTD("A", A, true);
runTest(true, false, null, -1);
if (// in CP no MR jobs should be executed
instType == ExecType.CP || instType == ExecType.SPARK)
Assert.assertEquals("Unexpected number of executed MR jobs.", 0, Statistics.getNoOfExecutedMRJobs());
runRScript(true);
// compare matrices
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("B");
HashMap<CellIndex, Double> rfile = readRMatrixFromFS("B");
TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R");
} finally {
rtplatform = platformOld;
DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlagRewrites;
}
}
use of org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM in project incubator-systemml by apache.
the class FullCumprodTest method runColAggregateOperationTest.
/**
* @param sparseM1
* @param sparseM2
* @param instType
*/
private void runColAggregateOperationTest(InputType type, boolean sparse, ExecType instType, boolean rewrites) {
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;
break;
}
boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
if (rtplatform == RUNTIME_PLATFORM.SPARK)
DMLScript.USE_LOCAL_SPARK_CONFIG = true;
// rewrites
boolean oldFlagRewrites = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = rewrites;
try {
int cols = (type == InputType.COL_VECTOR) ? 1 : colsMatrix;
int rows = (type == InputType.ROW_VECTOR) ? 1 : rowsMatrix;
double sparsity = (sparse) ? spSparse : spDense;
String TEST_CACHE_DIR = "";
if (TEST_CACHE_ENABLED) {
TEST_CACHE_DIR = type.ordinal() + "_" + sparsity + "/";
}
TestConfiguration config = getTestConfiguration(TEST_NAME);
loadTestConfiguration(config, TEST_CACHE_DIR);
// This is for running the junit test the new way, i.e., construct the arguments directly
String HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = HOME + TEST_NAME + ".dml";
programArgs = new String[] { "-explain", "-args", input("A"), output("B") };
fullRScriptName = HOME + TEST_NAME + ".R";
rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
// generate actual dataset
double[][] A = getRandomMatrix(rows, cols, 0.99, 1, sparsity, 7);
writeInputMatrixWithMTD("A", A, true);
runTest(true, false, null, -1);
if (// in CP no MR jobs should be executed
instType == ExecType.CP || instType == ExecType.SPARK)
Assert.assertEquals("Unexpected number of executed MR jobs.", 0, Statistics.getNoOfExecutedMRJobs());
runRScript(true);
// compare matrices
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("B");
HashMap<CellIndex, Double> rfile = readRMatrixFromFS("B");
TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R");
} finally {
rtplatform = platformOld;
DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlagRewrites;
}
}
use of org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM in project incubator-systemml by apache.
the class FullCumsumTest method runColAggregateOperationTest.
/**
* @param sparseM1
* @param sparseM2
* @param instType
*/
private void runColAggregateOperationTest(InputType type, boolean sparse, ExecType instType, boolean rewrites) {
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;
break;
}
boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
if (rtplatform == RUNTIME_PLATFORM.SPARK)
DMLScript.USE_LOCAL_SPARK_CONFIG = true;
// rewrites
boolean oldFlagRewrites = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = rewrites;
try {
int cols = (type == InputType.COL_VECTOR) ? 1 : colsMatrix;
int rows = (type == InputType.ROW_VECTOR) ? 1 : rowsMatrix;
double sparsity = (sparse) ? spSparse : spDense;
String TEST_CACHE_DIR = "";
if (TEST_CACHE_ENABLED) {
TEST_CACHE_DIR = type.ordinal() + "_" + sparsity + "/";
}
TestConfiguration config = getTestConfiguration(TEST_NAME);
loadTestConfiguration(config, TEST_CACHE_DIR);
// This is for running the junit test the new way, i.e., construct the arguments directly
String HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = HOME + TEST_NAME + ".dml";
programArgs = new String[] { "-explain", "-args", input("A"), output("B") };
fullRScriptName = HOME + TEST_NAME + ".R";
rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
// generate actual dataset
double[][] A = getRandomMatrix(rows, cols, -0.05, 1, sparsity, 7);
writeInputMatrixWithMTD("A", A, true);
runTest(true, false, null, -1);
if (// in CP no MR jobs should be executed
instType == ExecType.CP || instType == ExecType.SPARK)
Assert.assertEquals("Unexpected number of executed MR jobs.", 0, Statistics.getNoOfExecutedMRJobs());
runRScript(true);
// compare matrices
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("B");
HashMap<CellIndex, Double> rfile = readRMatrixFromFS("B");
TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R");
} finally {
rtplatform = platformOld;
DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = oldFlagRewrites;
}
}
Aggregations