Search in sources :

Example 91 with TestConfiguration

use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.

the class IPAFunctionInliningTest method runIPAFunInlineTest.

private void runIPAFunInlineTest(String testName, boolean IPA) {
    boolean oldFlagIPA = OptimizerUtils.ALLOW_INTER_PROCEDURAL_ANALYSIS;
    try {
        TestConfiguration config = getTestConfiguration(testName);
        loadTestConfiguration(config);
        String HOME = SCRIPT_DIR + TEST_DIR;
        fullDMLScriptName = HOME + testName + ".dml";
        programArgs = new String[] { "-explain", "-stats", "-args", output("R") };
        fullRScriptName = HOME + testName + ".R";
        rCmd = getRCmd(expectedDir());
        OptimizerUtils.ALLOW_INTER_PROCEDURAL_ANALYSIS = IPA;
        // run script and compare output
        runTest(true, false, null, -1);
        // compare results
        if (!testName.equals(TEST_NAME6)) {
            double val = readDMLMatrixFromHDFS("R").get(new CellIndex(1, 1));
            Assert.assertTrue("Wrong result: 7 vs " + val, Math.abs(val - 7) < Math.pow(10, -14));
        }
        // compare inlined functions
        boolean inlined = (IPA && ArrayUtils.contains(new String[] { TEST_NAME1, TEST_NAME2, TEST_NAME3, TEST_NAME6 }, testName));
        Assert.assertTrue("Unexpected function call: " + inlined, !heavyHittersContainsSubString("foo") == inlined);
        // check for incorrect operation replication
        if (testName.equals(TEST_NAME6))
            Assert.assertTrue(Statistics.getCPHeavyHitterCount("print") == 1);
    } finally {
        OptimizerUtils.ALLOW_INTER_PROCEDURAL_ANALYSIS = oldFlagIPA;
    }
}
Also used : CellIndex(org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 92 with TestConfiguration

use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.

the class IPALiteralReplacementTest method setUp.

@Override
public void setUp() {
    TestUtils.clearAssertionInformation();
    addTestConfiguration(TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "R" }));
    addTestConfiguration(TEST_NAME2, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME2, new String[] { "R" }));
}
Also used : TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 93 with TestConfiguration

use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.

the class IPANnzPropagationTest method runIPANnzPropgationTest.

private void runIPANnzPropgationTest(String testname) {
    // Save old settings
    boolean sparkConfigOld = DMLScript.USE_LOCAL_SPARK_CONFIG;
    RUNTIME_PLATFORM platformOld = rtplatform;
    try {
        // Setup test
        TestConfiguration config = getTestConfiguration(testname);
        loadTestConfiguration(config);
        String HOME = SCRIPT_DIR + TEST_DIR;
        fullDMLScriptName = HOME + testname + ".dml";
        programArgs = new String[] { "-stats", "-explain", "recompile_hops" };
        DMLScript.USE_LOCAL_SPARK_CONFIG = true;
        rtplatform = RUNTIME_PLATFORM.HYBRID_SPARK;
        runTest(true, false, null, -1);
        // check for propagated nnz
        checkNumCompiledSparkInst(testname.equals(TEST_NAME1) ? 0 : 1);
        checkNumExecutedSparkInst(0);
    } finally {
        DMLScript.USE_LOCAL_SPARK_CONFIG = sparkConfigOld;
        rtplatform = platformOld;
    }
}
Also used : RUNTIME_PLATFORM(org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM) TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 94 with TestConfiguration

use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.

the class IPAScalarVariablePropagationTest method runIPAScalarVariablePropagationTest.

/**
 * @param testname
 * @param IPA
 */
private void runIPAScalarVariablePropagationTest(String testname, boolean IPA) {
    boolean oldFlagIPA = OptimizerUtils.ALLOW_INTER_PROCEDURAL_ANALYSIS;
    try {
        TestConfiguration config = getTestConfiguration(testname);
        loadTestConfiguration(config);
        String HOME = SCRIPT_DIR + TEST_DIR;
        fullDMLScriptName = HOME + testname + ".dml";
        programArgs = new String[] { "-stats", "-args", String.valueOf(10) };
        OptimizerUtils.ALLOW_INTER_PROCEDURAL_ANALYSIS = IPA;
        // run test, incl expected MR jobs (in case if IPA 0 due to scalar propagation)
        runTest(true, false, null, IPA ? 0 : 28);
        // check for applied rewrites (in both cases, we expect the rewrites to happen:
        // - without IPA it should be marked for recompilation and recompiled per iteration
        // - with IPA the scalar rank should be directly propagated into the function
        Assert.assertTrue("Missing opcode wdivmm", Statistics.getCPHeavyHitterOpCodes().contains(WeightedDivMM.OPCODE_CP));
        Assert.assertTrue("Missing opcode wcemm", Statistics.getCPHeavyHitterOpCodes().contains(WeightedCrossEntropy.OPCODE_CP));
    } finally {
        OptimizerUtils.ALLOW_INTER_PROCEDURAL_ANALYSIS = oldFlagIPA;
    }
}
Also used : TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Example 95 with TestConfiguration

use of org.apache.sysml.test.integration.TestConfiguration in project incubator-systemml by apache.

the class IPAScalarVariablePropagationTest method setUp.

@Override
public void setUp() {
    TestUtils.clearAssertionInformation();
    addTestConfiguration(TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] {}));
}
Also used : TestConfiguration(org.apache.sysml.test.integration.TestConfiguration)

Aggregations

TestConfiguration (org.apache.sysml.test.integration.TestConfiguration)866 Test (org.junit.Test)299 CellIndex (org.apache.sysml.runtime.matrix.data.MatrixValue.CellIndex)201 RUNTIME_PLATFORM (org.apache.sysml.api.DMLScript.RUNTIME_PLATFORM)171 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)50 IOException (java.io.IOException)18 MatrixBlock (org.apache.sysml.runtime.matrix.data.MatrixBlock)14 Modulus (org.apache.sysml.runtime.functionobjects.Modulus)9 HashMap (java.util.HashMap)8 FrameBlock (org.apache.sysml.runtime.matrix.data.FrameBlock)8 DMLException (org.apache.sysml.api.DMLException)6 Random (java.util.Random)5 ValueType (org.apache.sysml.parser.Expression.ValueType)5 Date (java.util.Date)3 BufferedReader (java.io.BufferedReader)2 FileReader (java.io.FileReader)2 Connection (org.apache.sysml.api.jmlc.Connection)2 DMLConfig (org.apache.sysml.conf.DMLConfig)2 DMLProgram (org.apache.sysml.parser.DMLProgram)2 DMLTranslator (org.apache.sysml.parser.DMLTranslator)2