[linux-audio-dev] double <--> float conversions speed benchmark and analysis

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: [linux-audio-dev] double <--> float conversions speed benchmark and analysis
From: Benno Senoner (sbenno_AT_gardena.net)
Date: Tue Apr 04 2000 - 16:31:33 EEST


Hi folks,after the float vs double debate, I decided to benchmark at least
conversion between the two datatypes.

The code is attached to the end of the mail
( compile with: gcc -O2 -o floatspeed floatspeed.c -lm )

basically I am testing: (loops of the instructions below unrolled
in sequences of 4 to minimize the overhead of the for loop)

float to float buffer passing:

*outbuf32ptr++ = *inbuf32ptr++;
*outbuf32ptr++ = *inbuf32ptr++;
*outbuf32ptr++ = *inbuf32ptr++;
*outbuf32ptr++ = *inbuf32ptr++;

double to double:

*outbuf64ptr++ = *inbuf64ptr++;
*outbuf64ptr++ = *inbuf64ptr++;
*outbuf64ptr++ = *inbuf64ptr++;
*outbuf64ptr++ = *inbuf64ptr++;

float to double:

*outbuf64ptr++ = (double) *inbuf32ptr++;
*outbuf64ptr++ = (double) *inbuf32ptr++;
*outbuf64ptr++ = (double) *inbuf32ptr++;
*outbuf64ptr++ = (double) *inbuf32ptr++;

double to float:

*outbuf32ptr++ = (float) *inbuf64ptr++;
*outbuf32ptr++ = (float) *inbuf64ptr++;
*outbuf32ptr++ = (float) *inbuf64ptr++;
*outbuf32ptr++ = (float) *inbuf64ptr++;

Test system intel Celeron 366:

RESULTS:
float to float buffers
time delta=15.906434
million operations/sec=128.753

double to double buffers
time delta=15.969527
million operations/sec=128.244

float to double buffers
time delta=17.425132
million operations/sec=117.531

double to float buffers
time delta=22.873382
million operations/sec=89.536

SUMMARY:

as you can see double to double and float to float assignments
deliver almost the same speed.
float 2 double cost is a few % , while double 2 float cost about 30%
of performance loss. (vs float2float or double2double)

This again proved that my multidatatype design is superiour to a
design limited to float.
Consider the fact that many VST plugins are now internally (except for inputs
and outputs) working with double to get full 24bit precision. (synths, and other
HQ stuff, since you can't pretend to deliver full 24bit precision while only
doing 24bit internal computations)
That means at least a double to float and float to
double conversion between many plugins, which can eat a part of your CPU to do
useless work.

With my design you can for example keep plugins using the "double"
datatype in a sequential chain without any useless datatype ( float
to double at every input and double to float at every output) conversions.

(flexible plugins should provide float and double, so that the host can choose
what to use (for precision or speed reasons))

comments ?

Benno.



New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Tue Apr 04 2000 - 17:33:43 EEST