[Ffmpeg-devel] int vs. float: Hard Numbers

Rich Felker dalias
Fri May 20 22:34:30 CEST 2005

On Fri, May 20, 2005 at 12:13:24PM -0600, Mike Melanson wrote:
> Hi,
> 	Persuant to the discussion about whether int or float ops were more 
> efficient on today's production CPUs, I performed some empirical tests.
> 	Tests written using gcc+nasm and clocked using the Intel timestamp 
> counter register (TSC) found in Pentium+ CPUs. I compared additions and 
> multiplications. Results:
> integer_adder() (10 adds) returned 50, 36 cycles used
> float_adder() (10 adds) returned 50.000000, 36 cycles used
> integer_mult() (10 mults) returned 9765625, 115 cycles used
> float_mult() (10 mults) returned 9765625.000000, 36 cycles used
> Interesting notes:
> * the "float" routines are all actually 64-bit double math; I just 
> didn't name them correctly
> * the read TSC instruction + other overhead between the rdtsc markers 
> was 26 cycles; thus, for 3/4 tests, each instruction actually required 1 
> clock cycle
> * the cycle count for integer_adder() floated around (36 was the lower 
> limit) but the cycle counts for the others are highly consistent
> * the integer_mult() function had a few more instructions between the 
> markers (2 extra movs), but I do not think that entirely accounts for 
> the discrepancy
> 	If anyone wants the code for these tests, let me know.
> 	Felker: I await your typical analysis based on these results 
> 	("OMG!!1! Intel sUx!!"). These tests were not conducted specifically on an 
> Intel-branded chip, though it is a P3-class chip.

Yes, Intel sucks. Try it on AMD. FYI, test results I recently saw on
#mplayerdev or one of the mailing lists (can't remember which right
off) showed P4 taking 4x as many cycles to perform common codec
operations as an Athlon took.


More information about the ffmpeg-devel mailing list