crafty-22.0

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Denis P. Mendoza
Posts: 415
Joined: Fri Dec 15, 2006 9:46 pm
Location: Philippines

Re: crafty-22.0

Post by Denis P. Mendoza »

Bob wrote:
what compiler are you using?
The errors were taken using MSVC8 interface during my first trial compiling with 64-bit.

Jarrko wrote:
Change
# define lock_t "volatile int"
to
# define lock_t volatile int
in lock.h
Thanks Jarrko. I also saw that, but that didn't help either.

I''m not familiar with these errors, so external help is a necessity :wink: .
User avatar
Denis P. Mendoza
Posts: 415
Joined: Fri Dec 15, 2006 9:46 pm
Location: Philippines

Re: crafty-22.0

Post by Denis P. Mendoza »

Jim Ablett wrote:Hi Denis,
hope somebody gives some tips to make a 64-bit compile on ICC or MSVC. Thanks.
The Important Switches you need to use for 64-bit Windows MSVC/Intel are >

Code: Select all

/DNT_i386 /DWIN64 /DNT_INTEREX 
The rest are optional. The problem is you can compile and run x64
successfully (non-smp) with low optimization switches only i.e
go any higher than

Code: Select all

/O1 or /Os
and compiled exe will crash.

Jim.
Many thanks Jim. I hope the problem is solved for the Windows versions for MSVC and ICC.

Have you tried MingW64?
frankp
Posts: 233
Joined: Sun Mar 12, 2006 3:11 pm

Re: crafty-22.0

Post by frankp »

Bob

Thanks for making this available.

Frank
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: crafty-22.0

Post by jwes »

Denis P. Mendoza wrote:Bob wrote:
what compiler are you using?
The errors were taken using MSVC8 interface during my first trial compiling with 64-bit.

Jarrko wrote:
Change
# define lock_t "volatile int"
to
# define lock_t volatile int
in lock.h
Thanks Jarrko. I also saw that, but that didn't help either.

I''m not familiar with these errors, so external help is a necessity :wink: .
Change

# define CPUS=1
to
# define CPUS 1
in chess.h

NumaStartThread(ThreadInit, (void *) proc);
to
#if CPUS > 1
NumaStartThread(ThreadInit, (void *) proc);
#endif
in iterate.c

and put
#if CPUS > 1

#endif
around the function
NumaStartThread();
in utility.c

and it compiles for me with VS7 and win32 on a single cpu machine.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: crafty-22.0

Post by bob »

Guetti wrote:Doesn't compile under linux 64-bit amd64:

Code: Select all

%make linux-amd64
make target=LINUX \
                CC=gcc CXX=g++ \
                CFLAGS=' -Wall -pipe \
                -fbranch-probabilities -fomit-frame-pointer -O3 -march=k8' \
                CXFLAGS= \
                LDFLAGS=' -lstdc++' \
                opt=' -DINLINE64 -DCPUS=1' \
                crafty-make
make[1]: Entering directory `/home/andreas/crafty-22.0'
make[2]: Entering directory `/home/andreas/crafty-22.0'
gcc -Wall -pipe \
                -fbranch-probabilities -fomit-frame-pointer -O3 -march=k8 -DINLINE64 -DCPUS=1 -DLINUX -c crafty.c
In file included from chess.h:132,
                 from searchr.c:1,
                 from crafty.c:1:
lock.h:121:1: warning: "lock_t" redefined
In file included from searchr.c:1,
                 from crafty.c:1:
chess.h:131:1: warning: this is the location of the previous definition
In file included from searchr.c:1,
                 from crafty.c:1:
