[Liboil] exp, log

Stephane Fillod f8cfe at free.fr
Thu Mar 16 00:22:19 PST 2006


On Wed, Mar 15, 2006 at 05:14:05PM -0500, James Bergstra wrote:
> 
> The problem which motivates this email is that if you write a loop like
> 
> for (int i = 0; i < 256; ++i) y[i] = exp(x[i]);
> 
> and compile it with gcc, you get code that runs much slower than if you make a
> call to amd's libacml_mv

..because amd's libacml_mv is doing what liboil should have done ;-)
BTW, I was not aware of the amd's libacml_mv. Can you talk a bit more
about it?

> 
> vrda_exp(256, x, y);
> 
> My question for the list is whether you think liboil might tackle the problem of
> vectorized functions like exp, log, cos, sin, sincos, cabs, etc... or whether
> these should be left for a compiler?   I believe that the answer should be
> "both"... first liboil, and the compiler :)

My answer would be, if your application has a need for it, then go ahead and
add it to liboil.

BTW, I have a patch in my tree which adds sin/cos/sincos (fixpoint with float
result) speedup. They are much needed in some application (DSP, ..). I can send
the ref/ API proposal as a starting point.

> The other aspect of implementing vectorized functions like these is demonstrated
> by the fact that amd's library has routines like
> __vrd1_exp()
> __vrd2_exp()
> __vrd4_exp()
> that compute 1, 2, and 4 exp(x) values per call.  I don't know of any open
> implementation of such functions.

In the amd's libacml_mv, why not wrapping (optionaly) the libacml_mv calls in liboil, 
and let the competition (individual call timing) decide ?
Talking about computing only 1, 2, and 4 values per call, normaly, liboil
does not chase such low optimizition gain. But you should know this already
by profiling your application first.

Cheers
-- 
Stephane


More information about the Liboil mailing list