Sign in to follow this  
Infinisearch

gcc/mingw sse/3dnow and c++

Recommended Posts

I know that mingw/gcc supports sse/3dnow, but i'm not sure how to ensure the compiler vectorizes my code. If i make a matrix/vector/quaternion... library and compile it with mingw/gcc is there a particular way to code it to ensure it compiles to take advantage of said instruction sets? Use arrays of four floats??? Make sure the data is aligned properly?? Oh and is there a vector/matix/quternion library available for mingw that already takes advantage of sse/3dnow? (preferebly lgpl)

Share this post


Link to post
Share on other sites
In terms of just having the compiler user sse for fp math, you can use:

-mfpmath=sse

(so also need to specify an architecture that has sse)

in terms of writing mmx or sse code, see:

-mmmx
-mno-mmx

-msse
-mno-sse

-msse2
-mno-sse2

-msse3
-mno-sse3

-m3dnow
-mno-3dnow

and this page:
http://gcc.gnu.org/onlinedocs/gcc-3.4.1/gcc/X86-Built-in-Functions.html

hope that helps

Share this post


Link to post
Share on other sites
Thanks alot, that reminds me alot of the 'intrinsics' with the intel compiler that i had read about. However i was refering to automatic vectorization, whereby i write a class in c++ and the compiler automatically uses the best availble method for implementing it. I remember reading somewhere that for the aforementioned intel compiler to automatically vectorize code you had to setup your data as arrays of floats in order for the compiler to recognize that said code would be vectorizable. But again thanks, i'll look into the 'intrinsics'.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this