This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Presburger] Support computing volumes via hyperrectangular overapproximation
ClosedPublic

Authored by arjunp on Feb 8 2022, 3:25 AM.

Details

Summary

Add support for computing an overapproximation of the number of integer points
in a polyhedron. The returned result is actually the number of integer points
one gets by computing the "rational shadow" obtained by projecting out the
local IDs, finding the minimal axis-parallel hyperrectangular approximation
of the shadow, and returning the number of integer points in that. This does
not currently support symbols.

Diff Detail

Event Timeline

arjunp created this revision.Feb 8 2022, 3:25 AM
arjunp requested review of this revision.Feb 8 2022, 3:25 AM
arjunp edited the summary of this revision. (Show Details)Feb 8 2022, 3:34 AM
arjunp edited the summary of this revision. (Show Details)Feb 8 2022, 3:37 AM
Groverkss accepted this revision.Feb 8 2022, 4:11 AM
Groverkss added inline comments.
mlir/lib/Analysis/Presburger/Simplex.cpp
1478–1479 ↗(On Diff #406758)

Maybe add an assert here with this comment.

mlir/unittests/Analysis/Presburger/PresburgerSetTest.cpp
699–723

You can put these into Utils.h after https://reviews.llvm.org/D119194 is landed

This revision is now accepted and ready to land.Feb 8 2022, 4:11 AM
arjunp marked 2 inline comments as done.Feb 8 2022, 4:30 AM

Thanks for the quick review!

mlir/lib/Analysis/Presburger/Simplex.cpp
1478–1479 ↗(On Diff #406758)

There is already an assert, inside Optional::operator*

bondhugula added inline comments.Feb 8 2022, 6:10 AM
mlir/lib/Analysis/Presburger/PresburgerSet.cpp
390–392

You may want to state in the doc comment that the approximation could be far away from a tight one depending on the overlap.

mlir/lib/Analysis/Presburger/Simplex.cpp
1476–1481 ↗(On Diff #406758)

Are these changes related?

arjunp updated this revision to Diff 406813.Feb 8 2022, 7:06 AM
arjunp marked an inline comment as done.

Move common functions into utils.h

arjunp added inline comments.Feb 8 2022, 7:33 AM
mlir/lib/Analysis/Presburger/Simplex.cpp
1476–1481 ↗(On Diff #406758)

Yeah, they're needed because we had to change the return type of computeIntegerBounds. That can be separated out into another commit though, which I've done now

arjunp edited the summary of this revision. (Show Details)Feb 8 2022, 7:35 AM
This revision was landed with ongoing or failed builds.Feb 8 2022, 7:37 AM
This revision was automatically updated to reflect the committed changes.
jpienaar added inline comments.
mlir/unittests/Analysis/Presburger/Utils.h
49

Getting error about this function being unused. Can it be removed?

arjunp marked an inline comment as done.Feb 8 2022, 8:59 AM
arjunp added inline comments.
mlir/unittests/Analysis/Presburger/Utils.h
49

It can't be removed. It's called from function called expectComputedVolumeIsValidOverapprox in IntegerPolyhedronTest.cpp and another with same name in PresburgerSetTest.cpp. Where does the error occur?

arjunp marked an inline comment as done.Feb 8 2022, 9:00 AM
arjunp added inline comments.
mlir/unittests/Analysis/Presburger/Utils.h
49

This has apparently been fixed

https://reviews.llvm.org/rG78eeda7529e7