Code: Select all
#include <immintrin.h>
Code: Select all
_tzcnt_u64(x)
_lzcnt_u64(x)
Moderators: hgm, Rebel, chrisw
Code: Select all
#include <immintrin.h>
Code: Select all
_tzcnt_u64(x)
_lzcnt_u64(x)
long time ago, and a support programmer wrote that stuff, but I think there is or was a pragma that allowed asm, and magically parameters were passed in registers, but that would need looking up. Quick search mobile phone suggests nowadays there’s an __asm or _asm to allow an asm block in VS, but I didn’t immediately find how you pass data in and out. Would be interested in what you find.OliverBr wrote: ↑Thu Sep 03, 2020 6:21 pmAn asm code snippet for Visual Studio would be very helpful. This is the machine command:chrisw wrote: ↑Thu Sep 03, 2020 5:56 pm If I remember correct from 1997, we were using beta dev version of what became Visual Studio and CSTal had the asm instruction in some sort of macro. I’ll look up what I do now when I get home, but am fairly sure there’s a standard fast way that works, may well be the Mar instructions above, and I do think you indeed have to check you’re giving them non zero data.
https://www.felixcloutier.com/x86/tzcnt
(the parameter is never 0)
No, I am developing OliThink572 using "tzcnt" and looking for a solution for my Windows executables. _BitscanForward64 works, but is slower.Btw, are you compiling SF NNUE in VS, I got stuck on compile errors demanding c++17 support?
unfortunately, inline assembly is only supported in 32-bit mode by microsoft compiler (in 64-bit mode you either have to use intrinsics or use masm to compile asm file, which in this case is out of question as that would mean a function call)chrisw wrote: ↑Thu Sep 03, 2020 6:46 pm long time ago, and a support programmer wrote that stuff, but I think there is or was a pragma that allowed asm, and magically parameters were passed in registers, but that would need looking up. Quick search mobile phone suggests nowadays there’s an __asm or _asm to allow an asm block in VS, but I didn’t immediately find how you pass data in and out. Would be interested in what you find.
Thank you. To already existing includesmar wrote: ↑Thu Sep 03, 2020 6:45 pm I did some googling and you you want is:
then useCode: Select all
#include <immintrin.h>
note that those are BMI1 (actually lzcnt was orginally ABM and tzcnt was added later as part of BMI1 as far as I understand)Code: Select all
_tzcnt_u64(x) _lzcnt_u64(x)
Code: Select all
#include <windows.h>
#include <conio.h>
...
_lzcnt_u64(x)
Code: Select all
# PLAYER : RATING ERROR POINTS PLAYED (%) W D L D(%) CFS(%)
1 OliThink 5.7.2 : 19 5 5277.0 10000 52.8 3152 4250 2598 42.5 100
2 OliThink 5.7.1 : 0 ---- 4723.0 10000 47.2 2598 4250 3152 42.5 ---
White advantage = -3.02 +/- 2.69
Draw rate (equal opponents) = 42.62 % +/- 0.50
Elo difference: 19.27 +/- 5.16
Code: Select all
# PLAYER : RATING ERROR POINTS PLAYED (%) W D L D(%) CFS(%)
1 Fruit 2.1 : 37 29 276.0 500 55.2 230 92 178 18.4 57
2 Scorpio_2.8.8 MCTS+NN : 33 28 273.5 500 54.7 236 75 189 15.0 91
3 K2 v.087 : 4 29 252.5 500 50.5 205 95 200 19.0 60
4 OliThink 5.7.2 : 0 ---- 1008.0 2000 50.4 837 342 821 17.1 100
5 Arasan 11.7 : -86 28 190.0 500 38.0 150 80 270 16.0 ---
White advantage = 0.00 +/- 7.21
Draw rate (equal opponents) = 17.30 % +/- 0.85
Looks like you are about to scale K2OliverBr wrote: ↑Thu Sep 03, 2020 9:53 pm I included the header and released OliThink 5.7.2. Everything is smaller now, code size (45k, 1615 lines), executable size (90kb), memory/cache usage, time usage.
Here is a mini tourney against friends.The first time even ever OliThink won more games than lost in this round.Code: Select all
# PLAYER : RATING ERROR POINTS PLAYED (%) W D L D(%) CFS(%) 1 Fruit 2.1 : 37 29 276.0 500 55.2 230 92 178 18.4 57 2 Scorpio_2.8.8 MCTS+NN : 33 28 273.5 500 54.7 236 75 189 15.0 91 3 K2 v.087 : 4 29 252.5 500 50.5 205 95 200 19.0 60 4 OliThink 5.7.2 : 0 ---- 1008.0 2000 50.4 837 342 821 17.1 100 5 Arasan 11.7 : -86 28 190.0 500 38.0 150 80 270 16.0 ---
But, of course, when the intrinsic is a single machine instrution the result is a program that is both smaller and faster.Dann Corbit wrote: ↑Thu Sep 03, 2020 7:35 pm From: https://docs.microsoft.com/en-us/cpp/pr ... ew=vs-2019
we have this:
"Programs that use intrinsic functions are faster because they don't have the overhead of function calls. However, they may be larger because of the additional code generated."