Repository: systemml Updated Branches: refs/heads/master e1efd844d -> 878430c9f
[HOTFIX] Fix literal replacement test (for new rewrite phase order) Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/878430c9 Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/878430c9 Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/878430c9 Branch: refs/heads/master Commit: 878430c9f7e9320c462bd377e9fd9d12eb0f5dff Parents: e1efd84 Author: Matthias Boehm <[email protected]> Authored: Fri Mar 16 15:50:28 2018 -0700 Committer: Matthias Boehm <[email protected]> Committed: Fri Mar 16 15:50:28 2018 -0700 ---------------------------------------------------------------------- .../LiteralReplaceCastScalarReadTest.java | 86 +++++++++----------- 1 file changed, 39 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/878430c9/src/test/java/org/apache/sysml/test/integration/functions/recompile/LiteralReplaceCastScalarReadTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/recompile/LiteralReplaceCastScalarReadTest.java b/src/test/java/org/apache/sysml/test/integration/functions/recompile/LiteralReplaceCastScalarReadTest.java index b19db85..2a7fd61 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/recompile/LiteralReplaceCastScalarReadTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/recompile/LiteralReplaceCastScalarReadTest.java @@ -21,7 +21,7 @@ package org.apache.sysml.test.integration.functions.recompile; import org.junit.Assert; import org.junit.Test; - +import org.apache.sysml.hops.OptimizerUtils; import org.apache.sysml.lops.UnaryCP; import org.apache.sysml.parser.Expression.ValueType; import org.apache.sysml.test.integration.AutomatedTestBase; @@ -29,76 +29,68 @@ import org.apache.sysml.test.integration.TestConfiguration; import org.apache.sysml.test.utils.TestUtils; import org.apache.sysml.utils.Statistics; -/** - * - */ public class LiteralReplaceCastScalarReadTest extends AutomatedTestBase { - private final static String TEST_NAME = "LiteralReplaceCastScalar"; private final static String TEST_DIR = "functions/recompile/"; private final static String TEST_CLASS_DIR = TEST_DIR + LiteralReplaceCastScalarReadTest.class.getSimpleName() + "/"; @Override - public void setUp() - { + public void setUp() { TestUtils.clearAssertionInformation(); addTestConfiguration(TEST_NAME, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME, new String[] { "R" })); } @Test - public void testRemoveCastsInputInteger() - { + public void testRemoveCastsInputInteger() { runScalarCastTest(ValueType.INT); } @Test - public void testRemoveCastsInputDouble() - { + public void testRemoveCastsInputDouble() { runScalarCastTest(ValueType.DOUBLE); } @Test - public void testRemoveCastsInputBoolean() - { + public void testRemoveCastsInputBoolean() { runScalarCastTest(ValueType.BOOLEAN); } - - - /** - * - * @param vt - */ - private void runScalarCastTest( ValueType vt ) - { - TestConfiguration config = getTestConfiguration(TEST_NAME); - - // input value - String val = null; - switch( vt ) { - case INT: val = "7"; break; - case DOUBLE: val = "7.3"; break; - case BOOLEAN: val = "TRUE"; break; - default: //do nothing - } - - // 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"; - //note: stats required for runtime check of rewrite - programArgs = new String[]{"-explain","-stats","-args", val }; + + private void runScalarCastTest( ValueType vt ) { + boolean oldCF = OptimizerUtils.ALLOW_CONSTANT_FOLDING; - loadTestConfiguration(config); - - runTest(true, false, null, -1); + try { + TestConfiguration config = getTestConfiguration(TEST_NAME); + loadTestConfiguration(config); + OptimizerUtils.ALLOW_CONSTANT_FOLDING = false; + + // input value + String val = null; + switch( vt ) { + case INT: val = "7"; break; + case DOUBLE: val = "7.3"; break; + case BOOLEAN: val = "TRUE"; break; + default: //do nothing + } + + // 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"; + //note: stats required for runtime check of rewrite + programArgs = new String[]{"-explain","-stats","-args", val }; + + runTest(true, false, null, -1); - //CHECK cast replacement and sum replacement - Assert.assertEquals(false, Statistics.getCPHeavyHitterOpCodes().contains(UnaryCP.CAST_AS_INT_OPCODE)); - Assert.assertEquals(false, Statistics.getCPHeavyHitterOpCodes().contains(UnaryCP.CAST_AS_DOUBLE_OPCODE)); - Assert.assertEquals(false, Statistics.getCPHeavyHitterOpCodes().contains(UnaryCP.CAST_AS_BOOLEAN_OPCODE)); - Assert.assertEquals(false, Statistics.getCPHeavyHitterOpCodes().contains("uak+")); //sum + //CHECK cast replacement and sum replacement + Assert.assertEquals(false, Statistics.getCPHeavyHitterOpCodes().contains(UnaryCP.CAST_AS_INT_OPCODE)); + Assert.assertEquals(false, Statistics.getCPHeavyHitterOpCodes().contains(UnaryCP.CAST_AS_DOUBLE_OPCODE)); + Assert.assertEquals(false, Statistics.getCPHeavyHitterOpCodes().contains(UnaryCP.CAST_AS_BOOLEAN_OPCODE)); + Assert.assertEquals(false, Statistics.getCPHeavyHitterOpCodes().contains("uak+")); //sum + } + finally { + OptimizerUtils.ALLOW_CONSTANT_FOLDING = oldCF; + } } - -} \ No newline at end of file +}
