Subversion Repositories Games.Chess Giants

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
33 pmbaty 1
# To build crafty:
2
#
3
#  You want to set up for maximum optimization, but typically you will
4
#  need to experiment to see which options provide the fastest code.  The
5
#  following option descriptions explain each option.  To use one or more
6
#  of these options, to the "opt =" line that follows the explanations and
7
#  add the options you want, being careful to stay inside the single quote
8
#  marks.
9
#   
10
#   -DAFFINITY     Include code to set processor/thread affinity on Unix
11
#                  systems.  Note this will not work on Apple OS X as it does
12
#                  not support any sort of processor affinity mechanism.
13
#   -DBOOKDIR      Path to the directory containing the book binary files.
14
#                  The default for all such path values is "." if you don't
15
#                  specify a path with this macro definition.
16
#   -DCPUS=n       Defines the maximum number of CPUS Crafty will be able
17
#                  to use in a SMP system.  Note that this is the max you
18
#                  will be able to use.  You need to use the smpmt=n command
19
#                  to make crafty use more than the default 1 process.
20
#   -DDEBUG        This is used for testing changes.  Enabling this option
21
#                  greatly slows Crafty down, but every time a move is made,
22
#                  the corresponding position is checked to make sure all of
23
#                  the bitboards are set correctly.
24
#   -DEPD          If you want full EPD support built in.
25
#   -DINLINEASM    Compiles with the Intel assembly code for FirstOne(),
26
#                  LastOne() and PopCnt().  This is for gcc-style inlining
27
#                  and now works with the Intel C/C++ compiler as well.  It
28
#                  also has a MSVC compatible version included.
29
#   -DLOGDIR       Path to the directory where Crafty puts the log.nnn and
30
#                  game.nnn files.
31
#   -DNODES        This enables the sn=x command.  Crafty will search until
32
#                  exactly X nodes have been searched, then the search 
33
#                  terminates as if time ran out.
34
#   -DNOEGTB       Eliminates the egtb code for compilers that can't deal
35
#                  with the large egtb.cpp code/templates.
36
#   -DNUMA         Says this system is NUMA, which is mainly used for Linux
37
#                  or Windows systems, and references libnuma, needed for the
38
#                  NUMA calls (crafty doesn't use many of these, it does the
39
#                  memory setup stuff itself)
40
#   -DPOPCNT       Says this system is a newer Intel/AMD processor with the
41
#                  built-in hardware popcnt instruction.
42
#   -DPOSITIONS    Causes Crafty to emit FEN strings, one per book line, as
43
#                  it creates a book.  I use this to create positions to use
44
#                  for cluster testing.
45
#   -DRCDIR        Path to the directory where we look for the .craftyrc or
46
#                  crafty.rc (windows) file.
47
#   -DSKILL        Enables the "skill" command which allows you to arbitrarily
48
#                  lower Crafty's playing skill so it does not seem so
49
#                  invincible to non-GM-level players.
50
#   -DTBDIR        Path to the directory where the endgame tablebase files
51
#                  are found.  default = "./TB"
52
#   -DTEST         Displays evaluation table after each move (in the logfile)
53
#   -DTRACE        This enables the "trace" command so that the search tree
54
#                  can be dumped while running.
55
#   -DUNIX         This identifies the target O/S as being Unix-based, if this
56
#                  option is omitted, windows is assumed.
57
 
58
default:
59
	$(MAKE) -j unix-gcc
60
help:
61
	@echo "You must specify the system which you want to compile for:"
62
	@echo ""
63
	@echo "make unix-gcc         Unix w/gcc compiler"
64
	@echo "make unix-icc         Unix w/icc compiler"
65
	@echo "make profile          profile-guided-optimizations"
66
	@echo "                      (edit Makefile to make the profile"
67
	@echo "                      option use the right compiler)"
68
	@echo ""
69
 
70
quick:
71
	$(MAKE) target=UNIX \
