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

2013-10-06 Thread Kjetil Matheussen
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;inum_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

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

2013-10-06 Thread Kjetil Matheussen
I don't think this particular example works though (?), but perhaps something similar could? Guess it would work to add all elements in the array, and see if the result is inf or nan. That operation sounds likely to be automatically vectorized by the c compiler...

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

2013-10-06 Thread Robin Gareus
On 10/06/2013 01:34 PM, Kjetil Matheussen wrote: 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;inum_samples;i++) if (!isfinite(samples[i])) break if(i!=num_samples) error();

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

2013-10-06 Thread Kjetil Matheussen
On Sun, Oct 6, 2013 at 5:01 PM, Robin Gareus ro...@gareus.org wrote: 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;inum_samples;i++) if(samples[i]!=samples[i])) break; where

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

2013-10-06 Thread Robin Gareus
On 10/06/2013 09:07 PM, Kjetil Matheussen wrote: But brainstorming further, it probably works to combine the peak finding routine (which is run on all signals) with the nan/inf-detection: +1 BTW compile with -ftree-vectorizer-verbose=7 to check what gcc does. If you're looking for something