chess.h:353: error: expected specifier-qualifier-list before string constant
chess.h:393: error: expected specifier-qualifier-list before string constant
In file included from crafty.c:1:
searchr.c: In function 'SearchRoot':
searchr.c:179: error: 'SHARED' has no member named 'draw_score'
In file included from crafty.c:2:
search.c: In function 'Search':
search.c:51: error: 'TREE' has no member named 'thread_id'
search.c:52: error: 'SHARED' has no member named 'next_time_check'
search.c:53: error: 'SHARED' has no member named 'next_time_check'
search.c:53: error: 'SHARED' has no member named 'nodes_between_time_checks'
search.c:73: error: 'SHARED' has no member named 'draw_score'
search.c:156: error: 'SHARED' has no member named 'draw_score'
search.c:245: error: 'TREE' has no member named 'stop'
search.c:282: error: 'TREE' has no member named 'stop'
search.c:289: error: 'TREE' has no member named 'stop'
search.c:335: error: 'TREE' has no member named 'stop'
search.c:358: error: 'TREE' has no member named 'stop'
search.c:368: error: 'TREE' has no member named 'stop'
search.c:389: error: 'TREE' has no member named 'stop'
search.c:391: error: 'SHARED' has no member named 'smp_idle'
search.c:392: error: 'SHARED' has no member named 'min_thread_depth'
search.c:393: error: 'TREE' has no member named 'alpha'
search.c:394: error: 'TREE' has no member named 'beta'
search.c:395: error: 'TREE' has no member named 'value'
search.c:396: error: 'TREE' has no member named 'wtm'
search.c:397: error: 'TREE' has no member named 'ply'
search.c:398: error: 'TREE' has no member named 'depth'
search.c:399: error: 'TREE' has no member named 'mate_threat'
search.c:401: error: 'TREE' has no member named 'stop'
search.c:403: error: 'TREE' has no member named 'thread_id'
search.c:429: error: 'SHARED' has no member named 'draw_score'
In file included from crafty.c:3:
thread.c: In function 'Thread':
thread.c:34: error: 'SHARED' has no member named 'max_threads'
thread.c:35: error: 'SHARED' has no member named 'max_threads'
thread.c:35: error: 'TREE' has no member named 'stop'
thread.c:63: error: 'SHARED' has no member named 'splitting'
thread.c:64: error: 'SHARED' has no member named 'parallel_splits'
thread.c:65: error: 'TREE' has no member named 'thread_id'
thread.c:66: error: 'TREE' has no member named 'nprocs'
thread.c:68: error: 'SHARED' has no member named 'max_threads'
thread.c:68: error: 'SHARED' has no member named 'max_thread_group'
thread.c:70: error: 'TREE' has no member named 'siblings'
thread.c:76: error: 'TREE' has no member named 'siblings'
thread.c:77: error: 'TREE' has no member named 'thread_id'
thread.c:78: error: 'TREE' has no member named 'parent'
thread.c:79: error: 'TREE' has no member named 'nprocs'
thread.c:85: error: 'TREE' has no member named 'siblings'
thread.c:87: error: 'TREE' has no member named 'value'
thread.c:90: error: 'TREE' has no member named 'thread_id'
thread.c:91: error: 'SHARED' has no member named 'splitting'
thread.c:103: error: 'SHARED' has no member named 'max_threads'
thread.c:104: error: 'TREE' has no member named 'siblings'
thread.c:105: error: 'TREE' has no member named 'siblings'
thread.c:106: error: 'SHARED' has no member named 'splitting'
thread.c:129: error: 'TREE' has no member named 'thread_id'
thread.c: In function 'CopyFromSMP':
thread.c:150: error: 'TREE' has no member named 'stop'
thread.c:151: error: 'TREE' has no member named 'ply'
thread.c:151: error: 'TREE' has no member named 'ply'
thread.c:173: error: 'TREE' has no member named 'root_move_text'
thread.c:173: error: 'TREE' has no member named 'root_move_text'
thread.c:174: error: 'TREE' has no member named 'used'
thread.c: In function 'CopyToSMP':
thread.c:193: error: 'SHARED' has no member named 'max_threads'
thread.c:195: error: 'TREE' has no member named 'used'
thread.c:200: error: 'TREE' has no member named 'used'
thread.c:209: error: 'TREE' has no member named 'used'
thread.c:211: error: 'SHARED' has no member named 'max_split_blocks'
thread.c:211: error: 'SHARED' has no member named 'max_split_blocks'
thread.c:211: error: 'SHARED' has no member named 'max_split_blocks'
thread.c:213: error: 'TREE' has no member named 'used'
thread.c:214: error: 'TREE' has no member named 'stop'
thread.c:215: error: 'SHARED' has no member named 'max_threads'
thread.c:216: error: 'TREE' has no member named 'siblings'
thread.c:218: error: 'TREE' has no member named 'ply'
thread.c:218: error: 'TREE' has no member named 'ply'
thread.c:219: error: 'TREE' has no member named 'ply'
thread.c:219: error: 'TREE' has no member named 'ply'
thread.c:220: error: 'TREE' has no member named 'ply'
thread.c:220: error: 'TREE' has no member named 'ply'
thread.c:221: error: 'TREE' has no member named 'ply'
thread.c:221: error: 'TREE' has no member named 'ply'
thread.c:222: error: 'TREE' has no member named 'ply'
thread.c:222: error: 'TREE' has no member named 'ply'
thread.c:228: error: 'TREE' has no member named 'ply'
thread.c:229: error: 'TREE' has no member named 'ply'
thread.c:229: error: 'TREE' has no member named 'ply'
thread.c:230: error: 'TREE' has no member named 'ply'
thread.c:256: error: 'TREE' has no member named 'alpha'
thread.c:256: error: 'TREE' has no member named 'alpha'
thread.c:257: error: 'TREE' has no member named 'beta'
thread.c:257: error: 'TREE' has no member named 'beta'
thread.c:258: error: 'TREE' has no member named 'value'
thread.c:258: error: 'TREE' has no member named 'value'
thread.c:259: error: 'TREE' has no member named 'wtm'
thread.c:259: error: 'TREE' has no member named 'wtm'
------ snip---------
etc, etc
It is compiling and running cleanly here... I should add are you sure that is the best target? that is a NUMA compile and you might or might not have libnuma installed... But for me, on my suse 10.2 and suse 10.3 64 bit boxes, either make linux-64 (uses intel compiler which is faster) and make linux-amd64 (uses gcc + libnuma) work perfectly. Do you have some old .h files laying around or perhaps old source that got mixed in? 22.0 is _drastically_ different from 21.7 in terms of data values, structures, etc...

