A Chess forum. ChessBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ChessBanter forum » Chess Newsgroups » rec.games.chess.computer (Computer Chess)
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , ,

Crafty - Microsoft C++ 2003 Build



 
 
Thread Tools Display Modes
  #1  
Old April 26th 04, 07:14 AM
Kym
external usenet poster
 
Posts: n/a
Default Crafty - Microsoft C++ 2003 Build

Hi
I'm having trouble building Crafty under the new free C++ downloadable from
MS (2003). Has anyone built for SMP - if so please post makefile (nmake)
and any source changes.

Robert if you are listening: Is there any chance of getting a Eugene Nalimov
build binary?

Errors follow...

Thanks, Kym

cl /D_CONSOLE /DWIN32 /O2 /Ox /G7 /Gr /Zm500 /DVC_INLINE_ASM
/DNT_i386
/c boolean.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3052 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

boolean.c
boolean.c(61) : error C2084: function 'int PopCnt(BITBOARD)' already has a
body
e:\Chess\crafty\vcinline.h(7) : see previous definition of 'PopCnt'
boolean.c(107) : error C2084: function 'int FirstOne(BITBOARD)' already has
a bo
dy
e:\Chess\crafty\vcinline.h(30) : see previous definition of
'FirstOne'
boolean.c(118) : error C2084: function 'int LastOne(BITBOARD)' already has a
bod
y
e:\Chess\crafty\vcinline.h(43) : see previous definition of
'LastOne'
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.


Ads
  #2  
Old April 26th 04, 11:47 PM
Michael Byrne
external usenet poster
 
Posts: n/a
Default Crafty - Microsoft C++ 2003 Build

"Kym" wrote in message ...
Hi
I'm having trouble building Crafty under the new free C++ downloadable from
MS (2003). Has anyone built for SMP - if so please post makefile (nmake)
and any source changes.

Robert if you are listening: Is there any chance of getting a Eugene Nalimov
build binary?

Errors follow...


do this


change the chess.h section for NT_i386 to look like this:

#if defined(NT_i386)
# undef HAS_64BITS /* machine has 64-bit integers / operators
*/
# define HAS_LONGLONG /* machine has 32-bit/64-bit integers
*/
# undef UNIX /* system is unix-based
*/
# undef STDCALL
# define STDCALL __stdcall
# ifdef VC_INLINE_ASM
# undef CDECL
# define CDECL __cdecl
# define USE_ASSEMBLY
# endif
#endif

change the the *.c files (boolean and data.c) that have "INLINE_ASM"
to "USE_ASSEMBLY" and then if you have problems with compiling the
NUMA scetion in utility.c - just comment out the NUMA section -- if
you be careful and follow the brackets.

here is the section that has it modified with the NUMA sections
commented out:

================================================== ============================

/*
************************************************** *****************************
*
*
* Windows NUMA support
*
*
*
************************************************** *****************************
*/

#if (defined(_WIN32) || defined(_WIN64)) && defined(SMP)

lock_t ThreadsLock;

static BOOL(WINAPI * pGetNumaHighestNodeNumber) (PULONG);
static BOOL(WINAPI * pGetNumaNodeProcessorMask) (UCHAR, PULONGLONG);
static DWORD(WINAPI * pSetThreadIdealProcessor) (HANDLE, DWORD);

static volatile BOOL fThreadsInitialized = FALSE;
static BOOL fSystemIsNUMA = FALSE;
static ULONGLONG ullProcessorMask[256];
static ULONG ulNumaNodes;
static ULONG ulNumaNode = 0;

// Get NUMA-related information from Windows

#if defined (NUMA) //byrne

