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

Use of thread-local variables in AbstractMCMC #128

Open
astrozot opened this issue Sep 20, 2023 · 0 comments
Open

Use of thread-local variables in AbstractMCMC #128

astrozot opened this issue Sep 20, 2023 · 0 comments

Comments

@astrozot
Copy link

I need to sample a distribution for which the calculation of the log-likelihood is particularly time consuming. To speed-up calculations, it is beneficial to pass to the likelihood mutable data that (1) partially contain pre-computed values and (2) can be modified by the log-likelihood depending on the specific set of parameters passed to each call.

It would be relatively easy to implement this on a sequential (non-parallel) execution of a sampling, since I could attach the mutable data to the object representing the distribution. Problems arise however for parallel processing: in this case I would need to have n copies of the mutable data, one for each task.

One way could be to store n-copies of the data and access them in each log-likelihood call using the threadid(), but as clarified here this is no longer correct.

Another possibility would be to use a lock, but this would cancel much of the benefits of going parallel, as the mutable data are used during all the loglikelihood computation.

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