mrc-ide / odin.dust

Compile odin to dust
https://mrc-ide.github.io/odin.dust
Other
3 stars 1 forks source link

Avoid f64 maths in single precision mode #121

Closed richfitz closed 1 year ago

richfitz commented 1 year ago

Cast literal real values (e.g., 1.23) to whatever real type we're using at compile time, to avoid use of f64 maths on GPUs when single precision is used. Without this, we emit lots of 64 bit floats, which end up using the (much) slower f64 pipelines on a GPU (there will be practically no difference but memory use on a CPU). This uglifies the generated code a bit, but it's not that bad.

Also include a set of math functions that will actually use single precision when used with single precision args, at least on a GPU, see https://github.com/mrc-ide/dust/pull/383 for details

~Depends on https://github.com/mrc-ide/dust/pull/383~

~Contains commits for #120 and #119, merge them first.~

~For the local diff see https://github.com/mrc-ide/odin.dust/compare/mrc-3829...mrc-3852~

codecov[bot] commented 1 year ago

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage :thumbsup:

Coverage data is based on head (32c11e8) compared to base (e9376b8). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #121 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 7 7 Lines 1125 1127 +2 ========================================= + Hits 1125 1127 +2 ``` | [Impacted Files](https://codecov.io/gh/mrc-ide/odin.dust/pull/121?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide) | Coverage Δ | | |---|---|---| | [R/common.R](https://codecov.io/gh/mrc-ide/odin.dust/pull/121/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9jb21tb24uUg==) | `100.00% <ø> (ø)` | | | [R/generate\_dust\_sexp.R](https://codecov.io/gh/mrc-ide/odin.dust/pull/121/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9nZW5lcmF0ZV9kdXN0X3NleHAuUg==) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.