This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Presburger] introduce SetCoalescer
ClosedPublic

Authored by webmiche on Mar 10 2022, 2:31 AM.

Details

Summary

This patch refactors the current coalesce implementation. It introduces
the SetCoalescer, a class in which all coalescing functionality lives.
The main advantage over the old design is the fact that the vectors of
constraints do not have to be passed around, but are implemented as
private fields of the SetCoalescer. This will become especially
important once more inequality types are introduced.

Diff Detail

Event Timeline

webmiche created this revision.Mar 10 2022, 2:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2022, 2:31 AM
webmiche published this revision for review.Mar 11 2022, 2:09 AM
Groverkss added inline comments.Mar 11 2022, 9:48 AM
mlir/include/mlir/Analysis/Presburger/PresburgerSet.h
114–122 ↗(On Diff #414362)
mlir/lib/Analysis/Presburger/PresburgerSet.cpp
383 ↗(On Diff #414362)

Please add some documentation about what the class does and it's usage.

383 ↗(On Diff #414362)

Can you have the implementations and definitions for this class separate? It makes the class more readable.

386 ↗(On Diff #414362)

const PresburgerSet &s would be better.

webmiche updated this revision to Diff 414827.Mar 12 2022, 6:32 AM

separate declaration and implementation and address comments.

webmiche marked 4 inline comments as done.Mar 12 2022, 6:32 AM
arjunp added inline comments.Mar 13 2022, 4:55 AM
mlir/lib/Analysis/Presburger/PresburgerSet.cpp
389 ↗(On Diff #414827)

I don't think namespace matters, nobody else can access this anyway.

396–398 ↗(On Diff #414827)
399 ↗(On Diff #414827)

Is this needed? Why can't we just use set.integerPolyhedrons everywhere and return set in the end? (note that it looks a little long now but it will become set.disjuncts everywhere after the other patch lands, which is ok IMO)

415–427 ↗(On Diff #414827)

Please write docs for these members.

442–457 ↗(On Diff #414827)

I feel this looks more like an implementation doc, move it above the impl and just write here that it tries to coalesce pairs of overlapping polys.

443–445 ↗(On Diff #414827)

Don't repeat that redundantIneqsA are the redundant ineqs of a in every declaration doc. Also, some docs still seem to write as though these are given as arguments to the function. Please update all these, and also write what these arrays are just once, at their actual declaration in the class.

webmiche updated this revision to Diff 415753.Mar 16 2022, 3:02 AM
Rebased and addressed comments.
webmiche added inline comments.Mar 16 2022, 3:03 AM
mlir/lib/Analysis/Presburger/PresburgerSet.cpp
399 ↗(On Diff #414827)

AFAIU, this makes coalesce still return a newSet, rather than changing the given set in-place. I felt like changing to in-place is a bit of a subtle change for such a refactoring and it should probably get an own patch.

webmiche updated this revision to Diff 415755.Mar 16 2022, 3:10 AM

Rebase on a (hopefully) working commit and fix a small comment

arjunp added inline comments.Mar 16 2022, 3:20 AM
mlir/lib/Analysis/Presburger/PresburgerSet.cpp
399 ↗(On Diff #414827)

What I was suggesting was a little different, to operate on the copy of s, i.e., set directly. We don't need another copy newSet of the copy set. But sure, we can do that in another patch.

By the way, do we need to store set here or only the PresburgerSpace of set? AFAICT, set is only used at the end of coalesce to know the number of dims?

webmiche updated this revision to Diff 416125.Mar 17 2022, 3:38 AM

Removed the explicit set form the SetCoalescer. It only stores the dimensions and a copy of the disjunct vector now. Updated the documentation to reflect the change and rebased.

arjunp accepted this revision.Mar 17 2022, 11:56 AM
This revision is now accepted and ready to land.Mar 17 2022, 11:56 AM
This revision was automatically updated to reflect the committed changes.
webmiche reopened this revision.Mar 18 2022, 12:34 AM
This revision is now accepted and ready to land.Mar 18 2022, 12:34 AM
webmiche updated this revision to Diff 416410.Mar 18 2022, 12:34 AM

Fixed the build failure. It seems that gcc really wants me to declare the SetCoalescer in the header file, whereas clang does not care.

webmiche updated this revision to Diff 416412.Mar 18 2022, 12:52 AM

move forward declaration to the top of the namespace

This revision was automatically updated to reflect the committed changes.