Skip to content
2 changes: 2 additions & 0 deletions examples/tt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class TT {

void prefetch(const std::uint64_t hash) const noexcept {
const auto idx = index(hash);
#ifndef __GNUC__
__builtin_prefetch(&entries_[idx]);
#endif
}

private:
Expand Down
10 changes: 6 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ project(Libataxx VERSION 1.0 LANGUAGES CXX)

# Flags
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "-fPIC -Wall -Wextra -Wshadow")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-fPIC -Wall -Wextra -Wshadow")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -DNDEBUG")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
endif ()

# Default build type
if(NOT CMAKE_BUILD_TYPE)
Expand Down
7 changes: 4 additions & 3 deletions src/libataxx/bitboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <cassert>
#include <cstdint>
#include <bit>
#include "square.hpp"

namespace libataxx {
Expand Down Expand Up @@ -38,7 +39,7 @@ class BitboardIterator {
}

[[nodiscard]] constexpr Square operator*() const noexcept {
const int n = __builtin_ctzll(data_);
const int n = std::countr_zero(data_);
return Square{File{n % 8}, Rank{n / 8}};
}

Expand Down Expand Up @@ -69,7 +70,7 @@ class Bitboard {
}

[[nodiscard]] constexpr int count() const noexcept {
return __builtin_popcountll(data_);
return std::popcount(data_);
}

constexpr void set(const Square &sq) noexcept {
Expand Down Expand Up @@ -195,7 +196,7 @@ class Bitboard {
}

[[nodiscard]] constexpr int lsbll() const noexcept {
return __builtin_ctzll(data_);
return std::countr_zero(data_);
}

[[nodiscard]] constexpr Bitboard flip_vertical() const noexcept {
Expand Down