-
Notifications
You must be signed in to change notification settings - Fork 77
Optimize two-locus site operations #3291
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
Open
lkirk
wants to merge
1
commit into
tskit-dev:main
Choose a base branch
from
lkirk:two-locus-optimizations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1104,29 +1104,31 @@ FILE *tsk_get_debug_stream(void); | |||||
|
||||||
/* Bit Array functionality */ | ||||||
|
||||||
typedef uint32_t tsk_bit_array_value_t; | ||||||
// define a 32-bit chunk size for our bitsets. | ||||||
// this means we'll be able to hold 32 distinct items in each 32 bit uint | ||||||
#define TSK_BITSET_BITS (tsk_size_t) 32 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Extra parentheses avoid unexpected casts when using the macro |
||||||
typedef uint32_t tsk_bitset_val_t; | ||||||
|
||||||
typedef struct { | ||||||
tsk_size_t size; // Number of chunks per row | ||||||
tsk_bit_array_value_t *data; // Array data | ||||||
} tsk_bit_array_t; | ||||||
|
||||||
#define TSK_BIT_ARRAY_CHUNK 5U | ||||||
#define TSK_BIT_ARRAY_NUM_BITS (1U << TSK_BIT_ARRAY_CHUNK) | ||||||
|
||||||
int tsk_bit_array_init(tsk_bit_array_t *self, tsk_size_t num_bits, tsk_size_t length); | ||||||
void tsk_bit_array_free(tsk_bit_array_t *self); | ||||||
void tsk_bit_array_get_row( | ||||||
const tsk_bit_array_t *self, tsk_size_t row, tsk_bit_array_t *out); | ||||||
void tsk_bit_array_intersect( | ||||||
const tsk_bit_array_t *self, const tsk_bit_array_t *other, tsk_bit_array_t *out); | ||||||
void tsk_bit_array_subtract(tsk_bit_array_t *self, const tsk_bit_array_t *other); | ||||||
void tsk_bit_array_add(tsk_bit_array_t *self, const tsk_bit_array_t *other); | ||||||
void tsk_bit_array_add_bit(tsk_bit_array_t *self, const tsk_bit_array_value_t bit); | ||||||
bool tsk_bit_array_contains( | ||||||
const tsk_bit_array_t *self, const tsk_bit_array_value_t bit); | ||||||
tsk_size_t tsk_bit_array_count(const tsk_bit_array_t *self); | ||||||
void tsk_bit_array_get_items( | ||||||
const tsk_bit_array_t *self, tsk_id_t *items, tsk_size_t *n_items); | ||||||
tsk_size_t row_len; // Number of size TSK_BITSET_BITS chunks per row | ||||||
tsk_size_t len; // Number of rows | ||||||
tsk_bitset_val_t *data; | ||||||
} tsk_bitset_t; | ||||||
|
||||||
int tsk_bitset_init(tsk_bitset_t *self, tsk_size_t num_bits, tsk_size_t length); | ||||||
void tsk_bitset_free(tsk_bitset_t *self); | ||||||
void tsk_bitset_intersect(const tsk_bitset_t *self, tsk_size_t self_row, | ||||||
const tsk_bitset_t *other, tsk_size_t other_row, tsk_bitset_t *out); | ||||||
void tsk_bitset_subtract(tsk_bitset_t *self, tsk_size_t self_row, | ||||||
const tsk_bitset_t *other, tsk_size_t other_row); | ||||||
void tsk_bitset_union(tsk_bitset_t *self, tsk_size_t self_row, const tsk_bitset_t *other, | ||||||
tsk_size_t other_row); | ||||||
void tsk_bitset_set_bit(tsk_bitset_t *self, tsk_size_t row, const tsk_bitset_val_t bit); | ||||||
bool tsk_bitset_contains( | ||||||
const tsk_bitset_t *self, tsk_size_t row, const tsk_bitset_val_t bit); | ||||||
tsk_size_t tsk_bitset_count(const tsk_bitset_t *self, tsk_size_t row); | ||||||
void tsk_bitset_get_items( | ||||||
const tsk_bitset_t *self, tsk_size_t row, tsk_id_t *items, tsk_size_t *n_items); | ||||||
|
||||||
#ifdef __cplusplus | ||||||
} | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, safer to wrap full expression of the macro in parantheses as unexpected things can happen if used with different precedence operators.