[FFmpeg-devel] [PATCH 2/2] configure: Use intel math.h header.

Matt Oliver protogonoi at gmail.com
Sat May 10 19:44:23 CEST 2014


On 11 May 2014 03:03, Reimar Döffinger <Reimar.Doeffinger at gmx.de> wrote:

> On 07.05.2014, at 15:52, Matt Oliver <protogonoi at gmail.com> wrote:
> > icl when run under msvc12 currently generates incorrect code. This is due
> > to an issue with msvc12's C99 additions to math.h. Several defines in
> > msvc's math.h are not compatible with icl and will compile but generate
> > erroneous results during runtime. An obvious example is that NAN from
> > math.h evaluates to 0.0 under icl which is clearly not a correct value
> for
> > NaN. This cause several errors that completly break FFmpeg.
> >
> > There are several ways to fix this. 1) Force icl's floating point
> > compliance but negatively impact performance in doing so. 2) Add compiler
> > specific code into FFmpeg or 3) Have icl use its own native math header
> > (which can also improve performance).
>
> To be honest I find this quite ridiculous.
> Almost two years should be enough for Intel to get the standard system
> headers to work correctly.
> Or to put it differently: Using ICL starts to sound like a horribly bad
> idea if it already miscompiles basic system headers, which in turn IMHO
> raises some questions how many hacks we should accept for it.


True, Im amazed this hasnt been an issue more often. Im guessing most
people with icl will use the icl header and the rest just havnt noticed the
problem. The exact issue is that the msvc headers define NAN as ( INFINITY
* 0.0 ) which the optimizers in icl just replace with 0. So it will work
fine if you disable optimization and force floating point compliance but
this defeats the purpose of an optimizing compiler like icl and whats the
point of a release build if it cant even be compiled using -O2. Optimizing
out multiplies by zero is standard procedure by all compilers not just icl
so im not sure whos to blame here intel or microsoft. Msvc also optimizes
out multiplies by zero but they must have an exception for their own header
whereas intel does not (im guessing because they have their own header and
just recommend using that). Given how many hacks are already in FFmpeg to
deal with various non-conformance issues with msvc headers/libs its not to
surprising and does make me lean more towards questioning microsoft rather
than intel.

Either way there are some performance advantages to using the intel math
library with various functions benchmarking 1.5x to 2x faster (many even
faster). Of course in the scheme of an entire program like ffmpeg the
actual performance difference benchmarks as being rather minimal
(especially with so much hand tuned asm being used). But any free
performance increase no matter how small probably shouldn't be scoffed at.
So with that in mind I have a slightly modified patch that also can be
applied to icc that ill submit once Ive run it through fate a few more
times.


More information about the ffmpeg-devel mailing list