static void WinNumaInit(void)
{
DWORD_PTR dwMask;
HMODULE hModule;
ULONG ulCPU, ulNode;
ULONGLONG ullMask;
DWORD dwCPU;

if (!fThreadsInitialized) {
Lock(ThreadsLock);
if (!fThreadsInitialized) {
printf("\nInitializing multiple threads.\n");
fThreadsInitialized = TRUE;
hModule = GetModuleHandle("kernel32");
pGetNumaHighestNodeNumber =
(void *) GetProcAddress(hModule,
"GetNumaHighestNodeNumber");
pGetNumaNodeProcessorMask =
(void *) GetProcAddress(hModule,
"GetNumaNodeProcessorMask");
pSetThreadIdealProcessor =
(void *) GetProcAddress(hModule, "SetThreadIdealProcessor");
if (pGetNumaHighestNodeNumber && pGetNumaNodeProcessorMask &&
pGetNumaHighestNodeNumber(&ulNumaNodes) && (ulNumaNodes
0)) {
fSystemIsNUMA = TRUE;
if (ulNumaNodes 255)
ulNumaNodes = 255;
printf("System is NUMA. %d nodes reported by Windows\n",
ulNumaNodes + 1);
for (ulNode = 0; ulNode = ulNumaNodes; ulNode++) {
pGetNumaNodeProcessorMask((UCHAR) ulNode,
&ullProcessorMask[ulNode]);
printf("Node %d CPUs: ", ulNode);
ullMask = ullProcessorMask[ulNode];
if (0 == ullMask)
fSystemIsNUMA = FALSE;
else {
ulCPU = 0;
do {
if (ullMask & 1)
printf("%d ", ulCPU);
ulCPU++;
ullMask = 1;
} while (ullMask);
}
printf("\n");
}
// Thread 0 was already started on some CPU. To simplify things
further,
// exchange ullProcessorMask[0] and ullProcessorMask[node for that
CPU],
// so ullProcessorMask[0] would always be node for thread 0
dwCPU =
pSetThreadIdealProcessor(GetCurrentThread(),
MAXIMUM_PROCESSORS);
printf("Current ideal CPU is %u\n", dwCPU);
pSetThreadIdealProcessor(GetCurrentThread(), dwCPU);
if ((((DWORD) - 1) != dwCPU) && (MAXIMUM_PROCESSORS != dwCPU)
&&
!(ullProcessorMask[0] & (1u i64 dwCPU))) {
for (ulNode = 1; ulNode = ulNumaNodes; ulNode++) {
if (ullProcessorMask[ulNode] & (1u i64 dwCPU)) {
printf("Exchanging nodes 0 and %d\n", ulNode);
ullMask = ullProcessorMask[ulNode];
ullProcessorMask[ulNode] = ullProcessorMask[0];
ullProcessorMask[0] = ullMask;
break;
}
}
}
} else
printf("System is SMP, not NUMA.\n");
}
Unlock(ThreadsLock);
}
}
#endif //byrne
// Start thread. For NUMA system set it affinity.

pthread_t NumaStartThread(void *func, void *args)
{
HANDLE hThread;
ULONGLONG ullMask;
//byrne
/*WinNumaInit();
if (fSystemIsNUMA) {
ulNumaNode++;
if (ulNumaNode ulNumaNodes)
ulNumaNode = 0;
ullMask = ullProcessorMask[ulNumaNode];
printf("Starting thread on node %d CPU mask %I64d\n", ulNumaNode,
ullMask);
SetThreadAffinityMask(GetCurrentThread(), (DWORD_PTR) ullMask);
hThread = (HANDLE) _beginthreadex(0, 0, func, args,
CREATE_SUSPENDED, 0);
SetThreadAffinityMask(hThread, (DWORD_PTR) ullMask);
ResumeThread(hThread);
SetThreadAffinityMask(GetCurrentThread(), ullProcessorMask[0]);
} else*/ //byrne
hThread = (HANDLE) _beginthreadex(0, 0, func, args, 0, 0);
return hThread;
}

// Allocate memory for thread #N

void *WinMalloc(size_t cbBytes, int iThread)
{
HANDLE hThread;
//DWORD_PTR dwAffinityMask; byrne
void *pBytes;
ULONG ulNode;

/*WinNumaInit(); byrne
if (fSystemIsNUMA) {
ulNode = iThread % (ulNumaNodes + 1);
hThread = GetCurrentThread();
dwAffinityMask = SetThreadAffinityMask(hThread,
ullProcessorMask[ulNode]);
pBytes = VirtualAlloc(NULL, cbBytes, MEM_COMMIT, PAGE_READWRITE);
memset(pBytes, 0, cbBytes);
SetThreadAffinityMask(hThread, dwAffinityMask);
return pBytes;
} else*/ //byrne
return malloc(cbBytes);
}