72
		CC=gcc CXX=g++ \
73
		opt='-DTEST -DTRACE -DINLINEASM -DCPUS=8' \
74
		CFLAGS='-Wall -O3 -pipe -pthread' \
75
		CXFLAGS='-Wall -pipe -O3 -pthread' \
76
		LDFLAGS='$(LDFLAGS) -pthread -lstdc++' \
77
		crafty-make
78
 
79
unix-gcc:
80
	$(MAKE) target=UNIX \
81
		CC=gcc CXX=g++ \
82
		opt='-DTEST -DINLINEASM -DCPUS=8' \
83
		CFLAGS='-Wall -pipe -O3 -fprofile-use -fprofile-correction -pthread' \
84
		CXFLAGS='-Wall -pipe -O3 -fprofile-use -fprofile-correction -pthread' \
85
		LDFLAGS='$(LDFLAGS) -fprofile-use -pthread -lstdc++' \
86
		crafty-make
87
 
88
unix-gcc-profile:
89
	$(MAKE) target=UNIX \
90
		CC=gcc CXX=g++ \
91
		opt='-DTEST -DINLINEASM -DCPUS=8' \
92
		CFLAGS='-Wall -pipe -O3 -fprofile-arcs -pthread' \
93
		CXFLAGS='-Wall -pipe -O3 -fprofile-arcs -pthread' \
94
		LDFLAGS='$(LDFLAGS) -fprofile-arcs -pthread -lstdc++ ' \
95
		crafty-make
96
 
97
unix-icc:
98
	$(MAKE) target=UNIX \
99
		CC=icc CXX=icc \
100
		opt='-DTEST -DINLINEASM -DCPUS=8' \
101
		CFLAGS='-Wall -w -O2 -prof_use -prof_dir ./prof -fno-alias -pthread' \
102
		CXFLAGS='-Wall -w -O2 -prof_use -prof_dir ./prof -pthread' \
103
		LDFLAGS='$(LDFLAGS) -pthread -lstdc++' \
104
		crafty-make
105
 
106
unix-icc-profile:
107
	$(MAKE) target=UNIX \
108
		CC=icc CXX=icc \
109
		opt='-DTEST -DINLINEASM -DCPUS=8' \
110
		CFLAGS='-Wall -w -O2 -prof_genx -prof_dir ./prof -fno-alias -pthread' \
111
		CXFLAGS='-Wall -w -O2 -prof_genx -prof_dir ./prof -pthread' \
112
		LDFLAGS='$(LDFLAGS) -pthread -lstdc++ ' \
113
		crafty-make
114
 
115
profile:
116
	@rm -rf prof
117
	@rm -rf *.gcda
118
	@mkdir prof
119
	@touch *.c *.cpp *.h
120
	$(MAKE) unix-gcc-profile
121
	@echo "#!/bin/csh" > runprof
122
	@echo "./crafty <<EOF" >>runprof
123
	@echo "st=10" >>runprof
124
	@echo "mt=0" >>runprof
125
	@echo "ponder=off" >>runprof
126
	@echo "display nomoves" >>runprof
127
	@echo "setboard rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq" >>runprof
128
	@echo "move" >>runprof
129
	@echo "book off" >>runprof
130
	@echo "setboard rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq" >>runprof
131
	@echo "move" >>runprof
132
	@echo "setboard 1k1r4/pp1b1R2/3q2pp/4p3/2B5/4Q3/PPP2B2/2K5 b" >>runprof
133
	@echo "move" >>runprof
134
	@echo "setboard 3r1k2/4npp1/1ppr3p/p6P/P2PPPP1/1NR5/5K2/2R5 w" >>runprof
135
	@echo "move" >>runprof
136
	@echo "setboard 2q1rr1k/3bbnnp/p2p1pp1/2pPp3/PpP1P1P1/1P2BNNP/2BQ1PRK/7R b" >>runprof
137
	@echo "move" >>runprof
138
	@echo "setboard rnbqkb1r/p3pppp/1p6/2ppP3/3N4/2P5/PPP1QPPP/R1B1KB1R w KQkq" >>runprof
139
	@echo "move" >>runprof
140
	@echo "setboard r1b2rk1/2q1b1pp/p2ppn2/1p6/3QP3/1BN1B3/PPP3PP/R4RK1 w" >>runprof
141
	@echo "move" >>runprof
142
	@echo "setboard 2r3k1/pppR1pp1/4p3/4P1P1/5P2/1P4K1/P1P5/8 w" >>runprof
143
	@echo "move" >>runprof
144
	@echo "setboard 1nk1r1r1/pp2n1pp/4p3/q2pPp1N/b1pP1P2/B1P2R2/2P1B1PP/R2Q2K1 w" >>runprof
145
	@echo "move" >>runprof
146
	@echo "setboard 4b3/p3kp2/6p1/3pP2p/2pP1P2/4K1P1/P3N2P/8 w" >>runprof
147
	@echo "move" >>runprof
148
	@echo "setboard 2kr1bnr/pbpq4/2n1pp2/3p3p/3P1P1B/2N2N1Q/PPP3PP/2KR1B1R w" >>runprof
149
	@echo "move" >>runprof
150
	@echo "setboard 3rr1k1/pp3pp1/1qn2np1/8/3p4/PP1R1P2/2P1NQPP/R1B3K1 b" >>runprof
151
	@echo "move" >>runprof
152
	@echo "setboard 2r1nrk1/p2q1ppp/bp1p4/n1pPp3/P1P1P3/2PBB1N1/4QPPP/R4RK1 w" >>runprof
153
	@echo "move" >>runprof
154
	@echo "setboard r3r1k1/ppqb1ppp/8/4p1NQ/8/2P5/PP3PPP/R3R1K1 b" >>runprof
155
	@echo "move" >>runprof
156
	@echo "setboard r2q1rk1/4bppp/p2p4/2pP4/3pP3/3Q4/PP1B1PPP/R3R1K1 w" >>runprof
157
	@echo "move" >>runprof
158
	@echo "setboard rnb2r1k/pp2p2p/2pp2p1/q2P1p2/8/1Pb2NP1/PB2PPBP/R2Q1RK1 w" >>runprof
159
	@echo "move" >>runprof
160
	@echo "setboard 2r3k1/1p2q1pp/2b1pr2/p1pp4/6Q1/1P1PP1R1/P1PN2PP/5RK1 w" >>runprof
161
	@echo "move" >>runprof
162
	@echo "setboard r1bqkb1r/4npp1/p1p4p/1p1pP1B1/8/1B6/PPPN1PPP/R2Q1RK1 w kq" >>runprof
163
	@echo "move" >>runprof
164
	@echo "setboard r2q1rk1/1ppnbppp/p2p1nb1/3Pp3/2P1P1P1/2N2N1P/PPB1QP2/R1B2RK1 b" >>runprof
165
	@echo "move" >>runprof
166
	@echo "setboard r1bq1rk1/pp2ppbp/2np2p1/2n5/P3PP2/N1P2N2/1PB3PP/R1B1QRK1 b" >>runprof
167
	@echo "move" >>runprof
168
	@echo "setboard 3rr3/2pq2pk/p2p1pnp/8/2QBPP2/1P6/P5PP/4RRK1 b" >>runprof
169
	@echo "move" >>runprof
170
	@echo "setboard r4k2/pb2bp1r/1p1qp2p/3pNp2/3P1P2/2N3P1/PPP1Q2P/2KRR3 w" >>runprof
171
	@echo "move" >>runprof
172
	@echo "setboard 3rn2k/ppb2rpp/2ppqp2/5N2/2P1P3/1P5Q/PB3PPP/3RR1K1 w" >>runprof
173
	@echo "move" >>runprof
