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

Implement various minor optimizations in fldr_preprocess #7

Open
fsaad opened this issue Sep 18, 2020 · 0 comments
Open

Implement various minor optimizations in fldr_preprocess #7

fsaad opened this issue Sep 18, 2020 · 0 comments

Comments

@fsaad
Copy link
Collaborator

fsaad commented Sep 18, 2020

  1. Remove initialization of H to -1; instead, use calloc for initalizatio nto 0 and index the samples by 1, ..., n+1; also make sure to update the sampler to check if the sample is <= n, and return one minus

https://github.com/probcomp/fast-loaded-dice-roller/blob/2fb32e94a04c744c86aa4cb54b3ee0259894e777/src/c/fldr.c#L55
https://github.com/probcomp/fast-loaded-dice-roller/blob/2fb32e94a04c744c86aa4cb54b3ee0259894e777/src/c/fldr.c#L97-L98

  1. Remove unneeded additions
    https://github.com/probcomp/fast-loaded-dice-roller/blob/2fb32e94a04c744c86aa4cb54b3ee0259894e777/src/c/fldr.c#L57
    https://github.com/probcomp/fast-loaded-dice-roller/blob/2fb32e94a04c744c86aa4cb54b3ee0259894e777/src/c/fldr.c#L65

  2. Change bool to int
    https://github.com/probcomp/fast-loaded-dice-roller/blob/2fb32e94a04c744c86aa4cb54b3ee0259894e777/src/c/fldr.c#L56
    https://github.com/probcomp/fast-loaded-dice-roller/blob/2fb32e94a04c744c86aa4cb54b3ee0259894e777/src/c/fldr.c#L64

The main bottleneck in preprocessing is bit extraction from the a[i]. It might more efficient to compute the probability matrix in reverse order (i.e., with the least significant bit in the first column) and using integer division on the running values of a[i], instead of bit shifts/masking.

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

No branches or pull requests

1 participant