Crafty-23.1 does not compile on Mac OS X

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Crafty-23.1 does not compile on Mac OS X

Post by zullil »

Code: Select all

#include <malloc.h>
on line 26 of chess.h prevents crafty-23.1 from compiling on Mac OS X systems (which neither have nor need malloc.h).

Simply comment out that line and all should be well.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Crafty-23.1 does not compile on Mac OS X

Post by Sven »

zullil wrote:

Code: Select all

#include <malloc.h>
on line 26 of chess.h prevents crafty-23.1 from compiling on Mac OS X systems (which neither have nor need malloc.h).

Simply comment out that line and all should be well.
Under Linux, Windows and MacOS using malloc.h should usually be redundant with current compilers, it is sufficient to include stdlib.h. So removing that line from Crafty should not create any platform dependencies.

EDIT: thread belongs into programming subforum IMO.

EDIT2: malloc.h is present under /usr/include/sys on Mac AFAIK, so would be found by #include <sys/malloc.h>, but since this were platform dependent, better remove.

Sven
IanO
Posts: 496
Joined: Wed Mar 08, 2006 9:45 pm
Location: Portland, OR

Re: Crafty-23.1 does not compile on Mac OS X

Post by IanO »

zullil wrote:

Code: Select all

#include <malloc.h>
on line 26 of chess.h prevents crafty-23.1 from compiling on Mac OS X systems (which neither have nor need malloc.h).

Simply comment out that line and all should be well.
Speaking of which, the "darwin" target seems to be quite out of date. It appears to assume a G4 processor (since there are no intel-specific optimization flags, and there is another "darwinG5" target). Apple hasn't shipped either processor for years.

How about changing the "darwin" target to assume an Intel Core 2 Duo as the default architecture, 64-bit executables, and gcc 4.2.1 as the default toolchain. In my prior testing of version 23.0, the flags "-m64 -fast -DINLINE64" had the greatest impact. I also tried "-fomit_frame_pointer" and "-msse3 -mmmx" but they had no effect (admittedly, that test was under gcc 4.0.1). Tests were done with "bench", using "smpmt=1" for repeatability.

Perhaps retain a "darwinG4" target if you wish.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Crafty-23.1 does not compile on Mac OS X

Post by zullil »

IanO wrote:
zullil wrote:

Code: Select all

#include <malloc.h>
on line 26 of chess.h prevents crafty-23.1 from compiling on Mac OS X systems (which neither have nor need malloc.h).

Simply comment out that line and all should be well.
Speaking of which, the "darwin" target seems to be quite out of date. It appears to assume a G4 processor (since there are no intel-specific optimization flags, and there is another "darwinG5" target). Apple hasn't shipped either processor for years.

How about changing the "darwin" target to assume an Intel Core 2 Duo as the default architecture, 64-bit executables, and gcc 4.2.1 as the default toolchain. In my prior testing of version 23.0, the flags "-m64 -fast -DINLINE64" had the greatest impact. I also tried "-fomit_frame_pointer" and "-msse3 -mmmx" but they had no effect (admittedly, that test was under gcc 4.0.1). Tests were done with "bench", using "smpmt=1" for repeatability.

Perhaps retain a "darwinG4" target if you wish.
This seems sensible to me. Why don't you post your proposed new version for the darwin target, and those who might care can comment. I'm sure Bob Hyatt would be happy to update the Makefile to reflect the current Mac hardware.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty-23.1 does not compile on Mac OS X

Post by bob »

zullil wrote:
IanO wrote:
zullil wrote:

Code: Select all

#include <malloc.h>
on line 26 of chess.h prevents crafty-23.1 from compiling on Mac OS X systems (which neither have nor need malloc.h).

Simply comment out that line and all should be well.
Speaking of which, the "darwin" target seems to be quite out of date. It appears to assume a G4 processor (since there are no intel-specific optimization flags, and there is another "darwinG5" target). Apple hasn't shipped either processor for years.

