Search in sources :

Example 56 with CellIndex

use of org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex in project incubator-systemml by apache.

the class ScalarFunctionTest method runScalarFunctionTest.

/**
 * @param sparseM1
 * @param sparseM2
 * @param instType
 */
private void runScalarFunctionTest(String testname) {
    String TEST_NAME = testname;
    TestConfiguration config = getTestConfiguration(TEST_NAME);
    loadTestConfiguration(config);
    String HOME = SCRIPT_DIR + TEST_DIR;
    fullDMLScriptName = HOME + TEST_NAME + ".dml";
    programArgs = new String[] { "-args", output("R") };
    fullRScriptName = HOME + TEST_NAME + ".R";
    rCmd = getRCmd(expectedDir());
    // run Tests
    runTest(true, false, null, -1);
    runRScript(true);
    // compare matrices
    HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("R");
    HashMap<CellIndex, Double> rfile = readRMatrixFromFS("R");
    TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R");
    // check meta data
    checkDMLMetaDataFile("R", new MatrixCharacteristics(1, 1, 1, 1));
}
Also used : CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration) MatrixCharacteristics(org.apache.sysml.runtime.matrix.MatrixCharacteristics)

Example 57 with CellIndex

use of org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex in project incubator-systemml by apache.

the class ZeroRowsColsMatrixTest method runEmptyMatrixTest.

private void runEmptyMatrixTest(String testname, boolean rewrites, boolean emptyRet, ExecType et) {
    RUNTIME_PLATFORM platformOld = rtplatform;
    switch(et) {
        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;
    boolean rewritesOld = OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION;
    OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = rewrites;
    try {
        String TEST_NAME = testname;
        TestConfiguration config = getTestConfiguration(TEST_NAME);
        loadTestConfiguration(config);
        String HOME = SCRIPT_DIR + TEST_DIR;
        fullDMLScriptName = HOME + TEST_NAME + ".dml";
        programArgs = new String[] { "-explain", "recompile_runtime", "-args", String.valueOf(dim), String.valueOf(emptyRet).toUpperCase(), output("R") };
        fullRScriptName = HOME + TEST_NAME + ".R";
        rCmd = getRCmd(String.valueOf(dim), String.valueOf(emptyRet).toUpperCase(), expectedDir());
        // run Tests
        runTest(true, false, null, -1);
        runRScript(true);
        // compare matrices
        HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("R");
        HashMap<CellIndex, Double> rfile = readRMatrixFromFS("R");
        TestUtils.compareMatrices(dmlfile, rfile, eps, "Stat-DML", "Stat-R");
        // check meta data
        if (!testname.equals(TEST_NAME4))
            checkDMLMetaDataFile("R", new MatrixCharacteristics(dim, 3, 1000, 1000));
    } finally {
        OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION = rewritesOld;
        rtplatform = platformOld;
        DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
    }
}
Also used : RUNTIME_PLATFORM(org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM) CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration) MatrixCharacteristics(org.apache.sysml.runtime.matrix.MatrixCharacteristics)

Example 58 with CellIndex

use of org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex in project incubator-systemml by apache.

the class ParForAccumulatorResultMergeTest method runParForAccumulatorResultMergeTest.

