Author: Vincent Diepeveen
Date: 07:36:25 02/20/06
Go up one level in this thread
On February 20, 2006 at 09:34:17, Tord Romstad wrote:
>On February 20, 2006 at 09:23:01, Richard Pijl wrote:
>
>>On February 20, 2006 at 06:45:17, Tord Romstad wrote:
>>
>>>My parallel search code uses POSIX threads, which means that it cannot be
>>>compiled for Windows without some changes. Therefore, the current version
>>>is for Linux and Mac OS X only (there will be a Windows version later, of
>>>course).
>>
>>There are a few libraries around that implement POSIX threads on windows.
>
>I know, but they are said to be terribly inefficient. Dann tried to compile
>a Windows binary for me using one of these libraries last week, and the results
>were rather unimpressive.
>
>Adding native Win32 threads seems much better, and it cannot possibly be very
>hard. My parallel search code is very simple and compact, and doesn't use any
>advanced POSIX threads features. All I need is the ability to launch
>additional threads during program initialisation, and some locking and
>unlocking during the search.
>
>Tord
Locking (also working for multiprocessor) header file of diep:
#if IRIX /* IRIX */
#if (_MIPS_SZLONG == 32)
#define Lock(v) {volatile unsigned long *tmpvar =
&((v).abi_lock); while (*tmpvar); spin_lock(&(v));}
#endif
#if (_MIPS_SZLONG == 64)
#define Lock(v) {volatile unsigned int *tmpvar =
&((v).abi_lock); while (*tmpvar); spin_lock(&(v));}
#endif
#define SlowLock(v) spin_lock(&v)
#define LockInit(v) init_lock(&v)
#define Unlock(v) release_lock(&v)
#define lockvar abilock_t
#elif MSVC /* windows NT */
#define lockvar volatile int
#define LockInit(v) ((v)=0)
#define Unlock(v) ((v)=0)
/* voor non-defined compilers onder windows: */
#if NOASSEMBLY
# define Lock(v) do { \
while(InterlockedExchange((LPLONG)&(v),1) != 0); \
} while (0)
#else
__inline void LockA (volatile int *hPtr) {
__asm {
mov ecx, hPtr
la: mov eax, 1
xchg eax, [ecx]
test eax, eax
jz end
lb: mov eax, [ecx]
test eax, eax
jz la
jmp lb
end:
}
}
#define Lock(v) LockA(&(v))
#endif
#define SlowLock(v) Lock(&(v))
//#define Lock(v) {if(v){printf("was already locked\n");StatusSMP();}else{v=1;}}
#elif IA64
#define Lock(v) spin_lock(&v)
#define SlowLock(v) spin_lock(&v)
#define LockInit(v) spin_lock_init(&v)
#define Unlock(v) spin_unlock(&v)
#define lockvar spinlock_t
#else /* linux P6/PII/P3/K7 */
#define lockvar volatile int
#define LockInit(p) (p=0)
#define exchange(adr,reg) ({volatile int _ret;asm volatile ("xchg
%0,%1":"=q"(_ret),"=m"(*(adr)):"m"(*(adr)),"0"(reg));_ret;})
#define Unlock(p) (exchange(&p,0))
#define SlowLock(p) while(exchange(&p,1)) while(p)
#define Lock(p) while(exchange(&p,1)) while(p)
#endif
#if USEC99
#define BITBOARD unsigned long long
#define INT64 long long
#else // windows
#define INT64 _int64
#define BITBOARD unsigned _int64
#endif
#if UNIX
#define getch() getchar()
#define FORCEINLINE __inline
#elif USEC99
#define FORCEINLINE
#else
#define FORCEINLINE __forceinline
#endif
#define HUMAN 0
#define COMPUTER 1
#define NEDERLANDS 0
#define DEUTSCH 1
#define ENGLISH 2
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.