X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fmisc.cpp;h=e03a0e2fa7302fbe4c1b4fa418a4b3be2fc8adbb;hp=0d27b615ea75122695f37e8c9da0ab3021525cb4;hb=26a8b844177ad6abd4aca1bef2ebb7f644bd465c;hpb=86c2d2fc3b596e544e7f280edf2bd7b3f755b83d diff --git a/src/misc.cpp b/src/misc.cpp index 0d27b615..e03a0e2f 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -39,6 +39,10 @@ #endif +#if !defined(NO_PREFETCH) +# include +#endif + #include #include #include @@ -54,7 +58,7 @@ using namespace std; /// Version number. If this is left empty, the current date (in the format /// YYMMDD) is used as a version number. -static const string EngineVersion = "1.7.1"; +static const string EngineVersion = ""; static const string AppName = "Stockfish"; static const string AppTag = ""; @@ -147,7 +151,7 @@ const string engine_name() { const string cpu64(CpuHas64BitPath ? " 64bit" : ""); if (!EngineVersion.empty()) - return AppName+ " " + EngineVersion + cpu64; + 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"); @@ -287,4 +291,27 @@ int Bioskey() return 0; } } + #endif + +/// 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. +#if defined(NO_PREFETCH) +void prefetch(char*) {} +#else + +void prefetch(char* addr) { + +#if defined(__INTEL_COMPILER) || defined(__ICL) + // This hack prevents prefetches to be optimized away by + // Intel compiler. Both MSVC and gcc seems not affected. + __asm__ (""); +#endif + + _mm_prefetch(addr, _MM_HINT_T2); + _mm_prefetch(addr+64, _MM_HINT_T2); // 64 bytes ahead +} + +#endif +