Calling a function from the opencl kernel with the concept of pass by value

what if i want to use the concept of pass by values. eg:

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 mistake is in the '&' character. I cannot pass arguments using pass by reference. what to do?

+4
source share
1 answer

C does not support passing a variable by reference; the Opencl core works like C99. You need to use direct pointers (which is a pass by value).

 int sum(int *u, int *v) { return (*u)+(*v); } 
+4
source

All Articles