- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Substituting function body instead of a call has no effect either

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page