Author Topic: Machine Architecture: Things Your Programming Language Never Told You  (Read 4039 times)

0 Members and 1 Guest are viewing this topic.

Machine Architecture: Things Your Programming Language Never Told You
Very interesting video about the internal workings and optimizations of the hardware and the compiler, and how it does affect programming in c++/c#/java

http://www.nwcpp.org/Meetings/2007/09.html

Direct link to video:
http://video.google.com/videoplay?docid=-4714369049736584770#

Direct link to the slides:
http://www.nwcpp.org/Downloads/2007/Machine_Architecture_-_NWCPP.pdf

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Re: Machine Architecture: Things Your Programming Language Never Told You
very interesting.

never ever ever use anything other than a vector.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 
Re: Machine Architecture: Things Your Programming Language Never Told You
very interesting.

never ever ever use anything other than a vector.

whoa there. There are damn good reasons for the existence of other structures.
Just try an algorithm that requires a heck of a lot of non-head or tail insertions.
STRONGTEA. Why can't the x86 be sane?

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Re: Machine Architecture: Things Your Programming Language Never Told You
I was being overly simplistic.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 
Re: Machine Architecture: Things Your Programming Language Never Told You
*phew*
STRONGTEA. Why can't the x86 be sane?

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Re: Machine Architecture: Things Your Programming Language Never Told You
but that does reinforce my existing bias flavouring vectors as a first choice.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline blackhole

  • Still not over the rainbow
  • 29
  • Destiny can suck it
    • Black Sphere Studios
Re: Machine Architecture: Things Your Programming Language Never Told You
This confirms my instinct of "it's not fast until you test it."

However I want to point out that lists are often significantly faster then vectors for completely different reasons (as well as having O(1) time for insertion and deletion).

 
Re: Machine Architecture: Things Your Programming Language Never Told You
Lists have an issue with data locality (so they're not brilliant for caching - avoid in tight, inner loops unless you want to miss the cache a fair bit)
They also have the issue of you can't just access element 10, you need to follow the list until you get to element 10.
Insertion/deletion time is good though :)
STRONGTEA. Why can't the x86 be sane?

 

Offline Aardwolf

  • 211
  • Posts: 16,384
    • Minecraft
Re: Machine Architecture: Things Your Programming Language Never Told You
Well yeah, but what's so special about element 10?

That is, while a list can't do the whole random access thing, you don't necessarily need random access anyway. So it may not matter.

 

Offline Sushi

  • Art Critic
  • 211
Re: Machine Architecture: Things Your Programming Language Never Told You
There's also the fact that most of the time, optimizing the way your data is cached to get a speed increase isn't usually super-high priority.

But it is nice to know about cache locality issues so when you *do* for some reason need to be really clever, you can.

 

Offline blackhole

  • Still not over the rainbow
  • 29
  • Destiny can suck it
    • Black Sphere Studios
Re: Machine Architecture: Things Your Programming Language Never Told You
Lists have an issue with data locality (so they're not brilliant for caching - avoid in tight, inner loops unless you want to miss the cache a fair bit)
They also have the issue of you can't just access element 10, you need to follow the list until you get to element 10.
Insertion/deletion time is good though :)

Actually if you're trying to access list element 10 then you should probably be using a vector. In all of my lists, I only ever need to access all of the elements in order, or the element I need to access has a pointer in some other object.

 

Offline Aardwolf

  • 211
  • Posts: 16,384
    • Minecraft
Re: Machine Architecture: Things Your Programming Language Never Told You
Lists have an issue with data locality (so they're not brilliant for caching - avoid in tight, inner loops unless you want to miss the cache a fair bit)
They also have the issue of you can't just access element 10, you need to follow the list until you get to element 10.
Insertion/deletion time is good though :)

Actually if you're trying to access list element 10 then you should probably be using a vector. In all of my lists, I only ever need to access all of the elements in order, or the element I need to access has a pointer in some other object.

I believe that was implied by what he said.