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

Reduce Global Variables in the C backend #373

Open
daviesje opened this issue Apr 2, 2024 · 0 comments
Open

Reduce Global Variables in the C backend #373

daviesje opened this issue Apr 2, 2024 · 0 comments
Labels
context: C backend Changes occur predominantly in the C code context: v4-prep This issue regards changes to the v4-prep branch type: refactor Code refactoring / restyling for internal benefit

Comments

@daviesje
Copy link
Contributor

daviesje commented Apr 2, 2024

There are a large amount of global variables throughout the backend which are used across multiple files. This makes the package rely on the structure of including all .c files in GenerateIC.c, and makes it difficult to debug/develop the backend. We should separate these into a few cases:

  • If the computation required to get a value is negligible, we can re-compute as needed
  • For values which are re-used many times, or which need to be stored (e.g prefactors computed outside a loop) These should be sorted into structs.
    • These will ideally be declared and allocated in the ComputeX function and passed further down.
    • If this is not practical (e.g. the value needs to be stored across multiple calls of the backend functions) the structures can be delcared as static globals to avoid them being used in other files

This should be closely related to a re-think of how we pass in the parameter structures from the wrapper (#TBD), which are currently declared separately in several files e.g astro_params_ps and broadcast manually when needed. This can result in several issues if one is not careful in if/when they broadcast (and we should never expect a user to keep track of this).

@daviesje daviesje added context: C backend Changes occur predominantly in the C code context: v4-prep This issue regards changes to the v4-prep branch type: refactor Code refactoring / restyling for internal benefit labels Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: C backend Changes occur predominantly in the C code context: v4-prep This issue regards changes to the v4-prep branch type: refactor Code refactoring / restyling for internal benefit
Projects
Status: Ready
Development

No branches or pull requests

1 participant