Answers.Body: <p><strong>EDIT:</strong></p>
  <p>Few other points raised in <a href="http://web.archive.org/web/20201022142829/http://rybkaforum.net/cgi-bin/rybkaforum/topic_show.pl?tid=32317" rel="nofollow noreferrer">http://web.archive.org/web/20201022142829/http://rybkaforum.net/cgi-bin/rybkaforum/topic_show.pl?tid=32317</a></p>
  <ul>
  <li>GPU not so good for recursion</li>
  <li>GPU not so good for floating</li>
  <li>GPU might work better for new machine-learning approach, but not the traditional engine algorithms</li>
  </ul>
  <p><strong>Original</strong>:</p>
  <p>@Maxwell86 has already given excellent links and resources. Pay attention to the zeta-chess engine. It's a GPU chess engine. Unfortunately, GPU has not proven its usefulness in chess programming. In fact, the zeta chess engine project went absolutely nowhere.</p>
  <p>GPU works very well on floating calculations and algorithms that can be paralleled. This requires independence. But if we look at a typical min-max (or alpha-beta) tree (used by every chess engine )</p>
  <p><img src="https://i.sstatic.net/b1H5V.png" alt="enter image description here" /></p>
  <p>The right branch depends on the left branch. In particular, if we can get a cutoff (fail-high), we wouldn't even need to search the remaining nodes. Unfortunately, this is not something that a GPU can do efficiently. It's possible to write a GPU program for alpha-beta, but the GPU threads (known as kernels) will need to be paused to wait. Unlike a CPU, a GPU kennel can't just switch to something else ( a process known as thread-switch or even process-switch).</p>
  <p>Our existing algorithm and engine knowledge was derived for the CPU world. The entire algorithm would need to be reinvestigated for the GPU. Unfortunately, there is not much interest and research on it.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-22T14:56:26.977Z
