Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

log(2.0f) = -1.#INF00 when compiling for Pentium 3 ?!

piet_de_weer
Beginner
322 Views
I'm experiencing some very strange behavior with Intel C++ compiler 10.1.013 [IA32]

I have a program that works fine when I compile it for Intel Pentium 4 with /Qipo, debug mode, Intel Pentium 3 debug mode and Intel Pentium 3 release mode.

But, if in Intel Pentium 3 I add the /Qipo option, I'm seeing the following:
[bash]printf("Pre Amp: db=%f (2) = 6.0f * %f / %f\n", db, log(MAIN_preamp_val), log(2.0f));[/bash]
(MAIN_preamp_val is a float, > 0) returns
[plain]Pre Amp: db=-1.#IND00 (2) = 6.0f * -1.#INF00 / -1.#INF00[/plain]
If I replace 2.0f by 2.0 I do get the proper result (0.693147). This seems to happen everywhere throughout my code.

For now I've just replaced all log statement arguments by doubles - fortunately none of them are in time critical parts of the code. Is this a known issue, or could it indicate some problem in my code?


Edit: Apparently more operations are affected: atan has the same behavior (float fails, double works fine).
0 Kudos
3 Replies
TimP
Honored Contributor III
322 Views
How are you "compiling for Pentium 3?" The -xK switch, unfortunately, wasn't adequately tested, and was documented as deprecated by the time your compiler was issued. It seems the math library might make some incorrect run-time choices, depending on th platform in use. Apparently, /Qipo makes it worse.
The only option for P-III in current compilers is the ia32 one (no SSE, the default in your compiler), and there is no longer separate support for SSE without SSE2.
0 Kudos
piet_de_weer
Beginner
322 Views
/QaxW /QxK

Anyway, for me the problem is solved by converting the arguments to log() and atan() to doubles. Except for this the Pentium 4 (/QaxW /QxW) and Pentium 3 (/QaxW /QxK, replacing /QaxW by /QaxK doesn't make a difference by the way) versions are identical in behavior (calculation gives the same result, except for some minor rounding issues which are probably caused by more aggressive optimizations (RCP, RSQRT) in the P4 version).
0 Kudos
TimP
Honored Contributor III
322 Views
I generally set /Qprec-div /Qprec-sqrt in icl.cfg so as to avoid the rcpps/rsqrtps and similar questions. This could give up some performance on P4 and Nocona CPUs, but CPUs from Harpertown (and 2nd generation Core 2) on are much better.
By forcing your P-III math functions into double, you should get the same result you would get without any of the xK flags.
/QaxW /QxW, as far as I can see, would have identical effect to /QxW (the default on recent compiler versions). I'll mention this would not work on P-III, in case someone else reads this.
0 Kudos
Reply