Well, without specific version info on the compiler and standard headers it' all speculation what went wrong . For C++ at least, Clang 3.3 is fully conforming at pretty much the same level as gcc 4.8.zullil wrote:I think Bob has mentioned MacPorts. He can get everything he wants there.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.
Clang vs GCC [stockfish 4]
Moderator: Ras
-
Rein Halbersma
- Posts: 771
- Joined: Tue May 22, 2007 11:13 am
Re: Clang vs GCC [stockfish 4]
-
JuLieN
- Posts: 2949
- Joined: Mon May 05, 2008 12:16 pm
- Location: Bordeaux (France)
- Full name: Julien Marcel
Re: Clang vs GCC [stockfish 4]
For reference, my version is:Rein Halbersma wrote:Well, without specific version info on the compiler and standard headers it' all speculation what went wrong . For C++ at least, Clang 3.3 is fully conforming at pretty much the same level as gcc 4.8.zullil wrote:I think Bob has mentioned MacPorts. He can get everything he wants there.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.
Code: Select all
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix"The only good bug is a dead bug." (Don Dailey)
[Blog: http://tinyurl.com/predateur ] [Facebook: http://tinyurl.com/fbpredateur ] [MacEngines: http://tinyurl.com/macengines ]
[Blog: http://tinyurl.com/predateur ] [Facebook: http://tinyurl.com/fbpredateur ] [MacEngines: http://tinyurl.com/macengines ]
-
Rein Halbersma
- Posts: 771
- Joined: Tue May 22, 2007 11:13 am
Re: Clang vs GCC [stockfish 4]
Clang 3.2 should be good enough, but you should also check your c/c++ headers. If they are provided by gcc 4.2 then you want to upgrade to at least 4.7
-
bob
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Clang vs GCC [stockfish 4]
I got this new macbook in December of last year. I had to install xcode myself, and then do the various updates. At that point in time, december or january, clang broke crafty badly. I used macports to download 4.7.2 and build it, and it worked perfectly as it generally always has (at least over last 10+ years, I was an EARLY "long long" user and it was certainly "dicey" to start with...Rein Halbersma wrote: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.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?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.Code: Select all
Official: =========================== Total time (ms) : 2836 Nodes searched : 4132374 Nodes/second : 1457113 info depth 30 seldepth 46 score cp 30 nodes 1699401570 nps 1207059 time 1407886 multipv 1 pv d2d4 g8f6 g1f3 e7e6 c2c4 f8b4 c1d2 b4d2 d1d2 b7b6 e2e3 e8g8 f1e2 f6e4 d2d3 c8b7 e1g1 d7d6 f3d2 e4d2 d3d2 d8g5 g2g3 b8d7 b1c3 d7f6 a1d1 info nodes 1699401570 time 1407886 bestmove d2d4 ponder g8f6 clang: =========================== Total time (ms) : 2691 Nodes searched : 4132374 Nodes/second : 1535627 info depth 30 seldepth 46 score cp 30 nodes 1699401570 nps 1293199 time 1314106 multipv 1 pv d2d4 g8f6 g1f3 e7e6 c2c4 f8b4 c1d2 b4d2 d1d2 b7b6 e2e3 e8g8 f1e2 f6e4 d2d3 c8b7 e1g1 d7d6 f3d2 e4d2 d3d2 d8g5 g2g3 b8d7 b1c3 d7f6 a1d1 info nodes 1699401570 time 1314106 bestmove d2d4 ponder g8f6
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 is an old gcc version...
-
bob
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Clang vs GCC [stockfish 4]
Note that if you run linux, icc is free. If you use a mac, it is not free, however. Seems odd, but oh well...zullil wrote: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.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:
Code: Select all
Official: =========================== Total time (ms) : 2836 Nodes searched : 4132374 Nodes/second : 1457113 info depth 30 seldepth 46 score cp 30 nodes 1699401570 nps 1207059 time 1407886 multipv 1 pv d2d4 g8f6 g1f3 e7e6 c2c4 f8b4 c1d2 b4d2 d1d2 b7b6 e2e3 e8g8 f1e2 f6e4 d2d3 c8b7 e1g1 d7d6 f3d2 e4d2 d3d2 d8g5 g2g3 b8d7 b1c3 d7f6 a1d1 info nodes 1699401570 time 1407886 bestmove d2d4 ponder g8f6 clang: =========================== Total time (ms) : 2691 Nodes searched : 4132374 Nodes/second : 1535627 info depth 30 seldepth 46 score cp 30 nodes 1699401570 nps 1293199 time 1314106 multipv 1 pv d2d4 g8f6 g1f3 e7e6 c2c4 f8b4 c1d2 b4d2 d1d2 b7b6 e2e3 e8g8 f1e2 f6e4 d2d3 c8b7 e1g1 d7d6 f3d2 e4d2 d3d2 d8g5 g2g3 b8d7 b1c3 d7f6 a1d1 info nodes 1699401570 time 1314106 bestmove d2d4 ponder g8f6
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!
my gcc-4.6 binary:
official binary:Code: Select all
Total time (ms) : 3198 Nodes searched : 4132374 Nodes/second : 1292174
This is on an old Nehalem Xeon running at 2.26 GHz. One thread.Code: Select all
Total time (ms) : 3552 Nodes searched : 4132374 Nodes/second : 1163393
-
zullil
- Posts: 6442
- Joined: Tue Jan 09, 2007 12:31 am
- Location: PA USA
- Full name: Louis Zulli
Re: Clang vs GCC [stockfish 4]
Yes, that's the version that comes with Xcode 4.6. It's Apple-specific, and is not quite clang-3.2. It will sometime fail to compile code that causes clang-3.2 no trouble.JuLieN wrote: For reference, my version is:
I think it's just the one that ships with the current XCode (not the beta for the upcoming one).Code: Select all
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn) Target: x86_64-apple-darwin12.4.0 Thread model: posix
-
jdart
- Posts: 4430
- Joined: Fri Mar 10, 2006 5:23 am
- Location: http://www.arasanchess.org
Re: Clang vs GCC [stockfish 4]
I don't think Intel's C/C++ compiler even supports Mac OS; see http://software.intel.com/en-us/intel-compilers. They have a Fortran compiler on that platform, though
.
--Jon
--Jon
-
zullil
- Posts: 6442
- Joined: Tue Jan 09, 2007 12:31 am
- Location: PA USA
- Full name: Louis Zulli
Re: Clang vs GCC [stockfish 4]
It always has, and I think it still does.jdart wrote:I don't think Intel's C/C++ compiler even supports Mac OS
--Jon
http://software.intel.com/en-us/intel-s ... -mac-os-x/
Somebody at Intel should fix that other webpage.
-
bob
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Clang vs GCC [stockfish 4]
I think it is a typo. icc comes with the fortran compiler. I used that when we found the old version of Cray Blitz source. To make a few changes as needed to make it compile on a normal (non-cray) compiler. We used something called "task common" that Cray supported but normal FORTRAN compilers did not. needed to fix that to make things compile and run.jdart wrote:I don't think Intel's C/C++ compiler even supports Mac OS; see http://software.intel.com/en-us/intel-compilers. They have a Fortran compiler on that platform, though.
--Jon
-
zullil
- Posts: 6442
- Joined: Tue Jan 09, 2007 12:31 am
- Location: PA USA
- Full name: Louis Zulli
Re: Clang vs GCC [stockfish 4]
Apparently, for OS X, the C++ and Fortran compilers are now disjoint products.bob wrote: I think it is a typo. icc comes with the fortran compiler.
http://software.intel.com/en-us/intel-s ... -mac-os-x/