Here is what I get on the make linux-amd64 on my suse laptop:

scrappy% make linux-amd64
make target=LINUX \
CC=gcc CXX=g++ \
CFLAGS=' -Wall -pipe \
-fbranch-probabilities -fomit-frame-pointer -O3 -march=k8' \
CXFLAGS= \
LDFLAGS=' -lnuma -lstdc++' \
opt=' -DINLINE64 -DCPUS=8 -DNUMA -DLIBNUMA' \
crafty-make
make[1]: Entering directory `/home/hyatt/crafty'
make[2]: Entering directory `/home/hyatt/crafty'
gcc -Wall -pipe \
-fbranch-probabilities -fomit-frame-pointer -O3 -march=k8 -DINLI
NE64 -DCPUS=8 -DNUMA -DLIBNUMA -DLINUX -c crafty.c
crafty.c: In function ‘ValidatePosition’:
crafty.c:46: note: file crafty.gcda not found, execution counts estimated
g++ -c -DINLINE64 -DCPUS=8 -DNUMA -DLIBNUMA -DLINUX egtb.cpp
egtb.cpp:4478: warning: ‘TB_CRC_CHECK’ initialized and declared ‘extern’
gcc -lnuma -lstdc++ -o crafty crafty.o egtb.o -lm
make[2]: Leaving directory `/home/hyatt/crafty'
make[1]: Leaving directory `/home/hyatt/crafty'

It also ran just fine...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: crafty-22.0

Post by bob »

Guetti wrote:Apparently line 121-124 in lock.h have to be changed:

Code: Select all

#  define lock_t volatile int
//#  define pthread_attr_t  HANDLE
//#  define pthread_t       HANDLE
//#  define thread_t        HANDLE
Furthermore, in line 33 chess.h the "=" in define CPUS=1 is not accpeted in a macro directive

compiles now
I have no idea why that fails. It works fine with both gcc and icc on my box, and on MSCV that crafty team members are using to compile. I changed it to omit the =, but do not see why it was causing compiler problems...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: crafty-22.0

Post by bob »

Uri Blass wrote:
bob wrote:The source is now up on the ftp box. While it is pretty clean, it is not the "finished product" yet. Additional cleanup will happen over the next few versions...

Feedback is welcome if there are any compiling issues that crop up. It works fine under gcc and intel's c compiler on linux, and a couple have compiled it on MSVC as well, so it should pose no problems...
looking at the move generator I see the following part repeats again and again and I wonder if you plan to replace it or something bigger by a function as part of the additional cleanup.

Code: Select all

while (moves) {
      to = Advanced(wtm, moves);
      *move++ = temp | (to << 6) | (Abs(PcOnSq(to)) << 15);
      Clear(to, moves);
    }
    Clear(from, piecebd);
