-1

I am working with a company to create a specialized set of codes that use SSE instructions. They are using the Qt Creator IDE. I have provided them with a C header file and corresponding *.c file that compile in XCode and Visual Studio; they don't compile in Qt Creator.

How do I alter the appropriate compiler settings so that SSE instructions will compile in Qt Creator?

The line causing the first error is as follows:

_mm_store_ps(outData, _mm_add_ps(*l, *r));

The error statements read:

Inlining failed in call to always_inline ‘__mm_add_ps’: target specific option mismatch
Inlining failed in call to always_inline ‘_mm_store_ps’: target specific option mismatch

We're also getting this warning:

SSE vector return without SSE enabled changes the ABI [-Wpsabi]
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
user24205
  • 481
  • 5
  • 15
  • 7
    Qt Creator is not a compiler, it's an IDE. Compilers and IDEs are different things. Please, show some error messages and problematic code, so the people could analyze. – Velkan Dec 12 '16 at 07:24
  • @Velkan Thank you; I have now done that (I think). – user24205 Dec 13 '16 at 05:54
  • It depends on chosen build system, how you pass it compiler flags. So is it a qmake, cmake, plain hand-written Makefile, or what kind of a project? Actually there are two levels here: the build system you could use from command line too, and then the Qt Creator project which uses the build system when you build in QtC. You should probably add the necessary compiler flags in the first one of these, if possible. – hyde Dec 13 '16 at 06:08
  • Try googling the error message "target specific option mismatch". People say that they had to add compiler flags that tell that the compiler is safe to use more CPU features: options like `-msse4.2`, `-march=haswell` or `-march=skylake` (nehalem, haswell, skylake, etc. are the names of the Intel processor architectures). – Velkan Dec 13 '16 at 08:01

1 Answers1

3

Compilers like gcc and clang require that the relevant instruction-set extensions be enabled when compiling code that uses intrinsics and vector types. e.g. -msse2. This also lets the compiler auto-vectorize with SSE2.

SSE2 is baseline for x86-64, so I guess you're building a 32-bit binary for some reason?

I think some compilers (maybe MSVC) will let you use intrinsics without enabling the compiler to automatically generate the instructions.

If you want to do runtime CPU dispatching, so you have some functions that use SSE4.1 or AVX, but need your program to work on computers without those: put your SSE4 and AVX functions in separate files, so you can build those compilation units with -msse4.1 and -mavx.

It's usually a good idea to enable -march=nehalem or -march=haswell to also enable stuff like -mpopcnt (if that's what you want), and more importantly to set -mtune=haswell to optimize for a likely target CPU as well as using extensions it supports.


Related questions with more detailed answers:


Peter Cordes
  • 328,167
  • 45
  • 605
  • 847