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. Why does qnumeric.h #include <initrin.h>
Forum Updated to NodeBB v4.3 + New Features

Why does qnumeric.h #include <initrin.h>

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 4 Posters 3.1k Views 3 Watching
  • 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #3

    That really doesn't qualify as the most informative of replies :(

    Christian EhrlicherC 1 Reply Last reply
    0
    • PerdrixP Perdrix

      That really doesn't qualify as the most informative of replies :(

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @Perdrix said in Why does qnumeric.h #include <initrin.h>:

      That really doesn't qualify as the most informative of replies :(

      What do you expect? There are no useless includes so they are needed. If you want to know where it is needed - remove it and see where it breaks...

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #5

        Hi,
        Can you show the exact problem you have ?

        Qt uses SIMD in QString.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply
        1
        • PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on last edited by Perdrix
          #6

          The problem occurs when we include the simde header - all the stuff it defines is already defined by the inclusion of intrin.h. The result is thousands of errors about re-definitions. No, we can't use the definitions from intrin.h :(

          I've made a post to the Interest mailing list about this.

          David

          1 Reply Last reply
          0
          • PerdrixP Offline
            PerdrixP Offline
            Perdrix
            wrote on last edited by
            #7

            Here's a (very) few lines showing the problem:

            1>C:\Users\mtoeltsch\dev\DSS\DeepSkyStackerKernel\simde\x86\avx512\types.h(624,26): error C2371: '__m512d': redefinition; different basic types
            1>(compiling source file '/avx.cpp')
            1>    C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\include\zmmintrin.h(51,62):
            1>    see declaration of '__m512d'
            1>C:\Users\mtoeltsch\dev\DSS\DeepSkyStackerKernel\simde\x86\avx512\types.h(634,27): error C2371: '__m128bh': redefinition; different basic types
            1>(compiling source file '/avx.cpp')
            1>    C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\include\zmmintrin.h(4900,17):
            1>    see declaration of '__m128bh'```
            1 Reply Last reply
            0
            • PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote on last edited by
              #8

              And here's what I posted to the mailing list:
              The header file qnumeric.h includes <intrin.h> if the MVSC compiler is in use so that implementations of qMulOverflow and qAddOverFlow that exploit the intrinsics can be defined.

              As far as I can determine, the code also implements “generic” versions of those which do not rely on the use of MSVC intrinsics.

              Why am going on about this. The project which I work on (DeepSkyStacker) uses SIMD on Intel right now and we want to port our code to macOS Arm and Windows Arm and after a lot of deliberation we decided we would use SIMD Everywhere (SIMDe) .

              We use pre-compiled headers and have a lot of Qt code, so we long ago placed an include for <QtCore> (and other Qt headers) in our precompiled header files.

              The problem we hit is that when we then include the simde headers we get LOTS of errors because of duplicate symbols (we compile with warnings as errors).

              I will be quite a lot of effort for us to work around that.

              I believe, but don't know for sure that qnumeric.h could be changed without a lot of effort so that it didn’t use intrinsics for qMulOverflow and qAddOverFlow and therefore not include <intrin.h>

              If that is possible, I'd like to request that this be done.

              Please could someone who knows that stuff better than I please comment.

              Christian EhrlicherC 1 Reply Last reply
              0
              • PerdrixP Perdrix

                And here's what I posted to the mailing list:
                The header file qnumeric.h includes <intrin.h> if the MVSC compiler is in use so that implementations of qMulOverflow and qAddOverFlow that exploit the intrinsics can be defined.

                As far as I can determine, the code also implements “generic” versions of those which do not rely on the use of MSVC intrinsics.

                Why am going on about this. The project which I work on (DeepSkyStacker) uses SIMD on Intel right now and we want to port our code to macOS Arm and Windows Arm and after a lot of deliberation we decided we would use SIMD Everywhere (SIMDe) .

                We use pre-compiled headers and have a lot of Qt code, so we long ago placed an include for <QtCore> (and other Qt headers) in our precompiled header files.

                The problem we hit is that when we then include the simde headers we get LOTS of errors because of duplicate symbols (we compile with warnings as errors).

                I will be quite a lot of effort for us to work around that.

                I believe, but don't know for sure that qnumeric.h could be changed without a lot of effort so that it didn’t use intrinsics for qMulOverflow and qAddOverFlow and therefore not include <intrin.h>

                If that is possible, I'd like to request that this be done.

                Please could someone who knows that stuff better than I please comment.

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by Christian Ehrlicher
                #9

                @Perdrix said in Why does qnumeric.h #include <initrin.h>:

                If that is possible, I'd like to request that this be done.

                Feel free to provide a patch ... Qt is opensource and when you think something has to change you can do it by yourself. Or pay for it.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                0
                • PerdrixP Offline
                  PerdrixP Offline
                  Perdrix
                  wrote on last edited by
                  #10

                  @Christian-Ehrlicher If I was sure it was safe to provide a patch, I would happily do so. But at this stage I await the input from the folks that know how that header is used better than I.

                  I've been investigating where and how qAddOverflow and qMulOverflow are used and I suspect that qnumeric.h could be made private to the build of Qt, rather than being a public header.

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mtoeltsch
                    wrote on last edited by
                    #11

                    @Christian-Ehrlicher
                    You use the "mulh" intrinsics to detect overflows in 2 template specialisations:

                    template <> inline bool qMulOverflow(...);

                    Can I suggest that you define these specialisations in a .cpp file instead of a header file? Then you only need to include <intrin.h> in the .cpp file and avoid pollution of the entire client code (as in our case).

                    Martin

                    Christian EhrlicherC 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Hi,
                      Can you show the exact problem you have ?

                      Qt uses SIMD in QString.

                      M Offline
                      M Offline
                      mtoeltsch
                      wrote on last edited by
                      #12

                      @SGaist said in Why does qnumeric.h #include <initrin.h>:

                      Qt uses SIMD in QString.

                      That's fine as long as you do it in .cpp files only and not in (public) header files.
                      <qstring.h> does not use SIMD intrinsics AFAIK.

                      1 Reply Last reply
                      0
                      • M mtoeltsch

                        @Christian-Ehrlicher
                        You use the "mulh" intrinsics to detect overflows in 2 template specialisations:

                        template <> inline bool qMulOverflow(...);

                        Can I suggest that you define these specialisations in a .cpp file instead of a header file? Then you only need to include <intrin.h> in the .cpp file and avoid pollution of the entire client code (as in our case).

                        Martin

                        Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #13

                        @mtoeltsch said in Why does qnumeric.h #include <initrin.h>:

                        Can I suggest that you define these specialisations in a .cpp file instead of a header file?

                        Why should I do here anything? It's neither my code nor do I have a problem with this. Feel free to provide a patch if you think it can work another way and see if it gets accepted.

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        0
                        • PerdrixP Offline
                          PerdrixP Offline
                          Perdrix
                          wrote on last edited by Perdrix
                          #14

                          I provided a patch and it was accepted. :)

                          https://bugreports.qt.io/browse/QTBUG-131757

                          1 Reply Last reply
                          4
                          • PerdrixP Perdrix has marked this topic as solved on
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #15

                            Congratulations !

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            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