Page MenuHomePhabricator

[mlir][dataflow] Remove Abstract{Sparse,Dense}Lattice::isAtFixpoint() and an ineffective optimization to simplify public API
ClosedPublic

Authored by phisiart on Aug 11 2022, 1:58 AM.

Details

Summary

Currently, in the MLIR {Sparse,Dense}DataFlowAnalysis API, there is a small optimization:

Before running a transfer function, if the "out state" is already at the pessimistic fixpoint (bottom lattice value), then we know that it cannot possibly be changed, therefore we can skip the transfer function.

I benchmarked and found that this optimization is ineffective, so we can remove it and simplify {Sparse,Dense}DataFlowAnalysis. In a subsequent patch, I plan to change/remove the concept of the pessimistic fixpoint so that the API is further simplified.

Benchmark: I ran the following tests 5 times (after 3 warmup runs), and timed the initializeAndRun() function.

TestBefore (us)After (us)
mlir-opt -test-dead-code-analysis mlir/test/Analysis/DataFlow/test-dead-code-analysis.mlir181.2536187.7074
mlir-opt -- -test-dead-code-analysis mlir/test/Analysis/DataFlow/test-last-modified-callgraph.mlir109.5504105.0654
mlir-opt -- -test-dead-code-analysis mlir/test/Analysis/DataFlow/test-last-modified.mlir333.3646322.4224
mlir-opt -- -allow-unregistered-dialect -sccp mlir/test/Analysis/DataFlow/test-combined-sccp.mlir1027.14921081.818

Note: test-combined-sccp.mlir is crafted by combining mlir/test/Transforms/sccp.mlir, mlir/test/Transforms/sccp-structured.mlir and mlir/test/Transforms/sccp-callgraph.mlir.

Diff Detail

Event Timeline

phisiart created this revision.Aug 11 2022, 1:58 AM
Herald added a project: Restricted Project. · View Herald Transcript
phisiart requested review of this revision.Aug 11 2022, 1:58 AM
aartbik accepted this revision.Aug 11 2022, 9:28 AM

I am added as reviewer due to the trigger word "sparse" ;-), but this changes looks acceptable (perhap make it a bit more clear that is does change semantics beyond just removing the function in the title)

This revision is now accepted and ready to land.Aug 11 2022, 9:28 AM
phisiart updated this revision to Diff 452033.Aug 11 2022, 4:31 PM

Also remove isAtFixpoint() from dense analysis.

phisiart retitled this revision from Remove isAtFixpoint(). to [mlir][dataflow] Remove Abstract{Sparse,Dense}Lattice::isAtFixpoint() and an ineffective optimization to simplify public API.Aug 11 2022, 4:53 PM
phisiart edited the summary of this revision. (Show Details)

I am added as reviewer due to the trigger word "sparse" ;-), but this changes looks acceptable (perhap make it a bit more clear that is does change semantics beyond just removing the function in the title)

I modified the title and description. Also included the change to dense analysis (it was previously missed).

Mogball accepted this revision.Aug 11 2022, 5:56 PM

Thanks!