Win executable on cpu which do not support __popcnt64

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

OliverBr
Posts: 725
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Win executable on cpu which do not support __popcnt64

Post by OliverBr »

Hello together,

I need a Windows executable for older CPUs that don't support __popcnt64.

I have now:

Code: Select all

#define bitcnt(x) __popcnt64(x)
Using Visual Studio 2019, what's the best way to create an executable that runs on older CPU?

It's little bit urgent, so any help is very welcome!

Thank you
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
User avatar
Guenther
Posts: 4606
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Win executable on cpu which do not support __popcnt64

Post by Guenther »

OliverBr wrote: Thu Jan 07, 2021 1:48 pm Hello together,

I need a Windows executable for older CPUs that don't support __popcnt64.

I have now:

Code: Select all

#define bitcnt(x) __popcnt64(x)
Using Visual Studio 2019, what's the best way to create an executable that runs on older CPU?

It's little bit urgent, so any help is very welcome!

Thank you
If it's really urgent you can download a few from my site too.
I can upload the latest one too, if needed (5.89 and 5.91 is already there).
https://rwbc-chess.de/download.htm

Edit:
5.92 is there now too
https://rwbc-chess.de

trollwatch:
Chessqueen + chessica + AlexChess + Eduard + Sylwy
OliverBr
Posts: 725
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: Win executable on cpu which do not support __popcnt64

Post by OliverBr »

Guenther wrote: Thu Jan 07, 2021 1:55 pm
OliverBr wrote: Thu Jan 07, 2021 1:48 pm Hello together,

I need a Windows executable for older CPUs that don't support __popcnt64.

I have now:

Code: Select all

#define bitcnt(x) __popcnt64(x)
Using Visual Studio 2019, what's the best way to create an executable that runs on older CPU?

It's little bit urgent, so any help is very welcome!

Thank you
If it's really urgent you can download a few from my site too.
I can upload the latest one too, if needed (5.89 and 5.91 is already there).
https://rwbc-chess.de/download.htm

Edit:
5.92 is there now too
This is great!!! Thank you very, very much.

PS:
I know it already for gcc/clang, but not for Windows.
It would be interesting to know what compiler you are using and what modifications you have to do.
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
User avatar
Guenther
Posts: 4606
Joined: Wed Oct 01, 2008 6:33 am
Location: Regensburg, Germany
Full name: Guenther Simon

Re: Win executable on cpu which do not support __popcnt64

Post by Guenther »

OliverBr wrote: Thu Jan 07, 2021 2:19 pm
Guenther wrote: Thu Jan 07, 2021 1:55 pm
OliverBr wrote: Thu Jan 07, 2021 1:48 pm Hello together,

I need a Windows executable for older CPUs that don't support __popcnt64.

I have now:

Code: Select all

#define bitcnt(x) __popcnt64(x)
Using Visual Studio 2019, what's the best way to create an executable that runs on older CPU?

It's little bit urgent, so any help is very welcome!

Thank you
If it's really urgent you can download a few from my site too.
I can upload the latest one too, if needed (5.89 and 5.91 is already there).
https://rwbc-chess.de/download.htm

Edit:
5.92 is there now too
This is great!!! Thank you very, very much.

PS:
I know it already for gcc/clang, but not for Windows.
It would be interesting to know what compiler you are using and what modifications you have to do.
Well, Oliver you asked me this already once ;-)
I use gcc/g++ (sometimes clang) in the Msys2 environment, but having no popcount hardware myself, I don't need to modify
anything, the compiler replaces the popcount instructions by itself, if I remove the popcount flags and do sth like march=native,
or whatever architecture, which has no popcount natively.

Ofc replacing the popcount instructions yourself in the source might give a faster compilation, but that has to be checked.

Note that the 5.92 compilation is no popcount, but needs sse4.1 (this was for myself). I can do another one, if the target
architecture is even older than that.
https://rwbc-chess.de

trollwatch:
Chessqueen + chessica + AlexChess + Eduard + Sylwy
OliverBr
Posts: 725
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: Win executable on cpu which do not support __popcnt64

Post by OliverBr »

Guenther wrote: Thu Jan 07, 2021 2:31 pm Well, Oliver you asked me this already once ;-)
I know that we talked about it. I couldn't find the tread quickly and I can't remember any solution for Visual Studio 2019...Sorry for the double question :/
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
Dann Corbit
Posts: 12540
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Win executable on cpu which do not support __popcnt64

Post by Dann Corbit »

the chess programming wiki has a boatload of routines for calculation of population count.
https://www.chessprogramming.org/Population_Count
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Dann Corbit
Posts: 12540
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Win executable on cpu which do not support __popcnt64

Post by Dann Corbit »

Msys2 with gcc and/or clang is a great way to create windows binaries.
That way it is also easier to keep a compatible code base for linux/win
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
BeyondCritics
Posts: 396
Joined: Sat May 05, 2012 2:48 pm
Full name: Oliver Roese

Re: Win executable on cpu which do not support __popcnt64

Post by BeyondCritics »

OliverBr
Posts: 725
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: Win executable on cpu which do not support __popcnt64

Post by OliverBr »

Dann Corbit wrote: Thu Jan 07, 2021 6:34 pm Msys2 with gcc and/or clang is a great way to create windows binaries.
That way it is also easier to keep a compatible code base for linux/win
Yes I like them, too.
Unfortunately OliThink loses about 10% performance with them. Visual Studio 2019 creates clearly faster code :roll:

This is why I was Guenther asking, which compiler he is using and if anyone can tell me a quick way to create non-popcnt executable with Visual Studio 2019...

PS: OliThink had for a long time own Popcnt methods. I removed them, because didn't know that there are still so many non-popcnt CPUs running.
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
Dann Corbit
Posts: 12540
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Win executable on cpu which do not support __popcnt64

Post by Dann Corbit »

If you need fast, the only place that 64 bit popcounts do not work is on 32 bit operating systems.
In those cases, you can use the 32 bit inline assembly version and call it twice.
I guess you cannot get faster than that.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.