mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Cleanup debug counters
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
54f1c383d3
commit
7f367e6019
6 changed files with 125 additions and 164 deletions
|
@ -64,7 +64,7 @@ int main(int argc, char* argv[]) {
|
|||
if (argc < 2)
|
||||
{
|
||||
// Print copyright notice
|
||||
cout << engine_name() << " by " << engine_author() << endl;
|
||||
cout << engine_name() << " by " << engine_authors() << endl;
|
||||
|
||||
if (CpuHasPOPCNT)
|
||||
cout << "Good! CPU has hardware POPCNT." << endl;
|
||||
|
|
181
src/misc.cpp
181
src/misc.cpp
|
@ -17,11 +17,6 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
////
|
||||
//// Includes
|
||||
////
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
|
||||
# include <sys/time.h>
|
||||
|
@ -55,83 +50,18 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
/// Version number. If this is left empty, the current date (in the format
|
||||
/// YYMMDD) is used as a version number.
|
||||
/// Version number. If EngineVersion is left empty, then AppTag plus
|
||||
/// current date (in the format YYMMDD) is used as a version number.
|
||||
|
||||
static const string EngineVersion = "";
|
||||
static const string AppName = "Stockfish";
|
||||
static const string EngineVersion = "";
|
||||
static const string AppTag = "";
|
||||
|
||||
|
||||
////
|
||||
//// Variables
|
||||
////
|
||||
|
||||
static uint64_t dbg_cnt0 = 0;
|
||||
static uint64_t dbg_cnt1 = 0;
|
||||
|
||||
bool dbg_show_mean = false;
|
||||
bool dbg_show_hit_rate = false;
|
||||
|
||||
|
||||
////
|
||||
//// Functions
|
||||
////
|
||||
|
||||
void dbg_hit_on(bool b) {
|
||||
|
||||
assert(!dbg_show_mean);
|
||||
dbg_show_hit_rate = true;
|
||||
dbg_cnt0++;
|
||||
if (b)
|
||||
dbg_cnt1++;
|
||||
}
|
||||
|
||||
void dbg_hit_on_c(bool c, bool b) {
|
||||
|
||||
if (c)
|
||||
dbg_hit_on(b);
|
||||
}
|
||||
|
||||
void dbg_before() {
|
||||
|
||||
assert(!dbg_show_mean);
|
||||
dbg_show_hit_rate = true;
|
||||
dbg_cnt0++;
|
||||
}
|
||||
|
||||
void dbg_after() {
|
||||
|
||||
assert(!dbg_show_mean);
|
||||
dbg_show_hit_rate = true;
|
||||
dbg_cnt1++;
|
||||
}
|
||||
|
||||
void dbg_mean_of(int v) {
|
||||
|
||||
assert(!dbg_show_hit_rate);
|
||||
dbg_show_mean = true;
|
||||
dbg_cnt0++;
|
||||
dbg_cnt1 += v;
|
||||
}
|
||||
|
||||
void dbg_print_hit_rate() {
|
||||
|
||||
cout << "Total " << dbg_cnt0 << " Hit " << dbg_cnt1
|
||||
<< " hit rate (%) " << (dbg_cnt1*100)/(dbg_cnt0 ? dbg_cnt0 : 1) << endl;
|
||||
}
|
||||
|
||||
void dbg_print_mean() {
|
||||
|
||||
cout << "Total " << dbg_cnt0 << " Mean "
|
||||
<< (float)dbg_cnt1 / (dbg_cnt0 ? dbg_cnt0 : 1) << endl;
|
||||
}
|
||||
|
||||
|
||||
/// engine_name() returns the full name of the current Stockfish version.
|
||||
/// This will be either "Stockfish YYMMDD" (where YYMMDD is the date when
|
||||
/// the program was compiled) or "Stockfish <version number>", depending
|
||||
/// on whether the constant EngineVersion (defined in misc.h) is empty.
|
||||
/// on whether the constant EngineVersion is empty.
|
||||
|
||||
const string engine_name() {
|
||||
|
||||
|
@ -154,11 +84,55 @@ const string engine_name() {
|
|||
return s.str();
|
||||
}
|
||||
|
||||
const string engine_author() { return "Tord Romstad, Marco Costalba and Joona Kiiski"; }
|
||||
|
||||
/// Our brave developers! Required by UCI
|
||||
|
||||
const string engine_authors() {
|
||||
|
||||
return "Tord Romstad, Marco Costalba and Joona Kiiski";
|
||||
}
|
||||
|
||||
|
||||
/// get_system_time() returns the current system time, measured in
|
||||
/// milliseconds.
|
||||
/// Debug stuff. Helper functions used mainly for debugging purposes
|
||||
|
||||
static uint64_t dbg_hit_cnt0;
|
||||
static uint64_t dbg_hit_cnt1;
|
||||
static uint64_t dbg_mean_cnt0;
|
||||
static uint64_t dbg_mean_cnt1;
|
||||
|
||||
void dbg_print_hit_rate() {
|
||||
|
||||
if (dbg_hit_cnt0)
|
||||
cout << "Total " << dbg_hit_cnt0 << " Hit " << dbg_hit_cnt1
|
||||
<< " hit rate (%) " << 100 * dbg_hit_cnt1 / (dbg_hit_cnt0 + 1) << endl;
|
||||
}
|
||||
|
||||
void dbg_print_mean() {
|
||||
|
||||
if (dbg_mean_cnt0)
|
||||
cout << "Total " << dbg_mean_cnt0 << " Mean "
|
||||
<< (float)dbg_mean_cnt1 / (dbg_mean_cnt0 + 1) << endl;
|
||||
}
|
||||
|
||||
void dbg_mean_of(int v) {
|
||||
|
||||
dbg_mean_cnt0++;
|
||||
dbg_mean_cnt1 += v;
|
||||
}
|
||||
|
||||
void dbg_hit_on(bool b) {
|
||||
|
||||
dbg_hit_cnt0++;
|
||||
if (b)
|
||||
dbg_hit_cnt1++;
|
||||
}
|
||||
|
||||
void dbg_hit_on_c(bool c, bool b) { if (c) dbg_hit_on(b); }
|
||||
void dbg_before() { dbg_hit_on(false); }
|
||||
void dbg_after() { dbg_hit_on(true); dbg_hit_cnt0--; }
|
||||
|
||||
|
||||
/// get_system_time() returns the current system time, measured in milliseconds
|
||||
|
||||
int get_system_time() {
|
||||
|
||||
|
@ -174,45 +148,37 @@ int get_system_time() {
|
|||
}
|
||||
|
||||
|
||||
/// cpu_count() tries to detect the number of CPU cores.
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
|
||||
# if defined(_SC_NPROCESSORS_ONLN)
|
||||
int cpu_count() {
|
||||
return Min(sysconf(_SC_NPROCESSORS_ONLN), MAX_THREADS);
|
||||
}
|
||||
# elif defined(__hpux)
|
||||
int cpu_count() {
|
||||
struct pst_dynamic psd;
|
||||
if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) == -1)
|
||||
return 1;
|
||||
|
||||
return Min(psd.psd_proc_cnt, MAX_THREADS);
|
||||
}
|
||||
# else
|
||||
int cpu_count() {
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
#else
|
||||
/// cpu_count() tries to detect the number of CPU cores
|
||||
|
||||
int cpu_count() {
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
SYSTEM_INFO s;
|
||||
GetSystemInfo(&s);
|
||||
return Min(s.dwNumberOfProcessors, MAX_THREADS);
|
||||
}
|
||||
#else
|
||||
|
||||
# if defined(_SC_NPROCESSORS_ONLN)
|
||||
return Min(sysconf(_SC_NPROCESSORS_ONLN), MAX_THREADS);
|
||||
# elif defined(__hpux)
|
||||
struct pst_dynamic psd;
|
||||
if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) == -1)
|
||||
return 1;
|
||||
return Min(psd.psd_proc_cnt, MAX_THREADS);
|
||||
# else
|
||||
return 1;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/// Check for console input. Original code from Beowulf, Olithink and Greko
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
int input_available()
|
||||
{
|
||||
int input_available() {
|
||||
|
||||
fd_set readfds;
|
||||
struct timeval timeout;
|
||||
|
||||
|
@ -227,8 +193,8 @@ int input_available()
|
|||
|
||||
#else
|
||||
|
||||
int input_available()
|
||||
{
|
||||
int input_available() {
|
||||
|
||||
static HANDLE inh = NULL;
|
||||
static bool usePipe = false;
|
||||
INPUT_RECORD rec[256];
|
||||
|
@ -282,9 +248,11 @@ int input_available()
|
|||
|
||||
/// prefetch() preloads the given address in L1/L2 cache. This is a non
|
||||
/// blocking function and do not stalls the CPU waiting for data to be
|
||||
/// loaded from RAM, that can be very slow.
|
||||
/// loaded from memory, that can be quite slow.
|
||||
#if defined(NO_PREFETCH)
|
||||
|
||||
void prefetch(char*) {}
|
||||
|
||||
#else
|
||||
|
||||
void prefetch(char* addr) {
|
||||
|
@ -300,4 +268,3 @@ void prefetch(char* addr) {
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,16 +24,13 @@
|
|||
#include "types.h"
|
||||
|
||||
extern const std::string engine_name();
|
||||
extern const std::string engine_author();
|
||||
extern const std::string engine_authors();
|
||||
extern int get_system_time();
|
||||
extern int cpu_count();
|
||||
extern int input_available();
|
||||
extern void prefetch(char* addr);
|
||||
extern void prefetchTables(Key pKey, Key mKey, int threadID);
|
||||
|
||||
// Debug functions
|
||||
extern bool dbg_show_mean;
|
||||
extern bool dbg_show_hit_rate;
|
||||
extern void dbg_hit_on(bool b);
|
||||
extern void dbg_hit_on_c(bool c, bool b);
|
||||
extern void dbg_before();
|
||||
|
|
|
@ -33,7 +33,7 @@ enum MoveType {
|
|||
MV_PSEUDO_LEGAL
|
||||
};
|
||||
|
||||
template<MoveType T>
|
||||
template<MoveType>
|
||||
MoveStack* generate(const Position& pos, MoveStack* mlist);
|
||||
|
||||
#endif // !defined(MOVEGEN_H_INCLUDED)
|
||||
|
|
|
@ -1933,10 +1933,7 @@ split_point_start: // At split points actual search starts from here
|
|||
{
|
||||
lastInfoTime = t;
|
||||
|
||||
if (dbg_show_mean)
|
||||
dbg_print_mean();
|
||||
|
||||
if (dbg_show_hit_rate)
|
||||
dbg_print_hit_rate();
|
||||
|
||||
// Send info on searched nodes as soon as we return to root
|
||||
|
|
|
@ -77,7 +77,7 @@ bool execute_uci_command(const string& cmd) {
|
|||
|
||||
else if (token == "uci")
|
||||
cout << "id name " << engine_name()
|
||||
<< "\nid author " << engine_author()
|
||||
<< "\nid author " << engine_authors()
|
||||
<< "\n" << options_to_uci()
|
||||
<< "\nuciok" << endl;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue