Commit Graph

978 Commits

Author SHA1 Message Date
Mehdi Amini
1837579bbc Apply clang-tidy fixes for readability-simplify-boolean-expr in IntegerRelation.cpp (NFC) 2024-03-04 23:15:10 -08:00
Mehdi Amini
1934fc6a0c Apply clang-tidy fixes for readability-container-size-empty in Barvinok.cpp (NFC) 2024-03-04 23:15:10 -08:00
Mehdi Amini
2db8b94138 Apply clang-tidy fixes for performance-unnecessary-value-param in Barvinok.cpp (NFC) 2024-03-04 23:15:10 -08:00
Mehdi Amini
9915418144 Apply clang-tidy fixes for modernize-use-emplace in Barvinok.cpp (NFC) 2024-03-04 23:15:10 -08:00
Mehdi Amini
a36b73e5a7 Apply clang-tidy fixes for modernize-loop-convert in Barvinok.cpp (NFC) 2024-03-04 23:15:10 -08:00
Adrian Kuegel
654e65d3b2 [mlir] Apply ClangTidy performance fix.
Use const reference for loop variable.
2024-02-21 13:17:43 +00:00
Abhinav271828
562790f371 [MLIR][Presburger] Implement vertex enumeration and chamber decomposition for polytope generating function computation. (#78987)
We implement a function to compute the generating function corresponding
to a full-dimensional parametric polytope whose tangent cones are all
unimodular.
We fix a bug in unimodGenFunc to check the absolute value of the index.
We also implement Matrix<T>::negateMatrix() and Matrix<T>::scaleRow for
convenience.
2024-02-15 11:03:32 +05:30
Jie Fu
3c94154c86 [mlir] Fix -Wunused-variable in Barvinok.cpp (NFC)
llvm-project/mlir/lib/Analysis/Presburger/Barvinok.cpp:262:21:
 error: unused variable 'd' [-Werror,-Wunused-variable]
  for (const Point &d : ds)
                    ^
1 error generated.
2024-01-22 20:12:39 +08:00
Abhinav271828
68a5261d26 [MLIR][Presburger] Implement function to evaluate the number of terms in a generating function. (#78078)
We implement `computeNumTerms()`, which counts the number of terms in a
generating function by substituting the unit vector in it.
This is the main function in Barvinok's algorithm – the number of points
in a polytope is given by the number of terms in the generating function
corresponding to it.
We also modify the GeneratingFunction class to have `const` getters and
improve the simplification of QuasiPolynomials.
2024-01-22 14:22:01 +05:30
Bharathi Ramana Joshi
d70bfeb4e1 [MLIR][Presburger] Implement IntegerRelation::setId (#77872) 2024-01-20 15:19:10 +05:30
Benjamin Kramer
9c33a2e9a3 [MLIR][Presburger] Fold loop into assert
This way it doesn't trigger -Wunused-variable when assertions are disabled.
2024-01-13 17:52:58 +01:00
Abhinav271828
850f713e80 [MLIR][Presburger] Helper functions to compute the constant term of a generating function (#77819)
We implement two functions that are needed to compute the constant term
of a GF.
One finds a vector not orthogonal to all the non-null vectors in a given
set.
One computes the coefficient of any term in an arbitrary rational
function (quotient of two polynomials).
2024-01-13 21:30:06 +05:30
Bharathi Ramana Joshi
66786a79d6 [MLIR][Presburger] Implement Matrix::moveColumns (#68362) 2024-01-13 18:51:26 +05:30
Bharathi Ramana Joshi
c39926e679 [MLIR][Presburger] Fix style violations in ff80414 (NFC) (#76720)
Use preincrement not postincrement; use `Identifier::getIds` not
`getVarKindOffset`
2024-01-12 10:36:28 +05:30
Abhinav271828
2dde029df8 [MLIR][Presburger] Implement computation of generating function for unimodular cones (#77235)
We implement a function that computes the generating function
corresponding to a unimodular cone.
The generating function for a polytope is obtained by summing these
generating functions over all tangent cones.
2024-01-11 01:28:36 +05:30
Bharathi Ramana Joshi
3eb9fd8ac8 [MLIR][Presburger] Implement IntegerRelation::mergeAndAlignSymbols (#76736) 2024-01-07 17:06:52 +05:30
Abhinav271828
4c8dbb6813 [MLIR][Presburger] Definitions for basic functions related to cones (#76650)
We add some basic type aliases and function definitions relating to
cones for Barvinok's algorithm.
These include functions to get the dual of a cone and find its index.
2024-01-07 10:30:22 +00:00
Abhinav271828
bd0dc357af [MLIR][Presburger] Shift GeneratingFunction.h to includes (#77114)
We shift the GeneratingFunction.h header file to the include/ directory
and wrap it in a `detail` namespace.
2024-01-06 17:08:25 +05:30
drblallo
2bd6642533 [mlir][dataflow]Fix dense backward dataflow intraprocedural hook (#76865)
The dataflow analysis framework within MLIR allows to customize the
transfer function when a `call-like` operation is encuntered.

The check to see if the analysis was executed in intraprocedural mode
was executed after the check to see if the callee had the
CallableOpInterface, and thus intraprocedural analyses would behave as
interpocedural ones when performing indirect calls.

This commit fixes the issue by performing the check for
intraprocedurality first.

Dense forward analyses were already behaving correctly.
https://github.com/llvm/llvm-project/blob/main/mlir/lib/Analysis/DataFlow/DenseAnalysis.cpp#L63

Co-authored-by: massimo <mo.fioravanti@gmail.com>
2024-01-04 10:28:12 +01:00
Adrian Kuegel
b238a0d989 [mlir] Apply ClangTidy findings.
- Remove redundant return
- Use .empty() instead of size() == 0.
2024-01-02 08:53:01 +00:00
Bharathi Ramana Joshi
ff80414620 [MLIR][Presburger] Implement PresburgerSpace::mergeAndAlignSymbols (#76397) 2024-01-01 23:40:57 +05:30
Bharathi Ramana Joshi
b8e4053c06 [MLIR][Presburger] Fix bug in Identifier::isEqual assert (#76380)
Make identifiers::isEqual return false instead of failing assertion when
identifiers are not equal.
2023-12-31 11:02:13 +05:30
Abhinav271828
e213af78b2 [MLIR][Presburger] Fix a bug with determinant of IntMatrix (#76622)
Fixed a bug where IntMatrix determinant() had a bug where it would try to assign to a null
pointer.
Added a test case that triggers this bug to avoid regressions.
2023-12-30 22:03:01 +02:00
Balaji V. Iyer
36fd7291cd [mlir][Quasipolynomial] Fixed -Wunused-variable in GeneratorFunction.h (#76419)
```
llvm-project/mlir/lib/Analysis/Presburger/GeneratingFunction.h:56:28:
error: unused variable 'term' [-Werror,-Wunused-variable]
   56 |     for (const ParamPoint &term : numerators)
      |                            ^~~~
1 error generated.
```
2023-12-26 19:29:04 -06:00
Jie Fu
c86fe3ee0b [mlir][Quasipolynomials] Fix -Wunused-variable in QuasiPolynomial.cpp (NFC)
llvm-project/mlir/lib/Analysis/Presburger/QuasiPolynomial.cpp:29:39:
 error: unused variable 'aff' [-Werror,-Wunused-variable]
    for (const SmallVector<Fraction> &aff : term) {
                                      ^
1 error generated.
2023-12-27 08:00:58 +08:00
Balaji V. Iyer
532d4845ed [mlir][Quasipolynomials] Fixed type issues in GeneratorFuunction.h (#76413)
Fixed two issues: A SmallVector size that caused size-differences issue
(8 vs. 12). Thus removed this size restriction. Also a constant
parameter was causing an issue in a function not marked constant.
2023-12-26 16:34:32 -06:00
Abhinav271828
1022febd9d [MLIR][Presburger] Generating functions and quasi-polynomials for Barvinok's algorithm (#75702)
Define basic types and classes for Barvinok's algorithm, including
polyhedra, generating functions and quasi-polynomials.
The class definitions include methods for arithmetic manipulation,
printing, logical relations, etc.
2023-12-26 21:29:26 +02:00
Oleksandr "Alex" Zinenko
11140cc238 [mlir] mark ChangeResult as nodiscard (#76147)
This enum is used by dataflow analyses to indicate whether further
propagation is necessary to reach the fix point. Accidentally discarding
such a value will likely lead to propagation stopping early, leading to
incomplete or incorrect results. The most egregious example is the
duality between `join` on the analysis class, which triggers propagation
internally, and `join` on the lattice class that does not and expects
the caller to trigger it depending on the returned `ChangeResult`.
2023-12-21 17:58:53 +01:00
Abhinav271828
cfd51fbadd [MLIR][Presburger] Add LLL basis reduction (#75565)
Add a method for LLL basis reduction to the FracMatrix class.
This needs an abs() method for Fractions, which is added to Fraction.h.
2023-12-19 17:31:38 +01:00
Oleksandr "Alex" Zinenko
32a4e3fcca [mlir] support non-interprocedural dataflow analyses (#75583)
The core implementation of the dataflow anlysis framework is
interpocedural by design. While this offers better analysis precision,
it also comes with additional cost as it takes longer for the analysis
to reach the fixpoint state. Add a configuration mechanism to the
dataflow solver to control whether it operates inteprocedurally or not
to offer clients a choice.

As a positive side effect, this change also adds hooks for explicitly
processing external/opaque function calls in the dataflow analyses,
e.g., based off of attributes present in the the function declaration or
call operation such as alias scopes and modref available in the LLVM
dialect.

This change should not affect existing analyses and the default solver
configuration remains interprocedural.

Co-authored-by: Jacob Peng <jacobmpeng@gmail.com>
2023-12-18 14:16:52 +01:00
Bharathi Ramana Joshi
8d7c979815 [MLIR][Presburger] Fix IntegerRelation::swapVar not swapping identifiers (#74407)
This commit fixes a bug where identifiers were not swapped when doing a
IntegerRelation::swapVar.
2023-12-13 22:47:19 +05:30
Abhinav271828
84ab06ba2f [MLIR][Presburger] Add Gram-Schmidt (#70843)
Implement Gram-Schmidt orthogonalisation for the FracMatrix class.
This requires dotProduct, which has been added as a util.
2023-12-13 08:28:47 +00:00
Victor Perez
13c648f6bd [MLIR][IntegerRangeAnalysis] Avoid crash reached when loop bound is uninitialized (#74832)
If the loop bound is not initialized, the analysis crashed, as it only checked for nullity. Also checking for initialization fixes the issue.

Signed-off-by: Victor Perez <victor.perez@codeplay.com>
Co-authored-by: Tsang, Whitney <whitney.tsang@intel.com>
2023-12-11 10:36:03 +01:00
long.chen
dc4786b487 [mlir][affine] remove divide zero check when simplifer affineMap (#64622) (#68519)
When performing constant folding on the affineApplyOp, there is a
division of 0 in the affine map.
[related issue](https://github.com/llvm/llvm-project/issues/64622)

---------

Co-authored-by: Javier Setoain <jsetoain@users.noreply.github.com>
2023-11-19 02:14:53 +08:00
Adrian Kuegel
b4c1421466 [mlir] Apply ClangTidy fix
Remove redundant return.
2023-11-17 09:56:07 +00:00
Uday Bondhugula
c79ffb02bb Generalize affine fusion to work at all depths and inside other region-holding ops (#72288)
Generalize affine fusion to work at any inner depth; fusing loops inside
other
affine.for or even inside scf.for or scf.while nests. Apply in post
order on
all affine nests on the pass' top-level operation.

Fix MDG init for blocks inside other affine nests.

Relax unnecessary requirement for unique vars during merge and align of
FlatLinearValueConstraints. There are several cases where
FlatLinearValueConstraints need to have duplicate Values for the
dimensions:
for eg. in dependence relation systems with source and destination
accesses
could have common loop IVs. `mergeAndAlign` can be done even in the
presence
of Values reappearing by simply aligning from left to right in that
order.

While at this, drop outdated comments; improve some debug messages.
2023-11-16 08:52:12 +05:30
long.chen
1609f1c2a5 [mlir][affine][nfc] cleanup deprecated T.cast style functions (#71269)
detail see the docment: https://mlir.llvm.org/deprecation/

Not all changes are made manually, most of them are made through a clang
tool I wrote https://github.com/lipracer/cpp-refactor.
2023-11-14 13:01:19 +08:00
Jeremy Kun
f778eafdd8 [IntegerRangeAnalysis] remove constraint on integer-typed results (#72007) 2023-11-13 22:10:47 -06:00
Mehdi Amini
285a229f20 [MLIR] Apply clang-tidy fixes for misc-include-cleaner (NFC) 2023-11-12 20:35:46 -08:00
Mehdi Amini
06927848da Apply clang-tidy fixes for performance-unnecessary-value-param in SliceAnalysis.cpp (NFC) 2023-10-31 21:25:47 -07:00
Mehdi Amini
2ee87cd610 [MLIR] Apply clang-tidy fixes for misc-include-cleaner in Presburger library (NFC) 2023-10-31 21:24:57 -07:00
Mehdi Amini
ebc2c4bde3 Apply clang-tidy fixes for misc-include-cleaner in SparseAnalysis.cpp (NFC) 2023-10-28 21:39:30 -07:00
Mehdi Amini
37d1d9fe41 Apply clang-tidy fixes for misc-include-cleaner in LivenessAnalysis.cpp (NFC) 2023-10-28 21:39:30 -07:00
Mehdi Amini
383f2bd597 Apply clang-tidy fixes for misc-include-cleaner in IntegerRangeAnalysis.cpp (NFC) 2023-10-28 21:39:30 -07:00
Mehdi Amini
a5a908654e Apply clang-tidy fixes for misc-include-cleaner in DataFlowFramework.cpp (NFC) 2023-10-28 21:39:30 -07:00
gilsaia
39b939555f [MLIR][Presburger] Add simplify function (#69107)
Added the simplify function to reduce the size of the constraint system,
referencing the ISL implementation.

Tested it on a simple Benchmark implemented by myself, calling SImplify
before the operation and calling Simplify on the result after Subtract
were tested, respectively.

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

For the case of calling Simplify before each operation, the overall
result is shown in the following figure.

![image](https://github.com/llvm/llvm-project/assets/38588948/7099286e-b9a2-42e0-bc2a-1ed6627ead00)

A comparison of the constraint system sizes and time for each operation
is as follows

![image](https://github.com/llvm/llvm-project/assets/38588948/e5d0e488-f76e-4438-b19e-f6163699c526)

![image](https://github.com/llvm/llvm-project/assets/38588948/119a08de-4ee1-4cde-886c-50a91b502d93)

![image](https://github.com/llvm/llvm-project/assets/38588948/7a8b69ac-6cdb-41ab-9a75-cd016664fa5a)

![image](https://github.com/llvm/llvm-project/assets/38588948/c84b6eb1-62dc-4bae-a771-67d97ebf514a)

![image](https://github.com/llvm/llvm-project/assets/38588948/cdbfa3ed-0155-481e-9273-9d6dba3a2d7b)

![image](https://github.com/llvm/llvm-project/assets/38588948/8c945cff-a0a4-472a-a178-6b6a70a1b16a)

![image](https://github.com/llvm/llvm-project/assets/38588948/0bfe3a2b-3568-4d31-bebf-bd1b3c4e734e)

![image](https://github.com/llvm/llvm-project/assets/38588948/f1a99d56-edf5-45de-a506-512c0584f1d8)

![image](https://github.com/llvm/llvm-project/assets/38588948/ffef3312-6c99-494c-bb52-73aa8df275bb)

![image](https://github.com/llvm/llvm-project/assets/38588948/3e5924a7-8e1f-49d1-bd27-02a2e10a5cc4)

![image](https://github.com/llvm/llvm-project/assets/38588948/cec8be0e-dd19-46fa-88b4-2585d4031c9e)

![image](https://github.com/llvm/llvm-project/assets/38588948/3cb68e89-82c7-4cd2-b6bc-70f15e495ce8)

For the case of calling Simplify on the result after Subtract, the
overall results are as follows

![image](https://github.com/llvm/llvm-project/assets/38588948/be5b9c50-7417-42c8-abbf-8a50f093c3f5)

A comparison of the constraint system sizes and time for subtract is as
follows

![image](https://github.com/llvm/llvm-project/assets/38588948/fafe10ba-f8bd-43cd-b281-aaebf09af0af)

![image](https://github.com/llvm/llvm-project/assets/38588948/24662b40-42fc-47ee-a0a3-1b8b8f5778d2)
2023-10-28 16:25:44 +05:30
Mehdi Amini
fba3951b28 Apply clang-tidy fixes for misc-include-cleaner in DenseAnalysis.cpp (NFC) 2023-10-26 23:58:10 -07:00
Mehdi Amini
e48038a84b Apply clang-tidy fixes for misc-include-cleaner in DeadCodeAnalysis.cpp (NFC) 2023-10-26 23:58:09 -07:00
Mehdi Amini
8a51518025 Apply clang-tidy fixes for misc-include-cleaner in ConstantPropagationAnalysis.cpp (NFC) 2023-10-26 23:58:09 -07:00
Mehdi Amini
9dd06a1259 Apply clang-tidy fixes for misc-include-cleaner in CallGraph.cpp (NFC) 2023-10-26 23:58:09 -07:00