clang compiler

Discussion of chess software programming and technical issues.

Moderator: Ras

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: clang compiler

Post by bob »

rbarreira wrote:I was quite impressed with gcc 4.5.0, in my benchmarks its generated code was as fast as with the newest Intel Compiler on Intel CPUs (and of course much faster on AMD CPUs, due to the purposefully bad performance icc has there).
I have 4.5 on my Fedora 14 laptop. I can't get PGO to work. If I try to PGO crafty, and try a run with several single-thread positions, and then one multi-thread position, the PGO output files are always corrupted and the re-compile fails when the compiler complains.

I've given up on it as for me, Intel has always been well over 10% faster since PGO works there...
NaltaP312
Posts: 56
Joined: Wed Oct 29, 2008 1:06 pm
Full name: Marc Paule

Re: clang compiler

Post by NaltaP312 »

That's an extremely old GCC version. GCC 4.2.1 was released in July 2007. The current version is 4.5.2, and a release candidate for 4.6 was released just a couple of weeks ago.

Comparing a recent version of clang to an almost four year old version of GCC is quite meaningless, especially when you enable link-time optimization in clang. GCC 4.2.1 does not support link-time optimization, but 4.5 does. It is possible that clang would still come out ahead in a direct comparison to the latest GCC version, but I doubt it.



Hello Tord,

you're right but for mac user we are very closed by the apple choice, and xcode install.
do you know where we can download a gcc version for mac user ?

Regards
Yves
User avatar
marcelk
Posts: 348
Joined: Sat Feb 27, 2010 12:21 am

Re: clang compiler

Post by marcelk »

NaltaP312 wrote:
you're right but for mac user we are very closed by the apple choice, and xcode install.
do you know where we can download a gcc version for mac user ?
I installed gcc4.6 from the MacPorts project. http://www.macports.org/

Code: Select all

sudo port install gcc46
PGO works and gave me a 5% speedup.
NaltaP312
Posts: 56
Joined: Wed Oct 29, 2008 1:06 pm
Full name: Marc Paule

Re: clang compiler

Post by NaltaP312 »

Many thanks i will try it.
At same time i have found this
http://hpc.sourceforge.net/index.php
Aaron Becker
Posts: 292
Joined: Tue Jul 07, 2009 4:56 am

Re: clang compiler

Post by Aaron Becker »

The real value of clang right now is not the speed of its generated code, but the quality of its warning and error messages and its static analysis features. Its error messages are so much better than gcc's it's amazing, especially for C++, most especially for templates. I've gotten a lot of use out of it even though gcc and icc both generate faster binaries.
micron
Posts: 155
Joined: Mon Feb 15, 2010 9:33 am
Location: New Zealand

Re: clang compiler

Post by micron »

Yes indeed. See the examples here:

http://clang.llvm.org/diagnostics.html

Robert P.
micron
Posts: 155
Joined: Mon Feb 15, 2010 9:33 am
Location: New Zealand

Re: clang compiler

Post by micron »

Clang, but not gcc, gives a thought-provoking warning when compiling OliThink
http://home.arcor.de/dreamlike/chess/

Code: Select all

$ clang -O3 -flto olithink.c -o OliThink
olithink.c:1180:50: warning: use of unary operator that may be intended as compound assignment (-=)
        if (*sf == 1 && !(pieceb[PAWN] & colorb[c])) mn =- 200; //No mating material
                                                        ^~
Should that be mn = -200; or mn -= 200;?
UncombedCoconut
Posts: 319
Joined: Fri Dec 18, 2009 11:40 am
Location: Naperville, IL

Re: clang compiler

Post by UncombedCoconut »

micron wrote:Clang, but not gcc, gives a thought-provoking warning when compiling OliThink
http://home.arcor.de/dreamlike/chess/

Code: Select all

$ clang -O3 -flto olithink.c -o OliThink
olithink.c:1180:50: warning: use of unary operator that may be intended as compound assignment (-=)
        if (*sf == 1 && !(pieceb[PAWN] & colorb[c])) mn =- 200; //No mating material
                                                        ^~
Should that be mn = -200; or mn -= 200;?
Good catch! It's almost surely a bug, although I doubt it has a noticeable effect on playing strength. (What was written probably works about as well as what was meant; it wouldn't be crazy just to "fix" the whitespace.) Have you contacted Oliver?
I'm amazed that this error message is still useful so long after 1976. :o (Dennis Ritchie wrote that 1976 was when the ill-chosen "=+" and "=-" operators were renamed.)
OliverBr
Posts: 846
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: clang compiler

Post by OliverBr »

UncombedCoconut wrote:
micron wrote:Clang, but not gcc, gives a thought-provoking warning when compiling OliThink
http://home.arcor.de/dreamlike/chess/

Code: Select all

$ clang -O3 -flto olithink.c -o OliThink
olithink.c:1180:50: warning: use of unary operator that may be intended as compound assignment (-=)
        if (*sf == 1 && !(pieceb[PAWN] & colorb[c])) mn =- 200; //No mating material
                                                        ^~
Should that be mn = -200; or mn -= 200;?
Good catch! It's almost surely a bug, although I doubt it has a noticeable effect on playing strength. (What was written probably works about as well as what was meant; it wouldn't be crazy just to "fix" the whitespace.) Have you contacted Oliver?
I'm amazed that this error message is still useful so long after 1976. :o (Dennis Ritchie wrote that 1976 was when the ill-chosen "=+" and "=-" operators were renamed.)
To avoid the warning it should be: mn = -200.