vectormathlibrary SSE fixes for GCC + cleanup

Post Reply
Tjapter
Posts: 1
Joined: Sun May 16, 2010 5:13 pm

vectormathlibrary SSE fixes for GCC + cleanup

Post by Tjapter »

The SSE implementation of vectormathlibrary uses Microsoft-specific keywords __declspec(align(16)) and __forceinline. For compatibility with GCC, I replaced these with macros _VECTORMATH_ALIGN16 and _VECTORMATH_FORCE_INLINE, and when _MSC_VER isn't defined (which means the compiler isn't Visual C/C++, and GCC is probably being used), these are defined as __attribute__ ((aligned(16))) and __attribute__ ((always_inline)) respectively.

I also took the opportunity to clean up the whitespace and comments and things like that. vectormath_aos.h didn't have consistent line-endings. Tabs and spaces were mixed (converted everything to spaces). And one of the files used a special character in the comments for dot-products, which was confusing some simpler text editors, so I just replaced it with the word "dot".

When compiling it with GCC and -msse, it spits out #error "SSE2 instruction set not enabled". Perhaps vectormath/cpp/vectormath_aos.h should check for __SSE2__ instead of __SSE__ before using the SSE implementation? Looking through some of the data-types used, it really requires SSE2.

I can't guarantee that it works exactly the same with GCC; but it at least compiles now. For my purposes, it works the same so far.

I'm attaching my fixes.
Attachments
vectormathlibrary_SSE_Tjapter_Fixes_v1.zip
(35.22 KiB) Downloaded 475 times
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: vectormathlibrary SSE fixes for GCC + cleanup

Post by Erwin Coumans »

Thanks a lot for the patch, we'll look into this.

There is an issue for it on the Google issue tracker: http://code.google.com/p/bullet/issues/detail?id=383
Thanks,
Erwin
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: vectormathlibrary SSE fixes for GCC + cleanup

Post by Erwin Coumans »

It has been finally fixed, it took a while.
http://code.google.com/p/bullet/source/detail?r=2307

Tested using attached main.cpp, copied in same folder as Bullet/src/vectormath/sse and running

g++ -msse3 main.cpp
or
g++ -msse2 main.cpp
./a.out
Attachments
main.zip
(419 Bytes) Downloaded 357 times
Post Reply