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

Release 0.1.17 #202

Merged
merged 6 commits into from
Jul 18, 2024
Merged

Release 0.1.17 #202

merged 6 commits into from
Jul 18, 2024

Conversation

plietar
Copy link
Member

@plietar plietar commented Jul 18, 2024

No description provided.

plietar added 6 commits July 12, 2024 11:08
Because of how R assigns names to stack frames, all processes in a
typical individual simulation would end up being called `p`. This makes
it difficult to interpret profiling results.

R uses the name of the variable the called function is bound to. By
dynamically creating a variable with a chosen name and using `eval` to
execute that variable, we can get the stack frame to show up with any
desired name.

This uses this trick to allow the list of processes to be given names,
and these names are used in the calls.
In addition to a vector of numerical indices and another bitset, the
filter_bitset now accepts a vector of logicals (ie. booleans). Each set
bit of the bitset is included in the return value only if the
corresponding value in the logical vector is TRUE.

Given `v` a logical vector, `filter_bitset(b, v)` is equivalent to the
already supported `filter_bitset(v, which(v))` but is more performant.
The new semantics also align with subsetting of R vectors, which
similarly supports either a vector of indices or vector of logicals.
The variable stores the number of bits per word and is used throughout
the implementation to split a position into a word index and bit
position in the word.

The value can be determined statically from the size of the template
parameter and does not need to be stored as a field. Keeping it as a
`constexpr` value allows the compiler to optimize operations that use
it. In particular, since the value is always a power of two, any
multiplication, division, and modulo operations by this value, which are
quite common, can be turned into bit shifts or masks by a constant.

The performance impact of this change is quite small, but measurable, at
around 2% for a 1M malariasimulation run, with no downside.
Make num_bits a constant expression.
This copies the value from one bitset to another one.
@plietar plietar requested a review from giovannic July 18, 2024 12:25
@plietar plietar merged commit 76496ec into master Jul 18, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants