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

From: Kjetil Matheussen <k.s.matheussen@email-addr-hidden>
Date: Sun Oct 06 2013 - 14:34:47 EEST

I want to detect INFs and NANs in my DSP graph to avoid having
them spread and cause various trouble.

Here is the straight forward way:

int i;
for (i=0;i<num_samples;i++)
  if (!isfinite(samples[i])) break

if(i!=num_samples)
  error();

But is this as efficient as we get it?

I'm wondering if comparing samples using for instance SIMD
instructions, for instance, could make it around 4 times faster,
Something like this:

for(i=0;i<num_samples;i++)
  if(samples[i]!=samples[i]))
     break;

where the samples[i]!=samples[i] test would succeed
if it was a nan or inf, since INFs and NANs don't behave normally.

I don't think this particular example works though (?),
but perhaps something similar could?

Anyone doing something like this?
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Mon Oct 7 00:15:02 2013

This archive was generated by hypermail 2.1.8 : Mon Oct 07 2013 - 00:15:02 EEST