Jump to content
  • Advertisement
Sign in to follow this  
Laval B

Mathematic Library management

This topic is 2295 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 everyone.

I've been working on math libs for a while now and with the new AVX technology, i have just written a 256 bits AVX version of the lib (mostly implementing matrix related stuff for batch vertex processing like skinning). So i endup with a generic version (fallback C implementation), an SSE2 implementation, an altivec implementation and an AVX implementation. Passing to 64 bits and getting rid of all that inline asm is also great. No need to say i'm working in C++.

That's all good and dandy but my problem is how to manage the lib in the application. I have good detection code for CPU features but i'm still not sure how i should dynamically choose the right lib at run-time.

I have checked how Id Software does it in DOOM3 engine. It's very simple in fact. They define an interface (a class with only abstract methods) and they define implementations (derivatives) for different implementations. Then they create the one they need according to the platform and cpu features available.

I was just wondering if there is a way to do that at run-time without the use of virtual methods (i know i know, it's only a couple of nano seconds)? How do you guys manage this situation in your engine ?


P.S.
I'm sorry about my english, this isn't my every day language.

Share this post


Link to post
Share on other sites
Advertisement
I've seen that some games actually compile their code several times into several EXEs/DLLs. When you run the game, you're actually just running a "launcher" program, which checks your CPU and decides which version of the game to actually launch.

e.g.
User A runs [font=courier new,courier,monospace]game.exe[/font], which then runs [font=courier new,courier,monospace]game_singlecore_SSE2.exe[/font]
but
User B runs [font=courier new,courier,monospace]game.exe[/font], which then runs [font=courier new,courier,monospace]game_multicore_AVX.exe[/font]

Share this post


Link to post
Share on other sites

I've seen that some games actually compile their code several times into several EXEs/DLLs. When you run the game, you're actually just running a "launcher" program, which checks your CPU and decides which version of the game to actually launch.

e.g.
User A runs [font=courier new,courier,monospace]game.exe[/font], which then runs [font=courier new,courier,monospace]game_singlecore_SSE2.exe[/font]
but
User B runs [font=courier new,courier,monospace]game.exe[/font], which then runs [font=courier new,courier,monospace]game_multicore_AVX.exe[/font]



Yes, that's a solution i was thinking about but it would still be nice to have only one executable though it's not a problem to have many. Putting the lib into a DLL could alos be a solution. It there a penalty for using functions in a dll compared to functions that are builtin in your code ? Also, i'm worried about allignment and memory passing the dll barrier ...

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!