UCI2WB 4.0
Posted: Sun Dec 09, 2018 10:47 am
I released a new version (4.0) of UCI2WB (the default UCI adapter packaged with WinBoard in the WinBoard-AA beta distro). The previous version turned out to have some problems, which were just made worse by my earlier attempts to fix those; in particular it had become insensitive to 'quit' commands while the engine was thinking, which could lead to hanging engine processes after an opponent out-of-turn resign.
I now completely redesigned the master logic of UCI2WB: instead of having threads for all engine->GUI and all GUI->engine traffic, which would now and then block waiting for each other when there is a need to synchronize, it now has one of threads always listenining to the GUI, and instantly handling any incoming command, either processing it (if that can be done during search), or queueing it for execution by the 'engine thread'. The latter listens to the engine for as long as it is searching. (UCI engines always tell you when they are done searching!) But if the engine is idle or merely pondering it first processes all queued commands, before it starts listening to any ponder output. Only when the engine is idle and the queue empty it blocks waiting for a command to appear in the queue.
This way the GUI thread can examine all incoming commands immediately, and judge whether these should abort the search that is currently running, or be ignored until that search terminates for other reasons. If the search is to be aborted, it sends 'stop' to the engine, which will then focus the attention of the engine thread on the queued command.
I tested the new UCI2WB with Stockfish, and everything seems to work as intended. The source code can be found in my on-line git repository. I uploaded a Windows executable at http://hgm.nubati.net/UCI2WB.zip . The WinBoard-AA beta package now also contains this new UCI2WB version.
I now completely redesigned the master logic of UCI2WB: instead of having threads for all engine->GUI and all GUI->engine traffic, which would now and then block waiting for each other when there is a need to synchronize, it now has one of threads always listenining to the GUI, and instantly handling any incoming command, either processing it (if that can be done during search), or queueing it for execution by the 'engine thread'. The latter listens to the engine for as long as it is searching. (UCI engines always tell you when they are done searching!) But if the engine is idle or merely pondering it first processes all queued commands, before it starts listening to any ponder output. Only when the engine is idle and the queue empty it blocks waiting for a command to appear in the queue.
This way the GUI thread can examine all incoming commands immediately, and judge whether these should abort the search that is currently running, or be ignored until that search terminates for other reasons. If the search is to be aborted, it sends 'stop' to the engine, which will then focus the attention of the engine thread on the queued command.
I tested the new UCI2WB with Stockfish, and everything seems to work as intended. The source code can be found in my on-line git repository. I uploaded a Windows executable at http://hgm.nubati.net/UCI2WB.zip . The WinBoard-AA beta package now also contains this new UCI2WB version.