Yearly Compile of Crafty

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

jhaglund
Posts: 173
Joined: Sun May 11, 2008 7:43 am

Yearly Compile of Crafty

Post by jhaglund »

So I haven't compiled Crafty in awhile, infact Crafty seems overdue for a new release ;) ... nothing has changed with the source code ...

Last time I compiled with VS Express 2008 (32-bit). (Aug 02, 2010)

This time I compiled with VS Express 2010 (32-bit).

Here's what I find:

For Windows -> Makefile.xp

Default:

Code: Select all

C:\WinBoard\crafty-23.4>nmake -f Makefile.xp

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl /D_CONSOLE /DWIN32 /D_CRT_SECURE_NO_DEPRECATE /Ox /Gr /GL /MT /DSMP /
DCPUS=4  /DNT_i386 /c crafty.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

crafty.c
c:\winboard\crafty-23.4\lock.h(14) : error C2061: syntax error : identifier 'Num
aStartThread'
c:\winboard\crafty-23.4\lock.h(14) : error C2059: syntax error : ';'
c:\winboard\crafty-23.4\lock.h(14) : error C2059: syntax error : 'type'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BI
N\cl.EXE"' : return code '0x2'
Stop.
Comment
lock.h (14)

Code: Select all

//extern pthread_t NumaStartThread(void *func, void *args);

Code: Select all

C:\WinBoard\crafty-23.4>nmake -f Makefile.xp

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl /D_CONSOLE /DWIN32 /D_CRT_SECURE_NO_DEPRECATE /Ox /Gr /GL /MT /DSMP /
DCPUS=4  /DNT_i386 /c crafty.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

crafty.c
        cl /D_CONSOLE /DWIN32 /D_CRT_SECURE_NO_DEPRECATE /Ox /Gr /GL /MT /DSMP /
DCPUS=4  /DNT_i386 /Zm500 /c egtb.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

egtb.cpp
        link /LTCG crafty.obj egtb.obj /out:crafty.exe
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Generating code
Finished generating code

Code: Select all

C:\WinBoard\crafty-23.4>crafty
unable to open book file [./book.bin].
book is disabled
unable to open book file [./books.bin].

Initializing multiple threads.
System is SMP, not NUMA.

Crafty v23.4 (1 cpus)

White(1): mt 2
Warning--  xboard 'cores' option disabled
max threads set to 2.
White(1): bench
Running benchmark. . .
......
Total nodes: 285658677
Raw nodes per second: 1947628
Total elapsed time: 146.67
White(1):
Besides the one line of code in lock.h, it compiles out-of-the-box again, easily... but it probably doesn't work with NUMA systems now. :wink:

I uploaded Crafty 23.4 for anyone...
http://www.mediafire.com/?ynocbae3slncsqw

Joshua D. Haglund
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Yearly Compile of Crafty

Post by bob »

jhaglund wrote:So I haven't compiled Crafty in awhile, infact Crafty seems overdue for a new release ;) ... nothing has changed with the source code ...

Last time I compiled with VS Express 2008 (32-bit). (Aug 02, 2010)

This time I compiled with VS Express 2010 (32-bit).

Here's what I find:

For Windows -> Makefile.xp

Default:

Code: Select all

C:\WinBoard\crafty-23.4>nmake -f Makefile.xp

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl /D_CONSOLE /DWIN32 /D_CRT_SECURE_NO_DEPRECATE /Ox /Gr /GL /MT /DSMP /
DCPUS=4  /DNT_i386 /c crafty.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

crafty.c
c:\winboard\crafty-23.4\lock.h(14) : error C2061: syntax error : identifier 'Num
aStartThread'
c:\winboard\crafty-23.4\lock.h(14) : error C2059: syntax error : ';'
c:\winboard\crafty-23.4\lock.h(14) : error C2059: syntax error : 'type'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BI
N\cl.EXE"' : return code '0x2'
Stop.
Comment
lock.h (14)

Code: Select all

//extern pthread_t NumaStartThread(void *func, void *args);

Code: Select all

C:\WinBoard\crafty-23.4>nmake -f Makefile.xp

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl /D_CONSOLE /DWIN32 /D_CRT_SECURE_NO_DEPRECATE /Ox /Gr /GL /MT /DSMP /
DCPUS=4  /DNT_i386 /c crafty.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

