This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Presburger] Optimize for union & subtract
ClosedPublic

Authored by gilsaia on Jul 25 2023, 8:03 AM.

Details

Summary

Added a series of optimization to the Subtract & Union function of PresburgerRelation, referring to the ISL implementation.
Add isPlainEqual to Subtract & union,also some basic check to union.
Tested it on a simple Benchmark implemented by myself to see that it can speed up the Subtract operation and Union operation, also decrease the result size.

The Benchmark can be found here: benchmark

The overall results for Union & Subtract are as follows (previous benchmark has a bug,after fix that,the figure below is new)

The results for each case are as follows



Diff Detail

Event Timeline

gilsaia created this revision.Jul 25 2023, 8:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 25 2023, 8:03 AM
gilsaia requested review of this revision.Jul 25 2023, 8:03 AM
gilsaia edited the summary of this revision. (Show Details)Jul 25 2023, 8:06 AM
gilsaia added a reviewer: Groverkss.
Groverkss added a subscriber: grosser.
Groverkss added inline comments.Jul 26 2023, 7:24 AM
mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
136

I don't think this documentation is accurate. The first line is inaccurate, it should be something like

"Perform a quick equality check on this and other. The relations are equal if the check return true, but may or may not be equal if the check returns false. The equality check is ..."

mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
157

Can you make the documentation of this similar to IntegerRelation::isPlainEmpty?

mlir/lib/Analysis/Presburger/IntegerRelation.cpp
83–85

You don't need to repeat documentation here. The header file already specifies this. You can omit this.

87

I think you should use space.isEqual here. Local variables also need to be the same.

95–104

You can just write "unsigned" instead of "unsigned int"

mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
63–64

No need to add this line.

533–534

Sentences must end with a full stop.

535–537

You can remove braces here.

gilsaia updated this revision to Diff 544366.Jul 26 2023, 7:38 AM
  • [fix] change comment and style
gilsaia marked 7 inline comments as done.Jul 26 2023, 7:39 AM
gilsaia marked an inline comment as done.Jul 26 2023, 7:46 AM
gilsaia edited the summary of this revision. (Show Details)Jul 26 2023, 9:19 AM
Groverkss accepted this revision.Jul 27 2023, 8:05 AM

Nice! LGTM.

mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
140
mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
158

Full stop at end of sentence.

mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
557–560

No need to repeat what is already in the header. In general, we use header files for API documentation and the documentation in the cpp file explains the implementation. You can drop this.

This revision is now accepted and ready to land.Jul 27 2023, 8:05 AM
gilsaia updated this revision to Diff 545149.Jul 28 2023, 7:05 AM
  • [fix] change comment
gilsaia marked 3 inline comments as done.Jul 28 2023, 7:08 AM
gilsaia added inline comments.
mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
158

Sorry,forgot about that.

gilsaia marked an inline comment as done.Jul 31 2023, 6:25 AM
This revision was automatically updated to reflect the committed changes.