I compiled the official Stockfish 4's sources with clang, and got an exe significantly faster than the official gcc build for mac included in the archive. Here are the compared results of the bench command and a search to depth 30 in the starting position:
the GCC build takes 23mn and 27 seconds, while the clang one takes 21mn and 54 seconds on my corei7 CPU.
I don't say that Clang produces faster code than GCC, but in some occurrences, like this one, it clearly does. So if you have access to both compilers you might want to try them both for your engine.
JuLieN wrote:I compiled the official Stockfish 4's sources with clang, and got an exe significantly faster than the official gcc build for mac included in the archive. Here are the compared results of the bench command and a search to depth 30 in the starting position:
the GCC build takes 23mn and 27 seconds, while the clang one takes 21mn and 54 seconds on my corei7 CPU.
I don't say that Clang produces faster code than GCC, but in some occurrences, like this one, it clearly does. So if you have access to both compilers you might want to try them both for your engine.
clang has bugs. The version that came with xcode on my 8-month-old macbook will NOT compile a functional crafty. gcc 4.7.2 works perfectly, however. I don't trust clang, period. Did you PGO and such?
bob wrote:
clang has bugs. The version that came with xcode on my 8-month-old macbook will NOT compile a functional crafty. gcc 4.7.2 works perfectly, however. I don't trust clang, period. Did you PGO and such?
clang is an old gcc version...
Yes I did. And I also compiled Crafty with clang with no problem at all and it runs very well. Could you please describe the problem you had with your clang Crafty ?
Note that no compiler is free of bugs. With Tim Kosse we ran into a GCC 4.8.x bug when trying to compile Octochess, and had to go back to GCC 4.7. Since then I've made a clang compile of Octochess as well.
bob wrote:
clang has bugs. The version that came with xcode on my 8-month-old macbook will NOT compile a functional crafty. gcc 4.7.2 works perfectly, however. I don't trust clang, period. Did you PGO and such?
clang is an old gcc version...
Yes I did. And I also compiled Crafty with clang with no problem at all and it runs very well. Could you please describe the problem you had with your clang Crafty ?
Crashed instantly. There have been updates, perhaps it was fixed. It is STILL an old version of gcc...
When I typed "crafty" I got an instant crash. I can test the most recent clang since I keep up to date, will take a bit to figure out how to avoid using the newer gcc...
JuLieN wrote:
the GCC build takes 23mn and 27 seconds, while the clang one takes 21mn and 54 seconds on my corei7 CPU.
Excuse my ignorance.
Refers to compilation 21 minutes.
No, sorry for the confusion, Jose. It was the time both versions of Stockfish took to reach depth 30. In both cases the compilation time was a matter of second (clang being a bit faster in compiling.)
JuLieN wrote:I compiled the official Stockfish 4's sources with clang, and got an exe significantly faster than the official gcc build for mac included in the archive. Here are the compared results of the bench command and a search to depth 30 in the starting position:
According to the bench, your clang binary is about 5% faster than the official one. I've tried all recent versions of both gcc and clang (llvm). My best is a binary that is about 11% faster than the official one. This was produced using gcc-4.6 from MacPorts. popcount was used, PGO was used, but not LTO. Add -fno-tree-pre to the optimization flags.
clang is improving, but for me it has never produced a faster binary than some version of gcc. Don't have icc, since it's not free!
JuLieN wrote:I compiled the official Stockfish 4's sources with clang, and got an exe significantly faster than the official gcc build for mac included in the archive. Here are the compared results of the bench command and a search to depth 30 in the starting position:
the GCC build takes 23mn and 27 seconds, while the clang one takes 21mn and 54 seconds on my corei7 CPU.
I don't say that Clang produces faster code than GCC, but in some occurrences, like this one, it clearly does. So if you have access to both compilers you might want to try them both for your engine.
clang has bugs. The version that came with xcode on my 8-month-old macbook will NOT compile a functional crafty. gcc 4.7.2 works perfectly, however. I don't trust clang, period. Did you PGO and such?
clang is an old gcc version...
This is a known issue for some versions of XCode. It includes an old (v2.9) Clang compiler and an even older C/C++ Standard Library (based on gcc 4.2). There are plenty of links out there on how to install the latest Clang compiler and C/C++ headers (or the LLVM new libc++ headers). You might want to check clang --version on your system to see if you are up to date.
Rein Halbersma wrote: There are plenty of links out there on how to install the latest Clang compiler and C/C++ headers (or the LLVM new libc++ headers). You might want to check clang --version on your system to see if you are up to date.
I think Bob has mentioned MacPorts. He can get everything he wants there.