How about changing the "darwin" target to assume an Intel Core 2 Duo as the default architecture, 64-bit executables, and gcc 4.2.1 as the default toolchain. In my prior testing of version 23.0, the flags "-m64 -fast -DINLINE64" had the greatest impact. I also tried "-fomit_frame_pointer" and "-msse3 -mmmx" but they had no effect (admittedly, that test was under gcc 4.0.1). Tests were done with "bench", using "smpmt=1" for repeatability.

Perhaps retain a "darwinG4" target if you wish.
This seems sensible to me. Why don't you post your proposed new version for the darwin target, and those who might care can comment. I'm sure Bob Hyatt would be happy to update the Makefile to reflect the current Mac hardware.
Fine by me. If someone can edit the Makefile, verify that it works, and send me the copy, I will make it the default. I obviously did not write the various Makefile options since I don't have all of those machines here. :)
schlucke
Posts: 58
Joined: Thu Apr 09, 2009 1:38 pm

Re: Crafty-23.1 does not compile on Mac OS X

Post by schlucke »

Hi,

I do it this way (in Makefile)

Code: Select all

darwin-x86_64&#58;
        $&#40;MAKE&#41; target=FreeBSD \
                CC=gcc CXX=g++ \
                CFLAGS='$&#40;CFLAGS&#41; -Wall -pipe -O3 -m64' \
                CXFLAGS=$&#40;CFLAGS&#41; \
                LDFLAGS=$&#40;LDFLAGS&#41; \
                LIBS='-lpthread -lstdc++' \
                opt='$&#40;opt&#41; -DCPUS=2' \
                crafty-make
Gives this bench results on my MacBook Pro (2.4 GHz Intel Core 2 Duo):

Code: Select all

White&#40;1&#41;&#58; mt=2 
max threads set to 2.
White&#40;1&#41;&#58; bench
Running benchmark. . .
......
Total nodes&#58; 127082421
Raw nodes per second&#58; 4288978
Total elapsed time&#58; 29.63
With the suggested options:

Code: Select all

darwin-x86_64&#58;
        $&#40;MAKE&#41; target=FreeBSD \
                CC=gcc CXX=g++ \
                CFLAGS='$&#40;CFLAGS&#41; -Wall -pipe -O3 -m64 -fast -DINLINE64' \
                CXFLAGS=$&#40;CFLAGS&#41; \
                LDFLAGS=$&#40;LDFLAGS&#41; \
                LIBS='-lpthread -lstdc++' \
                opt='$&#40;opt&#41; -DCPUS=2' \
                crafty-make
A little faster ;)

Code: Select all

White&#40;1&#41;&#58; mt=2
max threads set to 2.
White&#40;1&#41;&#58; bench
Running benchmark. . .
......
Total nodes&#58; 157182499
Raw nodes per second&#58; 5544356
Total elapsed time&#58; 28.35
And in crafty.h

Code: Select all

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#if !defined&#40;FreeBSD&#41;
#  include <malloc.h>
#endif
#include <string.h>
#if !defined&#40;TYPES_INCLUDED&#41;
....
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty-23.1 does not compile on Mac OS X

Post by bob »

schlucke wrote:Hi,

I do it this way (in Makefile)

Code: Select all

darwin-x86_64&#58;
        $&#40;MAKE&#41; target=FreeBSD \
                CC=gcc CXX=g++ \
                CFLAGS='$&#40;CFLAGS&#41; -Wall -pipe -O3 -m64' \
                CXFLAGS=$&#40;CFLAGS&#41; \
                LDFLAGS=$&#40;LDFLAGS&#41; \
                LIBS='-lpthread -lstdc++' \
                opt='$&#40;opt&#41; -DCPUS=2' \
                crafty-make
Gives this bench results on my MacBook Pro (2.4 GHz Intel Core 2 Duo):

Code: Select all

White&#40;1&#41;&#58; mt=2 
max threads set to 2.
White&#40;1&#41;&#58; bench
Running benchmark. . .
......
Total nodes&#58; 127082421
Raw nodes per second&#58; 4288978
Total elapsed time&#58; 29.63
With the suggested options:

