Skip to content

Commit 3515a65

Browse files
committed
create new test class
1 parent 7f38c7c commit 3515a65

4 files changed

Lines changed: 23 additions & 20 deletions

File tree

src/test/java/org/apache/sysds/performance/primitives/SparseRowAllocPerfTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public SparseRowAllocPerfTest() {
3939
}
4040

4141
public static void main(String[] args) {
42-
new SparseRowAllocPerfTest().compareInitAndAlloc();
42+
new SparseRowAllocPerfTest().testDenAndSpaAlloc();
4343
}
4444

4545
public void testDenAndSpaAlloc() {

src/test/java/org/apache/sysds/performance/primitives/TypicalExpressionTest.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
import org.apache.sysds.api.jmlc.PreparedScript;
88
import org.apache.sysds.common.Types.ExecMode;
99
import org.apache.sysds.common.Types.ExecType;
10+
import org.apache.sysds.conf.CompilerConfig;
11+
import org.apache.sysds.conf.DMLConfig;
1012
import org.apache.sysds.hops.OptimizerUtils;
1113
import org.apache.sysds.performance.TimingUtils;
1214
import org.apache.sysds.runtime.matrix.data.MatrixValue;
1315
import org.apache.sysds.test.AutomatedTestBase;
1416
import org.apache.sysds.test.TestConfiguration;
1517
import org.apache.sysds.test.TestUtils;
1618
import org.apache.sysds.test.functions.codegen.RowAggTmplTest;
19+
import org.apache.sysds.utils.Explain;
1720
import org.junit.Test;
1821

1922
import java.io.File;
@@ -40,11 +43,11 @@ public class TypicalExpressionTest extends AutomatedTestBase {
4043
private final static double sparsity1 = 0.9;
4144
private final static double sparsity2 = 0.1;
4245
private final static double eps = 1e-8;
43-
private int rows = 500;
44-
private int cols = 1000;
45-
double[] sparsities = new double[] {1, 0.3333, 0.1111, 0.0333, 0.0111, 0.0033, 0.0011};
46-
int warmupRuns = 1;
47-
int repetitions = 2;
46+
private int rows = 10;
47+
private int cols = 10000;
48+
double[] sparsities = new double[] {1, 0.3333333, 0.1111111, 0.0333333, 0.0111111, 0.0033333, 0.0011111, 0.0003333, 0.0001111, 0.0000333, 0.0000111, 0.0000033, 0.0000011, 0.0000003, 0.0000001};
49+
int warmupRuns = 10;
50+
int repetitions = 500;
4851

4952
@Override
5053
public void setUp() {
@@ -68,14 +71,14 @@ public void setUp() {
6871
public static void main(String[] args) {
6972
TypicalExpressionTest t = new TypicalExpressionTest();
7073
t.setUpBase();
71-
t.runBenchmark(TEST_NAME2);
74+
t.runBenchmark(TEST_NAME1);
7275
t.tearDown();
7376
}
7477

7578
public void runBenchmark(String testname) {
76-
setUp();
79+
// setUp();
7780
logResults(runPerfTest(testname, true, ExecType.CP), true);
78-
logResults(runPerfTest(testname, false, ExecType.CP), false);
81+
// logResults(runPerfTest(testname, false, ExecType.CP), false);
7982
}
8083

8184
public void runBenchmark(String testname, int rows, int cols) {
@@ -92,29 +95,28 @@ private String[] runPerfTest(String testname, boolean sparseRowVec, ExecType et)
9295

9396
String[] resultTime = new String[sparsities.length];
9497

95-
Connection conn = new Connection();
98+
Connection conn = new Connection(new DMLConfig(), CompilerConfig.ConfigType.CODEGEN_ENABLED);
99+
DMLScript.EXPLAIN = Explain.ExplainType.CODEGEN;
100+
boolean oldSparse = DMLScript.SPARSE_INTERMEDIATE;
101+
DMLScript.SPARSE_INTERMEDIATE = sparseRowVec;
96102

97103
try {
98104

99-
getAndLoadTestConfiguration(testname);
105+
// getAndLoadTestConfiguration(testname);
100106
String HOME = SCRIPT_DIR + TEST_DIR;
101107
String script = DMLScript.readDMLScript(true, HOME + testname + ".dml");
102108

103109
String[] inputs = new String[] {"A", "v", "B"};
104110
PreparedScript pscript = conn.prepareScript(script, inputs, new String[] {"S"});
105111

106-
boolean oldSparse = DMLScript.SPARSE_INTERMEDIATE;
107-
DMLScript.SPARSE_INTERMEDIATE = sparseRowVec;
108-
109112
for(int i = 0; i < sparsities.length; i++) {
110-
//generate random input matrices
111113
double[][] A = getRandomMatrix(rows, cols, 1, 31, sparsities[i], 1234);
112114
double[][] B = getRandomMatrix(rows, cols, 1, 31, sparsities[i], 5678);
113115
double[][] V = getRandomMatrix(rows, 1, 1, 31, sparsities[i], 9876);
114116

115-
pscript.setMatrix("A", A);
116-
pscript.setMatrix("v", V);
117-
pscript.setMatrix("B", B);
117+
pscript.setMatrix("A", A, true);
118+
pscript.setMatrix("B", B, true);
119+
pscript.setMatrix("v", V, true);
118120

119121
TimingUtils.time(() -> pscript.executeScript(), warmupRuns);
120122
double[] result = TimingUtils.time(() -> pscript.executeScript(), repetitions);
@@ -136,6 +138,7 @@ private String[] runPerfTest(String testname, boolean sparseRowVec, ExecType et)
136138
resetExecMode(platformOld);
137139
OptimizerUtils.ALLOW_AUTO_VECTORIZATION = true;
138140
OptimizerUtils.ALLOW_OPERATOR_FUSION = true;
141+
conn.close();
139142
}
140143
return resultTime;
141144
}

src/test/scripts/functions/codegen/rowAggPattern49.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ K = rbind(Z, Y, Y, Y, Y, Y, Y, Y, Y)
3939

4040
# S = (X < rowSums(X*K))
4141
# S = X*rowMins(K)*X
42-
S = X*rowSums(K*v)*X
42+
# S = X*rowSums(K*v)*X
4343
# S = (X*v)/rowSums(X*v)
4444
# S = abs((X*v)/rowSums(X*v))
4545
# S = (X/v)+rowMeans(X-v)

src/test/scripts/functions/codegen/rowAggPattern49.dml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ while(FALSE) { }
3838

3939
# S = (X < rowSums(X*K))
4040
# S = X*(k>1)*X
41-
S = X*rowSums(K*v)*X
41+
# S = X*rowSums(K*v)*X
4242
# S = (X*v)/rowSums(X*v)
4343
# S = abs((X*v)/rowSums(X*v))
4444
# S = (X/v)+rowMeans(X-v)

0 commit comments

Comments
 (0)