Casting float to int, fast math operations on double/float

support for the powerpc toolchain
Post Reply
Eke
Posts: 64
Joined: Sat Mar 01, 2008 11:01 am

Casting float to int, fast math operations on double/float

Post by Eke » Tue Aug 19, 2008 8:25 pm

I've seen ASM routines in cast.h which seems to quickly convert integer into floats and floats into integer: if I directly call these functions instead of doing a simple cast from the compiler like int x= (float) y, how much faster will it be ?

also, I use libsamplerate in my project and it requires LRINT and LRINTF functions to be set: everything compiles fine so I guess they are present in libmath but again, what the performance against the functions in cast.h ?

thanks


PS: libsamplerate also ask about CPU_CLIPS_NEGATIVE and CPU_CLIPS_POSITIVE flags, does the Gekko automatically clips value on negative/positive float to int conversion ?
Last edited by Eke on Wed Jan 28, 2009 10:39 am, edited 1 time in total.

Eke
Posts: 64
Joined: Sat Mar 01, 2008 11:01 am

Re: casting float to int

Post by Eke » Wed Jan 28, 2009 9:37 am

I've been recently informed about the bottleneck issues that could occur when using simple float/double to int cast on modern CPU that use pipelining and load&store scheme (like the Power PC)

Some interesting articles here:

http://www.mega-nerd.com/FPcast/
http://assemblyrequired.crashworks.org/ ... s-to-ints/


Any ideas about what I should use ? lrint from math.h or those functions in libogc/cast.h ?
Or is powerpc-gekko-gcc already able to get ride of this alone with optimization enabled ?


Secondly, what about the __FAST_MATH__ define in math.h, is it defined by default or do we have to somehow enable it in gcc ?

Any advices would be appreciated, thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests