Skip to content

Array data dependence analysis#180

Open
joscao wants to merge 32 commits intoecmwf-ifs:mainfrom
joscao:devel/array_data_dependence_analysis
Open

Array data dependence analysis#180
joscao wants to merge 32 commits intoecmwf-ifs:mainfrom
joscao:devel/array_data_dependence_analysis

Conversation

@joscao
Copy link
Contributor

@joscao joscao commented Oct 24, 2023

Provides a array dependency analysis as* described by "Compilers: Principles, Techniques, and Tools".

Requires functionality of #179 and #178.

Implemented features:

  • has_data_dependencyin analyse_array_data_dependency_detection.py allowing to determine if two array accesses in different loops exhibit a data dependency
  • a notebook 06_array_data_dependency_detection.ipynb showing a full integration (from source code, manual selecting of arrays, to determining if there exists a dependency)
  • a test test_analyse_array_data_dependency_detection.py testing 8 different test cases mostly taken from the Dragon book

Current Problems/Things I need help with: --> Expecting failure of tests due to missing ortools

  • How do I integrate the requirement of ortools for the solving of the integer linear problem into loki?
  • I have written an additional latex document, for exact formulation of linear algebra equations, since the Dragon is lacking them for this chapter, I will append it, how should it be preserved? array_data_dependency_description.pdf

Asterisk:
The following parts of the Dragon book are implemented:

  • "11.6.1 Definition of Data Dependence of Array Accesses", i.e. the full linear algebra description of the problem (iteration space, array access function)
  • "11.6.3 The GCD Test", i.e. a Gaussian Elimination algorithm specialized for Diophantine equations (i.e. pure integer matrix vector equation) and therefore the substitution of the result into the inequalities as described by equation (5) of the array_data_dependency_description mentioned above.
  • Independent-Variables Test from "11.6.4 Heuristics for Solving Integer Linear Program"
  • The Acyclic Test, Loop-Residue-Test, Memoization and the full Branch and bound solution to integer linear programming problems were not implemented, to ensure full usability a general integer linear program solver provided by ortools is used, therfore full usability is ensured, to the best of my abilities.

@reuterbal
Copy link
Collaborator

Again, just a quick response to your immediate questions:

To integrate ortools, I suggest to add them to pyproject.toml as an optional dependency for now, similar to the examples:

loki/pyproject.toml

Lines 62 to 65 in af8ec9f

examples = [
"jupyter",
"ipyparams",
]

Call the option dataflow_analysis or something similarly meaningful. The import of ortools should then be wrapped with a safeguard similar to open-fortran-parser and clean exception if it isn't available.

try:
import open_fortran_parser
HAVE_OFP = True
"""Indicate whether OpenFortranParser frontend is available."""
except ImportError:
HAVE_OFP = False

For the document, the best would probably be to convert this to a Sphinx document and integrate it into the documentation. But we can take care of that, so keeping the PDF like this is fine for now.

@joscao
Copy link
Contributor Author

joscao commented Oct 27, 2023

Since #178 and #179 are now stable, this branch has been rebased and most issues fixed.

Not functional (require help):

  • ortools installation (cant seem to figure it out how to add it to install)
  • test of notebook "06_..." complains about ungrouped-imports, but it is a notebook? that shouldnt matter there, at least to my understanding

Enhancements:

  • convert function documentation to numpy style

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Merging #180 (e031348) into main (af8ec9f) will decrease coverage by 0.14%.
The diff coverage is 86.74%.

@@            Coverage Diff             @@
##             main     #180      +/-   ##
==========================================
- Coverage   92.14%   92.00%   -0.14%     
==========================================
  Files          90       93       +3     
  Lines       16690    16950     +260     
==========================================
+ Hits        15379    15595     +216     
- Misses       1311     1355      +44     
Flag Coverage Δ
lint_rules 96.22% <ø> (ø)
loki 91.95% <86.74%> (-0.17%) ⬇️
transformations 91.40% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
loki/analyse/util_linear_algebra.py 100.00% <100.00%> (ø)
loki/transform/transform_loop.py 96.12% <100.00%> (+0.03%) ⬆️
loki/analyse/util_polyhedron.py 92.68% <92.68%> (ø)
...analyse/analyse_array_data_dependency_detection.py 79.68% <79.68%> (ø)

@joscao
Copy link
Contributor Author

joscao commented Oct 27, 2023

  • Missing if statement added if local column matrix is empty. 11103e4

Fixed: "Example 11.35 from Compilers: Principles, Techniques, and Tools" should return false due to indepdent variable test, that is not the case. Whats going on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants