ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Senpai 2.0
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: General Topics Flat
View previous topic :: View next topic  
Author Message
Lucas Braesch



Joined: 31 May 2010
Posts: 2919

PostPost subject: Re: Senpai 2.0    Posted: Sat Nov 11, 2017 12:53 pm Reply to topic Reply with quote

lucasart wrote:
Xann wrote:
lucasart wrote:
What I can say regarding compilation is:
* indeed gcc is significantly slower than clang, which is very unusual (normally it's the other way around). I discovered a gcc bug recently, perhaps it's the same. ...

No bug. I think it's LTO, more precisely cross-module inlining.

Here's what happened. During the development of my draughts program Scan, I discovered Clang's -flto. For the first time ever, I could move "critical" code from the include files to where they belong: with related functions. And not lose performance, or very little (at least with Clang/LLVM). Having code in the include files also triggers a lot of useless recompilation during development. By contrast, the cost of LTO is slower linking; something I can live with. During the release, I moved a selected set back to the include files. It took some time in itself, and is not fun at all. I also couldn't do profiling on my machine, so a lot of guesswork was needed. At least, I still remembered which functions used to be there.

But since then, I've been used to not thinking about it anymore. After all it's the compiler's job to inline functions, regardless of their placement in the source code. The Senpai 2 release was already taking a lot of time and, among other things, I skipped the "manual inlining" step.

GCC most likely has vastly inferior inlining ability than LLVM, perhaps due to its design at a time when separate compilation was a must. Thinking about it, the Windows compilers might have similar shortcomings. So it's not a bug, and it's also partly my fault. The question is, do we do something about it?

Totally agree with you regarding inlining. I never use the word "inline" in my code. I simply declare (externally linked) functions in headers, and implement them in source files, even the most trivial functions. And I rely on LTO to make the magic happen (code generating is done while linking, allowing cross module optimization, including inlining). But I use GCC and it works perfectly. Last I checked, my code compiles to a slower executable with Clang compared to GCC.

But then my code is in C, yours is in C++. And with C++ (at least the way you use it) come lots of do nothing wrappers, making performance more sensitive to LTO inlining capacity. Perhaps that's why.

I tried again with a recent Clang, and confirm your finding. Indeed Clang produces faster compiles than GCC (by 4.5%) on my code (which relies heavily on cross-module inlining, making zero use of "static inline" implementation of function in header files).
_________________
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Subject Author Date/Time
Senpai 2.0 Fabien Letouzey Fri Nov 10, 2017 6:07 am
      Re: Senpai 2.0 Dann Corbit Fri Nov 10, 2017 6:20 am
      Re: Senpai 2.0 Brendan J. Norman Fri Nov 10, 2017 6:30 am
            Re: Senpai 2.0 Frank Quisinsky Fri Nov 10, 2017 6:36 am
                  Re: Senpai 2.0 Michael B Fri Nov 10, 2017 6:42 am
                  Re: Senpai 2.0 Brendan J. Norman Sat Nov 11, 2017 3:58 pm
                        Re: Senpai 2.0 ... BTW: Wasp (other things). Frank Quisinsky Sat Nov 11, 2017 5:23 pm
      Re: Senpai 2.0 Evert Glebbeek Fri Nov 10, 2017 6:43 am
            Re: Senpai 2.0 Fabien Letouzey Fri Nov 10, 2017 6:53 am
                  Re: Senpai 2.0 Evert Glebbeek Fri Nov 10, 2017 9:17 am
      Re: Senpai 2.0 Guenther Simon Fri Nov 10, 2017 7:29 am
            Re: Senpai 2.0 Guenther Simon Fri Nov 10, 2017 1:08 pm
                  Re: Senpai 2.0 Fabien Letouzey Fri Nov 10, 2017 1:44 pm
                        Re: Senpai 2.0 Marek Soszynski Fri Nov 10, 2017 3:35 pm
      Re: Senpai 2.0 Gabor Szots Fri Nov 10, 2017 7:41 am
      Re: Senpai 2.0 Gabor Szots Fri Nov 10, 2017 7:51 am
      Re: Senpai 2.0 Michel Van den Bergh Fri Nov 10, 2017 9:34 am
      Re: Senpai 2.0 Bigler Fri Nov 10, 2017 9:39 am
      Re: Senpai 2.0 Volker Pittlik Fri Nov 10, 2017 12:43 pm
      Re: Senpai 2.0 Lucas Braesch Fri Nov 10, 2017 1:02 pm
            Re: Senpai 2.0 Fabien Letouzey Sat Nov 11, 2017 3:58 am
                  Re: Senpai 2.0 Lucas Braesch Sat Nov 11, 2017 6:37 am
                        Re: Senpai 2.0 Lucas Braesch Sat Nov 11, 2017 12:53 pm
                              Re: Senpai 2.0 Rein Halbersma Mon Nov 13, 2017 10:40 pm
                        Re: Senpai 2.0 Rasmus Althoff Tue Nov 14, 2017 12:05 am
      Re: Senpai 2.0 Tamás Kuzmics Fri Nov 10, 2017 2:05 pm
      Re: Senpai 2.0 Brendan J. Norman Fri Nov 10, 2017 2:47 pm
      Re: Senpai 2.0 Carl Langan Fri Nov 10, 2017 10:13 pm
      Re: Senpai 2.0 fernando Sat Nov 11, 2017 5:51 pm
            Re: Senpai 2.0 Tony Mokonen Tue Nov 14, 2017 4:06 am
                  Re: Senpai 2.0 Guenther Simon Tue Nov 14, 2017 6:39 am
                        Re: Senpai 2.0 Tony Mokonen Tue Nov 14, 2017 10:41 pm
                              Re: Senpai 2.0 Guenther Simon Wed Nov 15, 2017 1:28 pm
                              Re: Senpai 2.0 alexei chernakoff Fri Nov 17, 2017 8:04 am
                                    Re: Senpai 2.0 Fabien Letouzey Fri Nov 17, 2017 11:59 am
                                          Re: Senpai 2.0 alexei chernakoff Fri Nov 17, 2017 12:16 pm
                              Re: Senpai 2.0 Ernest Bonnem Fri Nov 17, 2017 6:24 pm
                                    Re: Senpai 2.0 Guenther Simon Fri Nov 17, 2017 6:55 pm
                                          Re: Senpai 2.0 Tony Mokonen Fri Nov 17, 2017 7:03 pm
                                                Re: Senpai 2.0 Steve Maughan Fri Nov 17, 2017 7:13 pm
                                                Re: Senpai 2.0 Ernest Bonnem Fri Nov 17, 2017 7:24 pm
                                                      Re: Senpai 2.0 Guenther Simon Fri Nov 17, 2017 7:30 pm
                  Re: Senpai 2.0 fernando Wed Nov 15, 2017 3:19 am
                  Re: Senpai 2.0 -32-bit compile - Tahank you !! Ruxy Sylwyka Wed Nov 15, 2017 8:52 pm
      Re: Senpai 2.0 Peter Berger Mon Nov 13, 2017 10:23 pm
            Re: Senpai 2.0 Eelco de Groot Mon Nov 13, 2017 11:57 pm
      Re: Senpai 2.0 Tony Soares Mon Nov 13, 2017 11:44 pm
      Re: Senpai 2.0 Ryan Benitez Sat Nov 25, 2017 5:14 am
            Re: Senpai 2.0 Fabien Letouzey Sat Nov 25, 2017 5:49 am
                  Re: Senpai 2.0 T. Poppins Sat Nov 25, 2017 8:21 am
                        Re: Senpai 2.0 Guenther Simon Sat Nov 25, 2017 9:07 am
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: General Topics

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads