OpenCL with discrete distributions

With little experience in parallelisation programming, I’m currently trying to understand whether I should try to set up OpenCL on my linux server to speed up the sampling of my model.

I found this section of the User’s Guide and I understand I won’t be able to get OpenCL speed gains for neither Dirichlet or Categorical distribitions’ computations that I use in my model.

However, at the same time I use some of the OpenCL implemented distributions for my priors. Until now, I have used threading with 4 parallel chains. Am I right to assume that for such a model with OpenCL enabled,

  • any implemented distribution on the list linked above would be computed using OpenCL, and
  • any other distribution would be computed without OpenCL …

… while enabling OpenCL would result in threading being disabled entirely as OpenCL and threading apparently cannot be used at the same time?

Would I expect speed gains for the OpenCL implemented distributions on the one hand, but a general slowing down due to disabled threading on the other hand? Or would I even have to assume that OpenCL, in my case, will not bring any meaningful speed gain because each model evaluation can only be as fast as it’s slowest (not implemented) element.

And out of curiosity - why won’t STAN let me run some distribution computations in parallel using OpenCL?

Thanks!

Stan has several OpenCL implementations for discrete distributions. Here’s the complete list:

https://mc-stan.org/docs/stan-users-guide/parallelization.html#opencl

You can see that it includes discrete distributions like Bernoulli, binomial and Poisson, and is missing some continuous distributions like the Dirichlet and multivariate normal. This is just a matter of where the devs have focused effort. @stevebronder should know more as he’s been doing a lot of this coding.

Thanks for the clarification, corrected in original post.

Then it would be interesting to know how it affects performance when using both already and not yet implemented distributions.