diff --git a/src/extra/nnue_data_binpack_format.h b/src/extra/nnue_data_binpack_format.h index c86a55c2..3204b4b4 100644 --- a/src/extra/nnue_data_binpack_format.h +++ b/src/extra/nnue_data_binpack_format.h @@ -39,17 +39,11 @@ THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include -#include - -#ifdef linux -#include -#else -#include -#endif - -#include #include +#if (defined(_MSC_VER) || defined(__INTEL_COMPILER)) && !defined(__clang__) +#include +#endif namespace chess { @@ -177,87 +171,12 @@ namespace chess #endif } - - template - [[nodiscard]] constexpr IntT mulSaturate(IntT lhs, IntT rhs) - { - static_assert(std::is_unsigned_v); // currently no support for signed - - #if defined (_MSC_VER) - - if (lhs == 0) return 0; - - const IntT result = lhs * rhs; - return result / lhs == rhs ? result : std::numeric_limits::max(); - - #elif defined (__GNUC__) - - IntT result{}; - return __builtin_mul_overflow(lhs, rhs, &result) ? std::numeric_limits::max() : result; - - #endif - } - - template - [[nodiscard]] constexpr IntT addSaturate(IntT lhs, IntT rhs) - { - static_assert(std::is_unsigned_v); // currently no support for signed - - #if defined (_MSC_VER) - - const IntT result = lhs + rhs; - return result >= lhs ? result : std::numeric_limits::max(); - - #elif defined (__GNUC__) - - IntT result{}; - return __builtin_add_overflow(lhs, rhs, &result) ? std::numeric_limits::max() : result; - - #endif - } - - template - [[nodiscard]] constexpr bool addOverflows(IntT lhs, IntT rhs) - { - #if defined (_MSC_VER) - - return static_cast(lhs + rhs) < lhs; - - #elif defined (__GNUC__) - - IntT result{}; - __builtin_add_overflow(lhs, rhs, &result); - return result; - - #endif - } - template [[nodiscard]] constexpr IntT floorLog2(IntT value) { return intrin::msb_constexpr(value); } - template - constexpr std::size_t maxFibonacciNumberIndexForType() - { - static_assert(std::is_unsigned_v); - - switch (sizeof(IntT)) - { - case 8: - return 93; - case 4: - return 47; - case 2: - return 24; - case 1: - return 13; - } - - return 0; - } - template constexpr auto computeMasks() { @@ -278,26 +197,6 @@ namespace chess template constexpr auto nbitmask = computeMasks(); - template - constexpr auto computeFibonacciNumbers() - { - constexpr std::size_t size = maxFibonacciNumberIndexForType() + 1; - std::array numbers{}; - numbers[0] = 0; - numbers[1] = 1; - - for (std::size_t i = 2; i < size; ++i) - { - numbers[i] = numbers[i - 1] + numbers[i - 2]; - } - - return numbers; - } - - // F(0) = 0, F(1) = 1 - template - constexpr auto fibonacciNumbers = computeFibonacciNumbers(); - template > inline ToT signExtend(FromT value) { @@ -2700,7 +2599,7 @@ namespace chess return Bitboard::square(sq0) | sq1; } - [[nodiscard]] constexpr Bitboard operator""_bb(std::uint64_t bits) + [[nodiscard]] constexpr Bitboard operator""_bb(unsigned long long bits) { return Bitboard::fromBits(bits); }