Array optimizations
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 1.2k
- Forks
- 271
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 173
Description
Original issue: https://gitlab.com/lfortran/lfortran/-/issues/383
Very frequently I use array operations such as:
maxval(abs(a-b))for finding maximum error betweenaandb.sqrt(dot_product(array,array))or evensqrt(sum(x**2))to compute a norm. There is now anorm2intrinsic for this.
I think the compiler optimizer should be able to recognize such common expressions and generate optimal code for those.
Implementation: this could be an ASR pass that recognized such expressions and replaces them with internal functions. Alternatively, once we have some general framework for simplifying such array operations (perhaps using Mathematics of Arrays), it could handle such a case.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the proposed ASR pass approach and the alternative Mathematics of Arrays direction described in the issue. Define how expressions such as maxval(abs(a-b)), sqrt(dot_product(array,array)), and sqrt(sum(x**2)) should be recognized and replaced with internal functions, then verify that the resulting code is optimized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, fortran
- Domain
- compilers, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100