.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > General Programming
General Programming Help others and get yourself helped here!

Reply
 
Thread Tools
c++ optimised vector class
Old
  (#1)
mirv
Super Moderator
 
mirv's Avatar
 
Status: Offline
Posts: 152
Join Date: Apr 2004
Default c++ optimised vector class - 31-07-2004

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!


mirv the Silly Fish.
  
Reply With Quote
Re: c++ optimised vector class
Old
  (#2)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: c++ optimised vector class - 31-07-2004

what do you mean by "heavily" optimized ? for my purposes the STL vector class was sufficient ...


  
Reply With Quote
Re: c++ optimised vector class
Old
  (#3)
mirv
Super Moderator
 
mirv's Avatar
 
Status: Offline
Posts: 152
Join Date: Apr 2004
Default Re: c++ optimised vector class - 31-07-2004

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


mirv the Silly Fish.
  
Reply With Quote
Re: c++ optimised vector class
Old
  (#4)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: c++ optimised vector class - 31-07-2004

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 ?!


  
Reply With Quote
Re: c++ optimised vector class
Old
  (#5)
mirv
Super Moderator
 
mirv's Avatar
 
Status: Offline
Posts: 152
Join Date: Apr 2004
Default Re: c++ optimised vector class - 31-07-2004

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.


mirv the Silly Fish.
  
Reply With Quote
Re: c++ optimised vector class
Old
  (#6)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: c++ optimised vector class - 01-08-2004

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.
  
Reply With Quote
Re: c++ optimised vector class
Old
  (#7)
mirv
Super Moderator
 
mirv's Avatar
 
Status: Offline
Posts: 152
Join Date: Apr 2004
Default Re: c++ optimised vector class - 01-08-2004

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.


mirv the Silly Fish.

Last edited by mirv; 01-08-2004 at 11:32.. Reason: silly mistake
  
Reply With Quote
Re: c++ optimised vector class
Old
  (#8)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: c++ optimised vector class - 01-08-2004

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)



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Re: c++ optimised vector class
Old
  (#9)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: c++ optimised vector class - 02-08-2004

Please don't use SSE, my computer doesn't support it!!! :'(
  
Reply With Quote
Re: c++ optimised vector class
Old
  (#10)
mirv
Super Moderator
 
mirv's Avatar
 
Status: Offline
Posts: 152
Join Date: Apr 2004
Default Re: c++ optimised vector class - 02-08-2004

what cpu do you have, just out of curiosity?


mirv the Silly Fish.
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com