ComStock 1.0.2 Stockfish with robobases

Discussion about chess-playing software (engines, hosts, opening books, platforms, etc...)
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 26, 2011 8:17 am

Time permitting over the weekend, I'll probably release ComStock build minus GTB.
PAWN : Knight >> Bishop >> Rook >>Queen

Peter C
Posts: 154
Joined: Thu Jun 10, 2010 3:12 am
Real Name: Peter C

Re: ComStock 1.0.2 Stockfish with robobases

Post by Peter C » Wed Jan 26, 2011 5:57 pm

BB+ wrote:
the ComStock source has the egtb.h, egtb.cpp, endgame.cpp and endgame.h.
My understanding is that egtb.cpp (and its header file) is from Peter C for GTB access, whilst endgame.cpp is standard to Stockfish. I deleted egtb.cpp, and this left four unresolved symbols if I recall correctly. I then got rid of the attempt_probe_egtb stuff in search.cpp, and also the init_egtb and close_egtb in some file that I forget. In other words, I kept on deleting functionality until it worked (as I say, I was in a hurry and just fooling around to refresh my memory as to how compiling under Windows worked)... Of course, it would be better to try to get it to work with GTBs still present. :) [Under Linux, it all "just works", with both GTBs and RobboBases].
Actually, all the EGTB stuff is from the Stockfish team, I just ported it to 2.0(.1) and added tbhits and UCI options. And added a broken ProbeOnlyAtRoot feature, but let's not talk about that... :P

Removing egtb.cpp, egtb.h, all attempt_probe_egtb() stuff in search.cpp, the UseGaviotaTb and ProbeOnlyAtRoot booleans in search.cpp, a small chunk near the top of think() in search.cpp that looks like this:

Code: Select all

  if (UseGaviotaTb)
      init_egtb();
  else
      close_egtb();
and every section that starts with a "Step 4b. EGTB probe" comment in search.cpp is a good start, but there might be some other junk to remove that I can't remember right now.

Peter

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

Re: ComStock 1.0.2 Stockfish with robobases

Post by BB+ » Wed Jan 26, 2011 9:58 pm

After looking at the build procedure for GTB, I think the following is the trouble.

In Linux it builds libgtb.a as a static library (using ar) and then links Stockfish against that.
There must be some way to tell a Windows compiler to do this, but I really don't know how.

Peter C
Posts: 154
Joined: Thu Jun 10, 2010 3:12 am
Real Name: Peter C

Re: ComStock 1.0.2 Stockfish with robobases

Post by Peter C » Thu Jan 27, 2011 5:25 pm

BB+ wrote:After looking at the build procedure for GTB, I think the following is the trouble.

In Linux it builds libgtb.a as a static library (using ar) and then links Stockfish against that.
There must be some way to tell a Windows compiler to do this, but I really don't know how.
I simply added -L. -lgtb to the LDFLAGS in the Makefile.

Peter

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 » Mon Jan 31, 2011 3:09 am

kingliveson wrote:Time permitting over the weekend, I'll probably release ComStock build minus GTB.

Peterpan has already a couple binaries found at http://ippolit.wikispaces.com/message/v ... k/33368814. If there were no other builds then I probably would have released one. I had built one at the time of the quoted comment, but did not release it due to some errors that I think are now corrected in the latest source.
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 » Wed Feb 16, 2011 1:33 am

BB+ wrote:I think you do need these pthread definitions, at least if you want ComStock to run in SMP mode (at least the LOCK/UNLOCK parts are necessary I presume)--- but I would have thought it should "just work" if you have the right compiler switches to tell the compiler to use them. Trying putting "#define WINDOWS" at the top of IH-win-linux.h and see what happens.
kingliveson wrote:You are correct, this should not be a problem once he has the right #define. There are other linkage issues though...I looked at the use of extern "C" which all seemed fine. Thought I would have some time this past weekend to try to correct or find a way to build it, but there was no time
Sorry to bring this up. 'Couldn't resist finding out Why I couldn't compile Comstock 1.0.2 when someone else successfully did so.

After careful editing of the required .cpp / .h source files of Comstock 1.0.2, I retried compiling via Intel Composer XE 2011 Intel64 command prompt, I get just one error this time around:
RobboTripleCode/IH-win-linux.h (68): catastrophic error: cannot open source file "pthread.h"
#include <pthread.h> /* for what when no SMP? */
I had browsed back to previous pages (of this Topic) discussing pthread definition but could not see an explicit pthread / SMP definition or instructions for Windows.