// Allocate interleaved memory

void *WinMallocInterleaved(size_t cbBytes, int cThreads)
{
char *pBase;
char *pEnd;
char *pch;
HANDLE hThread;
//DWORD_PTR dwAffinityMask;byrne
ULONG ulNode;
SYSTEM_INFO sSysInfo;
size_t dwStep;
int iThread;
DWORD dwPageSize; // the page size on this computer
LPVOID lpvResult;

/*WinNumaInit();//byrne
if (fSystemIsNUMA && (cThreads 1)) {
GetSystemInfo(&sSysInfo); // populate the system information
structure
dwPageSize = sSysInfo.dwPageSize;

// Reserve pages in the process's virtual address space.
pBase = (char *) VirtualAlloc(NULL, cbBytes, MEM_RESERVE,
PAGE_NOACCESS);
if (pBase == NULL) {
printf("VirtualAlloc() reserve failed\n");
exit(0);
}
// Now walk through memory, committing each page
hThread = GetCurrentThread();
dwStep = dwPageSize * cThreads;
pEnd = pBase + cbBytes;
for (iThread = 0; iThread cThreads; iThread++) {
ulNode = iThread % (ulNumaNodes + 1);
dwAffinityMask = SetThreadAffinityMask(hThread,
ullProcessorMask[ulNode]);
for (pch = pBase + iThread * dwPageSize; pch pEnd; pch +=
dwStep) {
lpvResult = VirtualAlloc(pch, // next page to commit
dwPageSize, // page size, in bytes
MEM_COMMIT, // allocate a committed page
PAGE_READWRITE); // read/write access
if (lpvResult == NULL)
ExitProcess(GetLastError());
memset(lpvResult, 0, dwPageSize);
}
SetThreadAffinityMask(hThread, dwAffinityMask);
}
} else {*/ //byrne
pBase = VirtualAlloc(NULL, cbBytes, MEM_COMMIT, PAGE_READWRITE);
if (pBase == NULL)
ExitProcess(GetLastError());
memset(pBase, 0, cbBytes);
//}byrne
return (void *) pBase;
}

// Free interleaved memory

void WinFreeInterleaved(void *pMemory, size_t cBytes)
{
VirtualFree(pMemory, 0, MEM_RELEASE);
}

#endif

/*
************************************************** *****************************
*
*
* Linux NUMA support
*
*
*
************************************************** *****************************
*/

#if defined(LINUX) && defined(NUMA)

/*
************************************************** *****************************
*
*
* First, discover if we are on a NUMA box. If not, the normal SMP
stuff is *
* primed and ready to go. If we are on a NUMA machine, we need to
know (a) *
* how many processors (nodes in the case of AMD/Intel) we have on
the *
* machine and (b) how many processors (threads) the user intends to
run. *
* It becomes important for the "smpmt=n" command to be either on
the *
* command-line or in the crafty.rc/.craftyrc files, otherwise we
might not *
* get things initialized optimally in a NUMA environment.
*
*
*
************************************************** *****************************
*/

