All of lore.kernel.org
 help / color / mirror / Atom feed
* alsa-lib and floating point support
@ 2017-09-20 10:55 Ricard Wanderlof
  2017-09-20 11:26 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Ricard Wanderlof @ 2017-09-20 10:55 UTC (permalink / raw)
  To: alsa-devel; +Cc: Mersad Jelacic


We recently came across an issue with the alsa-lib softvol plugin, which 
requires hardware floating-point (i.e. --with-softfloat not enabled during 
build) support in order to use anything but a set of default values (min 
gain -51 dB, max 0 dB, and 256 gain steps). With no hardware floating 
point support, the plugin just prints an error message when loaded.

static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol,
 ...
#ifndef HAVE_SOFT_FLOAT
 ...
                        double v = (pow(10.0, db / 20.0) * (double)(1 << 
VOL_SCALE_SHIFT));
 ...
#else
                SNDERR("Cannot handle the given dB range and resolution");
                return -EINVAL;
#endif
        }
 ...

I'm trying to understand why it is critical to have hardware floating 
point support in this case. The pow() function is very resource hungry, 
true, but the function is only called when the plugin is loaded, and not 
for instance on every sample while the stream is running, so on the whole 
I would expect the impact to be minimal. Is there some other rationale 
that I'm missing?

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: alsa-lib and floating point support
  2017-09-20 10:55 alsa-lib and floating point support Ricard Wanderlof
@ 2017-09-20 11:26 ` Takashi Iwai
  2017-09-20 14:45   ` Ricard Wanderlof
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2017-09-20 11:26 UTC (permalink / raw)
  To: Ricard Wanderlof; +Cc: alsa-devel, Mersad Jelacic

On Wed, 20 Sep 2017 12:55:30 +0200,
Ricard Wanderlof wrote:
> 
> 
> We recently came across an issue with the alsa-lib softvol plugin, which 
> requires hardware floating-point (i.e. --with-softfloat not enabled during 
> build) support in order to use anything but a set of default values (min 
> gain -51 dB, max 0 dB, and 256 gain steps). With no hardware floating 
> point support, the plugin just prints an error message when loaded.
> 
> static int softvol_load_control(snd_pcm_t *pcm, snd_pcm_softvol_t *svol,
>  ...
> #ifndef HAVE_SOFT_FLOAT
>  ...
>                         double v = (pow(10.0, db / 20.0) * (double)(1 << 
> VOL_SCALE_SHIFT));
>  ...
> #else
>                 SNDERR("Cannot handle the given dB range and resolution");
>                 return -EINVAL;
> #endif
>         }
>  ...
> 
> I'm trying to understand why it is critical to have hardware floating 
> point support in this case. The pow() function is very resource hungry, 
> true, but the function is only called when the plugin is loaded, and not 
> for instance on every sample while the stream is running, so on the whole 
> I would expect the impact to be minimal. Is there some other rationale 
> that I'm missing?

The softfloat option is to avoid calculation in float as much as
possible, i.e. alsa-lib will be built without any usage of math
library.


Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: alsa-lib and floating point support
  2017-09-20 11:26 ` Takashi Iwai
@ 2017-09-20 14:45   ` Ricard Wanderlof
  2017-09-20 16:10     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Ricard Wanderlof @ 2017-09-20 14:45 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, Mersad Jelacic


On Wed, 20 Sep 2017, Takashi Iwai wrote:

> > I'm trying to understand why it is critical to have hardware floating 
> > point support in this case. The pow() function is very resource hungry, 
> > true, but the function is only called when the plugin is loaded, and not 
> > for instance on every sample while the stream is running, so on the whole 
> > I would expect the impact to be minimal. Is there some other rationale 
> > that I'm missing?
> 
> The softfloat option is to avoid calculation in float as much as
> possible, i.e. alsa-lib will be built without any usage of math
> library.

"as much as possible" sounds like the softvol case would be a reasonable 
exception, on the other hand, if the goal is to completely avoid using the 
softfloat library I can see the point. Is the reason to avoid dependency 
issues, or to minimize the total resulting code size, especially on 
systems with limited memory?

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: alsa-lib and floating point support
  2017-09-20 14:45   ` Ricard Wanderlof
@ 2017-09-20 16:10     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2017-09-20 16:10 UTC (permalink / raw)
  To: Ricard Wanderlof; +Cc: alsa-devel, Mersad Jelacic

On Wed, 20 Sep 2017 16:45:46 +0200,
Ricard Wanderlof wrote:
> 
> 
> On Wed, 20 Sep 2017, Takashi Iwai wrote:
> 
> > > I'm trying to understand why it is critical to have hardware floating 
> > > point support in this case. The pow() function is very resource hungry, 
> > > true, but the function is only called when the plugin is loaded, and not 
> > > for instance on every sample while the stream is running, so on the whole 
> > > I would expect the impact to be minimal. Is there some other rationale 
> > > that I'm missing?
> > 
> > The softfloat option is to avoid calculation in float as much as
> > possible, i.e. alsa-lib will be built without any usage of math
> > library.
> 
> "as much as possible" sounds like the softvol case would be a reasonable 
> exception, on the other hand, if the goal is to completely avoid using the 
> softfloat library I can see the point. Is the reason to avoid dependency 
> issues, or to minimize the total resulting code size, especially on 
> systems with limited memory?

Well, actually no, because we don't link with -lm when the option is
specified, so far.  That is, the softfloat option is for controlling
whether to allow the usage of math function or not.


Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-20 16:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-20 10:55 alsa-lib and floating point support Ricard Wanderlof
2017-09-20 11:26 ` Takashi Iwai
2017-09-20 14:45   ` Ricard Wanderlof
2017-09-20 16:10     ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.