ComStock 1.0.2 Stockfish with robobases

Discussion about chess-playing software (engines, hosts, opening books, platforms, etc...)
BB+
Posts: 1484
Joined: Thu Jun 10, 2010 4:26 am

Re: ComStock 1.0.2 Stockfish with robobases

Post by BB+ » Tue Jan 18, 2011 5:07 pm

I tried building this in Windows, but no success -- will try again this coming weekend. No issue with Linux however.
Can you build normal Stockfish (with or without GTBs) under Windows? My perception was that they didn't do much more than copy the C-based IvanHoe code for RobboBases, and made some "glue" functions (in C++) for ComStock to operate them. Another possibility is some C/C++ mixing-convention is not followed the same in Windows as in Linux.

Incidentally, ComStock was notably faster than IvanHoe in working out some of the wins for Kramnik-Carlsen from London.

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: ComStock 1.0.2 Stockfish with robobases

Post by Prima » Wed Jan 19, 2011 12:42 am

In my opinion, posting of the ComStock source without Window builds is a tease :mrgreen: . Tremendous torture beyond verbal description, I tell you :lol: .

On similar note, I have a Window 7, Quad 6700, 64-bit. My Phenom X6 is currently in suspense, or unusable. If I want to start/learn compiling, what tools would I need? Any one willing to tutor me through the procedures is deeply appreciated. Thanks.

User avatar
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: ComStock 1.0.2 Stockfish with robobases

Post by kingliveson » Wed Jan 19, 2011 2:39 am

BB+ wrote:Another possibility is some C/C++ mixing-convention is not followed the same in Windows as in Linux.
The regular Stockfish builds fine, and it looks from what I saw, the mixing of C/C++ is the issue...
PAWN : Knight >> Bishop >> Rook >>Queen

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: ComStock 1.0.2 Stockfish with robobases

Post by Prima » Tue Jan 25, 2011 8:11 pm

I tried compiling ComStock 1.0.2 in Windows7 64-bit but got these errors:

Compile error when RobboTotalCode & RobboTripleCode are Added to the already "Added"/Existing items (via Add/Existing items):

Code: Select all

Warning	1	warning C4146: unary minus operator applied to unsigned type, result still unsigned	C:\Users\PRIMA\Desktop\Src\bitboard.cpp	312	1	ComStockfish1.0.2GTB-x64
Warning	2	warning C4146: unary minus operator applied to unsigned type, result still unsigned	C:\Users\PRIMA\Desktop\Src\bitboard.cpp	318	1	ComStockfish1.0.2GTB-x64
Warning	10	warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.	C:\Users\PRIMA\Desktop\Src\uci.cpp	244	1	ComStockfish1.0.2GTB-x64
Warning	11	warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.	C:\Users\PRIMA\Desktop\Src\uci.cpp	253	1	ComStockfish1.0.2GTB-x64
Warning	12	warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.	C:\Users\PRIMA\Desktop\Src\uci.cpp	264	1	ComStockfish1.0.2GTB-x64
Warning	13	warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.	C:\Users\PRIMA\Desktop\Src\uci.cpp	269	1	ComStockfish1.0.2GTB-x64
Warning	14	warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.	C:\Users\PRIMA\Desktop\Src\uci.cpp	274	1	ComStockfish1.0.2GTB-x64
Warning	15	warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.	C:\Users\PRIMA\Desktop\Src\uci.cpp	279	1	ComStockfish1.0.2GTB-x64
Compile error with egtb Added, after adding the source in the Add/Existing items (via Add/Exisitng items):

Code: Select all

Error	3	error C2143: syntax error : missing ')' before ':'	c:\users\prima\desktop\Src\robbotriplecode\bits.h	40	1	ComStockfish1.0.2GTB-x64
Error	4	error C2290: C++ 'asm' syntax ignored. Use __asm.	c:\users\prima\desktop\Src\robbotriplecode\bits.h	40	1	ComStockfish1.0.2GTB-x64
Error	5	error C2059: syntax error : ')'	c:\users\prima\desktop\Src\robbotriplecode\bits.h	42	1	ComStockfish1.0.2GTB-x64
Error	6	error C2143: syntax error : missing ')' before ':'	c:\users\prima\desktop\Src\robbotriplecode\bits.h	49	1	ComStockfish1.0.2GTB-x64
Error	7	error C2290: C++ 'asm' syntax ignored. Use __asm.	c:\users\prima\desktop\Src\robbotriplecode\bits.h	49	1	ComStockfish1.0.2GTB-x64
Error	8	error C2059: syntax error : ')'	c:\users\prima\desktop\Src\robbotriplecode\bits.h	51	1	ComStockfish1.0.2GTB-x64
Error	9	error C1083: Cannot open include file: 'pthread.h': No such file or directory	c:\users\prima\desktop\Src\RobboTripleCode\IH-win-linux.h	68	1	ComStockfish1.0.2GTB-x64
At the very least, I should be able to compile Stockfish 2.0gtb & 2.0.1gtb since Peter C was able to compile a 32-bit version of SF 2.0.1 gtb. What do I need to do here or is this strictly a ComStock source code problem that is out of my hands?

Thanks.

BB+
Posts: 1484
Joined: Thu Jun 10, 2010 4:26 am

Re: ComStock 1.0.2 Stockfish with robobases

Post by BB+ » Tue Jan 25, 2011 8:49 pm

The first part is C++ warnings in Stockfish. These are not that important, though I think the developers desire to know about such.

The second group of errors is for RobboBase C code, and looks to be that the wrong bits.h file is being used. I think you need to tell the compiler to

Code: Select all

#define WINDOWS
either when invoking the compiler (this is some sort of /D switch if I recall), or at the top of the file IH-win-linux.h.

Note this part of the code in that file:

Code: Select all

#ifdef WINDOWS
[...]
#ifdef WINDOWS_X64 /* 64 bits */
#include "win64bits.h"
#else
#include "win32bits.h"
#endif
[...]
#else /* LINUX */
[...]
#include "bits.h"
[...]
#endif
So it looks to me that you should not be using "bits.h" when compiling in WINDOWS, and this is where the error appears to be.

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: ComStock 1.0.2 Stockfish with robobases

Post by Prima » Tue Jan 25, 2011 9:08 pm

BB+ wrote:The first part is C++ warnings in Stockfish. These are not that important, though I think the developers desire to know about such.

The second group of errors is for RobboBase C code, and looks to be that the wrong bits.h file is being used. I think you need to tell the compiler to

Code: Select all

#define WINDOWS
either when invoking the compiler (this is some sort of /D switch if I recall), or at the top of the file IH-win-linux.h.

Note this part of the code in that file:

Code: Select all

#ifdef WINDOWS
[...]
#ifdef WINDOWS_X64 /* 64 bits */
#include "win64bits.h"
#else
#include "win32bits.h"
#endif
[...]
#else /* LINUX */
[...]
#include "bits.h"
[...]
#endif
So it looks to me that you should not be using "bits.h" when compiling in WINDOWS, and this is where the error appears to be.
Thanks BB+ for this explanation, though I should re-state that I'm not a programmer. I'll look into it.

You are a Linux user but any pointers as to how I can tell the compiler to #define WINDOWS when invoking the compiler?
As for the second option recommendation to be done at the top of the file IH-win-linux.h, can I open & edit this IH-win-linux.h file manually?
If so, how should it to look like upon edition, that will be compatible for a Win7 64-bit OS?

Or, base on your assessment that I should not be using "bits.h" when compiling in WINDOWS, do I remove this "bits.h" file from both the RobboTotalCode & RobboTripleCode folders and re-attempt compiling? Please, more clarification here.

Thanks for your help.

BB+
Posts: 1484
Joined: Thu Jun 10, 2010 4:26 am

Re: ComStock 1.0.2 Stockfish with robobases

Post by BB+ » Tue Jan 25, 2011 9:13 pm

