Skip to content

Commit

Permalink
Update clang-format to version 18
Browse files Browse the repository at this point in the history
clang-format-18 is available in ubuntu noble(24.04), if you are on
a version lower than that you can use the update script from llvm.
https://apt.llvm.org/

Windows users should be able to download and use clang-format from
their release builds https://github.com/llvm/llvm-project/releases
or get the latest from msys2
https://packages.msys2.org/package/mingw-w64-x86_64-clang.

macOS users can resort to "brew install clang-format".

closes official-stockfish#5365

No functional change
  • Loading branch information
Disservin authored and vondele committed Jun 5, 2024
1 parent 36eb9bc commit fb18caa
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ jobs:
id: clang-format
continue-on-error: true
with:
clang-format-version: "17"
clang-format-version: "18"
exclude-regex: "incbin"

- name: Comment on PR
if: steps.clang-format.outcome == 'failure'
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6 # @v2.5.0
with:
message: |
clang-format 17 needs to be run on this PR.
clang-format 18 needs to be run on this PR.
If you do not have clang-format installed, the maintainer will run it when merging.
For the exact version please see https://packages.ubuntu.com/mantic/clang-format-17.
For the exact version please see https://packages.ubuntu.com/noble/clang-format-18.
_(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_
comment_tag: execution
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ discussion._

Changes to Stockfish C++ code should respect our coding style defined by
[.clang-format](.clang-format). You can format your changes by running
`make format`. This requires clang-format version 17 to be installed on your system.
`make format`. This requires clang-format version 18 to be installed on your system.

## Navigate

Expand Down
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ dotprod = no
arm_version = 0
STRIP = strip

ifneq ($(shell which clang-format-17 2> /dev/null),)
CLANG-FORMAT = clang-format-17
ifneq ($(shell which clang-format-18 2> /dev/null),)
CLANG-FORMAT = clang-format-18
else
CLANG-FORMAT = clang-format
endif
Expand Down
10 changes: 5 additions & 5 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,10 @@ Value Search::Worker::search(
// Step 2. Check for aborted search and immediate draw
if (threads.stop.load(std::memory_order_relaxed) || pos.is_draw(ss->ply)
|| ss->ply >= MAX_PLY)
return (ss->ply >= MAX_PLY && !ss->inCheck) ? evaluate(
networks[numaAccessToken], pos, refreshTable, thisThread->optimism[us])
: value_draw(thisThread->nodes);
return (ss->ply >= MAX_PLY && !ss->inCheck)
? evaluate(networks[numaAccessToken], pos, refreshTable,
thisThread->optimism[us])
: value_draw(thisThread->nodes);

// Step 3. Mate distance pruning. Even if we mate at the next move our score
// would be at best mate_in(ss->ply + 1), but if alpha is already bigger because
Expand Down Expand Up @@ -775,8 +776,7 @@ Value Search::Worker::search(

// Step 8. Futility pruning: child node (~40 Elo)
// The depth condition is important for mate finding.
if (!ss->ttPv && depth < 13
&& eval - futilityMargin - (ss - 1)->statScore / 263 >= beta
if (!ss->ttPv && depth < 13 && eval - futilityMargin - (ss - 1)->statScore / 263 >= beta
&& eval >= beta && eval < VALUE_TB_WIN_IN_MAX_PLY && (!ttMove || ttCapture))
return beta > VALUE_TB_LOSS_IN_MAX_PLY ? beta + (eval - beta) / 3 : eval;

Expand Down
2 changes: 1 addition & 1 deletion src/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void ThreadPool::set(const NumaConfig& numaConfig,
const size_t threadId = threads.size();
const NumaIndex numaId = doBindThreads ? boundThreadToNumaNode[threadId] : 0;
auto manager = threadId == 0 ? std::unique_ptr<Search::ISearchManager>(
std::make_unique<Search::SearchManager>(updateContext))
std::make_unique<Search::SearchManager>(updateContext))
: std::make_unique<Search::NullSearchManager>();

// When not binding threads we want to force all access to happen
Expand Down
3 changes: 1 addition & 2 deletions src/tune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ void Tune::Entry<Tune::PostUpdate>::read_option() {

namespace Stockfish {

void Tune::read_results() { /* ...insert your values here... */
}
void Tune::read_results() { /* ...insert your values here... */ }

} // namespace Stockfish

0 comments on commit fb18caa

Please sign in to comment.