Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat Jul 28, 2007 1:19 am 
Offline

Joined: Mon Oct 28, 2013 12:18 am
Posts: 13
Sony Computer Entertainment Inc. contributed Vector Math library and SIMD math library as open source under the BSD license. Bullet physics SDK will be the main repository. Vector Math was previously only available to licensed PlayStation 3 developers.

Vector Math provides linear algebra useful for 3D graphics (vector, matrix, quaternion). SIMD implementations for PowerPC PPU, Cell SPU and x86 SSE are available, next to a portable generic scalar version. You can read the overview document on-line. Reference manuals and documentation is included in the doc folder.
Repository:
http://bullet.svn.sourceforge.net/viewv ... thlibrary/

SIMD math library provides 4-way SIMD implementations of common math functions like cos4f, sin4f, floor4f, fabs4f etc. Vector Math depends on this lower level C library on PPU and SPU.
Repository:
http://bullet.svn.sourceforge.net/viewv ... thlibrary/

Both libraries are included in the Bullet distribution under the Bullet/Extras folder, available from Bullet 2.55. Download Bullet physics SDK.

Feedback, patches for Vector Math and SIMD math library are welcome in this forum.
Thanks,
Erwin


Top
 Profile  
 
PostPosted: Wed Mar 04, 2009 4:08 pm 
Offline

Joined: Wed Mar 04, 2009 2:50 pm
Posts: 1
That's a very good news for everybody looking for a well written math lib, especially the SoA one which is quite rare.

Anyway, it seems to me that I'm facing an issue:
- The sse implementation of boolInVec uses for the == operator the _mm_cmpeq_ps intrinsic (vectormathlibrary\include\vectormath\SSE\cpp\boolInVec.h line 207).
- The __m128 argument stores either 0xfffffff or 0x0 to reflect a boolean value (respectively true or false). See constructor boolInVec::boolInVec(bool scalar) line 139.
- As seen as a float value, 0xfffffff is a NAN.
- According to sse instruction specifications (that I found here : http://www.cs.cmu.edu/~410/doc/intel-isr.pdf), _mm_cmpeq_ps always returns false when comparing NANs.

Thus comparing 2 boolInVec that are initialized to "true" with the == operator returns false, which is not the expected result.

I've experimented this behavior with those 3 lines of code:
Code:
   
int i = 0xffffffff;
__m128 a = _mm_set1_ps(*(float*)&i);
__m128 c = _mm_cmpeq_ps(a, a);


You'll notice that c equals 0x0 instead of the expected 0xffffffff.

Am I wrong?

Guillaume


Top
 Profile  
 
PostPosted: Thu Jun 04, 2009 12:05 am 
Offline

Joined: Thu Sep 18, 2008 1:44 am
Posts: 2
When you compare two numbers in SIMD, you should be always aware of the type of entities you compare. VMX and modern SSE allows you to treat register contents as integers, masks or floats freely, but it doesn't mean you can magically add two numbers when they're float and int. Or compare two masks as if they were floats.

cmpeq_ps will compare two floating-point numbers. If you have masks in your registers, it is logically a wrong operation to perform. Comparing masks bit-wise would be a NOT-XOR operation, for example.


Top
 Profile  
 
PostPosted: Tue Aug 31, 2010 2:00 pm 
Offline

Joined: Tue Aug 31, 2010 1:43 pm
Posts: 1
Hi,

I just discovered the lib (yes, 3 years later :)), and I read the code and found things like this:

(somewhere in scalar/cpp/mat_aos.h, but ti's the same in all implementaiton)
Code:
inline float Matrix4::getElem( int col, int row ) const
{
    return this->getCol( col ).getElem( row );
}

inline const Vector4 Matrix4::getCol( int col ) const
{
    return *(&mCol0 + col);
}


Why do the getter getCol creates a copy of a member variable ? Why can't we return a const reference like this:
Code:
inline const Vector4 & Matrix4::getCol( int col ) const
{
    return *(&mCol0 + col);
}


Because here, each time I want to access 1 element of a matrix, I do a Vector4 copy... not very efficient.

But maybe I'm missing a good reason for this.
Anyone can clarify this for me ?

Thanks again for making Bullet Open Source, I learn a lot.


Top
 Profile  
 
PostPosted: Thu Oct 14, 2010 3:06 am 
Offline

Joined: Thu May 20, 2010 10:45 pm
Posts: 10
If the architecture, abi, compiler, and math library all cooperate, then returning a vector by value is cheap -- it goes in a register. Also, the less aliasing means more opportunities for the compiler to optimize.

It's not OK for the api to change between the scalar and simd implementations (the change in semantics is subtle but real). vectormath is really not a great choice if you're not going to use a simd implementation.


Top
 Profile  
 
PostPosted: Thu Oct 06, 2011 8:34 am 
Offline

Joined: Thu Oct 06, 2011 8:25 am
Posts: 1
Location: France
Hi,

I ran some quick SSE tests with a naive c++ implementation, some intrisics on simple float arrays and the sony library. It appears that the prefetch and the cache have a huge impact on the performance. For example, my compiler seems to manage cache optimization on the naive c++ implementation which give better performances than Vectormath::Aos.

Is there any plans to add prefetch call to the library ?

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group