Peephole optimization for commonly paired functions
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 160
- Forks
- 59
- Avg merge
- 21h 45m
- Merged PRs (30d)
- 26
Description
See #1674 for an initial attempt. Thanks to @sims1253 for the suggestion
There are several functions that historically duplicated work and now can be done in a single call returning a tuple. These were primarily added in https://github.com/stan-dev/math/pull/2931:
qr: replaces calls toqr_Q/qr_Rqr_thin: replaces calls toqr_thin_Q/qr_thin_Reigendecompose_sym: replaces calls toeigenvalues_sym/eigenvectors_symeigendecompose: replaces calls toeigenvalues/eigenvectorscomplex_schur_decompose: replaces calls tocomplex_schur_decompose_t/complex_schur_decompose_usvd: replaces calls tosvd_U/svd_Vcsr_extract: replaces calls tocsr_extract_u/csr_extract_v/csr_extract_w
The proposal is to add a small optimization which detects cases where these are called one after the other and rewrite them to use the combined version.
It may also be useful to separately flag a warning for models where the older functions are both called on the same thing.
Contributor guide
No contributing guide indexed for this repository
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 reading issue #1674 and the stanc3 optimization code that handles function-call patterns. Trace how paired calls to qr, qr_thin, eigendecompose, complex_schur_decompose, svd, or csr_extract are represented and transformed. Done means qualifying consecutive calls use the combined tuple-returning function, with coverage for the rewrite and possibly a separate warning for older paired calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- compilers, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100