I have following code using loop unrolling:
#pragma unroll
for (int i=0;i<n;i++)
{
....
}
here if n is a defined constant, everything works fine. However, if n is a variable, performance dramatically reduced. I noticed roughly 3 times the instructions are issued and executed. I guess I am looking for a way to do loop unrolling at run time, may be that's just not feasible.