what if i want to use pass by values concept. for example:
void sum(int &u, int &v)
{ return u+v; }
__kernel void testing(__global int *a, __global int *b, __global int *c)
{ int i = get_global_id(0);
int u = max(a,b);
int v = min(b,c);
int x = sum(u,v);
}
now my error is at '&' symbol. i am unable to pass arguments using pass by reference concept. what to do?
C does not support passing a variable by reference, Opencl(v1.x) kernel works as C99. You need to use direct pointers(which is a pass-by-value).
int sum(int *u, int *v)
{ return (*u)+(*v); }
OpenCL v2.x can compile C++ but still it is needed to be supported by drivers and hardware first.
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