Useful programming links

Development directions, tasks, and features being actively implemented or pursued by the development team.

Share On:

Share on Facebook Facebook Share on Twitter Twitter Share on Digg Digg

Re: Useful programming links

Postby snow_Cat » Mon Mar 08, 2010 1:59 am

Thanks for collecting these resources.
User avatar
snow_Cat
Confed Special Operative
Confed Special Operative
 
Posts: 349
Topics: 31
Joined: Wed Jan 04, 2006 5:43 pm
Location: /stray/

Re: Useful programming links

Postby chuck_starchaser » Mon Mar 08, 2010 9:17 am

Hey, Snow_Cat; been a while. My pleasure; I'm doing this for selfish reasons; so I don't lose the links.

Here's a brilliant piece:
Idioms for Typesafe Enums in C++ --by Martin Buchholz

I'm thinking of trying to come up with an enum macro and templates that allows you to declare
an enum=based switch statement that caches the last switch used, so that if the switch argument
would be the same it goes there directly, rather than go through the switch (computed goto). This would
speed-up the runtime in many places. For instance, VDU mode rarely changes (user changes it); but at
each iteration of VDU::draw() there's a switch statement with all modes as cases to go through.
I might use the code above and modify it to add the switch and last-used-cache-ing.
User avatar
chuck_starchaser
Elite
Elite
 
Posts: 8014
Topics: 195
Joined: Thu Sep 04, 2003 9:03 pm
Location: Montreal

Re: Useful programming links

Postby klauss » Mon Mar 08, 2010 11:36 am

chuck_starchaser wrote:I'm thinking of trying to come up with an enum macro and templates that allows you to declare
an enum=based switch statement that caches the last switch used, so that if the switch argument
would be the same it goes there directly, rather than go through the switch (computed goto). This would
speed-up the runtime in many places. For instance, VDU mode rarely changes (user changes it); but at
each iteration of VDU::draw() there's a switch statement with all modes as cases to go through.
I might use the code above and modify it to add the switch and last-used-cache-ing.


That's nonsense. The CPU already tracks the last target efficiently enough (the branch target buffer).

The problem is with unpredictable (by BTB means) change patterns. Imagine the target changes every other execution or something like that.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina

Re: Useful programming links

Postby chuck_starchaser » Mon Mar 08, 2010 11:42 am

I've never read about cpu's cacheing the targets of computed goto's, which is what switch statements often get compiled to;
but it could be there is such a thing and I never heard about it. What I know cpu's have is a branch prediction cache, which
is indexed by the address of the branch instruction. In a case statement based on enums, the compiler produces an array
of goto's preceded by an operation that adds some k*SwitchArg to the program counter. What would the cpu index its branch
prediction to, in such a case? Or does it have a separate "computed goto cache"?
User avatar
chuck_starchaser
Elite
Elite
 
Posts: 8014
Topics: 195
Joined: Thu Sep 04, 2003 9:03 pm
Location: Montreal

Re: Useful programming links

Postby klauss » Mon Mar 08, 2010 11:49 am

Well, there's a similar predictive cache that caches branch targets. It was introduced, AFAIK, in the netburst architecture and it sped up dynamic code a lot, like that of VMs (JVM, python, virtual calls in C++, indirect calls in C, etc).
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina


Re: Useful programming links

Postby www2 » Wed Mar 10, 2010 10:10 am

I heft gift the topic the sticky status
All Your Base Are Belong To Us
User avatar
www2
Venturer
Venturer
 
Posts: 536
Topics: 52
Joined: Sat May 14, 2005 3:51 am
Location: milkyway->the sol system->earth->Europe->The Nederland->Soud Holland->Leiden

Re: Useful programming links

Postby chuck_starchaser » Wed Mar 10, 2010 10:51 am

Excellent! Thanks! I'll keep adding any good links I come across.
User avatar
chuck_starchaser
Elite
Elite
 
Posts: 8014
Topics: 195
Joined: Thu Sep 04, 2003 9:03 pm
Location: Montreal

Re: Useful programming links

Postby chuck_starchaser » Thu Mar 11, 2010 10:20 am

Allocators, allocators...
A couple of years ago, Boost had a fast block allocator, and a half-baked multithreading library; and I put the two together and made a per-thread block allocator, super-fast.
I don't remember where the code would be, but it doesn't matter, as Boost has come up with a brand new multithreading library; and now that I'm looking for its fast block allocator I can't find it... But I'm finding useful links, anyways:

Fast allocations and deallocations --on Wikibooks
FSB Allocator

FOUND IT!
Boost Pool Allocator
Boost Pool Interfaces

I'll have a closer look tonight. I like the FSB allocator because it is NOT thread-safe, and therefore a lot faster. Not sure whether the boost one is, or isn't. I could re-implement the per-thread pool allocator, even if we don't have threads yet, just for scalability.
User avatar
chuck_starchaser
Elite
Elite
 
Posts: 8014
Topics: 195
Joined: Thu Sep 04, 2003 9:03 pm
Location: Montreal

Re: Useful programming links

Postby klauss » Wed Mar 17, 2010 8:15 am

Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
User avatar
klauss
Elite
Elite
 
Posts: 7243
Topics: 55
Joined: Mon Apr 18, 2005 7:40 am
Location: LS87, Buenos Aires, República Argentina



Return to Engine Development

Who is online

Users browsing this forum: No registered users and 1 guest