rbchan / unmarked

R package for hierarchical models in ecological research
https://rbchan.github.io/unmarked/
36 stars 25 forks source link

Add openMP support to some functions #195

Closed kenkellner closed 3 years ago

kenkellner commented 3 years ago

This PR adds openMP support to pcount, occuRN, gpcount, gmultmix, and gdistsamp. Partially fixes #189. I prioritized functions where we have to marginalize across a bunch of possible abundance values, since those tend to be the slowest functions.

Probably the open-pop functions (like pcountOpen) would benefit from calculating the likelihood in parallel even more, but because of the way their likelihoods are written now it's going to be a lot more work to make sure they are thread-safe.

This works both on Linux and in Windows (based on my tests), if you have Rtools. I suspect that you'd have to compile yourself on Windows though, I don't think the binary CRAN provides will work with openMP out of the box, but I can't test that.

Also as part of this I started updating the interface with Rcpp, i.e. using // [[Rcpp::export]] so that the wrapper SEXP function is generated automatically.