174
	@echo "setboard 2r2rk1/1bqnbpp1/1p1ppn1p/pP6/N1P1P3/P2B1N1P/1B2QPP1/R2R2K1 b" >>runprof
175
	@echo "move" >>runprof
176
	@echo "setboard r1bqk2r/pp2bppp/2p5/3pP3/P2Q1P2/2N1B3/1PP3PP/R4RK1 b kq" >>runprof
177
	@echo "move" >>runprof
178
	@echo "setboard r2qnrnk/p2b2b1/1p1p2pp/2pPpp2/1PP1P3/PRNBB3/3QNPPP/5RK1 w" >>runprof
179
	@echo "move" >>runprof
180
	@echo "setboard /k/3p/p2P1p/P2P1P///K/ w" >>runprof
181
	@echo "move" >>runprof
182
	@echo "egtb" >>runprof
183
	@echo "setboard /k/rnn////5RBB/K/ w" >>runprof
184
	@echo "move" >>runprof
185
	@echo "mt=0" >>runprof
186
	@echo "quit" >>runprof
187
	@echo "EOF" >>runprof
188
	@chmod +x runprof
189
	@./runprof
190
	@echo "#!/bin/csh" > runprof
191
	@echo "./crafty <<EOF" >>runprof
192
	@echo "st=10" >>runprof
193
	@echo "ponder=off" >>runprof
194
	@echo "mt=2" >>runprof
195
	@echo "setboard 2r2rk1/1bqnbpp1/1p1ppn1p/pP6/N1P1P3/P2B1N1P/1B2QPP1/R2R2K1 b" >>runprof
196
	@echo "move" >>runprof
197
	@echo "mt=2" >>runprof
198
	@echo "quit" >>runprof
199
	@echo "EOF" >>runprof
200
	@chmod +x runprof
201
	@./runprof
202
	@rm runprof
203
	@touch *.c *.cpp *.h
204
	$(MAKE) unix-gcc
205
 
206
#
207
#  one of the two following definitions for "objects" should be used.  The
208
#  default is to compile everything separately.  However, if you use the 
209
#  definition that refers to crafty.o, that will compile using the file crafty.c
210
#  which #includes every source file into one large glob.  This gives the
211
#  compiler max opportunity to inline functions as appropriate.  You should try
212
#  compiling both ways to see which way produces the fastest code.
213
#
214
 
215
#objects = search.o thread.o repeat.o next.o killer.o quiesce.o evaluate.o     \
216
       movgen.o make.o unmake.o hash.o  attacks.o swap.o boolean.o  utility.o  \
217
       probe.o book.o data.o drawn.o edit.o epd.o epdglue.o init.o input.o     \
218
       interrupt.o iterate.o main.o option.o output.o ponder.o resign.o root.o \
219
       learn.o setboard.o test.o time.o validate.o annotate.o analyze.o        \
220
       evtest.o bench.o
221
objects = crafty.o
222
 
223
# Do not change anything below this line!
224
 
225
opts = $(opt) -D$(target)
226
 
227
includes = data.h chess.h
228
 
229
crafty-make:
230
	@$(MAKE) -j opt='$(opt)' CXFLAGS='$(CXFLAGS)' CFLAGS='$(CFLAGS)' crafty
231
 
232
crafty.o: *.c *.h
233
 
234
crafty:	$(objects) egtb.o
235
	$(CC) $(LDFLAGS) -o crafty $(objects) egtb.o -lm  $(LIBS)
236
 
237
egtb.o: egtb.cpp
238
	$(CXX) -c $(CXFLAGS) $(opts) egtb.cpp
239
clean:
240
	-rm -f *.o crafty
241
 
242
$(objects): $(includes)
243
 
244
.c.o:
245
	$(CC) $(CFLAGS) $(opts) -c $*.c
246
 
247
.s.o:
248
	$(AS) $(AFLAGS) -o $*.o $*.s