is there a possibility to use self-defined C++ - classes in an OpenCL kernel? It should work like this:
#include "element.cpp"
__kernel void do_something(__global element* input, __global element* output);
{
int index = get_global_id(0);
output[index] = input[index].update(index);
}
This is interesting, because you can specify the work that must be done in element::update(int no) afterwards.
I did not get it to work. This is what the OpenCL-Compiler tells me:
unknown type name 'class'
In CUDA this works. Are there any other ideas, if the approach with objects in the OpenCL kernel does not work?
Thanks for your hints in advance!
I believe OpenCL follows C99 language specification and not C++. The specifications for C++ version of OpenCL is going on. I believe AMD APP has implemented the C++ version of OpenCL. Coming back to your question, I think it's best to have a struct as the interface between C++ and C. The C++ version should be a wrapper around the C implementation, IF you direly need to do so.
EDIT: I couldn't place this in comments, hence putting it here. AMD's C++ libraries around OpenCL include a static C++ library and Bolt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With