![]() |
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! |
Re: c++ optimised vector class
what do you mean by "heavily" optimized ? for my purposes the STL vector class was sufficient ...
|
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 |
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 ?! |
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. |
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. |
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. |
Re: c++ optimised vector class
Quote:
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) |
Re: c++ optimised vector class
Please don't use SSE, my computer doesn't support it!!! :'(
|
Re: c++ optimised vector class
what cpu do you have, just out of curiosity?
|
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.