From ce5d9eb19da890c77d8ef00e078c60edc3e8e4aa Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Sat, 23 May 2009 11:42:43 +0100 Subject: [PATCH] Print info about use of 64bit functions and hardware POPCNT With this patch at the applications startup a line is printed with info about use of optimized 64 bit routines and hardware POPCNT. Also allow the possibility to disable POPCNT support during PGO compiles to exercise the fallback software only path. Signed-off-by: Marco Costalba --- src/bitcount.h | 23 +++++++++++++++++++++-- src/main.cpp | 6 +++--- src/misc.cpp | 7 +++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/bitcount.h b/src/bitcount.h index a4133fb2..c6e969a8 100644 --- a/src/bitcount.h +++ b/src/bitcount.h @@ -22,6 +22,12 @@ #if !defined(BITCOUNT_H_INCLUDED) #define BITCOUNT_H_INCLUDED +// To disable POPCNT support uncomment following line. You should do it only +// in PGO compiling to exercise the default fallback path. Don't forget to +// re-comment the line for the final optimized compile though ;-) +//#define DISABLE_POPCNT_SUPPORT + + #include "bitboard.h" @@ -160,8 +166,21 @@ inline int count_1s_max_15(Bitboard b) { // Global variable initialized at startup that is set to true if -// CPU on which application runs support POPCNT intrinsic. - +// CPU on which application runs supports POPCNT intrinsic. Unless +// DISABLE_POPCNT_SUPPORT is defined. +#if defined(DISABLE_POPCNT_SUPPORT) +const bool CpuHasPOPCNT = false; +#else const bool CpuHasPOPCNT = cpu_has_popcnt(); +#endif + + +// Global variable used to print info about the use of 64 optimized +// functions to verify that a 64bit compile has been correctly built. +#if defined(BITCOUNT_SWAR_64) +const bool CpuHas64BitPath = true; +#else +const bool CpuHas64BitPath = false; +#endif #endif // !defined(BITCOUNT_H_INCLUDED) diff --git a/src/main.cpp b/src/main.cpp index 9c860114..fc970a0e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,11 +75,11 @@ int main(int argc, char *argv[]) { } // Print copyright notice - cout << engine_name() << ". Copyright (C) " + cout << engine_name() << ". Copyright (C) " << "2004-2009 Tord Romstad, Marco Costalba. " << endl; - // FIXME ONLY FOR DEBUG, REMOVE BEFORE RELEASE - cout << "Support for POPCNT is " << CpuHasPOPCNT << endl; + if (CpuHasPOPCNT) + cout << "Good! CPU has hardware POPCNT. We will use it." << endl; // Enter UCI mode uci_main_loop(); diff --git a/src/misc.cpp b/src/misc.cpp index ba4da568..149cfb45 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -65,6 +65,7 @@ static int gettimeofday(struct timeval* tp, struct timezone*) #include #include +#include "bitcount.h" #include "misc.h" using namespace std; @@ -162,8 +163,10 @@ void dbg_print_mean(ofstream& logFile) { const string engine_name() { + const string cpu64(CpuHas64BitPath ? " 64bit" : ""); + if (!EngineVersion.empty()) - return "Stockfish " + EngineVersion; + return AppName+ " " + EngineVersion + cpu64; string date(__DATE__); // From compiler, format is "Sep 21 2008" string months("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"); @@ -176,7 +179,7 @@ const string engine_name() { string name = AppName + " " + AppTag + " "; s << name << date.substr(date.length() - 2) << setfill('0') - << setw(2) << mon << setw(2) << day; + << setw(2) << mon << setw(2) << day << cpu64; return s.str(); } -- 2.39.2