KataGo icon indicating copy to clipboard operation
KataGo copied to clipboard

i686 compile error type casting no matching function for call to min()

Open jason1987d opened this issue 3 years ago • 10 comments

/builddir/KataGo-1.11.0/cpp/search/search.cpp: In member function 'void Search::runWholeSearch(std::atomic<bool>&, std::function<void()>*, bool, const TimeControls&, double)': /builddir/KataGo-1.11.0/cpp/search/search.cpp:493:114: error: no matching function for call to 'min(double&, double_t&)' 493 | double upperBoundVisits = computeUpperBoundVisitsLeftDueToTime(rootVisits, timeUsed, std::min(tcLimit,maxTime));

jason1987d avatar Jul 22 '22 21:07 jason1987d

Oh, nice catch thanks! https://github.com/lightvector/KataGo/blob/master/cpp/search/search.cpp#L461

That this variable is declared as "double_t" instead of "double" is definitely a typo, it should just be "double", I don't think it was ever intentional to use https://en.cppreference.com/w/c/numeric/math/float_t.

Grepping the repo, I can find 2 other instances of "double_t" that can all just be "double". Pushed a change to master just now at https://github.com/lightvector/KataGo/commit/d426f5408803344fdb67535ea065314a20594942 to make them just "double". Does that fix the issue?

lightvector avatar Jul 23 '22 03:07 lightvector

Have not tested that yet. When might the next release be set? I've been porting packages to Void Linux https://github.com/void-linux/void-packages/pull/38190 and could make a patch for this or if you have a patch file ready I could test that.

It could be a tricky process in general, given the several different backends available.

jason1987d avatar Jul 23 '22 03:07 jason1987d

Finally had time to test. Running it now through void's CI after pushing patches to my template. Thank you for looking into this quickly.

jason1987d avatar Jul 23 '22 16:07 jason1987d

I can't find the actual error for some reason, but it's still failing on two of the architectures void supports. https://github.com/void-linux/void-packages/actions/runs/2724316092

Update: after scrolling carefully, found this fun thing: FATAL ERROR: Failed test assert: sizeof(size_t) == 8

jason1987d avatar Jul 23 '22 16:07 jason1987d

FATAL ERROR: Failed test assert: sizeof(size_t) == 8

I will note that for void anyway, we found this only fails for x86 (i686) architecture. The builds work for all the others.

jason1987d avatar Jul 26 '22 18:07 jason1987d

FATAL ERROR: Failed test assert: sizeof(size_t) == 8

I will note that for void anyway, we found this only fails for x86 (i686) architecture. The builds work for all the others.

Do I need to make this a separate issue and mark this one closed? And it would be my guess to add a check such that sizeof(size_t) == 4 on 32bit archs?

jason1987d avatar Jul 28 '22 19:07 jason1987d

Thanks for the bump - heh, size_t being 4 bytes is interesting. I think there's some chance everything works if you simply remove or suppress that assert. Does that seems like it's the case? I never actually myself tested KataGo on a 4-byte system, though, since I don't personally even have such a system.

lightvector avatar Jul 29 '22 00:07 lightvector

It looks like that fixed it so far for i686. The package built. Still testing to see whether everything still builds for the other architectures.

jason1987d avatar Jul 29 '22 21:07 jason1987d

It built for i686 on my machine, but on the void linux CI it failed on this line in tests fancymath.cpp:

APPROX_EQ(betapdf(1-1e-4,.5e5,.5e1), 8773.80701229644182604, 1e-14);

jason1987d avatar Jul 29 '22 21:07 jason1987d

Thanks for working through this. I know that different system libraries may return slightly different answers for transcendental functions, but of course numerical analysis is hard so I just set thresholds working on the machines I had access to. So the tolerance might indeed be too small.

Does it work if you raise 1e-14 on this and other lines where it fails to a somewhat larger value? Like 1e-12 or 1e-10? As part of that error it should have reported also to stdout or to stderr what the full numerical values actually were so you can see how many decimals they match.

Looking at the code now, the T distribution tests at the end also aren't particularly cross-machine friendly since in theory a value could end up close to a rounding boundary such that even a small difference could cause a printed digit to change. I'm happy to fix that too if needed.

lightvector avatar Jul 29 '22 21:07 lightvector