Jump to content
  • Advertisement
Sign in to follow this  
ldeej

Optimized math libraries out there

This topic is 4221 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have been looking for a fast math library, but my google and sourceforge searches have not produced anything good yet. What I am looking for: A minimal library that provides matrix and vector math, bonus would be quaternions, and other math helpers (random number generators and such) but matrix and vector math would be more than enough. There are plenty of libraries out there that have full source code, but what I need is a library that provides source code and that is written with optimizations (i.e. SSE2 or SSE3) I looked at AMD's Math library, and it seems overkill and cumbersome for what I need. I guess if I cannot find one I can always write it, but if somebody already has done it then I just want to use it and not have to write it. Thanks

Share this post


Link to post
Share on other sites
Advertisement
Thanks Dave,

Yes D3DX is an option, but I would prefer something with source code and that I could modify.

Share this post


Link to post
Share on other sites
What do you need to modify it for? Maybe there is an alternative solution as any extensive modification will be alot of work and could be best avoided.

What are you looking for that it doesn't provide?

Share this post


Link to post
Share on other sites
A want a minimalistic library with source code (a preference), I want the source code so I can modify it, update it, and extend it, and I want the source code to be part of my app, and not ship an extra dll if I can.

As I said D3DX fits the need, but there has to be something out there that is less heavy, provides source code, and is highly optimized.

Share this post


Link to post
Share on other sites
Thanks Zipster,

Unfortunately I do not see any optimizations made on that library (i.e. SSE, SSE2), I already have something similar and much simpler, but thanks for the pointer

Share this post


Link to post
Share on other sites
Quote:
Original post by Zipster
Not so long ago, one of our members (jyk) released a math library that should suit your needs. Of course he could provide further details as to what features it has :)
The CML uses expression templates for all the low-level math code, and so probably doesn't meet the OP's particular requirements (as the OP has noted).

Thanks for the mention though - it is much appreciated :)

Share this post


Link to post
Share on other sites
Quote:
Original post by ldeej
Hello,

I have been looking for a fast math library, but my google and sourceforge searches have not produced anything good yet.

What I am looking for:
A minimal library that provides matrix and vector math, bonus would be quaternions, and other math helpers (random number generators and such) but matrix and vector math would be more than enough.

There are plenty of libraries out there that have full source code, but what I need is a library that provides source code and that is written with optimizations (i.e. SSE2 or SSE3)


SSE2/SSE3 are not optimizations, these are assembly instructions. When people are starting to talk about math libraries with optimizations, they have often badly designed algorithm. And now a sweet secret, SSE2 are for double precision floating point numbers (and some whole numbers operations). If you will not use 64 bit floating point, these are for nothing. (On the other hand from my experience if you are not working with OGL, 64 bit floating point is worthy that potential slowdown. Whole numbers are even better.)

Quaternions are bit unnecessary, and RNG are not related to matrix and vector operations, as RNGs are NOT math (in a same way as "IF" isn't a math).

BTW I seen a butt ugly .h file from Nvidia, simple and probably working. Try to look into theirs SDK/developer section. (I don't recall precisely its name because of HD crash.)


SSE2 instructions are not worthy for math library if that math library isn't handwritten in a 64 bit ASM, as these additional registers (in 64 bit mode) are important for cache.

Share this post


Link to post
Share on other sites
Thanks Raghar,

We can play the language game as much as you want, sure SSE are assembly instructions, but are assembly instructions that can apply the same instruction to multiple data (SIMD) making operations faster (i.e. running a dot product as a single assembly instruction rather than multiple ones)

Note also that you can safely use SSE with 32-bit data, not only 64-bit, by packing 32-bit data into memory aligned for SSE consumption.

If you think it is not worth it you should try to compare any unoptimzed library to the D3DX math library, and you will see the difference, D3DX is optimized for both Intel and AMD, and it uses SSE (It might use other data)

To use SSE you do not need to hand code assembly, you can use compiler intrinsics/extensions, and compiler settings. The VC compiler has settings to let the optimizer use SSE when it is cheaper and it makes sense, the Intel compiler has similar settings.

Thanks for the reply though

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!