[Liboil] Liboil slower than plain gcc?

Jason Sewall jasonsewall at gmail.com
Sat Dec 15 10:08:51 PST 2007


I thought I'd take liboil for a spin and I've been disappointed with
its performance.

I have this code:
float * src1 = (float*) malloc(sizeof (float) * size);
float * src2 = (float*) malloc(sizeof (float) * size);
float * dest =  (float*) malloc(sizeof (float) * size);

srand48(3412);
for(int i =0; i < size; ++i)
{
     src1[i] = (float)drand48()-0.5f;
     src2[i] = (float)drand48()-0.5f;
}

float c1 = 2.0f;
float c2 = 0.5f;

If I ask liboil to do this:
oil_vectoradd_f32(dest, sizeof(float), src1, sizeof(float), src2,
sizeof(float), size, &c1, &c2);

it ends up being about 3-4x slower than gcc with this:
for(int i = 0; i < size; ++i)
     dest[i] = c1*src1[i]+c2*src2[i];

If they are compiled with:
-DNDEBUG -O3 -funroll-all-loops -march=prescott --std=c99 -msse3 -mfpmath=sse

Am I doing something grossly wrong? Just curious; I'm very surprised
by this result. I've gotten similar results with oil_abs_f32_f32.

[sewall at localhost oiltest (master)]$ gcc --version
gcc (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33)

And this is with liboil built from commit 95326889fb


More information about the Liboil mailing list