Home * Programming * Thread
Two threads on a single processor [1]
A Thread is the smallest unit of processing that can be scheduled by an operating system. One or multiple threads can exist within the same process to share its resources such as memory. Modern operating systems support both time-sliced and multiprocessor threading within a process scheduler. Some operating systems such as Windows distinguish worker threads from GUI-threads, which incorporate a message loop, able to receive messages from worker threads. Threads share global data of the process, but use disjoint stacks for local variables.
Chess programs using threads for a parallel search have to deal with synchronization issues, if multiple threads read and write none atomic global data simultaneously, requiring multiple read and/or write cycles. A good step to make a program thread safe, is to avoid global variables and to keep board and game states as locals on the stack. To minimize context switching, chess programs often implement a thread pooling pattern along with explicitly or implicitly controlling processor affinity, where the number of threads of the chess program is less or equal to the number of physical processor cores. Threads are further versatile to control standard input inside an engine.
See also
Publications
1994 ...
- Michael Halbherr, Yuli Zhou, Chris Joerg (1994). MIMD-Style Parallel Programming with Continuation-Passing Threads. Proceedings of the 2nd International Workshop on Massive Parallelism: Hardware, Software, and Applications
- Robert Blumofe (1995). Executing Multithreaded Programs Efficiently. Ph.D. thesis, MIT, pdf
- Robert Blumofe, Chris Joerg, Bradley Kuszmaul, Charles Leiserson, Keith H. Randall, Yuli Zhou (1995). Cilk: An Efficient Multithreaded Runtime System. Proceedings of the Fifth ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP), pdf » Cilk
- Yaoqing Gao, Tony Marsland (1996). Multithreaded Pruned Tree Search in Distributed Systems. Journal of Computing and Information, 2(1), 482-492, pdf
- Charles Leiserson, Harald Prokop (1998). A Minicourse on Multithreaded Programming. pdf
2000 ...
2010 ...
- Subhash Saini, Haoqiang Jin, Robert Hood, David Barker, Piyush Mehrotra, Rupak Biswas (2011). The Impact of Hyper-Threading on Processor Resource Utilization in Production Applications. NASA Advanced Supercomputing Division, pdf, pdf [2]
- Anthony Williams (2012). C++ Concurrency in Action: Practical Multithreading. [3]
- Georg Hager [4], Jan Treibig, Gerhard Wellein (2013). The Practitioner's Cookbook for Good Parallel Performance on Multi- and Many-Core Systems. RRZE, SC13, slides as pdf
Forum Posts
1999
2000 ...
- Re: Stormx is this a Crafty Clone?? by Sean Empey, CCC, May 25, 2004 » Windows
- Approaches to threading by Eric Oldre, CCC, June 15, 2004
- Kiwi for Win98 and input-reading stuff by Alessandro Scotti, CCC, September 29, 2004 » Kiwi, Windows, C++
2005 ...
- POSIX threads by Steven Edwards, CCC, July 05, 2005
- Threading issue under Polyglot by Nathan Thom, Winboard Forum, September 18, 2006 » PolyGlot
- pthread weirdness by James Swafford, CCC, May 29, 2007
- multithreading questions by Martin Fierz, CCC, August 08, 2007
- Threads and cores questions by Casey, CCC, September 07, 2007
- threads vs processes by Robert Hyatt, CCC, July 16, 2008
- threads vs processes again by Robert Hyatt, CCC, August 05, 2008
- Hyperthreading Hype predates Intel by Steven Edwards, CCC, February 07, 2009
- Multithreaded movepath enumeration (perft) by Steven Edwards, CCC, February 27, 2009
- kbhit() taking huge CPU?? by John Merlino, CCC, April 01, 2009 » C
2010 ...
- Stockfish-1.7.0 Hyper-threading Detection by Louis Zulli, CCC, April 09, 2010
- Hyperthreading by Gerd Isenberg, CCC, September 17, 2010
- To hyperthread or not to hyperthread (Crafty tested) by Martin Thoresen, CCC, October 24, 2010 » Crafty
- Input / ThinkingThreads by Richard Allbert, CCC, November 08, 2010
- Thread management / organization in parallel processing? by Nguyen Pham, CCC, December 06, 2010
2011
2012
2013
- Multi-threaded memory access by ThinkingALot, OpenChess Forum, February 10, 2013 » Memory, Shared Hash Table
- Hyperthreading and Computer Chess: Intel i5-3210M by Mike Scheidl, CCC, April 12, 2013
- Implementation of multithreaded search in Jazz by Evert Glebbeek, CCC, April 20, 2013 » Parallel Search, Jazz
- use sleeping threads by Don Dailey, CCC, July 10, 2013 » Stockfish
- C++ Question by Ted Wong, CCC, July 30, 2013 » C++
- Writing to a Text File (Thread Safe) by Steve Maughan, CCC, August 10, 2013 » Logging
- SMP and Thread Pool Design pattern by Edsel Apostol, CCC, October 02, 2013
- Multithreaded LRU by Alvaro Cardoso, CCC, October 06, 2013 » Memory, Endgame Tablebases
2014
- C++11 threads seem to get shafted for cycles by User923005, OpenChess Forum, March 18, 2014 » C++, Parallel Search, Senpai
- Threads-Test by Andreas Strangmüller, CCC, March 18, 2014 » Parallel Search, Stockfish
- Threads-Test - SF, Zappa, Komodo - 1 vs. 2, 4, 8, 16 Threads by Andreas Strangmüller, CCC, May 04, 2014 » Stockfish, Zappa, Komodo
- Threads factor: Komodo, Houdini, Stockfish and Zappa by Andreas Strangmüller, CCC, May 17, 2014 » Komodo, Houdini, Stockfish, Zappa
- TinyThread++ by Alberto Sanjuan, CCC, July 24, 2014 [5]
- Best way to handle input thread by Stefano Gemma, CCC, August 09, 2014
- (Why) Is hyperthreading bad for chess engines? by Syed Fahad, CCC, September 23, 2014
- Threads test incl. Stockfish 5 and Komodo 8 by Andreas Strangmüller, CCC, October 09, 2014
- Threads test - Stockfish 5 against Komodo 8 by Andreas Strangmüller, CCC, October 10, 2014 » Thread, Parallel Search, Stockfish, Komodo
- Threads test incl. Crafty 24.1 by Andreas Strangmüller, CCC, October 15, 2014 » Crafty
- Current data - threads-nps efficiency up to 32 threads by Andreas Strangmüller, CCC, October 24, 2014
2015 ...
- Explanation for non-expert? by Louis Zulli, CCC, February 16, 2015 » Stockfish
- Thread count limits and core counts by Steven Edwards, CCC, March 22, 2015
- Thread synchronization questions for experts by Steven Edwards, CCC, April 21, 2015 » Symbolic
- A cautionary tale on thread safety by Steven Edwards, CCC, April 25, 2015
- A Nice routine by Steven Edwards, CCC, May 12, 2015
- Does Hyperthreading have trouble with AVX? by cmylin, Stack Overflow, May 19, 2015 » AVX, AVX2
- Deep split perft() by Steven Edwards, CCC, May 29, 2015 » Perft, Symbolic
- thread affinity by Martin Sedlak, CCC, July 03, 2015
- Stockfish now benefits from hyperthreading by Dmitri Gusev, CCC, November 12, 2015 » Stockfish
2016
- Using more than 1 thread in C beginner question by Uri Blass, CCC, January 11, 2016
- Threads test incl. Stockfish 7 by Andreas Strangmüller, CCC, January 11, 2016 » Parallel Search, Stockfish
- Threads test incl. Komodo 9.3 by Andreas Strangmüller, CCC, January 17, 2016 » Komodo
- threading by Folkert van Heusden, CCC, March 03, 2016
- lazy smp using ms vs2015 c++11 std::async by Edward Yu, CCC, July 29, 2016 » Lazy SMP [6]
- Baffling multithreading scaling behavior by Tom Kerrigan, CCC, September 06, 2016
- Re: Baffling multithreading scaling behavior by Robert Hyatt, CCC, September 07, 2016
- Some hyperthreading results by Kai Laskos, CCC, September 12, 2016
- Stockfish 8 - Double time control vs. 2 threads by Andreas Strangmüller, CCC, November 15, 2016 » Doubling TC, Diminishing Returns, Playing Strength, Stockfish
- Hyperthreading debate reopened? by Zat, Rybka Forum, December 03, 2016
- Diminishing returns and hyperthreading by Kai Laskos, CCC, December 27, 2016 » Diminishing Returns, Match Statistics, Playing Strength
2017
- Re: Lazy SMP >4 Thread Slowdown by Ronald de Man, CCC, November 29, 2017
2018
2019
- Re: Hyperthreading on or off by Andrew Grant, CCC, January 20, 2019
- Prefetch and Threading by Dennis Sceviour, CCC, April 25, 2019 » Memory, Transposition Table
- strategies for finding slowdows in lazy smp by Folkert van Heusden, CCC, June 04, 2019 » Lazy SMP, Nodes per Second
- Multithreaded noob question by Michael Sherwin, CCC, September 06, 2019
2020 ...
- What happens with my hyperthreading? by Kai Laskos, CCC, August 06, 2020 » Stockfish NNUE, NNUE
- SMP, first shot at implementation by Chris Whittington, CCC, September 12, 2020 » Lazy SMP
- Memory management and threads by Chris Whittington, CCC, September 15, 2020 » Memory
- Very Lazy SMP and worker threads by Chris Whittington, CCC, September 18, 2020 » Lazy SMP
- Dispelling the Myth of NNUE with LazySMP: An Analysis by Andrew Grant, CCC, December 30, 2020 » NNUE, Lazy SMP
2021
- Missing input in ponder by Fabio Gobbato, CCC, April 15, 2021 » UCI, Pondering
- Thread overhead in C++ by JohnWoe, CCC, April 21, 2021
- Listening for GUI input when searching by Niels Abildskov, CCC, April 27, 2021 » GUI, Search, UCI
External Links
Thread
-
Multithreading
Posix
- Creating Threads
References
Up one Level