Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🦑 Transform ASSIGNED to LOCAL #1973

Open
thorstenhater opened this issue Sep 8, 2022 · 1 comment
Open

🦑 Transform ASSIGNED to LOCAL #1973

thorstenhater opened this issue Sep 8, 2022 · 1 comment
Assignees
Labels
enhancement nmodl Interpretation or extension of NMODL. optimization

Comments

@thorstenhater
Copy link
Contributor

thorstenhater commented Sep 8, 2022

We can safely transform an ASSIGNED var into a LOCAL iff the following condition holds for all API blocks
in an NMODL mechanism:var written before it's read. If var is never read, we can remove it alltogether.

The only wrinkle are if-then-else statements, but these are fine with a bit of care.
For that consider both arms (if present!) individually and merge their reads and
writes:

  • if 'written-before-read' is true for both branches, then it's true overall
  • if 'written-before-read' is true for one branch, dismiss and proceed
  • if it's false for one branch, it's false overall
  • if var is written in one branch, dismiss this fact
  • if var is written in both branches, propagate that fact.

We miss some cases

ASSIGNED { q10 }

INITIAL { q10 = ...}

BREAKPOINT { ix = f(q10) }

but there it's questionable (without a cost model depending on the backend CPU/SIMD/GPU) whether it's
an optimisation anyhow. These could be recovered by ordering the blocks (and their possible interleavings,
potentially) by the order prescribed by fvm_lowered_cell::integrate, but I consider this quite brittle.

@thorstenhater thorstenhater added enhancement optimization nmodl Interpretation or extension of NMODL. labels Sep 8, 2022
@thorstenhater thorstenhater self-assigned this Sep 8, 2022
@thorstenhater
Copy link
Contributor Author

Note

This also requires at least a primitive cost model as things that are expensive to compute and never change
are worth writing to memory. That also might depend on CPU ./. GPU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement nmodl Interpretation or extension of NMODL. optimization
Projects
None yet
Development

No branches or pull requests

1 participant