Albert Graef a écrit :
Yann Orlarey wrote:
[denormals issues]
This is a real problem but it should be solved on
modern intel cpu by
enabling the FTZ mode.
It would be useful if the Faust guide had a brief explanation of
denormals, along with instructions on how to enable FTZ with gcc and the
Intel compiler, and other workarounds. Or maybe it's time to start a
Faust FAQ? This problem is surely going to bite a lot of dsp newbies who
start playing with Faust on the "wrong" system.
Albert
Right. The interactions with the various gcc flags are not very easy to
understand. The FTZ mode is supposed to be enabled by the -ffast-math
flag. But alone this flag is not enough.
Here are various tests I did on karplus32.dsp to figure out the right
combination of gcc flags to avoid denormals.
The first thing is to modify Karplus32 to produce denormals by
commenting out " :+(leak)" line 21 :
trigger(n) = upfront : release(n) : >(0.0); // : +(leak);
Then compile karplus32.dsp only with "-O3". If you play with the
modified karplus32, after few seconds (~30s) of inactivity it starts
using 100% of the CPU.
Now if you recompile karplus32.dsp using "-O3 -ffast-math" you will
still have denormals because you need to be in sse mode. Being in sse
mode "-O3 -march=native -mfpmath=sse" is not enough and still produces
denormals.
The minimal combination to activate FTZ mode seems to be :
"-O3 -march=native -mfpmath=sse -ffast-math"
when you are on a sse capable cpu. Here it works, you don't have
denormals any more :-).
Yann
PS : from the gcc manual about -ffast-math : "This option should never
be turned on by any ‘-O’ option since it can result in incorrect output
for programs which depend on an exact implementation of IEEE or ISO
rules/specifications for math functions."