Uri
I can already eliminate all of that, not just the part to extract the moves and stuff 'em in an array. But I have not done so yet. Eventually I will have one loop to generate moves for all pieces, and one loop to generate moves for pawns (which are different enough to make it not worthwhile to try to share any code).

As I mentioned, there is a lot of cleanup left to do now that the basic infrastructure is present to eliminate the duplication.

Replacing the above with a function is really pointless, because the function just get inlined and there is no performance gain at all. But collapsing all piece move generations into one loop will shrink the size of the code and have a positive impact...

If you look at make/unmake, you will not see anything duplicated between different piece types, and that is my goal for movgen as well...
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: crafty-22.0

Post by jwes »

it fails if you don't have CPUS defined in your makefile.
Guetti

Re: crafty-22.0

Post by Guetti »

bob wrote: It is compiling and running cleanly here... I should add are you sure that is the best target? that is a NUMA compile and you might or might not have libnuma installed... But for me, on my suse 10.2 and suse 10.3 64 bit boxes, either make linux-64 (uses intel compiler which is faster) and make linux-amd64 (uses gcc + libnuma) work perfectly. Do you have some old .h files laying around or perhaps old source that got mixed in? 22.0 is _drastically_ different from 21.7 in terms of data values, structures, etc...

Here is what I get on the make linux-amd64 on my suse laptop:

scrappy% make linux-amd64
make target=LINUX \
CC=gcc CXX=g++ \
CFLAGS=' -Wall -pipe \
-fbranch-probabilities -fomit-frame-pointer -O3 -march=k8' \
CXFLAGS= \
LDFLAGS=' -lnuma -lstdc++' \
opt=' -DINLINE64 -DCPUS=8 -DNUMA -DLIBNUMA' \
crafty-make
make[1]: Entering directory `/home/hyatt/crafty'
make[2]: Entering directory `/home/hyatt/crafty'
gcc -Wall -pipe \
-fbranch-probabilities -fomit-frame-pointer -O3 -march=k8 -DINLI
NE64 -DCPUS=8 -DNUMA -DLIBNUMA -DLINUX -c crafty.c
crafty.c: In function ‘ValidatePosition’:
crafty.c:46: note: file crafty.gcda not found, execution counts estimated
g++ -c -DINLINE64 -DCPUS=8 -DNUMA -DLIBNUMA -DLINUX egtb.cpp
egtb.cpp:4478: warning: ‘TB_CRC_CHECK’ initialized and declared ‘extern’
gcc -lnuma -lstdc++ -o crafty crafty.o egtb.o -lm
make[2]: Leaving directory `/home/hyatt/crafty'
make[1]: Leaving directory `/home/hyatt/crafty'

It also ran just fine...
So, which is the correct target to build for gcc, Linux 64-bit, Athlon64 and 1 CPU?
I think it was failing because I have only 1 CPU. As you can see I removed the -DLIBNUMA -DNUMA and -lnuma -DCPUS from linux-amd64 in the Makefile. But it didn't work.

chess.h:353: error: expected specifier-qualifier-list before string constant
chess.h:393: error: expected specifier-qualifier-list before string constant
jwes
Posts: 778
Joined: Sat Jul 01, 2006 7:11 am

Re: crafty-22.0

Post by jwes »

A compile error, a feature request and a minor bug.
1. in epd.c you need to move chess.h above epddefs.h
2. Could you add a linelength command to control the display of PVs ? No one has 80 column terminals anymore, and it would also make parsing logfiles much easier.
3. If you compile with DEBUG defined, and try to annotate a PGN file with a FEN string, crafty exits immediately with the message
ERROR! hash_key is bad.

[Event "London"]
[Site "?"]
[Date "1922.??.??"]
[Round "?"]
[White "Reti"]
[Black "Borovsky, Znosko"]
[Result "1-0"]
[FEN "3q1r2/1p1b1pk1/pn5p/3pN1pQ/3P3P/2r3B1/P4PP1/3RR1K1 w - - 0 1"]

1. Nxf7 Rxf7 2. Be5+ Rf6 3. hxg5 hxg5 4. Qxg5+ Kf7 5. Qh5+
Kg7 (5... Kg8 6. Qh4) 6. g4 Nc4 7. Qg5+ Kf7 8. Bxf6 Qxf6 9. Qxd5+ Be6 10. Qxb7+
Kg8 11. Qxa6 $18 1-0