stan-dev / stan-dev/stanc3

SoA should allow arbitrary initialization of matrix if it isn't elementwise accessed thereafter

Open
#1,503 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

optimization
Dominant language
OCaml
Stars
160
Forks
59
Avg merge
21h 45m
Merged PRs (30d)
26

Description

Currently, the memory pattern optimization relies on all functions being inlined and then searches for elementwise accesses as its heuristic to disable function promotion.

It would be really nice if we instead allowed things like

transformed parameters {
  matrix[N,M] foo = some_function(N, M, other_arguments) + possibly_other_expressions;
}

to be code generated to something like auto foo = to_soa(some_function(...) ...) when there are no further elementwise accesses of foo, even if the code in some_function does use for-loops to construct it. This is sort of on-the-way to something like a comprehension, but I believe it is implementable right now for many models.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by tracing the memory pattern optimization and its elementwise-access heuristic, then examine how matrix initialization is code generated. Done means non-elementwise matrix construction can use the requested SoA representation when there are no later elementwise accesses, including constructions using loops.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, ocaml
Domain
compilers, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.