Geschrieben von:/Posted by: Bryan Hofmann at 13 April 2004 18:14:02:
Als Antwort auf:/In reply to: Re: Building your own Crafty geschrieben von:/posted by: Tord Romstad at 13 April 2004 14:51:00:
Just as a FYI you can greatly reduce your batch file and achive a faster crafty by using the following;
gcc -c -DNT_i386 -O3 crafty.c
gcc -c -DNT_i386 -O3 egtb.cpp
gcc -o crafty.exe *.o
By doing this you compile the crafty.c as one large object which allows for better optimization.
Why is the optimization better with a single input file? I just tried with
my own engine, and didn't notice any improvement.
Also, are you sure -O3 is best? For Gothmog -O is better than -O2 and -O3.
I would expect the same to be true for Crafty, which is very much bigger.
Tord
By compiling Crafty in to one large object file it gives the compiler a better chance to optimize the program. When I did some compile tests back in version 19.10 I found this to be the case. I will say however that I used my own make file an used other option flags as well as the profile guided optimize (2 stage compile). I found that using one large object over the several small ones gave about a 2-4% speed increase in the crafty bench for the NPS.
Below is the make file I used to get the fastest 19.10 compile for a AMD XP 3000+ system. As Dann likes to say YMMV.
# This makefile is to be used for compilation of Crafty with
# gcc under Windows.
# Tested with Dev-C++ 4.9.8.5, which includes gcc/g++ 3.2
all: profile
NT_i386_1:
$(MAKE) target=NT_i386 \
CC=gcc CXX=g++ CYY=g++\
CFLAGS='$(CFLAGS) -pipe -D_REENTRANT -fomit-frame-pointer -O3 -msse\
-fforce-mem -fno-gcse -m3dnow -fprofile-arcs\
-funroll-loops -march=athlon-xp' \
CXFLAGS='$(CFLAGS) -pipe -D_REENTRANT -fomit-frame-pointer -O3 -msse\
-fforce-mem -fno-gcse -m3dnow -fprofile-arcs\
-funroll-loops -march=athlon-xp' \
LDFLAGS=$(LDFLAGS) \
opt='$(opt) -DUSE_ASSEMBLY -DINLINE_ASM -DFAST -DFUTILITY' \
asm='X86.o' \
crafty-make
NT_i386_2:
$(MAKE) target=NT_i386 \
CC=gcc CXX=g++ CYY=g++\
CFLAGS='$(CFLAGS) -pipe -D_REENTRANT -fomit-frame-pointer -O3 -msse\
-fforce-mem -fno-gcse -m3dnow -fbranch-probabilities\
-funroll-loops -march=athlon-xp' \
CXFLAGS='$(CFLAGS) -pipe -D_REENTRANT -fomit-frame-pointer -O3 -msse\
-fforce-mem -fno-gcse -m3dnow -fbranch-probabilities\
-funroll-loops -march=athlon-xp' \
LDFLAGS=$(LDFLAGS) \
opt='$(opt) -DUSE_ASSEMBLY -DINLINE_ASM -DFAST -DFUTILITY' \
asm='X86.o' \
crafty-make
profile:
$(MAKE) NT_i386_1
@crafty < prof
@rm crafty.exe
@rm *.o
$(MAKE) NT_i386_2
opts = $(opt) -D$(target)
#objects = searchr.o search.o singular.o thread.o searchmp.o repeat.o next.o \
# nexte.o nextr.o history.o quiesce.o evaluate.o movgen.o make.o unmake.o \
# hash.o attacks.o swap.o boolean.o utility.o valid.o probe.o book.o \
# data.o drawn.o edit.o epd.o epdglue.o init.o input.o interupt.o \
# iterate.o main.o option.o output.o phase.o ponder.o preeval.o resign.o \
# root.o learn.o setboard.o test.o time.o validate.o annotate.o analyze.o \
# evtest.o bench.o egtb.o dgt.o $(asm)
objects = crafty.o egtb.o $(asm)
includes = data.h chess.h
epdincludes = epd.h epddefs.h epdglue.h
eval_users = data.o evaluate.o preeval.o
crafty-make:
@$(MAKE) \
opt='$(opt)' asm='$(asm)' \
crafty
crafty: $(objects)
$(CYY) $(LDFLAGS) -o crafty $(objects) -lm $(LIBS)
dgt: dgtdrv.o
@cc -O -o dgt dgtdrv.c
egtb.o: egtb.cpp
$(CXX) -c $(CXFLAGS) $(opts) egtb.cpp
clean:
del *.o;del crafty.exe
$(objects): $(includes)
$(eval_users): evaluate.h
epd.o epdglue.o option.o init.o : $(epdincludes)
.c.o:
$(CC) $(CFLAGS) $(opts) -c $*.c
.s.o:
$(AS) $(AFLAGS) -o $*.o $*.s