Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Regarding Qt configuration and SSE/SSE2
QtWS25 Last Chance

Regarding Qt configuration and SSE/SSE2

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 11.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MuldeR
    wrote on 26 Apr 2012, 22:47 last edited by
    #1

    Hi.

    I generally try to make my applications as compatible as possible.

    However the following configuration options of Qt came to my attention recently:

    @ + -mmx ............... Compile with use of MMX instructions

    • -3dnow ............. Compile with use of 3DNOW instructions
    • -sse ............... Compile with use of SSE instructions
    • -sse2 .............. Compile with use of SSE2 instructions@

    These are enabled by default, it seems.

    Does "Compile with use of SSE2 instructions" mean that the Qt binary will actually (potentially) use SSE2-instructions on all code paths or does it mean that there will be a SSE2-optimized code path that is used only if supported by the CPU? Or in other words: Does Qt internally apply Runtime CPU-Detection?

    BTW: In the Visual Studio project settings I have disabled the generation of SSE/SSE2 code. Would Qt still use SSE or SSE2 instructions (e.g. via Assembly or via Intrinsics) when "-sse" or "-sse2" have been set?

    My OpenSource software at: http://muldersoft.com/

    Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

    Go visit the coop: http://youtu.be/Jay...

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on 26 Apr 2012, 23:51 last edited by
      #2

      Okay, after searching the code a bit, I found this:

      @ const uint features = qDetectCPUFeatures();
      Q_UNUSED(features);

      #ifdef QT_HAVE_SSE2
      if (features & SSE2) {
      extern bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags);
      inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_sse2;
      }
      #endif@

      So am I right that the "-sse2" configure option will define QT_HAVE_SSE2 and will enable CPU Runtime Detection for SSE2, but it won't enable SSE2 optimizations in a "hardcoded" way?

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GGodis
        wrote on 11 Apr 2013, 11:49 last edited by
        #3

        As far as I've tested, if Qt library is compiled with SSE2 and machine does not have the SSE2 support, your Qt application will crash with "The application failed to initialize properly "0xc000001d"" error message.

        Not sure why, but when I try to compile Qt with "-no-sse2" flag - I'm getting some compiler errors while compiling the qtgui library...

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AcerExtensa
          wrote on 11 Apr 2013, 12:08 last edited by
          #4

          I have had same question for a long time ago. I'm not sure, but I remember I have checked the source code of Qt regarding instruction checks etc... and found what Qt checks for supported instruction before it is executed/method selected...

          But I can be wrong, I don't really remember if it was in Qt already or it was a patch or I have merged this checks from other code when I was playing with asm and SSE instructions....

          Maybe some Qt Dev-Trolls can answer this for us. Have you asked your question on IRC channel?

          God is Real unless explicitly declared as Integer.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MuldeR
            wrote on 12 Apr 2013, 21:15 last edited by
            #5

            Yes, I checked it too and found that Qt will only execute MMX/3DNOW/SSE/SSE2 code paths after a CPU runtime check. But that of course only applies to the special "hand optimized" assembler code in Qt.

            MMX/SSE/SSE2 instructions might be used in any plain C/C++ code, unconditionally, if enabled in the compiler settings. Up to and including VS2010, the default was that SSE or SSE2 are disabled by default (aka "not set"). But starting VS2012, the default (aka "not set") now is SSE2. You need to select "IA32" for max compatibility.

            My OpenSource software at: http://muldersoft.com/

            Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

            Go visit the coop: http://youtu.be/Jay...

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved