> > No compiler will ever do *all* of the optimizations > > that are possible, because most optimizations are > > NP-complete or even much worse. For example the > > equivalance of boolean expressions is NP-complete. > > Some potential optimizations (such as replacement > > of data structures) may not even computable. > > This is why humans must choose the algorithms and > > data strucures. > > > > Compilers are very good at *small, local optimizations*, > > such as putting variables in registers, common > > sub-expression elimination, and choosing the fastest > > instructions. Compilers almost always > > outperform humans on these tasks because compilers > > consistently try every trick they know, and they > > don't get tired. > > > > Even way back in the 1970s, studies showed that > > optimizers consistently outperformed humans on > > these tasks, and back then, many people > > still practiced doing assembler regularly. > > > > Today, performance combines programmer and compiler > > intelligence. Neither can replace the other. > > Please use both.
> So this seems to support the idea that C code is potentially faster > than hand-coded assembly, because the more complicated optimizations > can be done by the programmer in C while the optimizations better > suited to a computer are done by the compiler. Although it would also > be possible to hand-code in assembly and then run a program to > optimize it, but then it seems like there is no advantage over C. As > far as I can tell, the optimizations that a compiler can't do are > higher-level optimizations that can be done in C and wouldn't require > the programmer to write assembly, or am I wrong about this? To extend your thought: well-written code in any HLL (like C, C++, Java, Fortran, D, etc.) will in-general out-perform assembler, because the programmer can do better algorithms and data structures, and compilers are better at assembler. There is one major exception. I have seen several apps where programmers wrote a few functions in assembler for speed, for example to use the SIMD instructions. But, that was only a few functions out of an entire app. Data structures and algorithms are very important. Given the success of MC and UCT, there seems to be a lot of enthusiasm for performance. But, even improving performance by a factor of 10 by using assembler will not make MC and UCT play professional level go on 19*19. We still need to find much better algorithms and data structures. Michael Wing _______________________________________________ computer-go mailing list computer-go@computer-go.org http://www.computer-go.org/mailman/listinfo/computer-go/