private void runParForAccumulatorResultMergeTest(String test, boolean init, boolean sparse, ExecType et) {
    RUNTIME_PLATFORM platformOld = rtplatform;
    switch(et) {
        case CP:
            rtplatform = RUNTIME_PLATFORM.SINGLE_NODE;
            break;
        case MR:
            rtplatform = RUNTIME_PLATFORM.HYBRID;
            break;
        case SPARK:
            rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK;
            break;
        default:
            throw new RuntimeException("Unsupported exec type: " + et.name());
    }
    boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
    if (et == ExecType.SPARK)
        DMLScript.USE_LOCAL_SPARK_CONFIG = true;
    try {
        String TEST_NAME = test;
        TestConfiguration config = getTestConfiguration(TEST_NAME);
        config.addVariable("rows", rows);
        config.addVariable("cols", cols);
        loadTestConfiguration(config);
        String HOME = SCRIPT_DIR + TEST_DIR;
        fullDMLScriptName = HOME + TEST_NAME + ".dml";
        programArgs = new String[] { "-args", String.valueOf(rows), String.valueOf(cols), String.valueOf(init).toUpperCase(), String.valueOf(sparse).toUpperCase(), output("R") };
        fullRScriptName = HOME + TEST_NAME.substring(0, TEST_NAME.length() - 1) + ".R";
        rCmd = "Rscript" + " " + fullRScriptName + " " + String.valueOf(rows) + " " + String.valueOf(cols) + " " + String.valueOf(init).toUpperCase() + " " + String.valueOf(sparse).toUpperCase() + " " + expectedDir();
        // run tests
        runTest(true, false, null, -1);
        runRScript(true);
        // compare matrices
        HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("R");
        HashMap<CellIndex, Double> rfile = readRMatrixFromFS("R");
        TestUtils.compareMatrices(dmlfile, rfile, eps, "DML", "R");
    } finally {
        rtplatform = platformOld;
        DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
    }
}
Also used : RUNTIME_PLATFORM(org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM) CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 59 with CellIndex

use of org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex in project incubator-systemml by apache.

the class ParForBlockwiseDataPartitioningTest method runParForDataPartitioningTest.

private void runParForDataPartitioningTest(String testname, PDataPartitioner partitioner, PExecMode mode, boolean sparse) {
    RUNTIME_PLATFORM oldRT = rtplatform;
    boolean oldUseSparkConfig = DMLScript.USE_LOCAL_SPARK_CONFIG;
    boolean oldDynRecompile = CompilerConfig.FLAG_DYN_RECOMPILE;
    // run always in spark execution mode
    DMLScript.USE_LOCAL_SPARK_CONFIG = true;
    rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK;
    try {
        TestConfiguration config = getTestConfiguration(testname);
        loadTestConfiguration(config);
        CompilerConfig.FLAG_DYN_RECOMPILE = false;
        String HOME = SCRIPT_DIR + TEST_DIR;
        fullDMLScriptName = HOME + testname + ".dml";
        programArgs = new String[] { "-stats", "-args", input("V"), partitioner.name(), mode.name(), output("R") };
        fullRScriptName = HOME + testname + ".R";
        rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
        // generate input data
        int lrows = testname.equals(TEST_NAME1) || testname.equals(TEST_NAME3) ? rows : cols;
        int lcols = testname.equals(TEST_NAME1) || testname.equals(TEST_NAME3) ? cols : rows;
        double lsparsity = sparse ? sparsity2 : sparsity1;
        double[][] V = getRandomMatrix(lrows, lcols, 0, 1, lsparsity, System.nanoTime());
        writeInputMatrixWithMTD("V", V, true);
        // run test
        runTest(true, false, null, -1);
        runRScript(true);
        // compare matrices
        HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("R");
        HashMap<CellIndex, Double> rfile = readRMatrixFromFS("Rout");
        TestUtils.compareMatrices(dmlfile, rfile, eps, "DML", "R");
        // test for correct plan
        boolean pos = testname.equals(TEST_NAME1) || testname.equals(TEST_NAME2);
        Assert.assertEquals(pos, heavyHittersContainsSubString("ParFor-DPSP") || heavyHittersContainsSubString("ParFor-DPESP"));
    } finally {
        rtplatform = oldRT;
        DMLScript.USE_LOCAL_SPARK_CONFIG = oldUseSparkConfig;
        CompilerConfig.FLAG_DYN_RECOMPILE = oldDynRecompile;
    }
}
Also used : RUNTIME_PLATFORM(org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM) CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 60 with CellIndex

use of org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex in project incubator-systemml by apache.