Question 1: Where is this "pthread.h" file it wants for compile, since this "pthread.h" was/is not included in Comstock's source folder?
Questoin 2: If this pthread.h file is not compulsory, how do I define Comstock to use SMP, so as to avoid this "pthread.h" & SMP complaint message?


Attached is the error complaint from the Intel command prompt window.
Attachments
ComStockFish102-IntelCommandPromptCompile-Error-on-pthread.h.PNG
I now have just 1 complaint message on "pthread" and SMP.

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

Re: ComStock 1.0.2 Stockfish with robobases

Post by BB+ » Fri Feb 18, 2011 2:22 am

RobboTripleCode/IH-win-linux.h (68): catastrophic error: cannot open source file "pthread.h"
My understanding is that when you have "#define WINDOWS", then it should never ask for pthread.h (which is POSIX).

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

Re: ComStock 1.0.2 Stockfish with robobases

Post by Prima » Fri Feb 18, 2011 3:33 am

BB+ wrote:
RobboTripleCode/IH-win-linux.h (68): catastrophic error: cannot open source file "pthread.h"
My understanding is that when you have "#define WINDOWS", then it should never ask for pthread.h (which is POSIX).
I believe I did this BB+. For RobboTotalCode's IH-win-linux.h, I defined it as follows:

Code: Select all

#ifdef WINDOWS
#include <win64bits.h>
#define 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 /* */
#ifdef WINDOWS_X64 /* 64 bits */
#include "win64bits.h"
#else
#include "win32bits.h"
#endif
#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
For RobboTripleCode's IH-win-linux.h, I defined Windows as follows:

Code: Select all

#ifdef WINDOWS
#include <win64bits.h>
#define 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 /* */
#ifdef WINDOWS_X64 /* 64 bits */
#include "win64bits.h"
#else
#include "win32bits.h"
#endif
#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
If this error message still requires Windows definition, as you've stated, it's apparent that I have not done this correctly and therefore seek help here. If it helps, my OS is Windows 7 64-bit, Q6700 (8GB RAM). I uploaded these source files for inspection, if it matters, but I'll rather do the editing, based on your suggestions/corrections as part of the learning process - since computer programming and related fields is not my expertise.

I've attached my edited IH-win-liunux.h files for both RobboTripleCode & RobboTotalCode. I've also uploaded my RobboTripleGlue.cpp & RobboTotalGlue.cpp
Attachments
My Edited Comstock files.7z
My edited ComStock IH-win-linux.h files and RobboTotalGlue.cpp / RobboTripleGlue.cpp
(5.36 KiB) Downloaded 192 times

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

Re: ComStock 1.0.2 Stockfish with robobases

Post by BB+ » Fri Feb 18, 2011 4:11 am

Code: Select all

#ifdef WINDOWS
#include <win64bits.h>
#define WINDOWS
[...]
This is the wrong order od operations. You need to #define WINDOWS before testing whether it is defined with #ifdef WINDOWS. So put the #define WINDOWS on the line before the #ifdef WINDOWS directive.

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

Re: ComStock 1.0.2 Stockfish with robobases

Post by Prima » Fri Feb 18, 2011 4:37 am

BB+ wrote:

Code: Select all

#ifdef WINDOWS
#include <win64bits.h>
#define WINDOWS
[...]
This is the wrong order od operations. You need to #define WINDOWS before testing whether it is defined with #ifdef WINDOWS. So put the #define WINDOWS on the line before the #ifdef WINDOWS directive.
Done. #define WINDOWS is now placed before the #ifdef WINDOWS line (or directive). This procedure is done for both RobboTriple and RobboTotal's IH-win-linux.h files, so that it now looks like this;

Code: Select all

#define WINDOWS
/* 64 bits */
#ifdef WINDOWS
#include <win64bits.h>
#define sint8 __int8
#define sint16 __int16
The error persists except this time the number (68) is now replaced with (5). Also, it "can't open win64bit.h file" which I inserted in the #include <> line before previous compile attempt.
I've attached the message.
Attachments
ComStock-defineWindows-Error(IH-win-linux.h(5)).PNG

Post Reply