Results 1 to 2 of 2

Thread: How to use SSE(2,3) in C++/QT programs

  1. #1
    Join Date
    May 2010
    Posts
    24
    Thanks
    14
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default How to use SSE(2,3) in C++/QT programs

    I am working on a project with a lot of vector math and I'd like to find a way to speed it up. I've been reading about SSE, but I've found no explanation on how to actually use it in code (was looking for some kind of hello-world example, complete with compilation instructions).

    Does the gcc compiler automatically make use of SSE, if you add the -sse(2,3) option on the command line? Or are their specific functions/libraries you need to call?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How to use SSE(2,3) in C++/QT programs

    GCC has inbuilt support, refer the like GCC documentation, example of how to use it also described

    http://gcc.gnu.org/onlinedocs/gcc-4....tor-Extensions

    example you can try compiling

    Qt Code:
    1. #include "stdio.h"
    2.  
    3. typedef float v4 __attribute__ ((vector_size(sizeof(float)*4)));
    4.  
    5. union f4v
    6. {
    7. v4 v;
    8. float f[4];
    9. } ;
    10.  
    11. void print_f4v(union f4v* v)
    12. {
    13. printf("%f,%f,%f,%f\n", v->f[0], v->f[1], v->f[2], v->f[3]);
    14. }
    15.  
    16. int main()
    17. {
    18. union f4v a, b, c;
    19.  
    20. a.v = (v4){1.1, 2.2, 3.3, 4.4};
    21. b.v = (v4){5.5., 6.6, 7.7, 8.8};
    22. c.v = a.v + b.v;
    23.  
    24. print_f4v(&a);
    25. print_f4v(&b);
    26. print_f4v(&c);
    27. }
    To copy to clipboard, switch view to plain text mode 

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

    Ronayn (7th June 2011)

Similar Threads

  1. how to run Qt programs on non qt machine ?
    By aamer4yu in forum Installation and Deployment
    Replies: 15
    Last Post: 11th July 2012, 07:38
  2. Qt for programs on Windows CE
    By kyut in forum Newbie
    Replies: 20
    Last Post: 3rd March 2011, 12:32
  3. Enterprise Programs
    By migizi in forum General Discussion
    Replies: 0
    Last Post: 23rd September 2010, 23:54
  4. Building QT Programs for Mac OS X 10.5
    By manekineko in forum Qt Programming
    Replies: 0
    Last Post: 21st August 2010, 01:10
  5. Distributing Qt programs
    By scwizard in forum Qt Programming
    Replies: 3
    Last Post: 19th March 2007, 22:36

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.