Skip to content

Commit

Permalink
[MLIR][Presburger] Rename variable/identifier -> variable
Browse files Browse the repository at this point in the history
Currently, in the Presburger library, we use the words "variables" and
"identifiers" interchangeably. This patch changes this to only use "variables" to
refer to the variables of PresburgerSpace.

The reasoning behind this change is that the current usage of the word "identifier"
is misleading. variables do not "identify" anything. The information attached to them is the
actual "identifier" for the variable. The word "identifier", will later be used
to refer to the information attached to each variable in space.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D128585
  • Loading branch information
Groverkss committed Jun 28, 2022
1 parent 85593e7 commit d95140a
Show file tree
Hide file tree
Showing 28 changed files with 1,361 additions and 1,345 deletions.
296 changes: 151 additions & 145 deletions mlir/include/mlir/Analysis/Presburger/IntegerRelation.h

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions mlir/include/mlir/Analysis/Presburger/PWMAFunction.h
Expand Up @@ -9,7 +9,7 @@
// Support for piece-wise multi-affine functions. These are functions that are
// defined on a domain that is a union of IntegerPolyhedrons, and on each domain
// the value of the function is a tuple of integers, with each value in the
// tuple being an affine expression in the ids of the IntegerPolyhedron.
// tuple being an affine expression in the vars of the IntegerPolyhedron.
//
//===----------------------------------------------------------------------===//

