Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 367
Fakruddeen Avatar asked Nov 30 '12 09:11

Fakruddeen


1 Answers

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.

like image 89
huseyin tugrul buyukisik Avatar answered Oct 21 '22 03:10

huseyin tugrul buyukisik