void NumaInit(void)
{
int numa_machine, maxNumaNodes;

if (!fThreadsInitialized) {
Lock(ThreadsLock);
if (!fThreadsInitialized) {
printf("\nInitializing multiple threads.\n");
fThreadsInitialized = TRUE;
numa_machine = numa_available();
if (numa_machine = 0) {
maxNumaNodes = numa_max_node();
printf("System is NUMA. %d nodes reported by Linux\n",
maxNumaNodes + 1);
} else {
Print(4095, "system is not NUMA, skipping NUMA
initialization\n");
return;
}

pGetNumaHighestNodeNumber =
(void *) GetProcAddress(hModule,
"GetNumaHighestNodeNumber");
pGetNumaNodeProcessorMask =
(void *) GetProcAddress(hModule,
"GetNumaNodeProcessorMask");
pSetThreadIdealProcessor =
(void *) GetProcAddress(hModule, "SetThreadIdealProcessor");
if (pGetNumaHighestNodeNumber && pGetNumaNodeProcessorMask &&
pGetNumaHighestNodeNumber(&ulNumaNodes) && (ulNumaNodes
0)) {
fSystemIsNUMA = TRUE;
if (ulNumaNodes 255)
ulNumaNodes = 255;
printf("System is NUMA. %d nodes reported by Windows\n",
ulNumaNodes + 1);
for (ulNode = 0; ulNode = ulNumaNodes; ulNode++) {
pGetNumaNodeProcessorMask((UCHAR) ulNode,
&ullProcessorMask[ulNode]);
printf("Node %d CPUs: ", ulNode);
ullMask = ullProcessorMask[ulNode];
if (0 == ullMask)
fSystemIsNUMA = FALSE;
else {
ulCPU = 0;
do {
if (ullMask & 1)
printf("%d ", ulCPU);
ulCPU++;
ullMask = 1;
} while (ullMask);
}
printf("\n");
}
// Thread 0 was already started on some CPU. To simplify things
further,
// exchange ullProcessorMask[0] and ullProcessorMask[node for that
CPU],
// so ullProcessorMask[0] would always be node for thread 0
dwCPU =
pSetThreadIdealProcessor(GetCurrentThread(),
MAXIMUM_PROCESSORS);
printf("Current ideal CPU is %u\n", dwCPU);
pSetThreadIdealProcessor(GetCurrentThread(), dwCPU);
if ((((DWORD) - 1) != dwCPU) && (MAXIMUM_PROCESSORS != dwCPU)
&&
!(ullProcessorMask[0] & (1u i64 dwCPU))) {
for (ulNode = 1; ulNode = ulNumaNodes; ulNode++) {
if (ullProcessorMask[ulNode] & (1u i64 dwCPU)) {
printf("Exchanging nodes 0 and %d\n", ulNode);
ullMask = ullProcessorMask[ulNode];
ullProcessorMask[ulNode] = ullProcessorMask[0];
ullProcessorMask[0] = ullMask;
break;
}
}
}
} else
printf("System is SMP, not NUMA.\n");
}
Unlock(ThreadsLock);
}
}

// Start thread. For NUMA system set it affinity.

pthread_t NumaStartThread(void *func, void *args)
{
HANDLE hThread;
ULONGLONG ullMask;

/* WinNumaInit(); //byrne
if (fSystemIsNUMA) {
ulNumaNode++;
if (ulNumaNode ulNumaNodes)
ulNumaNode = 0;
ullMask = ullProcessorMask[ulNumaNode];
printf("Starting thread on node %d CPU mask %I64d\n", ulNumaNode,
ullMask);
SetThreadAffinityMask(GetCurrentThread(), (DWORD_PTR) ullMask);
hThread = (HANDLE) _beginthreadex(0, 0, func, args,
CREATE_SUSPENDED, 0);
SetThreadAffinityMask(hThread, (DWORD_PTR) ullMask);
ResumeThread(hThread);
SetThreadAffinityMask(GetCurrentThread(), ullProcessorMask[0]);
} else */ //byrne
hThread = (HANDLE) _beginthreadex(0, 0, func, args, 0, 0);
return hThread;
}

// Allocate memory for thread #N

void *WinMalloc(size_t cbBytes, int iThread)
{
HANDLE hThread;
DWORD_PTR dwAffinityMask;
void *pBytes;
ULONG ulNode;

/*WinNumaInit();//byrne
if (fSystemIsNUMA) {
ulNode = iThread % (ulNumaNodes + 1);
hThread = GetCurrentThread();
dwAffinityMask = SetThreadAffinityMask(hThread,
ullProcessorMask[ulNode]);
pBytes = VirtualAlloc(NULL, cbBytes, MEM_COMMIT, PAGE_READWRITE);
memset(pBytes, 0, cbBytes);
SetThreadAffinityMask(hThread, dwAffinityMask);
return pBytes;
} else*///byrne
return malloc(cbBytes);
}

// Allocate interleaved memory

