Vectorize function calls

Vectorize function calls

I have an OpenCL program wich failed to vectorize. Problem is in function in line marked XXXint 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[j] - 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 likeint4 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?

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Substituting function body instead of a call has no effect either

Leave a Comment

Please sign in to add a comment. Not a member? Join today