Skip to content

Commit

Permalink
Some more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaybit0 committed Jan 29, 2025
1 parent 5aa69ea commit 2851b1f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions conf/SystemDS-config-defaults.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
-->

<root>
<sysds.optlevel>2</sysds.optlevel>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public ProgramRewriter(boolean staticRewrites, boolean dynamicRewrites)
_dagRuleSet.add( new RewriteCommonSubexpressionElimination() );
if( OptimizerUtils.ALLOW_CONSTANT_FOLDING )
_dagRuleSet.add( new RewriteConstantFolding() ); //dependency: cse
if ( DMLScript.APPLY_GENERATED_REWRITES ) {
_dagRuleSet.add(new RewriteAutomaticallyGenerated(new GeneratedRewriteClass()));
}
if( OptimizerUtils.ALLOW_ALGEBRAIC_SIMPLIFICATION )
_dagRuleSet.add( new RewriteAlgebraicSimplificationStatic() ); //dependencies: cse
if( OptimizerUtils.ALLOW_COMMON_SUBEXPRESSION_ELIMINATION ) //dependency: simplifications (no need to merge leafs again)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class RewriteAutomaticallyGenerated extends HopRewriteRule {
public static final String FILE_PATH = "/Users/janniklindemann/Dev/MScThesis/rules.rl";
public static final String VALIDATED_FILE_PATH = "/Users/janniklindemann/Dev/MScThesis/rules_validated.rl";
public static final String RAW_FILE_PATH = "/Users/janniklindemann/Dev/MScThesis/raw_rules.rl";
public static final String FILE_PATH_MB = "/Users/janniklindemann/Dev/MScThesis/rules_mb.rl";
public static RewriteAutomaticallyGenerated existingRewrites;

private Function<Hop, Hop> rewriteFn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ public boolean determineConditionalApplicability() {
if (!requireCostCheck)
return false;

List<RewriterStatement> roots = toRoots == null ? List.of(toRoot) : toRoots;

boolean integrateSparsityInCosts = isConditionalMultiRule() || RewriterCostEstimator.doesHaveAnImpactOnOptimalExpression(costs, true, false, 20);

MutableObject<RewriterAssertions> assertionRef = new MutableObject<>(assertions);
fromCost = RewriterCostEstimator.getRawCostFunction(fromRoot, ctx, assertionRef, !integrateSparsityInCosts);
toCosts = getStmt2AsList().stream().map(root -> RewriterCostEstimator.getRawCostFunction(root, ctx, assertionRef, !integrateSparsityInCosts)).collect(Collectors.toList());

fromCost = RewriterSparsityEstimator.rollupSparsities(fromCost, RewriterSparsityEstimator.estimateAllNNZ(fromRoot, ctx), ctx);
toCosts = IntStream.range(0, toCosts.size()).mapToObj(i -> RewriterSparsityEstimator.rollupSparsities(toCosts.get(i), RewriterSparsityEstimator.estimateAllNNZ(toRoots.get(i), ctx), ctx)).collect(Collectors.toList());
toCosts = IntStream.range(0, toCosts.size()).mapToObj(i -> RewriterSparsityEstimator.rollupSparsities(toCosts.get(i), RewriterSparsityEstimator.estimateAllNNZ(roots.get(i), ctx), ctx)).collect(Collectors.toList());

return requireCostCheck;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public static void testExpressionClustering() {
int pruneDataSubexrBiggerThan = 1000;
int maxCostSamples = 50;

long startTime = System.currentTimeMillis();
AtomicLong generatedExpressions = new AtomicLong(0);
AtomicLong evaluatedExpressions = new AtomicLong(0);
AtomicLong failures = new AtomicLong(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void testConditional() {
@Test
public void codeGen() {
try {
List<String> lines = Files.readAllLines(Paths.get(RewriteAutomaticallyGenerated.FILE_PATH_CONDITIONAL));
List<String> lines = Files.readAllLines(Paths.get(RewriteAutomaticallyGenerated.FILE_PATH_MB));
RewriterRuleSet ruleSet = RewriterRuleSet.deserialize(lines, ctx);

RewriterRuntimeUtils.printUnknowns = false;
Expand Down

0 comments on commit 2851b1f

Please # to comment.