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

Encoders: turn into proper inline functions #58

Closed
aklomp opened this issue Nov 22, 2019 · 0 comments
Closed

Encoders: turn into proper inline functions #58

aklomp opened this issue Nov 22, 2019 · 0 comments
Assignees
Milestone

Comments

@aklomp
Copy link
Owner

aklomp commented Nov 22, 2019

Currently, encoder kernels are simple while loops that are inserted into a switch statement by an #include directive. Turn these loops into full static inline functions.

  • Makes early returning possible.
  • Makes it possible to do pre-loop and post-loop computations, such as calculating the number of rounds in advance. This could be done now, but not in a straightforward way.
  • Will later make it possible to unroll loops by inlining multiple copies of the inner loop.
  • Communicates additional constraints to the compiler, potentially allowing it to optimize better.

This change should have no adverse effects, because the compiler will inline the function at its only callsite. On the contrary, this change will be beneficial for maintenance and performance.

@aklomp aklomp changed the title Factor encoder kernels into inline functions Encoders: turn into proper inline functions Nov 23, 2019
@aklomp aklomp self-assigned this Nov 23, 2019
aklomp added a commit that referenced this issue Nov 26, 2019
Currently, encoder kernels are simple while loops that are inserted into
a switch statement by an #include directive. Turn these loops into full
static inline functions.

- Makes early returning possible.
- Makes it possible to do pre-loop and post-loop computations, such as
  calculating the number of rounds in advance. This could be done now,
  but not in a straightforward way.
- Will later make it possible to unroll loops by inlining multiple
  copies of the inner loop.
- Communicates additional constraints to the compiler, potentially
  allowing it to optimize better.

This change should have no adverse effects, because the compiler will
inline the function at its only callsite. On the contrary, this change
should be beneficial for maintenance and performance.
@aklomp aklomp closed this as completed Nov 26, 2019
aklomp added a commit that referenced this issue Nov 27, 2019
Currently, decoder kernels are simple while loops that are inserted into
a switch statement by an #include directive. Turn these loops into full
static inline functions.

See the merge commit for #58 for more background.
aklomp added a commit that referenced this issue Nov 28, 2019
The transformation of encoder kernels to inline functions (#58) allows
us to move the inner encoding loop into separate inline functions.

Because the number of remaining loop iterations is known, we can split
calls to the inner loop into long unrolled stretches. Tests show that
this can result in significant speedups.
@aklomp aklomp added this to the v0.5.0 milestone Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant