Results 1 to 4 of 4

Thread: MMX Programming

  1. #1
    Join Date
    Jul 2012
    Posts
    20
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4

    Default MMX Programming

    I've try this code:
    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <xmmintrin.h>
    3. #include <emmintrin.h>
    4.  
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QCoreApplication x(argc, argv);
    9.  
    10. quint32 a[256];
    11. quint32 b[256];
    12. quint32 c[256];
    13.  
    14. for (int i = 0; i < 256; i += 4)
    15. {
    16. __m128i vectorA = _mm_loadu_si128((__m128i*)&a[i]);
    17. __m128i vectorB = _mm_loadu_si128((__m128i*)&b[i]);
    18. __m128i vectorC = _mm_add_epi32(vectorA, vectorB);
    19. _mm_storeu_si128((__m128i*)&c[i], vectorC);
    20. }
    21.  
    22.  
    23. return x.exec();
    24. }
    To copy to clipboard, switch view to plain text mode 

    And got this:
    /usr/lib/gcc/i586-suse-linux/4.6/include/xmmintrin.h:32: error: #error "SSE instruction set not enabled"
    /usr/lib/gcc/i586-suse-linux/4.6/include/emmintrin.h:32: error: #error "SSE2 instruction set not enabled"
    error: ‘__m128i’ was not declared in this scope.

    How can I fix it ?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: MMX Programming

    Enable SSE and SSE2 by whatever method the headers require, probably by doing whatever causes defining of __SSE__ and __SSE2__. At a guess you want the "-msse -msse2" options passed to your GCC compiler.

    This has nothing to do with Qt directly although you can get qmake to put the options in a Makefile for you:
    Qt Code:
    1. QMAKE_CXXFLAGS += -msse -msse2
    To copy to clipboard, switch view to plain text mode 
    Last edited by ChrisW67; 19th November 2013 at 03:44.

  3. The following user says thank you to ChrisW67 for this useful post:

    vhptt (19th November 2013)

  4. #3
    Join Date
    Jul 2012
    Posts
    20
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4

    Default Re: MMX Programming

    Thanks for your supporting, I've added the option in .pro and build OK.
    But, QtCreator did not hightlight _m128i type and I cannot press F2 to navigate to declaration

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: MMX Programming

    Certainly does here.

Similar Threads

  1. Is this a QT programming?
    By knuxie1135 in forum Newbie
    Replies: 1
    Last Post: 7th November 2012, 16:09
  2. QT programming on Mac os x
    By invictus in forum General Discussion
    Replies: 6
    Last Post: 5th June 2008, 18:34
  3. Qt programming
    By archanasubodh in forum Installation and Deployment
    Replies: 2
    Last Post: 6th March 2008, 08:55
  4. Qt programming
    By archanasubodh in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2008, 12:32
  5. QT COM Programming
    By sarav in forum Newbie
    Replies: 5
    Last Post: 24th February 2007, 13:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.