How to correctly determine the `-march` flag when working with Intel oneAPI on Intel processors?

The issue you linked doesn’t suggest that -xHost “doesn’t work”, but rather that it is inappropriate for a mixed execution environment.

What -xHost does (I know, because I’m the one who implemented it) is query the CPU type. If it is an Intel processor, it applies the appropriate -x option for that processor, and that includes a check at the start of execution that the program is running on an Intel processor supporting the specified instruction set (or larger). If the compiling CPU is non-Intel, then it applies the appropriate -march option and omits the startup check. Even with -march, if you execute on a processor that doesn’t support the same instruction set as the compiling processor, the program may fail with an invalid instruction fault.

(Note that “Intel optimizations, for Intel compilers or other products, may not optimize to the same degree for non-Intel products.” Performance Index (intel.com))

1 Like