Can I embed C ++ classes in OpenCL kernels?

Is it possible to use self-defined C ++ classes in the OpenCL kernel? It should work as follows:

#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 to be done in the :: update (int no) element afterwards.

I did not get a job. This is what 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 tips in advance!

+3
source share
3 answers

, OpenCL C99, ++. ++ OpenCL. , AMD APP OpenCL ++. , , ++ C. ++ C, .

: , . AMD ++ OpenCL ++ Bolt.

+8

. OpenCL C99 , , ++, . "".

- ++, OpenCL i.e. , -

element update(element in) { ... ; return result; }

OpenCL ++, , ,

output[index] = update(input[index]);

, , C-.

OpenCL , .

+2

No, others, as they tell you that OpenCL is based on C99, so you can use structures like

typedef struct{
   float mini;
   int pos;
}A;
+2
source

Source: https://habr.com/ru/post/1792793/


All Articles