Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #128997
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Allocate variables within code blocks. |
| Date | 2018-04-09 12:17 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87muyc6341.fsf@bsb.me.uk> (permalink) |
| References | <pacshc$18uv$1@gioia.aioe.org> <kfnlgdxe23l.fsf@x-alumni2.alumni.caltech.edu> <paeo53$a2k$1@gioia.aioe.org> |
"itsme.susila" <itsme.susila@gmx.com> writes: <snip> > In fact, chess programmers are a lot who talk about speed. I did go to > talkchess.com (now no more) where there were much talk about coding > practice. A simple example that novice may not know: use integer(4 > bytes) data rather than short(2 bytes)...chess programming is almost > all with integer operations and there are overheads for modern cpu to > operate on char and short types. I don't think that's good advice. It may be true in some cases (it certainly used to be on some CPUs) but it may not be true in others. I used to be quite good at guessing what code changes would improve performance, but that was 25 years ago. With every new generation of CPU, and every new compiler release, I have become used being surprised and I've thrown out almost every "rule of thumb" that I used to use. For example, I just tried a nested loop calculation using short, int and long (long being 64-bit here) and the short version was faster than the (32-bit) int version. But that was un-optimised. With gcc -O2 I can't detect any difference between short and int. This was designed to avoid cache issues so it's possible that short might even be faster in some cases where the memory saving turns out to be helpful. And if someone now posts that they've also done a quick test and int was faster than short I would not be at all surprised. I have, in the past, been so frequently surprised by what clever chips and compilers do that I am rarely surprised any more. > In fact the experts would also do profiling (there is compiler auto > profiling optimizations too) and then to optimize at the particular > spots; but we already know it i recursive search which is the critical > function. That sounds odd. To me, a chess playing program /is/ recursive search with very little else! It sounds like saying that the program is the critical part of the program. When I wrote a chess program, it was the function that evaluated positions that was the bottle-neck. If I remember correctly, there was some measurable component from the function that generated valid moves, but I don't remember it being worth working on. And despite knowing the most expensive function, the best improvements came from re-ordering the move list because of the way the tree pruning worked. (I suspect the design of chess programs is more sophisticated these days. Even for the time, mine was crude, having no book of openings and no special end-game mode.) > But I think it is correct to start off with what you say, > good choice of data structures, etc... Yes. For macro-optimisation, think data structures and algorithms (and measure). For micro-optimisation, measure (don't try to guess). -- Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Allocate variables within code blocks. "itsme.susila" <itsme.susila@gmx.com> - 2018-04-08 18:56 +0800
Re: Allocate variables within code blocks. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-04-08 12:29 +0100
Re: Allocate variables within code blocks. Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-08 05:06 -0700
Re: Allocate variables within code blocks. Spiros Bousbouras <spibou@gmail.com> - 2018-04-08 13:00 +0000
Re: Allocate variables within code blocks. Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-08 08:14 -0700
Re: Allocate variables within code blocks. GOTHIER Nathan <nathan.gothier@gmail.com> - 2018-04-08 16:37 +0200
Re: Allocate variables within code blocks. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2018-04-08 08:53 -0600
Re: Allocate variables within code blocks. bartc <bc@freeuk.com> - 2018-04-08 16:32 +0100
Re: Allocate variables within code blocks. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2018-04-08 15:19 -0600
Re: Allocate variables within code blocks. Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-09 07:59 -0700
Re: Allocate variables within code blocks. Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-11 06:29 -0700
Re: Allocate variables within code blocks. bartc <bc@freeuk.com> - 2018-04-11 15:58 +0100
Re: Allocate variables within code blocks. Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-11 11:28 -0700
Re: Allocate variables within code blocks. Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-13 00:42 -0700
Re: Allocate variables within code blocks. Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-04-11 10:25 +0000
Re: Allocate variables within code blocks. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-04-08 19:27 +0100
Re: Allocate variables within code blocks. James Kuyper <jameskuyper@verizon.net> - 2018-04-08 07:54 -0400
Re: Allocate variables within code blocks. Spiros Bousbouras <spibou@gmail.com> - 2018-04-08 12:50 +0000
Re: Allocate variables within code blocks. bartc <bc@freeuk.com> - 2018-04-08 13:42 +0100
Re: Allocate variables within code blocks. "itsme.susila" <itsme.susila@gmx.com> - 2018-04-08 22:19 +0800
Re: Allocate variables within code blocks. "itsme.susila" <itsme.susila@gmx.com> - 2018-04-08 22:27 +0800
Re: Allocate variables within code blocks. Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2018-04-08 10:42 -0400
Re: Allocate variables within code blocks. bartc <bc@freeuk.com> - 2018-04-08 15:37 +0100
Re: Allocate variables within code blocks. David Brown <david.brown@hesbynett.no> - 2018-04-08 16:45 +0200
Re: Allocate variables within code blocks. "itsme.susila" <itsme.susila@gmx.com> - 2018-04-08 22:55 +0800
Re: Allocate variables within code blocks. GOTHIER Nathan <nathan.gothier@gmail.com> - 2018-04-08 17:52 +0200
Re: Allocate variables within code blocks. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2018-04-08 09:00 -0600
Re: Allocate variables within code blocks. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2018-04-08 08:51 -0600
Re: Allocate variables within code blocks. Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-08 15:59 -0700
Re: Allocate variables within code blocks. "itsme.susila" <itsme.susila@gmx.com> - 2018-04-09 11:54 +0800
Re: Allocate variables within code blocks. David Brown <david.brown@hesbynett.no> - 2018-04-09 09:31 +0200
Re: Allocate variables within code blocks. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-04-09 12:17 +0100
Re: Allocate variables within code blocks. "itsme.susila" <itsme.susila@gmx.com> - 2018-04-10 00:27 +0800
Re: Allocate variables within code blocks. Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-09 09:33 -0700
Re: Allocate variables within code blocks. Spiros Bousbouras <spibou@gmail.com> - 2018-04-09 16:52 +0000
Re: Allocate variables within code blocks. "itsme.susila" <itsme.susila@gmx.com> - 2018-04-10 01:17 +0800
Re: Allocate variables within code blocks. scott@slp53.sl.home (Scott Lurndal) - 2018-04-09 18:03 +0000
Re: Allocate variables within code blocks. supercat@casperkitty.com - 2018-04-09 13:39 -0700
Re: Allocate variables within code blocks. scott@slp53.sl.home (Scott Lurndal) - 2018-04-09 20:53 +0000
Re: Allocate variables within code blocks. bartc <bc@freeuk.com> - 2018-04-09 12:23 +0100
Re: Allocate variables within code blocks. "itsme.susila" <itsme.susila@gmx.com> - 2018-04-10 00:39 +0800
Re: Allocate variables within code blocks. Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-09 08:09 -0700
Re: Allocate variables within code blocks. Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2018-04-09 17:07 -0600
Re: Allocate variables within code blocks. supercat@casperkitty.com - 2018-04-09 16:28 -0700
Re: Allocate variables within code blocks. Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-10 00:46 -0700
Re: Allocate variables within code blocks. Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-11 07:10 -0700
csiph-web