77import org .apache .sysds .api .jmlc .PreparedScript ;
88import org .apache .sysds .common .Types .ExecMode ;
99import org .apache .sysds .common .Types .ExecType ;
10+ import org .apache .sysds .conf .CompilerConfig ;
11+ import org .apache .sysds .conf .DMLConfig ;
1012import org .apache .sysds .hops .OptimizerUtils ;
1113import org .apache .sysds .performance .TimingUtils ;
1214import org .apache .sysds .runtime .matrix .data .MatrixValue ;
1315import org .apache .sysds .test .AutomatedTestBase ;
1416import org .apache .sysds .test .TestConfiguration ;
1517import org .apache .sysds .test .TestUtils ;
1618import org .apache .sysds .test .functions .codegen .RowAggTmplTest ;
19+ import org .apache .sysds .utils .Explain ;
1720import org .junit .Test ;
1821
1922import 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 }
0 commit comments