Community
cancel
Showing results for 
Search instead for 
Did you mean: 
tempatel
Beginner
33 Views

Vectorize function calls

I have an OpenCL program wich failed to vectorize. Problem is in function in line marked XXX
int getNumEigensLess(float c, int n, __global float *d, __global float *e, float pivmin) {
float diff = d[0] - c;
diff = select(diff, -pivmin, fabs(diff) < pivmin);
int count = select(0, 1, diff <= 0);
for (int j = 1; j < n; ++j) {
diff = d - c - sqr(e[j - 1]) / diff; // XXX here is a problem line
diff = select(diff, -pivmin, fabs(diff) < pivmin);
count += select(0, 1, diff <= 0);
}
return count;
}
I see, that vectorization fails because each successive diff value depends on previous. But there is an another way. As far as I know, all non kernel functions are inlined in OpenCL, so instead of vectorizationgetNumEigensLess itself, compiler can vectorize function calls. Make signature something like
int4 getNumEigensLess(float4 c, int n, __global float *d, __global float *e, float pivmin)
Obviously I use same n, e, d and pivmin parameters between calls, changing only c.
How can I change my code, to make compiler vectorize function calls like this?
0 Kudos
1 Reply
tempatel
Beginner
33 Views

Substituting function body instead of a call has no effect either