digitalmars.D.announce - amoeba, a chess engine written in D
- Richard Delorme (9/9) May 20 2016 I am pleased to announce the release of a chess engine written in
- extrawurst (14/23) May 20 2016 That is awesome!
- Richard Delorme (23/33) May 21 2016 Yes, It is a strong program, but far from the top programs yet.
- Abdulhaq (4/14) May 22 2016 Congratulations 2700 is great, vastly better than I managed many
- Richard Delorme (8/9) May 22 2016 Yes, but I do not expect to make it as strong as stockfish.
- Johan Engelen (5/7) May 21 2016 Can you give cmdline details and compiler version data for this?
- Iain Buclaw via Digitalmars-d-announce (3/10) May 21 2016 I think he meant that ldc or gdc is twice as fast.
- Richard Delorme (33/39) May 21 2016 I used the following compiler versions,
- Johan Engelen (4/7) May 22 2016 With LDC, you can pass "-mattr=+popcnt" to use the popcount
- Johan Engelen (7/10) May 21 2016 In the makefile, I see you tried LDC's PGO, awesome! I hope to
- John Colvin (5/14) May 22 2016 LDC might benefit from copying the _popcnt source from ldc's
- Richard Delorme (11/15) May 22 2016 Thank you for those advices.
- David Nadlinger (13/14) May 22 2016 It changes compiler behaviour – only a single object file is
- David Nadlinger (11/13) May 22 2016 Allowing LDC to do cross-module optimisations (by adding the
- Andrei Alexandrescu (5/12) May 23 2016 https://www.reddit.com/r/programming/comments/4koi8q/amoeba_a_chess_engi...
I am pleased to announce the release of a chess engine written in D: https://github.com/abulmo/amoeba I am not aware of any other chess engine written with the D language. The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster). This is my first program using the D language (I am a former C programmer), and I enjoyed it a lot.
May 20 2016
On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:I am pleased to announce the release of a chess engine written in D: https://github.com/abulmo/amoeba I am not aware of any other chess engine written with the D language. The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster). This is my first program using the D language (I am a former C programmer), and I enjoyed it a lot.That is awesome! Two questions: 1) If it is using UCI protocol I guess there are other engines that you can compare amoeba with when it comes to performance and other aspects, did you ? 2) It would be awesome if you could write down how it was to use D for that project as someone freshly coming from C. What were the reasons you chose D, what did you like, what did u hate ? That would help you being read on reddit by a hundred blood thursty devs (street cred and all) and us for knowing what we can improve and also get the PR :) Cheers, Stephan
May 20 2016
On Saturday, 21 May 2016 at 00:29:13 UTC, extrawurst wrote:Two questions: 1) If it is using UCI protocol I guess there are other engines that you can compare amoeba with when it comes to performance and other aspects, did you ?Yes, It is a strong program, but far from the top programs yet. In the ccrl scale: http://www.computerchess.org.uk/ccrl/4040/ I guess its rating is close to 2700. The move generator is pretty fast, though: $ amoeba-linux-x64-sse4.2 perft -d 7 perft 7 : 3195901860 leaves in 17.920 s 178344094 leaves/s In comparison, stockfish 7, one of the strongest chess program in C++: $ stockfish-7 perft 7 [...] Total time (ms) : 16669 Nodes searched : 3195901860 Nodes/second : 191727269 So my implementation of a different algorithm in D is only 7% slower at generating moves, which is negligible in the overall program.2) It would be awesome if you could write down how it was to use D for that project as someone freshly coming from C. What were the reasons you chose D, what did you like, what did u hate ? That would help you being read on reddit by a hundred blood thursty devs (street cred and all) and us for knowing what we can improve and also get the PR :)Good idea, I will try to write something clever and constructive within the next days. -- Richard
May 21 2016
On Saturday, 21 May 2016 at 10:10:21 UTC, Richard Delorme wrote:On Saturday, 21 May 2016 at 00:29:13 UTC, extrawurst wrote:Congratulations 2700 is great, vastly better than I managed many years ago. Do you plan to take it further?[...]Yes, It is a strong program, but far from the top programs yet. In the ccrl scale: http://www.computerchess.org.uk/ccrl/4040/ I guess its rating is close to 2700. The move generator is pretty fast, though: $ amoeba-linux-x64-sse4.2 perft -d 7 perft 7 : 3195901860 leaves in 17.920 s 178344094 leaves/s [...]
May 22 2016
On Sunday, 22 May 2016 at 15:48:13 UTC, Abdulhaq wrote:Do you plan to take it further?Yes, but I do not expect to make it as strong as stockfish. 100 elo above the present level by the end of this year will be great. I have ideas for improving the evaluation function, many things to tune, test or retest in the search. -- Richard
May 22 2016
On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster).Can you give cmdline details and compiler version data for this? (how much faster is gdc relative to ldc?) Thanks, Johan
May 21 2016
On 21 May 2016 at 10:23, Johan Engelen via Digitalmars-d-announce <digitalmars-d-announce puremagic.com> wrote:On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:I think he meant that ldc or gdc is twice as fast.The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster).Can you give cmdline details and compiler version data for this? (how much faster is gdc relative to ldc?)
May 21 2016
On Saturday, 21 May 2016 at 08:23:59 UTC, Johan Engelen wrote:On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:I used the following compiler versions, dmd: DMD64 D Compiler v2.071.0 ldc: 0.17.0-beta2 (DMD v2.068.2, LLVM 3.7.1) gdc: gcc version 5.2.0 (crosstool-NG 203be35 - 20160205-2.066.1-e95a735b97) to compile, you can use the following commands: $ DC=ldc2 make amoeba (to compile with ldc) $ DC=dmd make amoeba (to compile with dmd) $ DC=gdc make amoeba (to compile with gdc) $ make amoeba (use gdc by default) $ make pgo (for profile guided optimization), $ make pgo BUILD=popcount (to use the CPU popcnt instruction) With the above versions & my poor knowledge of the compilers, pgo & BUILD=popcount only worked with gdc. I will try to upgrade to more recent versions to see if things changed. to test the speed , you can do: amoeba bench -f bk.epd -d 14 Here is what I get on my computer (an old i7 2600k at 4Ghz): dmd: 24 positions 29981105 nodes in 20.000s : 1499024 nps, depth = 13.71 ldc2: 24 positions 29981105 nodes in 18.340s : 1634711 nps, depth = 13.71 gdc: 24 positions 29981105 nodes in 12.005s : 2497388 nps, depth = 13.71 gdc+pgo: 24 positions 29981105 nodes in 10.224s : 2932328 nps, depth = 13.71 * gdc used the BUILD=popcount options. without, it is slower, doing the test in 15.4. & 13.6 s., respectively for gdc & gdc + pgo. So gdc benefits a lot from both pgo and using the popcnt instruction. -- RichardThe source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster).Can you give cmdline details and compiler version data for this? (how much faster is gdc relative to ldc?)
May 21 2016
On Saturday, 21 May 2016 at 16:25:27 UTC, Richard Delorme wrote:With the above versions & my poor knowledge of the compilers, pgo & BUILD=popcount only worked with gdc. I will try to upgrade to more recent versions to see if things changed.With LDC, you can pass "-mattr=+popcnt" to use the popcount instruction. Or "-mattr=+sse42" to enable SSE4.2 (like you seem to do in the Makefile).
May 22 2016
On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:I am pleased to announce the release of a chess engine written in D: https://github.com/abulmo/amoebaIn the makefile, I see you tried LDC's PGO, awesome! I hope to get (part of) it into LDC master very soon. All feedback is very welcome. (small typo: better use ldc-profdata instead of llvm-profdata) cheers, Johan
May 21 2016
On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:I am pleased to announce the release of a chess engine written in D: https://github.com/abulmo/amoeba I am not aware of any other chess engine written with the D language. The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster). This is my first program using the D language (I am a former C programmer), and I enjoyed it a lot.LDC might benefit from copying the _popcnt source from ldc's druntime in to your code as it has a problem inlining it from druntime. You might also see a benefit from the -single-obj flag (enabled by default in ldmd).
May 22 2016
On Sunday, 22 May 2016 at 11:20:44 UTC, John Colvin wrote:LDC might benefit from copying the _popcnt source from ldc's druntime in to your code as it has a problem inlining it from druntime. You might also see a benefit from the -single-obj flag (enabled by default in ldmd).Thank you for those advices. I succeeded to have popcnt in the LCD build, (using llvm_ctpop). -singleobj looks like a good idea too. for the above test: original: 18.7 s with popcnt & singleobj: 11.1s. LDC is now close to GDC in performance. A question: why singleobj is not activated by a -Ox options? -- Richard
May 22 2016
On Sunday, 22 May 2016 at 21:22:30 UTC, Richard Delorme wrote:A question: why singleobj is not activated by a -Ox options?It changes compiler behaviour – only a single object file is produced. Historically, the default behaviour was used by some people/build systems for incremental compilation. However, since incremental compilation only works when exactly the same (sub)sets of commands are invoked every time these days, -singleobj should arguably be on by default, at least when producing an executable. This is actually what ldmd2 does already, but we should probably take the plunge and break backwards compatibility to enable it for the main driver too. I can't think of a scenario where you wouldn't want to be using it. — David
May 22 2016
On Friday, 20 May 2016 at 23:16:01 UTC, Richard Delorme wrote:The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster).Allowing LDC to do cross-module optimisations (by adding the -singleobj flag) and make use of popcnt increased the performance by 47% for one specific benchmark, which should bring it into the same ballpark as GDC. See https://github.com/abulmo/amoeba/pull/2 for more details. PGO might still give the latter a bit of an edge, though, as LDC's implementation is still experimental and there is a lot of unused potential for making use of the profile data in LLVM's optimiser. — David
May 22 2016
On 05/20/2016 07:16 PM, Richard Delorme wrote:I am pleased to announce the release of a chess engine written in D: https://github.com/abulmo/amoeba I am not aware of any other chess engine written with the D language. The source can be compiled with dmd, ldc or gdc, but the best performance are obtained with the latter (almost twice faster). This is my first program using the D language (I am a former C programmer), and I enjoyed it a lot.https://www.reddit.com/r/programming/comments/4koi8q/amoeba_a_chess_engine_written_in_d/ https://www.facebook.com/dlang.org/posts/1302718359741842 https://twitter.com/D_Programming/status/734769561518510081 Andrei
May 23 2016