]> git.sesse.net Git - stockfish/commitdiff
Print info about use of 64bit functions and hardware POPCNT
authorMarco Costalba <mcostalba@gmail.com>
Sat, 23 May 2009 10:42:43 +0000 (11:42 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 23 May 2009 15:12:26 +0000 (16:12 +0100)
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 <mcostalba@gmail.com>
src/bitcount.h
src/main.cpp
src/misc.cpp

index a4133fb21723db8981205fdf6f0f843f580e0190..c6e969a82411d4b37dc1633e512ca5873d4a2912 100644 (file)
 #if !defined(BITCOUNT_H_INCLUDED)
 #define BITCOUNT_H_INCLUDED
 
 #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"
 
 
 #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
 
 
 // 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();
 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)
 
 #endif // !defined(BITCOUNT_H_INCLUDED)
index 9c8601148decb1fa1874418f0cd9f6cd631f48d8..fc970a0e78d09b4c92a1b878ec99d673f1aabdfc 100644 (file)
@@ -75,11 +75,11 @@ int main(int argc, char *argv[]) {
   }
 
   // Print copyright notice
   }
 
   // Print copyright notice
-  cout << engine_name() << ".  Copyright (C) "
+  cout << engine_name() << ". Copyright (C) "
        << "2004-2009 Tord Romstad, Marco Costalba. " << endl;
 
        << "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();
 
   // Enter UCI mode
   uci_main_loop();
index ba4da56896fee0bb5b4a9d745d639c3721970e23..149cfb4510e5bd2623887ae29e08c4459e0de7a2 100644 (file)
@@ -65,6 +65,7 @@ static int gettimeofday(struct timeval* tp, struct timezone*)
 #include <iostream>
 #include <sstream>
 
 #include <iostream>
 #include <sstream>
 
+#include "bitcount.h"
 #include "misc.h"
 
 using namespace std;
 #include "misc.h"
 
 using namespace std;
@@ -162,8 +163,10 @@ void dbg_print_mean(ofstream& logFile) {
 
 const string engine_name() {
 
 
 const string engine_name() {
 
+  const string cpu64(CpuHas64BitPath ? " 64bit" : "");
+
   if (!EngineVersion.empty())
   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");
 
   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')
   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();
 }
 
   return s.str();
 }