Skip to main content
GameDev.net gamedev.net
🔒 Locked

Optimizations

Started by IndyJones Oct 18, 2003 at 4:02 AM 6 replies 1.4k views
Original Post
IndyJones
IndyJones
Hi there! I''ve a question that''s buggin me for some time now. Let''s say I have a maths library with some classes (matrix and so on) and I have 2 versions of this library - one with optimizations for Intel processors and one with optimizations for AMDs. How do game developers now use this libraries ... i mean they have to use the AMD matrix class when the programm runs on an AMD and the same goes with the intel class. Do they things like
if(isIntel())
  pMatrix = new IntelMatrix;
else
  pMatrix = new AMDMatrix;
 
or is there another way. Of course you could make different executables for each processor but there are games out there that have only one and use extensions (or do they only use extensions that both processors have like SSE?) Thx for any information!
IndyJones
IndyJones
OK - everything clear - but with this approach you will end up having one file that is intel-optimized and one that is amd-optimized (one compiled with #define AMD and one with #define INTEL) ... my question was more like "how to do it (efficiently) in one executable"?
duke
duke
You could use DLL''s, put your amd code in one DLL and intel in another.

I wouldn''t recommend it for low level functions, because you''ll lose the ability to inline, but for higher level functions it will be fine because the low level functions will be inlined in the DLL itself.
super genius
silvermace
silvermace
This is what C++ inheritance is for

class IMatrix{
public:
virtual void Multiply(...) = 0;
...
}

class MatrixIntel{
public:
virtual Multiply(...) { /* code */ }
...
}

IMatrix *pMatrix;
if( intel )
pMatrix = new MatrixIntel
else
pMatrix = new MatrixAMD

pMatrix->Multiply(...)



yea, look it up, very handy.
IndyJones
IndyJones
Yeah - that''s really interessting (though not easy ) - thx for the link Sneftel!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.