bug-gnu-chess
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU chess seems to always run at 100% CPU


From: Antonio Ceballos
Subject: Re: GNU chess seems to always run at 100% CPU
Date: Sat, 27 Jul 2013 21:16:28 +0200

Hi George,

A change was included in version 6.0.3 with respect to 6.0.2 so that the CPU should not be at 100% usage in easy mode. Could you tell me which version you are using? In case you are using v6.0.3, could you tell me if you are observing 100% CPU usage in easy mode?

There is no particular reason for not using readline, other than "legacy" reasons. I will add an entry in the todo list to consider using it in the future. 

I cannot exactly tell you why 'stop' is checked in the source line you mention. It is related to whether an active search is in progress or not. It should not be the case, for instance, if the program is running in easy mode and it is the opponent turn. Nevertheless, the main loop of the engine comes from line 105 in protocol.cpp.

Cheers,
Antonio



On Fri, Jul 26, 2013 at 5:14 AM, George Pauly <address@hidden> wrote:

Antonio Ceballos wrote:

>
>  ...
>
> I will have a look into it as soon as I can. I will let you know of
> any news. Meanwhile, any help is much appreciated.
>
>
> Regards,
> Antonio

I'd like to use GNU chess to test a web interface-to-uci project, and
this bug will be a problem.


Referring to source code, starting at the console loop in
engine/protocol.cpp, line 135 (quoted below).

I haven't drilled down into this code to try to understand it in detail.
Browsing it raises some questions:

   Why isn't GNU readline used for the console?  Isn't readline the
defacto standard?

   Can someone who has a better understanding of this than me advise if
this code may (not) be responsible for the cpu racing?

   This is likely not relevant -- feel free to ignore this when you
answer -- , but why is the uci stop command (means cleanly stop
searching) referred to in the condition of the console while loop?  fwiw
entering a stop command does not affect the cpu racing.


thanks,

George Pauly



> // event()
>
> void event() {
>
>    while (!SearchInfo->stop && input_available()) loop_step();
> }
>
> // loop_step()
>
> static void loop_step() {
>
>    char string[65536];
>
>    // read a line
>
>    get(string,65536);
>
>    // parse
>
>    if (false) {
>
>    } else if (string_start_with(string,"debug ")) {
>
>       // dummy
>
>    } else if (string_start_with(string,"go ")) {
>
>       if (!Searching && !Delay) {
>          init();
>          parse_go(string);
>       } else {
>          ASSERT(false);
>       }
>
>    } else if (string_equal(string,"isready")) {
>
>       if (!Searching && !Delay) {
>          init();
>       }
>
>       send("readyok"); // no need to wait when searching (dixit SMK)
>
>    } else if (string_equal(string,"ponderhit")) {
>
>       if (Searching) {
>
>          ASSERT(Infinite);
>
>          SearchInput->infinite = false;
>          Infinite = false;
>
>       } else if (Delay) {
>
>          send_best_move();
>          Delay = false;
>
>       } else {
>
>          ASSERT(false);
>       }
>
>    } else if (string_start_with(string,"position ")) {
>
>       if (!Searching && !Delay) {
>          init();
>          parse_position(string);
>       } else {
>          ASSERT(false);
>       }
>
>    } else if (string_equal(string,"quit")) {
>
>       ASSERT(!Searching);
>       ASSERT(!Delay);
>
>       exit(EXIT_SUCCESS);
>
>    } else if (string_start_with(string,"setoption ")) {
>
>       if (!Searching && !Delay) {
>          parse_setoption(string);
>       } else {
>          ASSERT(false);
>       }
>
>    } else if (string_equal(string,"stop")) {
>
>       if (Searching) {
>
>          SearchInfo->stop = true;
>          Infinite = false;
>
>       } else if (Delay) {
>
>          send_best_move();
>          Delay = false;
>       }
>
>    } else if (string_equal(string,"uci")) {
>
>       ASSERT(!Searching);
>       ASSERT(!Delay);
>
>       send("id name GNU Chess " VERSION);
>       send("id author GNU Chess team");
>
>       option_list();
>
>       send("uciok");
>
>    } else if (string_equal(string,"ucinewgame")) {
>
>       if (!Searching && !Delay && Init) {
>          trans_clear(Trans);
>       } else {
>          ASSERT(false);
>       }
>
>    } else if (string_equal(string,"hashon")) {
>
>       UseTrans = true;
>
>    } else if (string_equal(string,"hashoff")) {
>
>       UseTrans = false;
>
>    }
> }




_______________________________________________
Bug-gnu-chess mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/bug-gnu-chess


reply via email to

[Prev in Thread] Current Thread [Next in Thread]