- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Consider
#include <complex.h>
complex float f(complex float x) {
return x*x;
}
If you compile it with -O3 -march=core-avx2 -fp-model strict
using the Intel Compiler you get:
f:
vmovsldup xmm1, xmm0 #3.12
vmovshdup xmm2, xmm0 #3.12
vshufps xmm3, xmm0, xmm0, 177 #3.12
vmulps xmm4, xmm1, xmm0 #3.12
vmulps xmm5, xmm2, xmm3 #3.12
vaddsubps xmm0, xmm4, xmm5 #3.12
ret
The good news is that the code is much simpler than what you get from gcc and clang. The bad news is that it doesn't handle Infinity and NaN according to the C99 specs as far I can tell (which is why it is so much simpler).
Is the compiler intended to be C99 conforming with these flag options or is there another set of flags that forces it to be?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I get exactly the same code when I specify -std=c99 .
As far I can tell this is a bug in ICC's support for complex float/double. As a non-corporate user is there some way I can report this bug? I am just using the version of icpc installed at my university.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The point is that in order to be compliant, as I specified in the question, the code needs to check for infinities. The code to do that correctly is given in Annex G.5.1.6. Here is a link that discusses it:
https://locklessinc.com/articles/complex_multiplication/
The code ICC produces simply doesn't do any of these checks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you use INF + i NAN as input for the ICC function the result is NaN + i NaN while it should be a complex number with at least one component infinite (per standard). I don't know how to test this except directly using the assembly.
I also asked a very similar question with x*y for which it's easier to make a test case only in C. Take a look at it here https://software.intel.com/en-us/forums/intel-c-compiler/topic/711186 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page