dangi12012 wrote: ↑Fri Dec 03, 2021 5:20 pmSo yeah you can use gcc with mingw (not cygwin) but every software that uses "fork" will crash.
Chess engines, which is what we're talking about in this thread, usually don't use fork anyway because they centre around threads, not processes. For that, plus thread synchronisation with mutexes and conditions, MingW with its pthread wrapper library (not Cygwin) works just fine. The main drawback is that it adds about 30kB to the executable.
It seems most discussions here get derailed. I wannt to stick to the topic:
I wonder if it is possible to build a Cfish fork for Windows with free tools ? Maybe a CMake file , Visual Studio community with Clang compiler. What do you think ?
Yes its possible to build with gcc, and other compilers under windows. I recommend clang for best performance!
hgm wrote: ↑Fri Dec 03, 2021 4:16 pmI have always used gcc. And yes, it works natively under Windows. When I compile with the option -mno-cygwin. Then it directly uses Windows API.
So yeah you can use gcc with mingw (not cygwin) but every software that uses "fork" will crash.
What I am telling the people here is that you should think about using the more modern and better benchmarking compiler CLANG over gcc.
Dont use emulation layers - create native binaries and use them on the native system.
I would only have to update my information when I update my compiler. But there seem to be other MinGW distros based on gcc.
And when I am programming for Windows I of course do not use "fork". The windows API for that function is CreateProcess.
$ gcc --version
gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I believe it is important that you have a POSIX version of gcc, for pthread reasons.
I wonder if it is possible to build a Cfish fork for Windows with free tools ? Maybe a CMake file , Visual Studio community with Clang compiler. What do you think ?
CFish was just to show what optimisations C CANNOT do? Because people think that C is faster - but with modern C++ you have much more modern compiler backends and features like constexpr/consteval that make code a lot faster because you can make your intentions to the compiler much clearer.
Also the last port is 1 year old so it will be weaker than current stockfish.
But to your question: Yes Clang is the only option - it is the only compiler besides MSVC that supports the Windows ABI.
You can build clang on windows with its own cmake file and you get native windows binaries of clang-64.exe that you can use like you would in linux.
It will compile a stockfish.exe.
IMO just try that with stockfish? I dont know what you have to gain by using Cfish.
wrong. I've been using GCC on windows for years.
You mean you are using "gcc" on windows for years. Please look up what library it links against - and i garuantee you that its not the one you think. The people here... So much half knowledge.
Just admit you're wrong, gcc works fine on Windows. The popular mingw-w64 toolchain enables compiling C++/C code for Windows with gcc targeting the WinAPI directly, no API translation necessary. Distributing a program compiled with Cygwin gcc wouldn't even be possible.
Also, while constexpr and consteval are certainly powerful features, any self respecting C compiler will perform constant propagation which covers the majority of the cases where such features might be practically useful in a chess engine.
It's abundantly evident you're the one with "half knowledge". There wouldn't be any issue with that were you not so insufferable.
AndrewGrant wrote: ↑Thu Dec 02, 2021 11:04 pm
So is CFish faster than C++ Stockfish because Stockfish devs are unaware of how to write the language to the degree of competence you can, or because Ronald is a genius?
CFish repo translation is over one year old - so any "conclusions" you might draw are useless because it is not the current state of the software.
Why would a C program be faster than the corresponding C++ program?
It wouldnt be unless you strip out and optimize the code - like they did for CFish. https://github.com/syzygy1/Cfish/network
Were you too lazy to look that up?
Cfish when up to date with Stockfish has always been faster by 10% to 15%.
In light of your ability to demonstrate something to counter this, I will stand by the collective belief most hold.
Since you've thrown an insult, I find it a good time to point out that your movegen thing is not even close to the fastest thing out there. There are PEFFT programs that beat what you have done, using bitboards, by orders of magnitude.
Idk what PEFFT means but i am happy if you provide an url
Its not for me to "demonstrate how C++ is faster than C" so you are satisfied. Either you read the documentation and think for yourself or you are stuck with your own assumptions.
Did you read what the man said? I have put a red color on it for you.
Realize what chess programmers are, speed junkies. They start hyperventilating when they can produce a 5% faster compile, me included If I were you I would tone down a bit.
90% of coding is debugging, the other 10% is writing bugs.
$ gcc --version
gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I believe it is important that you have a POSIX version of gcc, for pthread reasons.
connor_mcmonigle wrote: ↑Sat Dec 04, 2021 10:11 am
Also, while constexpr and consteval are certainly powerful features, any self respecting C compiler will perform constant propagation which covers the majority of the cases where such features might be practically useful in a chess engine.
Is an array a constant? In C the thing instantly decays to a pointer where even perfect C compilers wouldnt know what is constant and what is variable.
Its even the basics that are missing in C that really help the compiler a lot like passing values by reference (not pointer).
You make clear to the compiler what you want. You can do that 100x better in C++ than in C. It will transform it under the "as if" rule. The asm will not look like you think it does because compilers are not just translators anymore. Im not even bringing up templates because no one writes 1024 functions by hand just because one type changed.. and that costs runtime performance.
Just because the C binary looks identical for your 5 line hello world program doesnt mean all the keywords C++ people invented are useless.
Please setup a letter to the C++ standard comittee where you write them that constexpr is useless because your C compiler can do constant folding in your hobby project.
connor_mcmonigle wrote: ↑Sat Dec 04, 2021 10:11 am
Also, while constexpr and consteval are certainly powerful features, any self respecting C compiler will perform constant propagation which covers the majority of the cases where such features might be practically useful in a chess engine.
Is an array a constant? In C the thing instantly decays to a pointer where even perfect C compilers wouldnt know what is constant and what is variable.
Its even the basics that are missing in C that really help the compiler a lot like passing values by reference (not pointer).
You make clear to the compiler what you want. You can do that 100x better in C++ than in C. It will transform it under the "as if" rule. The asm will not look like you think it does because compilers are not just translators anymore. Im not even bringing up templates because no one writes 1024 functions by hand just because one type changed.. and that costs runtime performance.
Just because the C binary looks identical for your 5 line hello world program doesnt mean all the keywords C++ people invented are useless.
Please setup a letter to the C++ standard comittee where you write them that constexpr is useless because your C compiler can do constant folding in your hobby project.
What a joke.
Pretty confident that by-reference vs by-pointer are compiled down to the same machine code, on most platforms / under most cases.
Also pretty sure that your comment about templates is wrong. Either templates are akin to copy pasting (in which case no slowdown), or they are not, and therefore introduce some overhead (slowdown).
I tried to build your program, but after an hour it was still compiling. Nice.
connor_mcmonigle wrote: ↑Sat Dec 04, 2021 10:11 am
Also, while constexpr and consteval are certainly powerful features, any self respecting C compiler will perform constant propagation which covers the majority of the cases where such features might be practically useful in a chess engine.
Is an array a constant? In C the thing instantly decays to a pointer where even perfect C compilers wouldnt know what is constant and what is variable.
Its even the basics that are missing in C that really help the compiler a lot like passing values by reference (not pointer).
You make clear to the compiler what you want. You can do that 100x better in C++ than in C. It will transform it under the "as if" rule. The asm will not look like you think it does because compilers are not just translators anymore. Im not even bringing up templates because no one writes 1024 functions by hand just because one type changed.. and that costs runtime performance.
Just because the C binary looks identical for your 5 line hello world program doesnt mean all the keywords C++ people invented are useless.
Please setup a letter to the C++ standard comittee where you write them that constexpr is useless because your C compiler can do constant folding in your hobby project.
What a joke.
I note you still won't acknowledge you were wrong.
You don't seem to understand how reference passing works?? Passing a pointer gets compiled to literally the same machine code as passing by reference in C++. How do you propose the address to the structure in memory would be passed to a function if not by some register containing said address?
I never claimed constexpr/consteval are useless. What I said was, constant propagation covers majority of the cases where such features might be practically useful in a chess engine. This is evidenced by the fact that CFish has been historically been measurably faster than Stockfish. For example, Stockfish templates on side to move in move generation and node type in search. CFish passes such information as arguments, but C compilers are sufficiently advanced to perform constant propagation on such arguments and produce machine code with comparable performance.
I think constexpr and consteval are useful features in many circumstances, but their relevance in optimizing a modern chess engine is minimal.
connor_mcmonigle wrote: ↑Sat Dec 04, 2021 10:11 am
Also, while constexpr and consteval are certainly powerful features, any self respecting C compiler will perform constant propagation which covers the majority of the cases where such features might be practically useful in a chess engine.
Is an array a constant? In C the thing instantly decays to a pointer where even perfect C compilers wouldnt know what is constant and what is variable.
Im not even bringing up templates because no one writes 1024 functions by hand just because one type changed.. and that costs runtime performance.
Macros exist. They are shit but they exist.
dangi12012 wrote:No one wants to touch anything you have posted. That proves you now have negative reputations since everyone knows already you are a forum troll.
Maybe you copied your stockfish commits from someone else too?
I will look into that.