math icon indicating copy to clipboard operation
math copied to clipboard

opencl question

Open spinkney opened this issue 3 years ago • 4 comments

What's the priority for opencl versions of functions? Are we supposed to add them with the non-opencl version? For patches/fixes to functions, we should also patch/fix the opencl version. I know this adds to development debt and I have never touched opencl versions. Is there a way that we can keep track of changes that occur in the non-opencl functions where we probably need to update the opencl version?

In some ways, I think it would be better to have a stan-math-gpu library to keep track off all these changes and keep stan-math as it is. Though this suggestion is a bigger conversation.

@syclik @rok-cesnovar @bob-carpenter @WardBrian

spinkney avatar Sep 12 '22 12:09 spinkney

This is my view on this topic.

What's the priority for opencl versions of functions?

Currently, there is no priority list. The majority of the functions have OpenCL support, but not all. My PhD advisor Erik is still trying to get some students to fill the rest of the gaps. Regardless of that, I think we should just follow the same logic as for any other feature in Stan Math. If anyone wants something implemented, they can open an issue, and if someone is interested in addressing it and it's something that would be valuable for Stan Math, they can address it.

Are we supposed to add them with the non-opencl version?

No. If you want to, you are welcome, but it's definitely not a necessity.

I know this adds to development debt and I have never touched opencl versions. Is there a way that we can keep track of changes that occur in the non-opencl functions where we probably need to update the opencl version?

Opening an issue with an OpenCL label should be enough I think.

In some ways, I think it would be better to have a stan-math-gpu

I don't oppose this, but that would add an additional cost. I think we should start with labels, but if that gets out of hand, we can rethink.

rok-cesnovar avatar Sep 12 '22 14:09 rok-cesnovar

I'll second what @rok-cesnovar said. We might be able to split it out to a secondary library, but the integration pains will be no joke. I can already see some of the headache that we might face.

syclik avatar Oct 20 '22 02:10 syclik

What would a stan-math-gpu library look like and in what ways would it be better, and who will it be better. Is it a separate translation unit? Does that benefit developers or users in some way? Sorry for all the questions, but I don't understand why @spinkney is proposing this or what @syclik is indicating would be difficult to integrate.

bob-carpenter avatar Oct 20 '22 09:10 bob-carpenter

Sorry for all the questions, but I don't understand why @spinkney is proposing this or what @syclik is indicating would be difficult to integrate.

The main thing I need is documentation on how to write opencl. I'm having trouble getting conditional things to work because of the requirement for full array/vectorized operations in https://github.com/stan-dev/math/pull/2811. Anyway, I was mainly curious if a function which is written for opencl and cpu, can I leave the opencl version unpatched? Is it a strict requirement to update both? If the latter than I could see the proposal of splitting opencl off as beneficial to developers.

spinkney avatar Oct 20 '22 09:10 spinkney