Skip to content

Commit 742eec8

Browse files
committed
[SYSTEMDS-3765] Reproducible test case for the need of time() hoisting
1 parent 2ef2ebd commit 742eec8

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.sysds.test.functions.rewrite;
21+
22+
import org.junit.Test;
23+
import org.apache.sysds.common.Types.ExecMode;
24+
import org.apache.sysds.common.Types.ExecType;
25+
import org.apache.sysds.test.AutomatedTestBase;
26+
import org.apache.sysds.test.TestConfiguration;
27+
import org.apache.sysds.test.TestUtils;
28+
29+
public class RewriteHoistingTimeTest extends AutomatedTestBase
30+
{
31+
private static final String TEST_NAME1 = "RewriteTimeHoisting";
32+
33+
private static final String TEST_DIR = "functions/rewrite/";
34+
private static final String TEST_CLASS_DIR = TEST_DIR + RewriteHoistingTimeTest.class.getSimpleName() + "/";
35+
36+
private static final int rows = 1001;
37+
private static final int cols = 1002;
38+
39+
@Override
40+
public void setUp() {
41+
TestUtils.clearAssertionInformation();
42+
addTestConfiguration( TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] {"R"}) );
43+
}
44+
45+
@Test
46+
public void testTimeHoisting() {
47+
test(TEST_NAME1, ExecType.CP);
48+
}
49+
50+
private void test(String testname, ExecType et)
51+
{
52+
ExecMode platformOld = setExecMode(et);
53+
54+
try
55+
{
56+
TestConfiguration config = getTestConfiguration(testname);
57+
loadTestConfiguration(config);
58+
59+
String HOME = SCRIPT_DIR + TEST_DIR;
60+
fullDMLScriptName = HOME + testname + ".dml";
61+
programArgs = new String[] { "-explain", "-args",
62+
String.valueOf(rows), String.valueOf(cols) };
63+
64+
//FIXME need to hoist time() out of expression similar to function calls
65+
runTest(true, false, null, -1);
66+
}
67+
finally {
68+
resetExecMode(platformOld);
69+
}
70+
}
71+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#-------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
#-------------------------------------------------------------
21+
22+
t1 = time();
23+
X = rand(rows=$1, cols=$2);
24+
25+
print("time = "+(time()-t1)/1e9+"s"+" "+sum(X));
26+

0 commit comments

Comments
 (0)