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

-O0 -xAVX problems.

jrfsousa
Beginner
671 Views
Hi!
This really should be, I think, a bug report but I can not find how to do that ;-)
The code is not very beautiful since it is straigth from a configure script:
#include
int
main ()
{
__m256d a __attribute__((aligned(16)));
;
return 0;
}
$ icc -O0 -xAVX -o ./avx ./avx.c && ./avx
$ icc -O1 -xAVX -o ./avx ./avx.c && ./avx
Fatal Error: This program was not built to run in your system.
Please verify that both the operating system and the processor support Intel AVX.
$
With -O0 the program will not raise any errors leading to the incorect detection of the CPU as supporting AVX instructions.
Best regards,
Jos Rui
0 Kudos
8 Replies
Shenghong_G_Intel
671 Views
Hi Jose,

I will investigate and give you and update soon.

Thanks,
Shenghong
0 Kudos
Shenghong_G_Intel
671 Views

Hi Jose,

I can reproduce your issue with a simple test case such as:
int main() {return 0;}

I think it should be kind of a bug. I will report it to our tracking systerm and give you an update if I get any feedback.

Thanks,
Shenghong
Intel Developer Support

0 Kudos
mecej4
Honored Contributor III
671 Views
I doubt that this is a bug.

When the user specifies conflicting options such as -O0 (do not optimize) and -xAVX (optimize for a specific processor) the outcome of the conflict is unpredictable.

I would find it reasonable if the compiler ignored -xAVX after noting -O0 to be in effect.

You can use the -# compiler option to see which options survive the conflict and are passed on to the compiler mcpcom or fortcom (the actual names depend on the platform).
0 Kudos
Shenghong_G_Intel
671 Views

Hi mecej4,

I agree with your opinions. The compiler may ignore the -xAVX option when using -O0 to disable optimization. What I was thinking is whether there is a friendly way here, such as giving a warning. I think as these are conflicting options, it is better to let the user be aware of it.

Thanks,
Shenghong
Intel Developer Support

0 Kudos
Om_S_Intel
Employee
671 Views
The Intel compiler does not generate processor specific code when using -O0 option.

Om
0 Kudos
jrfsousa
Beginner
671 Views
This is somewhat unexpected.
If one tells the compiler to compile for a specific platform one would not expect it to compile for a diferent platform... Without even a warning...
And secondly the -xAVX is the last option on the command line it should take precedence.
This code is used in a configure script to detect the hardware platform and this way it does not fail as it should and leads to the program beeing compiled with the wrong options.
I guess that the way to solve this is to add a -O1 before the -xAVX to make sure that the compiler does generate code for the platform in question.
Best regards,
Jos Rui
0 Kudos
mecej4
Honored Contributor III
671 Views
I agree that a warning would be helpful, somewhat along the lines of

"option -xx conflicts with option -yy, resolved by ignoring -xx"

However, "If one tells the compiler to compile for a specific platform one would not expect it to compile for a diferent platform" is too harsh.

The compiler does output code for the specific platform in that it will only use instructions available on that platform. However, it need not use all available instructions, especially the more complex instructions, which may or may not exist on other platforms, when simpler instructions (which may be common to a whole family of processors) will do. This is very much in the realm of the optimizer, and -O0 may bypass the optimizer.
0 Kudos
Shenghong_G_Intel
671 Views

FYI.

many customers rely on -O0 to no generate any external library references. The cpu check is done by creating a call to libirc in main. If we added this call at -O0, it would potentially break a lot of customer code.

Closing as not a defect.

0 Kudos
Reply