This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Presburger] Optimize for intersect
ClosedPublic

Authored by gilsaia on Jul 8 2023, 11:10 AM.

Details

Summary

Added a series of optimizations to the Intersect function of PresburgerRelation, referring to the ISL implementation.
Tested it on a simple Benchmark implemented by myself to see that it can speed up the Intersect operation

The Benchmark can be found here:https://github.com/gilsaia/llvm-project-test-fpl/blob/develop_benchmark/mlir/benchmark/presburger/Benchmark.cpp

The overall results for Intersect are as follows

The results for each case are as follows

Diff Detail

Event Timeline

gilsaia created this revision.Jul 8 2023, 11:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2023, 11:10 AM
gilsaia requested review of this revision.Jul 8 2023, 11:10 AM
gilsaia edited the summary of this revision. (Show Details)Jul 8 2023, 11:16 AM
gilsaia added a reviewer: Groverkss.
Groverkss requested changes to this revision.Jul 10 2023, 6:57 AM
Groverkss added inline comments.
mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
134 ↗(On Diff #538380)

This method should be private.

mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
101

Could you make a method for this called isPlainEmpty?

101

Could you write a comment here that describes what this early exit does? Also, I don't think you need to do a space check here. The space check was done by space.isCompatible in the assert earlier.

113

No need for the space equality check.

118

The result here is not captured.

This revision now requires changes to proceed.Jul 10 2023, 6:57 AM
Groverkss added a subscriber: grosser.
gilsaia edited the summary of this revision. (Show Details)Jul 10 2023, 7:10 AM
gilsaia added inline comments.Jul 10 2023, 7:13 AM
mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
134 ↗(On Diff #538380)

Do we still need this method now?

mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
101

But I think isEqual also check NumLocalVar,which isCompatible not check

Groverkss added inline comments.Jul 10 2023, 7:25 AM
mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
134 ↗(On Diff #538380)

Probably not. You can remove it.

mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
101

The space of a PresburgerSet never has locals :), so it does not matter.

gilsaia added inline comments.Jul 10 2023, 7:26 AM
mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
101

Allright,i'll remove this check

gilsaia updated this revision to Diff 538639.Jul 10 2023, 7:29 AM

Remove wrong optim, add comment, remove useless check space

gilsaia marked 7 inline comments as done.Jul 10 2023, 7:30 AM
gilsaia updated this revision to Diff 538641.Jul 10 2023, 7:40 AM

fix patch wrong

Groverkss added inline comments.Jul 11 2023, 1:56 AM
mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
137–138

Can you rename this to "isPlainUniverse" as well? Since this is just a quick check, not a complete check.

mlir/lib/Analysis/Presburger/PresburgerRelation.cpp
101–102
506–509

I don't think this is a complete check for the universe. You should mention that this is just a quick check.

gilsaia updated this revision to Diff 539053.Jul 11 2023, 6:16 AM

[fix] change func name

gilsaia updated this revision to Diff 539056.Jul 11 2023, 6:18 AM
gilsaia marked 2 inline comments as done.

[fix] change comment

gilsaia marked an inline comment as done.Jul 11 2023, 6:18 AM
Groverkss accepted this revision.Jul 11 2023, 6:52 AM

LGTM. Nice!

This revision is now accepted and ready to land.Jul 11 2023, 6:52 AM
Groverkss retitled this revision from [MLIR][presburger] optimize for intersect to [MLIR][Presburger] Optimize for intersect.Jul 11 2023, 6:52 AM
This revision was landed with ongoing or failed builds.Jul 11 2023, 7:14 AM
This revision was automatically updated to reflect the committed changes.