Expand All @@ -25,7 +25,7 @@ namespace presburger {
/// This class represents a multi-affine function whose domain is given by an
/// IntegerPolyhedron. This can be thought of as an IntegerPolyhedron with a
/// tuple of integer values attached to every point in the polyhedron, with the
/// value of each element of the tuple given by an affine expression in the ids
/// value of each element of the tuple given by an affine expression in the vars
/// of the polyhedron. For example we could have the domain
///
/// (x, y) : (x >= 5, y >= x)
Expand All @@ -35,10 +35,10 @@ namespace presburger {
/// (x, y) -> (x + 2, 2*x - 3y + 5, 2*x + y).
///
/// In this way every point in the polyhedron has a tuple of integers associated
/// with it. If the integer polyhedron has local ids, then the output
/// with it. If the integer polyhedron has local vars, then the output
/// expressions can use them as well. The output expressions are represented as
/// a matrix with one row for every element in the output vector one column for
/// each id, and an extra column at the end for the constant term.
/// each var, and an extra column at the end for the constant term.
///
/// Checking equality of two such functions is supported, as well as finding the
/// value of the function at a specified point.
Expand All @@ -49,28 +49,28 @@ class MultiAffineFunction {
MultiAffineFunction(const Matrix &output, const PresburgerSpace &space)
: domainSet(space), output(output) {}

unsigned getNumInputs() const { return domainSet.getNumDimAndSymbolIds(); }
unsigned getNumInputs() const { return domainSet.getNumDimAndSymbolVars(); }
unsigned getNumOutputs() const { return output.getNumRows(); }
bool isConsistent() const {
return output.getNumColumns() == domainSet.getNumIds() + 1;
return output.getNumColumns() == domainSet.getNumVars() + 1;
}
const IntegerPolyhedron &getDomain() const { return domainSet; }
const PresburgerSpace &getDomainSpace() const { return domainSet.getSpace(); }

/// Insert `num` identifiers of the specified kind at position `pos`.
/// Positions are relative to the kind of identifier. The coefficient columns
/// corresponding to the added identifiers are initialized to zero. Return the
/// absolute column position (i.e., not relative to the kind of identifier)
/// of the first added identifier.
unsigned insertId(IdKind kind, unsigned pos, unsigned num = 1);
/// Insert `num` variables of the specified kind at position `pos`.
/// Positions are relative to the kind of variable. The coefficient columns
/// corresponding to the added variables are initialized to zero. Return the
/// absolute column position (i.e., not relative to the kind of variable)
/// of the first added variable.
unsigned insertVar(VarKind kind, unsigned pos, unsigned num = 1);

/// Remove the specified range of ids.
void removeIdRange(IdKind kind, unsigned idStart, unsigned idLimit);
/// Remove the specified range of vars.
void removeVarRange(VarKind kind, unsigned varStart, unsigned varLimit);

/// Given a MAF `other`, merges local identifiers such that both funcitons
/// have union of local ids, without changing the set of points in domain or
/// Given a MAF `other`, merges local variables such that both funcitons
/// have union of local vars, without changing the set of points in domain or
/// the output.
void mergeLocalIds(MultiAffineFunction &other);
void mergeLocalVars(MultiAffineFunction &other);

/// Return whether the outputs of `this` and `other` agree wherever both
/// functions are defined, i.e., the outputs should be equal for all points in
Expand All @@ -88,7 +88,7 @@ class MultiAffineFunction {

/// Truncate the output dimensions to the first `count` dimensions.
///
/// TODO: refactor so that this can be accomplished through removeIdRange.
/// TODO: refactor so that this can be accomplished through removeVarRange.
void truncateOutput(unsigned count);

void print(raw_ostream &os) const;
Expand Down Expand Up @@ -118,19 +118,19 @@ class MultiAffineFunction {
/// this class is undefined. The domains need not cover all possible points;
/// this represents a partial function and so could be undefined at some points.
///
/// As in PresburgerSets, the input ids are partitioned into dimension ids and
/// symbolic ids.
/// As in PresburgerSets, the input vars are partitioned into dimension vars and
/// symbolic vars.
///
/// Support is provided to compare equality of two such functions as well as
/// finding the value of the function at a point.
class PWMAFunction {
public:
PWMAFunction(const PresburgerSpace &space, unsigned numOutputs)
: space(space), numOutputs(numOutputs) {
assert(space.getNumDomainIds() == 0 &&
"Set type space should have zero domain ids.");
assert(space.getNumLocalIds() == 0 &&
"PWMAFunction cannot have local ids.");
assert(space.getNumDomainVars() == 0 &&
"Set type space should have zero domain vars.");
assert(space.getNumLocalVars() == 0 &&
"PWMAFunction cannot have local vars.");
assert(numOutputs >= 1 && "The function must output something!");
}

Expand All @@ -142,7 +142,7 @@ class PWMAFunction {
const MultiAffineFunction &getPiece(unsigned i) const { return pieces[i]; }
unsigned getNumPieces() const { return pieces.size(); }
unsigned getNumOutputs() const { return numOutputs; }
unsigned getNumInputs() const { return space.getNumIds(); }
unsigned getNumInputs() const { return space.getNumVars(); }
MultiAffineFunction &getPiece(unsigned i) { return pieces[i]; }

/// Return the domain of this piece-wise MultiAffineFunction. This is the
Expand All @@ -160,7 +160,7 @@ class PWMAFunction {

/// Truncate the output dimensions to the first `count` dimensions.
///
/// TODO: refactor so that this can be accomplished through removeIdRange.
/// TODO: refactor so that this can be accomplished through removeVarRange.
void truncateOutput(unsigned count);

void print(raw_ostream &os) const;
Expand All @@ -172,7 +172,7 @@ class PWMAFunction {
/// The list of pieces in this piece-wise MultiAffineFunction.
SmallVector<MultiAffineFunction, 4> pieces;

/// The number of output ids.
/// The number of output vars.
unsigned numOutputs;
};

Expand Down
23 changes: 12 additions & 11 deletions mlir/include/mlir/Analysis/Presburger/PresburgerRelation.h
Expand Up @@ -44,11 +44,11 @@ class PresburgerRelation {

explicit PresburgerRelation(const IntegerRelation &disjunct);

unsigned getNumDomainIds() const { return space.getNumDomainIds(); }
unsigned getNumRangeIds() const { return space.getNumRangeIds(); }
unsigned getNumSymbolIds() const { return space.getNumSymbolIds(); }
unsigned getNumLocalIds() const { return space.getNumLocalIds(); }
unsigned getNumIds() const { return space.getNumIds(); }
unsigned getNumDomainVars() const { return space.getNumDomainVars(); }
unsigned getNumRangeVars() const { return space.getNumRangeVars(); }
unsigned getNumSymbolVars() const { return space.getNumSymbolVars(); }
unsigned getNumLocalVars() const { return space.getNumLocalVars(); }
unsigned getNumVars() const { return space.getNumVars(); }

/// Return the number of disjuncts in the union.
unsigned getNumDisjuncts() const;
Expand Down Expand Up @@ -111,7 +111,7 @@ class PresburgerRelation {
bool findIntegerSample(SmallVectorImpl<int64_t> &sample);

/// Compute an overapproximation of the number of integer points in the
/// disjunct. Symbol ids are currently not supported. If the computed
/// disjunct. Symbol vars are currently not supported. If the computed
/// overapproximation is infinite, an empty optional is returned.
///
/// This currently just sums up the overapproximations of the volumes of the
Expand All @@ -136,8 +136,8 @@ class PresburgerRelation {
/// Construct an empty PresburgerRelation with the specified number of
/// dimension and symbols.
explicit PresburgerRelation(const PresburgerSpace &space) : space(space) {
assert(space.getNumLocalIds() == 0 &&
"PresburgerRelation cannot have local ids.");
assert(space.getNumLocalVars() == 0 &&
"PresburgerRelation cannot have local vars.");
}

PresburgerSpace space;
Expand Down Expand Up @@ -174,9 +174,10 @@ class PresburgerSet : public PresburgerRelation {
/// dimension and symbols.
explicit PresburgerSet(const PresburgerSpace &space)
: PresburgerRelation(space) {
assert(space.getNumDomainIds() == 0 && "Set type cannot have domain ids.");
assert(space.getNumLocalIds() == 0 &&
"PresburgerRelation cannot have local ids.");
assert(space.getNumDomainVars() == 0 &&
"Set type cannot have domain vars.");
assert(space.getNumLocalVars() == 0 &&
"PresburgerRelation cannot have local vars.");
}
};

Expand Down

0 comments on commit d95140a

Please sign in to comment.