Answers.Text: You don't have to offload the minimax itself. There are certain subtasks (e.g. Botvinnik's alpha path finding, board hashing, static evaluation, etc) which are very well suited for GPU. That said, I have no knowledge of any research in this area.
Answers.UserDisplayName: user58697
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-22T15:13:03.067Z
Answers.Text: True. But if the main search itself can't be offloaded, there should be no point to offload the small tasks.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-02-21T04:24:13.647Z
Answers.Text: @thb I completely disagree. The respondent thinks in terms of threaded programming, common thing on CPUs. For GPU programming every program must be split in small parallel algorithms. This guy probably never wrote any parallel algorithm if he says recursion is an obstacle for GPUs.  A simple sum can also be thought as a sequential process impossible to execute on GPUs, but there is a parallel scan, which accelerates sum on GPUs. If you are CPU-minded you are never going to get any benefits from GPUs. You need to switch your thinking into parallel.
Answers.UserDisplayName: Nulik
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-20T16:10:11.087Z
Answers.Text: When you say "floating", you mean "[floating *point*](https://en.wikipedia.org/wiki/Single-precision_floating-point_format)"?  As in, non-integer, that can represent numbers like 1.234.  GPUs can [do integer instructions (including bitwise)](https://stackoverflow.com/questions/4364879/integer-calculations-on-gpu), but often only 32-bit integers at a time, not great for chess where you want to shift 64-bit integer bit-boards.
Answers.UserDisplayName: Peter Cordes
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-07-20T01:40:16.583Z
Answers.LastActivityDate: 2021-10-04T07:21:13.677Z
Answers.LastEditDate: 2021-10-04T07:21:13.677Z
Answers.UserDisplayName: SmallChess
Answers.Body: <p>I have no experience with GPU programming, but, typically, GPUs are very efficient in executing simple commands in a parallel way. Apparently, this is not the case for the search tree that is used for chess engines. Therefore, the GPU loses its computational advantage over a CPU.</p>
  
  <p>Of course, this is the current state of GPU programming for chess engines, but GPU programming is relatively new, so maybe they'll find solutions for the current problems in the future.</p>
  
  <p>Here are a couple of interesting links, especially the blog about implementing a chess engine for GPU is quite insightful.</p>
  
  <ul>
  <li><a href="https://web.archive.org/web/20150821105749/http://zeta-chess.blogspot.com/" rel="nofollow">https://web.archive.org/web/20150821105749/http://zeta-chess.blogspot.com/</a> </li>
  <li><a href="https://chessprogramming.wikispaces.com/GPU" rel="nofollow">https://chessprogramming.wikispaces.com/GPU</a></li>
  <li><a href="https://chessgpgpu.blogspot.be/" rel="nofollow">https://chessgpgpu.blogspot.be/</a></li>
  <li><a href="https://chessgpgpu.blogspot.be/2013/01/what-is-goal.html" rel="nofollow">https://chessgpgpu.blogspot.be/2013/01/what-is-goal.html</a></li>
  <li><a href="https://chessgpgpu.blogspot.be/2013/01/existing-parallel-search-algorithms.html" rel="nofollow">https://chessgpgpu.blogspot.be/2013/01/existing-parallel-search-algorithms.html</a></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-19T12:10:19.853Z
Answers.Text: You've missed: http://zeta-chess.blogspot.com
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-19T16:57:28.917Z
Answers.Text: Things GPUs are good at include fractional math, vector operations, and parallelization requiring minimal synchronization. Chess engines have the last one but not the first two.
Answers.UserDisplayName: intx13
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-19T09:15:01.700Z
Answers.LastActivityDate: 2016-06-10T16:53:16.213Z
Answers.LastEditDate: 2016-06-10T16:53:16.213Z
Answers.UserDisplayName: Maxwell86
Answers.Body: <p>The LC0 (Leela Chess Zero) project,
  an open source adaption of AlphaZero for chess, 
  shows the benefit of gpus, 
  floating point performance and memory bandwidth used in large neural networks.</p>
  
  <p><a href="http://lczero.org/" rel="noreferrer">http://lczero.org/</a></p>
  
  <p><a href="https://en.wikipedia.org/wiki/AlphaZero" rel="noreferrer">https://en.wikipedia.org/wiki/AlphaZero</a></p>
  
  <p><a href="https://groups.google.com/forum/#!forum/lczero" rel="noreferrer">https://groups.google.com/forum/#!forum/lczero</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-04-24T10:03:02.253Z
Answers.LastActivityDate: 2018-04-24T10:03:02.253Z
Answers.UserDisplayName: fishy123
Answers.Body: <p>I finished my current run on Zeta v099a, my experimental gpu chess engine.</p>
  
  <p><a href="https://github.com/smatovic/Zeta" rel="nofollow noreferrer">https://github.com/smatovic/Zeta</a></p>
  
  <p>The actual conclusion of the current iteration is, that an simple engine, with
  standard chess programming techniques, can be ported to OpenCL to run on a gpu,
  but it would take more effort to make the engine competitive in terms of 
  computed nodes per second (speed), heuristics (expert knowledge), 
  and scaling (parallel search algorithm). </p>
  
  <p>Computer Chess, as an computer science topic, evolved over decades,
  starting in the 40s and 50s, and reached one peak 1997 with the match Deep
  Blue vs. Kapsarow. Nowadays chess engines are tuned by playing thousands
  and thousands of games, so to get an chess playing engine running on the gpu 
  and to get an competitive chess playing engine running on the gpu are 
  two different tasks.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-22T10:48:26.910Z
Answers.LastActivityDate: 2017-04-22T15:11:04.457Z
Answers.LastEditDate: 2017-04-22T15:11:04.457Z
Answers.UserDisplayName: smatovic
Answers.Body: <p>I've some experience with CUDA and chess programming (not engine programming). This question also came to my mind many times. Here is my opinion, I never studied this.</p>
  
  <p>Well, first, it is virtually certain that with current design of chess engines it's impossible. Otherwise someone would simply do it.</p>
  
  <p>Whether you could use it in completely new design, that's a bigger question. There's no problem with integer operations, but clearly there is huge thing that you must run primitive code with no serious branching on many of entities.</p>
  
  <p>In my opinion all the tree calculations should run on CPU.</p>
  
  <p>But I can imagine (I don't say it's possible) some partial evaluation function(s) that just make as much evaluations on positions as possible, to give CPU more time, to help him build the tree in a better way, lets say one such function could calculate how serious calculation should be made on each position.</p>
  
  <p>You can calculate number of squares attacked, pieces attacked, firepower around kings and in some subregions on board, pawn structure related things, you could probably make GPU optimised code for these. You can probably get a lot of useful informations for free (no CPU time, no CPU waiting), but you would have to be real genius to use full horsepower of modern GPUs for such small things.</p>
  
  <p>It is probably not very interesting thing to do to create completely new design of engines to get let's say 30% extra speed. And to get let's say 20x speedup on state of the art GPUs, you would have to make evaluation functions really alien.</p>
  
  <p>And last thing on this what I see to be a problem. You can run one code on CPU with not many thinking, but in CPU+GPU scenario you would have to deal with really different ratios of CPU and GPU. speeds and core counts. You would need different code for 16 cores cluster with weak GPU than on slow CPU with super fast GPU to use full capabilities of hardware. Benchmarking CPU vs. GPU and then running more code on the faster machine would be desirable. But still, I think you will get nowhere close to feeding 3000 cores beast just with evaluation function(s).</p>
  
  <p>Edit: Just to make things clear, CPU would regularly send GPU arrays of positions to make partial evaluations. Maybe that wasn't clear from what I wrote.</p>
  
  <p>Many problems to make this work.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-22T17:17:58.653Z
Answers.LastActivityDate: 2016-11-22T17:24:43.703Z
Answers.LastEditDate: 2016-11-22T17:24:43.703Z
Answers.UserDisplayName: hoacin
Answers.Body: <p>I see only benefits in using a GPU based chess engine and don't see any serious problems doing that. Maybe you have that issues try using a standard chess program, don't know much about the others. I just start up to write a chess programm from the first line on, as a second CUDA based program after I make some first programming tests on CUDA without specific sence. 
  Soon I can make some first performance tests and test games against other engines. Maybe during next week. I just start creating it but I'm already close finish it and most functions already finished.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-05T14:20:24.553Z
Answers.Text: Google has proven GPU ideal for machine learning but GPU is not good for traditional chess programming.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-04T18:21:46.100Z
Answers.LastActivityDate: 2018-05-04T20:00:35.617Z
Answers.LastEditDate: 2018-05-04T20:00:35.617Z
Answers.UserDisplayName: Rayjunx
Body: <p>GPUs are better at certain types of calculations, e.g. generating bitcoins and performing climate simulations.</p>
  
  <p>Would chess engines benefit if they calculated with GPUs instead of CPUs?</p>
  
  <p>Maybe some knowledgeable person can highlight the differences between the two and enlighten us as to whether GPUs are (un)suitable for the type of calculations that chess engines execute.</p>
  
Tags: <engines><calculation>
Title: CPU v. GPU for chess engines
ThreadText: # CPU v. GPU for chess engines
  
  (Asked by: username_0 on 2015-07-18)
  
  GPUs are better at certain types of calculations, e.g. generating bitcoins and performing climate simulations.
  
  Would chess engines benefit if they calculated with GPUs instead of CPUs?
  
  Maybe some knowledgeable person can highlight the differences between the two and enlighten us as to whether GPUs are (un)suitable for the type of calculations that chess engines execute.
  
  **Tags:** engines, calculation
  
  
  ---
  
  ## 6 answers
  
  ### Answer by username_1 on 2015-07-20. Score: 15
  
  **EDIT:**
  
  Few other points raised in <http://web.archive.org/web/20201022142829/http://rybkaforum.net/cgi-bin/rybkaforum/topic_show.pl?tid=32317>
  
  * GPU not so good for recursion
  * GPU not so good for floating
  * GPU might work better for new machine-learning approach, but not the traditional engine algorithms
  
  **Original**:
  
  @username_5 has already given excellent links and resources. Pay attention to the zeta-chess engine. It's a GPU chess engine. Unfortunately, GPU has not proven its usefulness in chess programming. In fact, the zeta chess engine project went absolutely nowhere.
  
  GPU works very well on floating calculations and algorithms that can be paralleled. This requires independence. But if we look at a typical min-max (or alpha-beta) tree (used by every chess engine )
  
  ![enter image description here](https://i.sstatic.net/b1H5V.png)
  
  The right branch depends on the left branch. In particular, if we can get a cutoff (fail-high), we wouldn't even need to search the remaining nodes. Unfortunately, this is not something that a GPU can do efficiently. It's possible to write a GPU program for alpha-beta, but the GPU threads (known as kernels) will need to be paused to wait. Unlike a CPU, a GPU kennel can't just switch to something else ( a process known as thread-switch or even process-switch).
  
  Our existing algorithm and engine knowledge was derived for the CPU world. The entire algorithm would need to be reinvestigated for the GPU. Unfortunately, there is not much interest and research on it.
  
  > **Comments:**
  > **username_2**: You don't have to offload the minimax itself. There are certain subtasks (e.g. Botvinnik's alpha path finding, board hashing, static evaluation, etc) which are very well suited for GPU. That said, I have no knowledge of any research in this area.  
  > **username_1**: True. But if the main search itself can't be offloaded, there should be no point to offload the small tasks.  
  > **username_3**: @thb I completely disagree. The respondent thinks in terms of threaded programming, common thing on CPUs. For GPU programming every program must be split in small parallel algorithms. This guy probably never wrote any parallel algorithm if he says recursion is an obstacle for GPUs.  A simple sum can also be thought as a sequential process impossible to execute on GPUs, but there is a parallel scan, which accelerates sum on GPUs. If you are CPU-minded you are never going to get any benefits from GPUs. You need to switch your thinking into parallel.  
  > **username_4**: When you say "floating", you mean "[floating *point*](https://en.wikipedia.org/wiki/Single-precision_floating-point_format)"?  As in, non-integer, that can represent numbers like 1.234.  GPUs can [do integer instructions (including bitwise)](https://stackoverflow.com/questions/4364879/integer-calculations-on-gpu), but often only 32-bit integers at a time, not great for chess where you want to shift 64-bit integer bit-boards.  
  
  ---
  
  ### Answer by username_5 on 2015-07-19. Score: 7
  
  I have no experience with GPU programming, but, typically, GPUs are very efficient in executing simple commands in a parallel way. Apparently, this is not the case for the search tree that is used for chess engines. Therefore, the GPU loses its computational advantage over a CPU.
  
  Of course, this is the current state of GPU programming for chess engines, but GPU programming is relatively new, so maybe they'll find solutions for the current problems in the future.
  
  Here are a couple of interesting links, especially the blog about implementing a chess engine for GPU is quite insightful.
  
  * <https://web.archive.org/web/20150821105749/http://zeta-chess.blogspot.com/>
  * <https://chessprogramming.wikispaces.com/GPU>
  * <https://chessgpgpu.blogspot.be/>
  * <https://chessgpgpu.blogspot.be/2013/01/what-is-goal.html>
  * <https://chessgpgpu.blogspot.be/2013/01/existing-parallel-search-algorithms.html>
  
  > **Comments:**
  > **username_1**: You've missed: http://zeta-chess.blogspot.com  
  > **username_6**: Things GPUs are good at include fractional math, vector operations, and parallelization requiring minimal synchronization. Chess engines have the last one but not the first two.  
  
  ---
  
  ### Answer by username_7 on 2018-04-24. Score: 5
  
  The LC0 (Leela Chess Zero) project,
  an open source adaption of AlphaZero for chess,
  shows the benefit of gpus,
  floating point performance and memory bandwidth used in large neural networks.
  
  <http://lczero.org/>
  
  <https://en.wikipedia.org/wiki/AlphaZero>
  
  <https://groups.google.com/forum/#!forum/lczero>
  
  
  ---
  
  ### Answer by username_8 on 2017-04-22. Score: 4
  
  I finished my current run on Zeta v099a, my experimental gpu chess engine.
  
  <https://github.com/username_8/Zeta>
  
  The actual conclusion of the current iteration is, that an simple engine, with
  standard chess programming techniques, can be ported to OpenCL to run on a gpu,
  but it would take more effort to make the engine competitive in terms of
  computed nodes per second (speed), heuristics (expert knowledge),
  and scaling (parallel search algorithm).
  
  Computer Chess, as an computer science topic, evolved over decades,
  starting in the 40s and 50s, and reached one peak 1997 with the match Deep
  Blue vs. Kapsarow. Nowadays chess engines are tuned by playing thousands
  and thousands of games, so to get an chess playing engine running on the gpu
  and to get an competitive chess playing engine running on the gpu are
  two different tasks.
  
  
  ---
  
  ### Answer by username_9 on 2016-11-22. Score: 1
  
  I've some experience with CUDA and chess programming (not engine programming). This question also came to my mind many times. Here is my opinion, I never studied this.
  
  Well, first, it is virtually certain that with current design of chess engines it's impossible. Otherwise someone would simply do it.
  
  Whether you could use it in completely new design, that's a bigger question. There's no problem with integer operations, but clearly there is huge thing that you must run primitive code with no serious branching on many of entities.
  
  In my opinion all the tree calculations should run on CPU.
  
  But I can imagine (I don't say it's possible) some partial evaluation function(s) that just make as much evaluations on positions as possible, to give CPU more time, to help him build the tree in a better way, lets say one such function could calculate how serious calculation should be made on each position.
  
  You can calculate number of squares attacked, pieces attacked, firepower around kings and in some subregions on board, pawn structure related things, you could probably make GPU optimised code for these. You can probably get a lot of useful informations for free (no CPU time, no CPU waiting), but you would have to be real genius to use full horsepower of modern GPUs for such small things.
  
  It is probably not very interesting thing to do to create completely new design of engines to get let's say 30% extra speed. And to get let's say 20x speedup on state of the art GPUs, you would have to make evaluation functions really alien.
  
  And last thing on this what I see to be a problem. You can run one code on CPU with not many thinking, but in CPU+GPU scenario you would have to deal with really different ratios of CPU and GPU. speeds and core counts. You would need different code for 16 cores cluster with weak GPU than on slow CPU with super fast GPU to use full capabilities of hardware. Benchmarking CPU vs. GPU and then running more code on the faster machine would be desirable. But still, I think you will get nowhere close to feeding 3000 cores beast just with evaluation function(s).
  
  Edit: Just to make things clear, CPU would regularly send GPU arrays of positions to make partial evaluations. Maybe that wasn't clear from what I wrote.
  
  Many problems to make this work.
  
  
  ---
  
  ### Answer by username_10 on 2018-05-04. Score: 0
  
  I see only benefits in using a GPU based chess engine and don't see any serious problems doing that. Maybe you have that issues try using a standard chess program, don't know much about the others. I just start up to write a chess programm from the first line on, as a second CUDA based program after I make some first programming tests on CUDA without specific sence.
  Soon I can make some first performance tests and test games against other engines. Maybe during next week. I just start creating it but I'm already close finish it and most functions already finished.
  
  > **Comments:**
  > **username_1**: Google has proven GPU ideal for machine learning but GPU is not good for traditional chess programming.  
  
  ---
  
  