Optimized math libraries out there

Started by
38 comments, last by kii 17 years ago
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
Advertisement
Are you working with DirectX, if so why not use D3DX?

Dave
Thanks Dave,

Yes D3DX is an option, but I would prefer something with source code and that I could modify.
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?
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.
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 :)
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
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 :)
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.
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

This topic is closed to new replies.

Advertisement