crafty.c
        cl /D_CONSOLE /DWIN32 /D_CRT_SECURE_NO_DEPRECATE /Ox /Gr /GL /MT /DSMP /
DCPUS=4  /DNT_i386 /Zm500 /c egtb.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

egtb.cpp
        link /LTCG crafty.obj egtb.obj /out:crafty.exe
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Generating code
Finished generating code

Code: Select all

C:\WinBoard\crafty-23.4>crafty
unable to open book file [./book.bin].
book is disabled
unable to open book file [./books.bin].

Initializing multiple threads.
System is SMP, not NUMA.

Crafty v23.4 (1 cpus)

White(1): mt 2
Warning--  xboard 'cores' option disabled
max threads set to 2.
White(1): bench
Running benchmark. . .
......
Total nodes: 285658677
Raw nodes per second: 1947628
Total elapsed time: 146.67
White(1):
Besides the one line of code in lock.h, it compiles out-of-the-box again, easily... but it probably doesn't work with NUMA systems now. :wink:

I uploaded Crafty 23.4 for anyone...
http://www.mediafire.com/?ynocbae3slncsqw

Joshua D. Haglund
It should work on NUMA boxes so far as I know. Most multiple-cpu (not multicore) boxes today are NUMA, in fact. Including the one I used in the last CCT...
jhaglund
Posts: 173
Joined: Sun May 11, 2008 7:43 am

Re: Yearly Compile of Crafty

Post by jhaglund »

Besides the one line of code in lock.h, it compiles out-of-the-box again, easily... but it probably doesn't work with NUMA systems now. :wink:

I uploaded Crafty 23.4 for anyone...
http://www.mediafire.com/?ynocbae3slncsqw

Joshua D. Haglund
It should work on NUMA boxes so far as I know. Most multiple-cpu (not multicore) boxes today are NUMA, in fact. Including the one I used in the last CCT...
Even with:

lock.h (line 14)

Code: Select all

//extern pthread_t NumaStartThread(void *func, void *args); //commented out
I'm saying it doesn't compile unless I disable that line of code.

:?:
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Yearly Compile of Crafty

Post by bob »

jhaglund wrote:
Besides the one line of code in lock.h, it compiles out-of-the-box again, easily... but it probably doesn't work with NUMA systems now. :wink:

I uploaded Crafty 23.4 for anyone...
http://www.mediafire.com/?ynocbae3slncsqw

Joshua D. Haglund
It should work on NUMA boxes so far as I know. Most multiple-cpu (not multicore) boxes today are NUMA, in fact. Including the one I used in the last CCT...
Even with:

lock.h (line 14)

Code: Select all

//extern pthread_t NumaStartThread(void *func, void *args); //commented out
I'm saying it doesn't compile unless I disable that line of code.

:?:
Should not cause any problems. That is just a function prototype declaration. What kind of error does it produce? I don't see how it can cause an error because NumaStartThread() is defined in utility.c and is declared exactly that same way, unless I am missing something somewhere...

But with that commented out, things should still work perfectly, since the function does get called where it is supposed to.
jhaglund
Posts: 173
Joined: Sun May 11, 2008 7:43 am

Re: Yearly Compile of Crafty

Post by jhaglund »

bob wrote:
jhaglund wrote:
Besides the one line of code in lock.h, it compiles out-of-the-box again, easily... but it probably doesn't work with NUMA systems now. :wink:

I uploaded Crafty 23.4 for anyone...
http://www.mediafire.com/?ynocbae3slncsqw

Joshua D. Haglund
It should work on NUMA boxes so far as I know. Most multiple-cpu (not multicore) boxes today are NUMA, in fact. Including the one I used in the last CCT...
Even with:

lock.h (line 14)

Code: Select all

//extern pthread_t NumaStartThread(void *func, void *args); //commented out
I'm saying it doesn't compile unless I disable that line of code.

:?:
Should not cause any problems. That is just a function prototype declaration. What kind of error does it produce? I don't see how it can cause an error because NumaStartThread() is defined in utility.c and is declared exactly that same way, unless I am missing something somewhere...

But with that commented out, things should still work perfectly, since the function does get called where it is supposed to.
Error:

Code: Select all

c:\winboard\crafty-23.4\lock.h(14) : error C2061: syntax error : identifier 'Num 
aStartThread' 
c:\winboard\crafty-23.4\lock.h(14) : error C2059: syntax error : ';' 
c:\winboard\crafty-23.4\lock.h(14) : error C2059: syntax error : 'type' 
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 10.0\VC\BI 
N\cl.EXE"' : return code '0x2' 
Stop.
Crafty will compile fine if you manually use the command lines:

Code: Select all

cl /D_CONSOLE /DWIN32 /D_CRT_CRT_SECURE_NO_DEPRECATE /Ox /Gr /GL /MT /DSMP /DCPU=4 /DNT_i386 /c crafty.c

cl /D_CONSOLE /DWIN32 /D_CRT_CRT_SECURE_NO_DEPRECATE /Ox /Gr /GL /MT /DSMP /DCPU=4 /DNT_i386 /Zm500 /c egtb.cpp

link /LTCG crafty.obj egtb.obj /out:crafty.exe
However, maybe I am over looking something by using the command line:

Code: Select all

C:\WinBoard\crafty-23.4>crafty
unable to open book file [./book.bin].
book is disabled
unable to open book file [./books.bin].

Initializing multiple threads.
System is SMP, not NUMA.
Warning--  xboard 'cores' option disabled
ERROR - Crafty was compiled with CPUS=1.  mt can not exceed this value.
max threads set to 1.
Warning--  xboard 'memory' option disabled
hash table memory = 128M bytes (8M entries).
Warning--  xboard 'memory' option disabled
pawn hash table memory = 32M bytes (1M entries).

Crafty v23.4 (1 cpus)

White(1):
It only uses one CPU? :?:

This is why I comment out
lock.h (line 14)

Code: Select all

//extern pthread_t NumaStartThread(void *func, void *args); //commented out 
... so when I use:
nmake -f Makefile.xp
All the CPU's work fine...
Otherwise, it doesn't...
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Yearly Compile of Crafty

Post by Sven »

Commenting out a line that is flagged with a compiler error message is sometimes not the best solution. In this case I think that the problem with line 14 in lock.h is most likely related to the type HANDLE which seems to be unknown at this point of compilation. At least this would be a possible explanation for the syntax error C2061 which indicates that the identifier NumaStartThread is unexpected. I can't tell exactly why this is the case since currently I have no way of checking it (my PC @home currently has no development system installed, actually almost no software at all, after installing the system from scratch due to a HD problem ...).

My proposal would be to change lines 10-14 of lock.h as follows:

Code: Select all

#  if defined(_WIN32) || defined(_WIN64)
#    define pthread_attr_t  HANDLE
#    define pthread_t       HANDLE
#    define thread_t        HANDLE
extern pthread_t NumaStartThread(void *func, void *args);
into

Code: Select all

#  if defined(_WIN32) || defined(_WIN64)
#    include <windows.h>
#    define pthread_attr_t  HANDLE
#    define pthread_t       HANDLE
#    define thread_t        HANDLE
extern pthread_t NumaStartThread&#40;void *func, void *args&#41;;
Sven
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Yearly Compile of Crafty

Post by bob »

jhaglund wrote:
bob wrote:
jhaglund wrote:
Besides the one line of code in lock.h, it compiles out-of-the-box again, easily... but it probably doesn't work with NUMA systems now. :wink:

I uploaded Crafty 23.4 for anyone...
http://www.mediafire.com/?ynocbae3slncsqw

Joshua D. Haglund
It should work on NUMA boxes so far as I know. Most multiple-cpu (not multicore) boxes today are NUMA, in fact. Including the one I used in the last CCT...
Even with:

lock.h (line 14)

Code: Select all

//extern pthread_t NumaStartThread&#40;void *func, void *args&#41;; //commented out
I'm saying it doesn't compile unless I disable that line of code.

:?:
Should not cause any problems. That is just a function prototype declaration. What kind of error does it produce? I don't see how it can cause an error because NumaStartThread() is defined in utility.c and is declared exactly that same way, unless I am missing something somewhere...

But with that commented out, things should still work perfectly, since the function does get called where it is supposed to.
Error:

Code: Select all

c&#58;\winboard\crafty-23.4\lock.h&#40;14&#41; &#58; error C2061&#58; syntax error &#58; identifier 'Num 
aStartThread' 
c&#58;\winboard\crafty-23.4\lock.h&#40;14&#41; &#58; error C2059&#58; syntax error &#58; ';' 
c&#58;\winboard\crafty-23.4\lock.h&#40;14&#41; &#58; error C2059&#58; syntax error &#58; 'type' 
NMAKE &#58; fatal error U1077&#58; '"C&#58;\Program Files\Microsoft Visual Studio 10.0\VC\BI 
N\cl.EXE"' &#58; return code '0x2' 
Stop.
Crafty will compile fine if you manually use the command lines:

Code: Select all

cl /D_CONSOLE /DWIN32 /D_CRT_CRT_SECURE_NO_DEPRECATE /Ox /Gr /GL /MT /DSMP /DCPU=4 /DNT_i386 /c crafty.c

cl /D_CONSOLE /DWIN32 /D_CRT_CRT_SECURE_NO_DEPRECATE /Ox /Gr /GL /MT /DSMP /DCPU=4 /DNT_i386 /Zm500 /c egtb.cpp

link /LTCG crafty.obj egtb.obj /out&#58;crafty.exe
However, maybe I am over looking something by using the command line:

Code: Select all

C&#58;\WinBoard\crafty-23.4>crafty
unable to open book file &#91;./book.bin&#93;.
book is disabled
unable to open book file &#91;./books.bin&#93;.

Initializing multiple threads.
System is SMP, not NUMA.
Warning--  xboard 'cores' option disabled
ERROR - Crafty was compiled with CPUS=1.  mt can not exceed this value.
max threads set to 1.
Warning--  xboard 'memory' option disabled
hash table memory = 128M bytes &#40;8M entries&#41;.
Warning--  xboard 'memory' option disabled
pawn hash table memory = 32M bytes &#40;1M entries&#41;.

Crafty v23.4 &#40;1 cpus&#41;

White&#40;1&#41;&#58;
It only uses one CPU? :?:

This is why I comment out
lock.h (line 14)

Code: Select all

//extern pthread_t NumaStartThread&#40;void *func, void *args&#41;; //commented out 
... so when I use:
nmake -f Makefile.xp
All the CPU's work fine...
Otherwise, it doesn't...
Do you have -DCPUS=2 or something set for a compiler option? The warning above:

ERROR - Crafty was compiled with CPUS=1. mt can not exceed this value.

says that Crafty was compiled without CPUS (a macro) being set to some value > 1 which turns on SMP/NUMA thread support...
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Yearly Compile of Crafty

Post by Sven »

Joshua's compiler command line seems to include /DCPU=4 instead of /DCPUS=4, maybe that is part of the problem at runtime.

Sven
jhaglund
Posts: 173
Joined: Sun May 11, 2008 7:43 am

Re: Yearly Compile of Crafty

Post by jhaglund »

Joshua's compiler command line seems to include /DCPU=4 instead of /DCPUS=4, maybe that is part of the problem at runtime.

Sven
Silly me. Changing to /DCPUS fixes the /MT compile...

...but I still have to comment out the declaration to compile
lock.h(14)

Code: Select all

//extern pthread_t NumaStartThread&#40;void *func, void *args&#41;; //commented out
With Sven's note of adding #include <windows.h> fixes the compile process, and I do NOT need to //comment out lock.h: line 14 anymore.

Code: Select all

#  if defined&#40;_WIN32&#41; || defined&#40;_WIN64&#41; 
#    include <windows.h> 
#    define pthread_attr_t  HANDLE 
#    define pthread_t       HANDLE 
#    define thread_t        HANDLE 
extern pthread_t NumaStartThread&#40;void *func, void *args&#41;;
Good work,
:)
Joshua D. Haglund
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Yearly Compile of Crafty

Post by bob »

jhaglund wrote:
Joshua's compiler command line seems to include /DCPU=4 instead of /DCPUS=4, maybe that is part of the problem at runtime.

Sven
Silly me. Changing to /DCPUS fixes the /MT compile...

...but I still have to comment out the declaration to compile
lock.h(14)

Code: Select all

//extern pthread_t NumaStartThread&#40;void *func, void *args&#41;; //commented out
With Sven's note of adding #include <windows.h> fixes the compile process, and I do NOT need to //comment out lock.h: line 14 anymore.

Code: Select all

#  if defined&#40;_WIN32&#41; || defined&#40;_WIN64&#41; 
#    include <windows.h> 
#    define pthread_attr_t  HANDLE 
#    define pthread_t       HANDLE 
#    define thread_t        HANDLE 
extern pthread_t NumaStartThread&#40;void *func, void *args&#41;;
Good work,
:)
Joshua D. Haglund
I've made that change...