the class ParForColwiseDataPartitioningTest method runParForDataPartitioningTest.

/**
 * @param outer execution mode of outer parfor loop
 * @param inner execution mode of inner parfor loop
 * @param instType execution mode of instructions
 */
private void runParForDataPartitioningTest(PDataPartitioner partitioner, PExecMode mode, boolean small, boolean sparse, boolean multiParts) {
    RUNTIME_PLATFORM oldRT = rtplatform;
    boolean oldUseSparkConfig = DMLScript.USE_LOCAL_SPARK_CONFIG;
    if (partitioner == PDataPartitioner.REMOTE_SPARK || mode == PExecMode.REMOTE_SPARK) {
        DMLScript.USE_LOCAL_SPARK_CONFIG = true;
        rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK;
    }
    try {
        // inst exec type, influenced via rows
        int rows = small ? rows1 : rows2;
        int cols = small ? cols1 : cols2;
        // script
        int scriptNum = -1;
        switch(partitioner) {
            case NONE:
                scriptNum = 1;
                break;
            case LOCAL:
                if (mode == PExecMode.LOCAL)
                    scriptNum = 2;
                else
                    scriptNum = 3;
            case REMOTE_MR:
                if (mode == PExecMode.LOCAL) {
                    if (!multiParts)
                        scriptNum = 4;
                    else
                        scriptNum = 6;
                } else
                    scriptNum = 5;
                break;
            case REMOTE_SPARK:
                if (mode == PExecMode.LOCAL) {
                    if (!multiParts)
                        scriptNum = 7;
                    else
                        scriptNum = 9;
                } else
                    scriptNum = 8;
                break;
            default:
        }
        TestConfiguration config = getTestConfiguration(TEST_NAME);
        config.addVariable("rows", rows);
        config.addVariable("cols", cols);
        loadTestConfiguration(config);
        /* 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 + scriptNum + ".dml";
        programArgs = new String[] { "-args", input("V"), Integer.toString(rows), Integer.toString(cols), output("R") };
        fullRScriptName = HOME + TEST_NAME + (multiParts ? "6" : "") + ".R";
        rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
        long seed = System.nanoTime();
        double sparsity = -1;
        if (sparse)
            sparsity = sparsity2;
        else
            sparsity = sparsity1;
        double[][] V = getRandomMatrix(rows, cols, 0, 1, sparsity, seed);
        writeInputMatrix("V", V, true);
        boolean exceptionExpected = false;
        runTest(true, exceptionExpected, null, -1);
        runRScript(true);
        // compare matrices
        HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromHDFS("R");
        HashMap<CellIndex, Double> rfile = readRMatrixFromFS("Rout");
        TestUtils.compareMatrices(dmlfile, rfile, eps, "DML", "R");
    } finally {
        rtplatform = oldRT;
        DMLScript.USE_LOCAL_SPARK_CONFIG = oldUseSparkConfig;
    }
}
Also used : RUNTIME_PLATFORM(org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM) CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Aggregations

CellIndex (org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex)257 TestConfiguration (org.apache.sysml.test.integration.TestConfiguration)201 RUNTIME_PLATFORM (org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM)173 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)37 Test (org.junit.Test)20 HashMap (java.util.HashMap)16 IOException (java.io.IOException)14 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)9 Random (java.util.Random)8 ArrayList (java.util.ArrayList)7 BufferedReader (java.io.BufferedReader)6 StringTokenizer (java.util.StringTokenizer)6 InputStreamReader (java.io.InputStreamReader)5 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)5 FileSystem (org.apache.hadoop.fs.FileSystem)5 Path (org.apache.hadoop.fs.Path)5 FileStatus (org.apache.hadoop.fs.FileStatus)4 FileReader (java.io.FileReader)2 DMLException (org.apache.sysml.api.DMLException)2 MMultMethod (org.apache.sysml.hops.AggBinaryOp.MMultMethod)2