Skip to content

Commit 4df7f8d

Browse files
committed
improved performance.
1 parent 4cf8aa4 commit 4df7f8d

7 files changed

Lines changed: 126 additions & 346 deletions

File tree

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
2-
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
31
name: CMake on multiple platforms
42

53
on:
@@ -13,20 +11,14 @@ jobs:
1311
runs-on: ${{ matrix.os }}
1412

1513
strategy:
16-
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
1714
fail-fast: false
18-
19-
# Set up a matrix to run the following 3 configurations:
20-
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
21-
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
22-
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
23-
#
24-
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
2515
matrix:
2616
os: [ubuntu-latest, windows-latest]
2717
build_type: [Debug, Release]
2818
c_compiler: [gcc, clang, cl]
19+
2920
include:
21+
# Windows
3022
- os: windows-latest
3123
c_compiler: cl
3224
cpp_compiler: cl
@@ -36,42 +28,44 @@ jobs:
3628
- os: windows-latest
3729
c_compiler: gcc
3830
cpp_compiler: g++
31+
32+
# Linux
3933
- os: ubuntu-latest
4034
c_compiler: gcc
4135
cpp_compiler: g++
4236
- os: ubuntu-latest
4337
c_compiler: clang
4438
cpp_compiler: clang++
39+
4540
exclude:
4641
- os: ubuntu-latest
4742
c_compiler: cl
4843

4944
steps:
5045
- uses: actions/checkout@v4
5146

52-
- name: Set reusable strings
53-
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
54-
id: strings
47+
- name: Set build dir
48+
id: vars
5549
shell: bash
56-
run: |
57-
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
50+
run: echo "dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
5851

5952
- name: Configure CMake
60-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
61-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
6253
run: >
63-
cmake -B ${{ steps.strings.outputs.build-output-dir }}
54+
cmake -B ${{ steps.vars.outputs.dir }}
6455
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
6556
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
6657
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
6758
-S ${{ github.workspace }}
6859
6960
- name: Build
70-
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
71-
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
61+
run: cmake --build ${{ steps.vars.outputs.dir }} --config ${{ matrix.build_type }}
7262

7363
- name: Test
74-
working-directory: ${{ steps.strings.outputs.build-output-dir }}
75-
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
76-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
77-
run: ctest --build-config ${{ matrix.build_type }} --verbose
64+
working-directory: ${{ steps.vars.outputs.dir }}
65+
shell: bash
66+
run: |
67+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
68+
ctest --build-config ${{ matrix.build_type }} --verbose
69+
else
70+
ctest --verbose
71+
fi

bitboard.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ __FORCEINLINE constexpr int msb(Bitboard x) noexcept {
9393
// -------------------------------
9494
__FORCEINLINE int pop_lsb(Bitboard &b) noexcept {
9595
int c = lsb(b);
96-
#ifndef __BMI2__
96+
#ifndef __BMI2__
9797
b &= b - 1;
98-
#else
99-
_blsr_u64(b);
100-
#endif
98+
#else
99+
b = _blsr_u64(b);
100+
#endif
101101
return c;
102102
}
103103

examples/perft_with_tt.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,17 @@ template <int DEPTH, bool EnableDiv=false, typename T=EnginePiece> void benchmar
113113
double avgTime = totalTime / N_RUNS;
114114
double avgMnps = (nodes / avgTime) / 1'000'000.0;
115115

116-
std::cout << "Average: " << avgTime << " s, " << avgMnps << " Mnps\n";
116+
std::cout << "Average: " << avgTime << " s, " << avgMnps << " Mnps (nodes="<<(nodes/N_RUNS)<<")\n";
117117
}
118118

119119

120120
int main() {
121-
_Position<ContiguousMappingPiece> pos("8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1");
121+
_Position<EnginePiece> pos;
122122

123123
#ifdef TT_ENABLED
124124
tt.resize(1 << 28);
125125
#endif
126-
benchmark<3, true, ContiguousMappingPiece>(pos);
127-
126+
benchmark<7, true, EnginePiece>(pos);
128127
// Movelist moves;
129128
// pos.template legals(moves);
130129
// for (const Move &m : moves) {

0 commit comments

Comments
 (0)