Re: [LAD] A more efficient way to detect INF and/or NAN in a block of samples

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <k.s.matheussen@...>
Cc: Kjetil Matheussen <k.s.matheussen@...>, <linux-audio-dev@...>
Date: Sunday, October 6, 2013 - 3:01 pm

On 10/06/2013 01:34 PM, Kjetil Matheussen wrote:

Probably. Unless you start to dive into CPU specifics and wander off to
assembly.

> I'm wondering if comparing samples using for instance SIMD

You probably already know that, but be careful with this when using
optimizations with this comparison. -ffast-math may void IEEE compat.

> if it was a nan or inf, since INFs and NANs don't behave normally.

In my case it's not only about detecting, but also flushing them to
zero. Depending on what is appropriate for DSP at hand (meters.lv2) I
settled on using math.h's isnan(), !isfinite() or simply adding
something (to minus infinite).

While that's probably not optimal it is portable and architecture
independent, and I don't notice any significant DSP load caused by it.

BTW gcc does not vectorize the isnan/isfinite loop that you've posted:
"control flow in loop" (i386, gcc 4.7.2). No dice when replacing the
break statement in the loop with v |= isfinite(); either. But it
unrolls the loop at least.

Another idea: add the signal (using SSE). If one of the summands is NaN,
the result will be Nan. -- that should effectively take less CPU
(assuming that NaN is non the common case).

brainstormingly yours,
robin
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[LAD] A more efficient way to detect INF and/or NAN in a blo..., Kjetil Matheussen, (Sun Oct 6, 11:34 am)
Re: [LAD] A more efficient way to detect INF and/or NAN in a..., Robin Gareus, (Sun Oct 6, 3:01 pm)
Re: [LAD] A more efficient way to detect INF and/or NAN in a..., Kjetil Matheussen, (Tue Oct 8, 11:30 am)