.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Programming (http://forums.bots-united.com/forumdisplay.php?f=25)
-   -   c++ optimised vector class (http://forums.bots-united.com/showthread.php?t=2394)

mirv 31-07-2004 17:17

c++ optimised vector class
 
Has anyone tried a heavily optimised vector class (c++) in an application? You can theorise about improvements a lot, but just wondered what noticeable differences in a runtime environment there were (if any). Not an awful lot of use creating efficient, yet complex, code if "nice" code runs just as well.
Thanks!

@$3.1415rin 31-07-2004 17:35

Re: c++ optimised vector class
 
what do you mean by "heavily" optimized ? for my purposes the STL vector class was sufficient ...

mirv 31-07-2004 17:41

Re: c++ optimised vector class
 
Sorry, should've been more specific...
3d vector class, not the stl vector-like-array. And by heavily optimised, I mean using a lot of templates and inline functions to cut down on extended register and/or stack usage for things like vecA = vecB + vecC + vecD

@$3.1415rin 31-07-2004 17:50

Re: c++ optimised vector class
 
I wrote a n-dim vector class using SSE/SSE2, but well, I gained no real speedup in my application, because that was limited by the memory transfer. dunno about using SSE otherwise. 3dimensional vectors are somehow bad, since their dimensionality is a multible of 2 or 4 :)

For bot developing purposes the HL vector class should be sufficient. Dunno if there is still this little disadvantage in the / operator. since multiplication is faster, calculating once 1.f/float and then multiplication is faster ( although it may not be optimal regarding precision ) And all those functions are inlined, so the compiler has to take care of that. dunno about using + ... + ... + and how it's done by the compiler ... pmb ?!

mirv 31-07-2004 18:04

Re: c++ optimised vector class
 
Hmm...think I'll just write complex code with lots of comments - a vector class shouldn't need much maintenance come to think of it, so the purpose of nice looking code is diminished.
I'm basically going to force the compiler to sum all x, then all y and lastly z components of vectors in a summation line so as it doesn't run around creating lots of internal temporary things.
But sleep first.

sfx1999 01-08-2004 06:54

Re: c++ optimised vector class
 
Instead of using SSE/SSE2 did you try just using plain old assembly (486)?

One thing you should know, when MMX did math it used something called register aliasing. It used the same registers as FPU math. So mixing MMX and FPU instructions can cause slowdown. I don't know if this is true with SSE or not.

mirv 01-08-2004 11:31

Re: c++ optimised vector class
 
I don't believe sse does.
Just started getting into SSE recently - haven't actually programmed with it yet though - so won't make something quite so dependent upon machine architecture just yet (though yes, I'm aware most venders these days support it). Using c++ operator overloading and a few inline functions can give a generic sort of vector class interface, so redoing it might be my first delving into SSE.

Pierre-Marie Baty 01-08-2004 23:07

Re: c++ optimised vector class
 
Quote:

Originally Posted by @$3.1415rin
And all those functions are inlined, so the compiler has to take care of that. dunno about using + ... + ... + and how it's done by the compiler ... pmb ?!

Yeah well I'd love to help you out here but Aspirin must know more than me about this low level stuff ... :)

One thing I'd take care to optimize first in the HL vector class though, is to pass the more you can of the Vector arguments by their addresses, and not completely like it's done (you save up 2 thirds of the bandwidth)

sfx1999 02-08-2004 07:23

Re: c++ optimised vector class
 
Please don't use SSE, my computer doesn't support it!!! :'(

mirv 02-08-2004 10:50

Re: c++ optimised vector class
 
what cpu do you have, just out of curiosity?

sfx1999 02-08-2004 12:55

Re: c++ optimised vector class
 
700 MHz Duron.


All times are GMT +2. The time now is 05:14.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.