Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++20? (Not an issue but a question) #453

Open
achimste opened this issue Feb 12, 2024 · 4 comments
Open

C++20? (Not an issue but a question) #453

achimste opened this issue Feb 12, 2024 · 4 comments

Comments

@achimste
Copy link

Hi!

Sorry, this is not an issue but a suggestion and I just would like to hear your opinion.

In my chess engines, I replaced all that CPU-specialised code (popcount, msb, lsb, etc) with C++20 std commands, where the compiler automatically uses the corresponding intrinsics or other codes depending on the code generation flags.

So my question is: Would you like to switch to C++20 or remain at a lower version? At least with C++20 your code would simplify (a lot?).

I downloaded your latest code and I am indeed replacing your CPU specific code with std-lib commands.
I am compiling for Windows only.

Regards
Achim

@Matthies
Copy link
Owner

Not sure if it is worth to switch to C++20 but I will give it a try. First step (and not last hopefully) will be to check if all platforms that I want to support allow switching to new standard.

@Matthies
Copy link
Owner

Matthies commented Feb 18, 2024

Speed comparison of master vs. 0935b7a of branch c++20 on BMI2 Intel CPU running Linux.

Every version was measured three times using Stockfish perf test:
sudo perf stat -r 5 -a -B -e cycles:u,instructions:u ./RubiChess bench > /dev/null

Version GCC-11.4 Clang-14.0 ICX-2023.0.0
Master 4.85s / 4.85s / 4.86s 4.84s / 4.86s / 4.86s 4.62s / 4.62s / 4.62s
c++20 4.87s / 4.88s / 4.87s 4.92s / 4.93s / 4.92s 4.66s / 4.66s / 4.67s

Seems that the compilers are not as smart as expected. Or my generic pullXsb implementation can be improved.

@Matthies
Copy link
Owner

After fixing pullLsb in bc22873 this looks better now. Well, not for Clang. This testing is on AVX2 AMD Ryzen 3700x running Linux and using more recent comnpilers.

Version GCC-13.2 Clang-16.0 ICX-2023.2.0
Master 3.33s / 3.36s / 3.33s 3.36s / 3.36s / 3.35s 3.35s / 3.34s / 3.35s
c++20 3.32s / 3.32s / 3.33s 3.42s / 3.41s / 3.41s 3.33s / 3.33s / 3.34s

@Matthies
Copy link
Owner

#456 shows the ongoing progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants