Say we have a kernel function:
kernel void function(global const float* a, global const float* b, global float* c, int nElements)
{
...
c[gid] = a[gid] * b[gid];
}
but want to break up a large complex kernel into several smaller functions. How do I pass the global buffers to these smaller functions?
If I do the following I get an error of the form "implicit declaration of function 'cl_axpbyr' is invalid in OpenCL":
kernel void function(global const float* a, global const float* b, global float* c, int nElements)
{
...
cl_axpbyr(1.0f, a, c, nElements);
}
inline void cl_axpy(float alpha, global const float* x, global float* y, int nElements)
{
int gid = get_global_id(0);
if (gid >= nElements)
{
return;
}
y[gid] = alpha*x[gid] + y[gid];
}