void *WinMallocInterleaved(size_t cbBytes, int cThreads)
{
char *pBase;
char *pEnd;
char *pch;
HANDLE hThread;
DWORD_PTR dwAffinityMask;
ULONG ulNode;
SYSTEM_INFO sSysInfo;
size_t dwStep;
int iThread;
DWORD dwPageSize; // the page size on this computer
LPVOID lpvResult;

WinNumaInit();
if (fSystemIsNUMA && (cThreads 1)) {
GetSystemInfo(&sSysInfo); // populate the system information
structure
dwPageSize = sSysInfo.dwPageSize;

// Reserve pages in the process's virtual address space.
pBase = (char *) VirtualAlloc(NULL, cbBytes, MEM_RESERVE,
PAGE_NOACCESS);
if (pBase == NULL) {
printf("VirtualAlloc() reserve failed\n");
exit(0);
}
// Now walk through memory, committing each page
hThread = GetCurrentThread();
dwStep = dwPageSize * cThreads;
pEnd = pBase + cbBytes;
for (iThread = 0; iThread cThreads; iThread++) {
ulNode = iThread % (ulNumaNodes + 1);
dwAffinityMask = SetThreadAffinityMask(hThread,
ullProcessorMask[ulNode]);
for (pch = pBase + iThread * dwPageSize; pch pEnd; pch +=
dwStep) {
lpvResult = VirtualAlloc(pch, // next page to commit
dwPageSize, // page size, in bytes
MEM_COMMIT, // allocate a committed page
PAGE_READWRITE); // read/write access
if (lpvResult == NULL)
ExitProcess(GetLastError());
memset(lpvResult, 0, dwPageSize);
}
SetThreadAffinityMask(hThread, dwAffinityMask);
}
} else {
pBase = VirtualAlloc(NULL, cbBytes, MEM_COMMIT, PAGE_READWRITE);
if (pBase == NULL)
ExitProcess(GetLastError());
memset(pBase, 0, cbBytes);
}
return (void *) pBase;
}

// Free interleaved memory

void WinFreeInterleaved(void *pMemory, size_t cBytes)
{
VirtualFree(pMemory, // base address of block
cBytes, // bytes of committed pages
MEM_DECOMMIT | MEM_RELEASE); // decommit the pages
}

#endif
================================================== ========================

Alternatively, you may download .exe or or sources for Crafty or
Crafty 19.12 SE ( a few extra options ) from this site:

http://crafty.webkikr.com/download.html

or this site (under downloads)

http://wbec-ridderkerk.nl/

Michael
  #3  
Old April 30th 04, 11:08 AM
Kym
external usenet poster
 
Posts: n/a
Default Crafty - Microsoft C++ 2003 Build

Thanks!!!

"Michael Byrne" wrote in message
om...
"Kym" wrote in message

...
Hi
I'm having trouble building Crafty under the new free C++ downloadable

from
MS (2003). Has anyone built for SMP - if so please post makefile

(nmake)
and any source changes.

Robert if you are listening: Is there any chance of getting a Eugene

Nalimov
build binary?

Errors follow...


do this


change the chess.h section for NT_i386 to look like this:

[snip]


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
crafty 19.11: case of a dubious move jake johnson rec.games.chess.computer (Computer Chess) 4 March 21st 04 04:45 PM
christmas-tournament 2003: a 15 rounds tournament on 1200 mhz and 40/120 time control Thorsten Czub rec.games.chess.computer (Computer Chess) 2 January 17th 04 01:25 AM
Crafty Move List Christopher rec.games.chess.computer (Computer Chess) 2 July 25th 03 09:27 PM
crafty coding alternate line Christopher rec.games.chess.computer (Computer Chess) 1 July 25th 03 07:20 PM
Crafty Learning Robert Hyatt rec.games.chess.computer (Computer Chess) 0 July 9th 03 08:44 PM


All times are GMT +1. The time now is 03:36 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Content Relevant URLs by vBSEO 2.4.0
Copyright ©2004-2008 ChessBanter, part of the NewsgroupBanter project.
The comments are property of their posters.
Car Loan - Savings Accounts - Credit Cards - Credit Cards - Car Loan