Code: Select all

darwin-x86_64&#58;
        $&#40;MAKE&#41; target=FreeBSD \
                CC=gcc CXX=g++ \
                CFLAGS='$&#40;CFLAGS&#41; -Wall -pipe -O3 -m64 -fast -DINLINE64' \
                CXFLAGS=$&#40;CFLAGS&#41; \
                LDFLAGS=$&#40;LDFLAGS&#41; \
                LIBS='-lpthread -lstdc++' \
                opt='$&#40;opt&#41; -DCPUS=2' \
                crafty-make
A little faster ;)

Code: Select all

White&#40;1&#41;&#58; mt=2
max threads set to 2.
White&#40;1&#41;&#58; bench
Running benchmark. . .
......
Total nodes&#58; 157182499
Raw nodes per second&#58; 5544356
Total elapsed time&#58; 28.35
And in crafty.h

Code: Select all

#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#if !defined&#40;FreeBSD&#41;
#  include <malloc.h>
#endif
#include <string.h>
#if !defined&#40;TYPES_INCLUDED&#41;
....
If you don't mind, please send me a Makefile that works on your box, modified from the distributed Makefile. I hate making editing changes that I can't verify easily and I want to avoid releasing a 23.2 that won't compile cleanly.
IanO
Posts: 496
Joined: Wed Mar 08, 2006 9:45 pm
Location: Portland, OR

Re: Crafty-23.1 does not compile on Mac OS X

Post by IanO »

Sent. Summarizing:

-m64 +75%
-fast +6%
-DINLINE64 +17%
-DCPUS=8 the maximum available to a Mac power user, the 8-core Nehalem tower. (Apple no longer sells any single core models.)
schlucke
Posts: 58
Joined: Thu Apr 09, 2009 1:38 pm

Re: Crafty-23.1 does not compile on Mac OS X

Post by schlucke »

bob wrote: If you don't mind, please send me a Makefile that works on your box, modified from the distributed Makefile. I hate making editing changes that I can't verify easily and I want to avoid releasing a 23.2 that won't compile cleanly.
On the way to your uab (dot) edu adress ....
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Crafty-23.1 does not compile on Mac OS X

Post by zullil »

schlucke wrote:
Gives this bench results on my MacBook Pro (2.4 GHz Intel Core 2 Duo):


With the suggested options:

Code: Select all

darwin-x86_64&#58;
        $&#40;MAKE&#41; target=FreeBSD \
                CC=gcc CXX=g++ \
                CFLAGS='$&#40;CFLAGS&#41; -Wall -pipe -O3 -m64 -fast -DINLINE64' \
                CXFLAGS=$&#40;CFLAGS&#41; \
                LDFLAGS=$&#40;LDFLAGS&#41; \
                LIBS='-lpthread -lstdc++' \
                opt='$&#40;opt&#41; -DCPUS=2' \
                crafty-make

Code: Select all

White&#40;1&#41;&#58; mt=2
max threads set to 2.
White&#40;1&#41;&#58; bench
Running benchmark. . .
......
Total nodes&#58; 157182499
Raw nodes per second&#58; 5544356
Total elapsed time&#58; 28.35
With the latest Intel compiler for OS X (free download for 30 day evaluation), using -fast -DINLINE64 and -prof-gen/-prof-use for profile-generated optimization:

Code: Select all

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

White&#40;1&#41;&#58; bench
Running benchmark. . .
......
Total nodes&#58; 120019300
Raw nodes per second&#58; 5002888
Total elapsed time&#58; 23.99
On my MacBook

Code: Select all

  Model Name&#58;	MacBook
  Model Identifier&#58;	MacBook3,1
  Processor Name&#58;	Intel Core 2 Duo
  Processor Speed&#58;	2 GHz
  Number Of Processors&#58;	1
  Total Number Of Cores&#58;	2
  L2 Cache&#58;	4 MB
  Memory&#58;	4 GB
  Bus Speed&#58;	800 MHz