Quoting Vesa <dii....@nbl.fi>:

> On 10/21/2014 03:32 PM, Vesa wrote:
>>> _mm_setcsr(  _mm_getcsr()  |  0x8040  );
>>>
>>>
>>> The plugins and LMMS engine/audio code will need to be built with
>>> fastmath and SSE2, the gcc arguments are:
>>>
>>> -ffast-math -mtune=generic -msse -msse2 -mfpmath=sse
>>> Note that this requires SSE2.
>>> But if LMMS does this, the issue with denormals will very likely go away.
>>>
>>>
>>> PS: I tried building the full LMMS code with "-ffast-math", but that
>>> breaks the timeline.
>>> So if this is going to be introduced it will need to be carefully
>>> selected (only audio engine and plugins).

Here's what I believe after some googling in the matter:
1. Setting the CPU flags is possible without fast-math. And for most
CPUs it's enough, too: http://carlh.net/plugins/denormals.php

2. This is really only about building win32 binaries:
- All x86-64 CPUs are at least SSE2 with the DAZ flag -> it should
always be on in 64-bit binaries.
- All Intel Macs are at least SSE3, so that would be a good level to  
use for building the OSX port. (maybe that's already taken care of?)
- On Linux, distros/packagers will continue to have the choice to  
build for a 80386 with software 387 emulation.

3. Some (not sure how many) 32-bit CPUs with SSE2 don't have the DAZ
flag and will crash the program trying to set it. Some options:
- Either set both DAZ and FTZ flags and make the CPU requirement "SSE2 with
DAZ", or...
- set just the FTZ flag in 32-bit builds, possibly drop the CPU requirement
to SSE level (Athlon XP and P3 users will be happy!), or...
- detect CPU features at runtime and set the appropriate flag(s) (some  
assembly required, I think).


Here's how the CAPS plugins do it (plugins/LadspaEffect/caps/Descriptor.h):
          #ifdef __SSE3__
          /* DAZ flag */
          _MM_SET_DENORMALS_ZERO_MODE (_MM_DENORMALS_ZERO_ON);
          #endif
          #ifdef __SSE__
          /* FTZ flag */
          _MM_SET_FLUSH_ZERO_MODE (_MM_FLUSH_ZERO_ON);
          #endif



This might be useful to get some portability in, if needed:
https://code.google.com/p/no-more-denormals/


> Is anyone really running LMMS on pre-SSE2 hardware anymore?

Most certainly someone is. If they're on Win32, where this actually  
matters, they can't run recent versions of Photoshop, Chrome, Windows,  
Skype, Flash player, Kontakt... and the list is growing. I'm betting  
90% of that handful have SSE, which means they could at least get some  
protection from denormals.


-- 
ra...@iki.fi
softrabbit on #lmms




------------------------------------------------------------------------------
_______________________________________________
LMMS-devel mailing list
LMMS-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lmms-devel

Reply via email to