Quantcast
Channel: Intel® C++-Compiler
Viewing all articles
Browse latest Browse all 1665

Macro Bug?

$
0
0

Hi,

I am in the Trial period of the Intel Parallel Studio 2015. We have a scientific software which works on Linux, Windows, and OS/X . Users were surprised by better performance on OS/X than on Windows (double time)! Thus  instead of cross-compiling on OS/X (or Linux) using gcc for WIndows (32 or even current mingw64), I decided  to test "native" compilers like Visual Studio 2013 as well as your Intel Parallel Studio 2015.

My current test concerns a Xeon 1225 V3 on Windows 8 64 bit. Clearly, the performance difference between OS/X vs Windows was linked to compilers!

I am not able to give precise comparisons yet because I could not find the same final results with the Intel 64. The program maximizes a Likelihood surface using a Powell algorithm. Up to now, any compiler on any machine 32 or 64 bit produced the same results with 34 iterations (http://euroreves.ined.fr/imach/wiki/index.php/Main_Page#Performance).

But compiled with intel ilcx64 it converges in 62 iterations. Strangely, final results from Intel are not wrong but even better and more accurate!

It deserved investigation and here is what I first found:

The optimization program, the Powell implementation, described in Numerical Recipes in C(powell function), defines a SQR macro:

#define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 :sqrarg*sqrarg)

and then this macro is used in the statement:

      t = 2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del) - del*SQR(fp-fptt);
      if (t < 0.0){ 

the compiled version gives wrong values of t which are sometimes positive instead of being negative. The path to reach the maximum is then different from other compiled versions.

If the SQR macro is replaced by a standard multiplication, it will work. Another workaround consists in cutting in two parts:

      t = 2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del);
      t = t - del*SQR(fp-fptt);
      if (t < 0.0){ 

It means that the ILC compiler has some difficulties to manage two successive SQR macros on the same line.

I don't know how many people in the world are using the Numerical Recipes in C library, but I was wanting to let you know about this interesting fact.

Thanks for the trial anyway,

 

Nicolas

 


Viewing all articles
Browse latest Browse all 1665

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>