You should be able to manually edit a file by double-clicking on it and using whatever text editor you have. I think KLO said the same.
You can edit source files by expanding Source File filter, and double clicking a file. There are also optimizations that can be configured under project property...Google is very resourceful.
I think there is no reason to have the "bits.h" file (it is only used in Linux), though there is also no reason to delete it. You just have to tell the compiler that you are using WINDOWS, and so it should use win32bits.h or win64bits.h instead (this is what the #define blocks do).

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: ComStock 1.0.2 Stockfish with robobases

Post by Prima » Tue Jan 25, 2011 10:31 pm

BB+ wrote:You should be able to manually edit a file by double-clicking on it and using whatever text editor you have. I think KLO said the same.
You can edit source files by expanding Source File filter, and double clicking a file. There are also optimizations that can be configured under project property...Google is very resourceful.
I think there is no reason to have the "bits.h" file (it is only used in Linux), though there is also no reason to delete it. You just have to tell the compiler that you are using WINDOWS, and so it should use win32bits.h or win64bits.h instead (this is what the #define blocks do).
Thanks for the pointers BB+.
I defined the IH-win-linux.h for both RobboTotalCode and RobboTripleCode.

Here's my RobboTotalCode definition:

Code: Select all

#ifdef WINDOWS
#include <windows.h>
#define NOME_WINDOWS
/* 64 bits */
#define sint8 __int8
#define sint16 __int16
#define sint32 __int32
#define sint64 __int64
#define uint8 unsigned __int8
#define uint16 unsigned __int16
#define uint32 unsigned __int32
#define uint64 unsigned __int64
#define INLINE _inline
#define atoll _atoi64
#define TYPE_64_BIT "%I64d"
#if 1
#define MEMALIGN(a, b, c) a = _aligned_malloc (c, b)
#define ALIGNED_FREE(x) _aligned_free (x)
#else
#define MEMALIGN(a, b, c) a = malloc (c)
#define ALIGNED_FREE(x) free (x)
#endif
#define __builtin_prefetch /* 64-bits */
#ifdef WINDOWS_X64 /* 64 bits */
#include "win64bits.h"
#else
#include "win32bits.h"
#endif
Here's my RobboTripleCode definition:

Code: Select all

#ifdef WINDOWS
#include <windows.h>
#define NOME_WINDOWS
/* 64-bits */
#define sint8 __int8
#define sint16 __int16
#define sint32 __int32
#define sint64 __int64
#define uint8 unsigned __int8
#define uint16 unsigned __int16
#define uint32 unsigned __int32
#define uint64 unsigned __int64
#define INLINE _inline
#define atoll _atoi64
#define TYPE_64_BIT "%I64d"
#if 1
#define MEMALIGN(a, b, c) a = _aligned_malloc (c, b)
#define ALIGNED_FREE(x) _aligned_free (x)
#else
#define MEMALIGN(a, b, c) a = malloc (c)
#define ALIGNED_FREE(x) free (x)
#endif
#define __builtin_prefetch /* 64-bits */
#ifdef WINDOWS_X64 /* 64 bits */
#include "win64bits.h"
#else
#include "win32bits.h"
#endif
After attempting a compile, the Intel C++ XE 2011 Error List states these:

Code: Select all

Error	1	error : cannot open source file "pthread.h"	C:\Users\PRIMA\Desktop\CSF - Copy\RobboTripleCode\IH-win-linux.h	68	1	ComStockfish_102RBsICC_x64
Error	2	error MSB6001: Invalid command line switch for "icl.exe". Parameter "path" cannot have zero length.	C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\PlatformToolsets\Intel C++ Compiler XE 12.0\Microsoft.Cpp.x64.Intel C++ Compiler XE 12.0.targets	204	6	ComStockfish_102RBsICC_x64
And the Output states these:

Code: Select all

1>  RobboTripleGlue.cpp
1>..\..\RobboTripleCode/IH-win-linux.h(68): error : cannot open source file "pthread.h"
1>    #include <pthread.h> /* for what when no SMP ? */
1>                                                     ^
1>  
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\PlatformToolsets\Intel C++ Compiler XE 12.0\Microsoft.Cpp.x64.Intel C++ Compiler XE 12.0.targets(204,5): error MSB6001: Invalid command line switch for "icl.exe". Parameter "path" cannot have zero length.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It appears the lack of the "pthread.h" from the ComStockfish 1.0.2RBs source is the problem here? I could not locate this pthread.h any where from the downloaded ComStock1.0.2 package. Any pointers here? Thanks.
Last edited by Prima on Tue Jan 25, 2011 10:32 pm, edited 1 time in total.

BB+
Posts: 1484
Joined: Thu Jun 10, 2010 4:26 am

Re: ComStock 1.0.2 Stockfish with robobases

Post by BB+ » Tue Jan 25, 2011 10:31 pm

pthread.h should only be used in Linux mode? Maybe it's a source code problem.

EDIT: If you look at "IH-win-linux.h" again, it seems that the pthread stuff in Linux has its own version in Windows:

Code: Select all

#ifdef WINDOWS
[...]
#define MUTEX_TYPE CRITICAL_SECTION
#define COND_TYPE HANDLE
#define LOCK(x) EnterCriticalSection (x)
#define UNLOCK(x) LeaveCriticalSection (x)
#define WAIT_CON_LOCK(x, y) WaitForSingleObject (x, INFINITE)
#define SIGNAL_CON_LOCK(x, y) SetEvent (x)
#define LOCK_INIT(x) InitializeCriticalSection (x)
#define LOCK_DESTROY DeleteCriticalSection
#define COND_INIT(x, y) (x) = CreateEvent (0, FALSE, FALSE, 0)
#if 0
#define TRY_LOCK(x)  WaitForSingleObject (x, 0) /* HACK */
#else /* LeonardoVinci */
#define TRY_LOCK(x)  (!TryEnterCriticalSection (x)) /* HACK */
#endif
#define PTHREAD_CREATE(N, b, thr, d) \
  (*(N)) = CreateThread (NULL, 0, thr, (LPVOID) (d), 0, NULL);
#define PTHREAD_JOIN(x) \
  { DWORD w; do { GetExitCodeThread (x, &w); } while (w == STILL_ACTIVE); }
HANDLE PTHREAD[MAX_CPUS], PTHREAD_IO;
#define IVAN_THREAD(A) DWORD WINAPI ivan_thread (LPVOID A)
#define IO_THREAD(A) DWORD WINAPI io_thread (LPVOID A)
#define VOID_STAR_TYPE DWORD
[...]
#else /* LINUX */
[...]
#define MUTEX_TYPE pthread_mutex_t
#define COND_TYPE pthread_cond_t
#define LOCK(x) pthread_mutex_lock (x)
#define UNLOCK(x) pthread_mutex_unlock (x)
#define WAIT(x, y) pthread_cond_wait (x, y)
#define SIGNAL(x) pthread_cond_signal (x)
#define WAIT_CON_LOCK(x, y) { LOCK (&(y)); WAIT (&(x), &(y)); UNLOCK (&(y)); }
#define SIGNAL_CON_LOCK(x, y) { LOCK (&(y)); SIGNAL (&(x)); UNLOCK (&(y)); }
#define LOCK_INIT(x) pthread_mutex_init ((x), NULL)
#define LOCK_DESTROY pthread_mutex_destroy /* new */
#define TRY_LOCK(x) pthread_mutex_trylock (x)
#define COND_INIT(x, y) \
 { pthread_cond_init (&(x), NULL); pthread_mutex_init (&(y), NULL); }
#define PTHREAD_CREATE(N, b, thr, d) pthread_create (N, NULL, thr, (void*) (d))
#define PTHREAD_JOIN(x) pthread_join (x, NULL)
pthread_t PTHREAD[MAX_CPUS], PTHREAD_IO;
#define IVAN_THREAD(A) void* ivan_thread (void* A)
#define IO_THREAD(A) void* io_thread (void* A)
#define VOID_STAR_TYPE void*
#define LINUX_LARGE_PAGES TRUE /* NEW */ /* HACK */
#endif

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: ComStock 1.0.2 Stockfish with robobases

Post by Prima » Tue Jan 25, 2011 10:43 pm

Okay. In IH-win-linux.h for RobboTotalCode & RobboTripleCode, I see these pthread definition:

Code: Select all

#define PTHREAD_CREATE(N, b, thr, d) \
  (*(N)) = CreateThread (NULL, 0, thr, (LPVOID) (d), 0, NULL);
#define PTHREAD_JOIN(x) \
  { DWORD w; do { GetExitCodeThread (x, &w); } while (w == STILL_ACTIVE); }
HANDLE PTHREAD[MAX_CPUS], PTHREAD_IO;
This definition is definitely different from the WINDOWS (and the 64-bit) definition I had to do. This pthread definition is complex, it seems. What is the best definition of pthread? Do I delete all other non-needed pthread characters? Google bombards me with too much/complex info that, at this time, I can't quite make sense of.

Post Reply