OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.

Vectorize function calls

tempatel
Beginner
90 Views
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
90 Views
Substituting function body instead of a call has no effect either
Reply