This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Presburger] Introduce Domain and Range identifiers in PresburgerSpace
ClosedPublic

Authored by Groverkss on Feb 14 2022, 6:14 AM.

Details

Summary

This patch introducing seperating dimensions into two types: Domain and Range.
This allows building relations over PresburgerSpace.

This patch is part of a series of patches to introduce relations in Presburger
library.

Diff Detail

Event Timeline

Groverkss created this revision.Feb 14 2022, 6:14 AM
Groverkss requested review of this revision.Feb 14 2022, 6:14 AM
bondhugula added inline comments.Feb 14 2022, 9:16 AM
mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
17

Do you need this header?

55–58

Use /*...=*/... format when passing constant values.

mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
50

exist

64

exist

Groverkss marked 4 inline comments as done.
  • Address Uday's comments
Groverkss added inline comments.Feb 14 2022, 12:21 PM
mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
17

Removed the header.

  • Remove accidently added file
Groverkss updated this revision to Diff 408811.Feb 15 2022, 4:06 AM
  • Fix compilation issue
arjunp added inline comments.Feb 15 2022, 6:47 AM
mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
92

This shouldn't be reached when getNumDomainIds != 0, right? I would add an assert for that and just increase range.

(In fact, maybe you can store an enum denoting whether this is a relation or not and assert throughout that the right IdKind is being used.

You can set this enum in the corresponding constructor, or maybe subclass to make a PresburgerSetSpace that has that constructor.)

Groverkss added inline comments.Feb 16 2022, 1:03 PM
mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
92

I think I can add the assert.

As for the enum, I don't think I want the implementation detail that a set is a relation with only range to be hidden. It should be rather visible that a set is a relation with only range.

Groverkss updated this revision to Diff 409379.Feb 16 2022, 1:09 PM
  • Address Arjun's comments
arjunp added inline comments.Feb 16 2022, 1:33 PM
mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
92

It's not really about hiding the implementation detail. I just meant that we can then use asserts to check at runtime that dimension idkinds is used when there is no distinction and range/domain idkinds are used only when there is distinction

  • Add enum to distinguish between Set and Relation.
mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
92

Ok makes sense. WIll add the enum.

Groverkss marked 2 inline comments as done.Feb 17 2022, 12:05 AM
arjunp added inline comments.Feb 17 2022, 12:14 AM
mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
40

I see, so we want to support using Dimension IdKind in relation spaces as well to consider domain + range as one block? This seems a little weird, is it needed?

142

These enums are usually named like SpaceKind I think

mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
92

You can add these asserts throughout, wherever idkinds are being used. You can make a member function isSupportedIdKind

Groverkss updated this revision to Diff 409570.Feb 17 2022, 3:10 AM
Groverkss marked 3 inline comments as done.
  • Add asserts to ensure domain is not used when a space is a Set.
  • Use IdKind::SetDim instead of IdKind::Dimension.
Groverkss added inline comments.Feb 17 2022, 3:11 AM
mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
40

It does seem a bit weird maybe. I tried a different design now.

arjunp added inline comments.Feb 18 2022, 3:15 AM
mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
44

I would mention that users should use PresburgerLocalSpace if they need that

51

I would mention that in the implementation of the class, SetDims are treated as range ids, and spaces with no distinction are treated as relations with zero domain ids

127–133

Personally, I prefer spacekind to be the first param and the first thing initialized

147

It's hard to see the different between the two constructors at the callsite. I would instead make two static functions, PresburgerLocalSpace::getRelationSpace() and getSetSpace() or something

Similarly for PresburgerSpace above

mlir/lib/Analysis/Presburger/PresburgerSpace.cpp
164

special case for SetDim spaceKind?

174

"Locals: " missing?

Groverkss marked 6 inline comments as done.
  • Address Arjun's comments
arjunp added inline comments.Feb 18 2022, 10:42 AM
mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
147

I would just remove the two extra constructors, they aren't needed and we can keep only the static functions for constructing sets, which would call into the single non-public constructor.

Groverkss added inline comments.Feb 18 2022, 10:52 AM
mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
147

These constructors are supposed to be called by IntegerPolyhedron, IntegerRelation (in future) and any other derived classes of PresburgerSpace. I don't think we can use static functions for that.

arjunp accepted this revision.Feb 18 2022, 10:53 AM
arjunp added inline comments.
mlir/include/mlir/Analysis/Presburger/PresburgerSpace.h
147

Right.

This revision is now accepted and ready to land.Feb 18 2022, 10:53 AM