Subversion Repositories Games.Chess Giants

Rev

Rev 110 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 110 Rev 154
Line 28... Line 28...
28
#   -DDEBUG        This is used for testing changes.  Enabling this option
28
#   -DDEBUG        This is used for testing changes.  Enabling this option
29
#                  greatly slows Crafty down, but every time a move is made,
29
#                  greatly slows Crafty down, but every time a move is made,
30
#                  the corresponding position is checked to make sure all of
30
#                  the corresponding position is checked to make sure all of
31
#                  the bitboards are set correctly.
31
#                  the bitboards are set correctly.
32
#   -DEPD          If you want full EPD support built in.
32
#   -DEPD          If you want full EPD support built in.
33
#   -DINLINEASM    Compiles with the Intel assembly code for FirstOne(),
-
 
34
#                  LastOne() and PopCnt().  This is for gcc-style inlining
-
 
35
#                  and now works with the Intel C/C++ compiler as well.  It
-
 
36
#                  also has a MSVC compatible version included.
-
 
37
#   -DLOGDIR       Path to the directory where Crafty puts the log.nnn and
33
#   -DLOGDIR       Path to the directory where Crafty puts the log.nnn and
38
#                  game.nnn files.
34
#                  game.nnn files.
39
#   -DNODES        This enables the sn=x command.  Crafty will search until
35
#   -DNODES        This enables the sn=x command.  Crafty will search until
40
#                  exactly X nodes have been searched, then the search 
36
#                  exactly X nodes have been searched, then the search 
41
#                  terminates as if time ran out.
37
#                  terminates as if time ran out.
42
#   -DNOEGTB       Eliminates the egtb code for compilers that can't deal
-
 
43
#                  with the large egtb.cpp code/templates.
-
 
44
#   -DPOPCNT       Says this system is a newer Intel/AMD processor with the
-
 
45
#                  built-in hardware popcnt instruction.
-
 
46
#   -DPOSITIONS    Causes Crafty to emit FEN strings, one per book line, as
38
#   -DPOSITIONS    Causes Crafty to emit FEN strings, one per book line, as
47
#                  it creates a book.  I use this to create positions to use
39
#                  it creates a book.  I use this to create positions to use
48
#                  for cluster testing.
40
#                  for cluster testing.
49
#   -DRCDIR        Path to the directory where we look for the .craftyrc or
41
#   -DRCDIR        Path to the directory where we look for the .craftyrc or
50
#                  crafty.rc (windows) file.
42
#                  crafty.rc (windows) file.
51
#   -DSKILL        Enables the "skill" command which allows you to arbitrarily
43
#   -DSKILL        Enables the "skill" command which allows you to arbitrarily
52
#                  lower Crafty's playing skill so it does not seem so
44
#                  lower Crafty's playing skill so it does not seem so
53
#                  invincible to non-GM-level players.
45
#                  invincible to non-GM-level players.
-
 
46
#   -DSYZYGY       This enables syzygy endgame tables (both WDL and DTC)
54
#   -DTBDIR        Path to the directory where the endgame tablebase files
47
#   -DTBDIR        Path to the directory where the endgame tablebase files
55
#                  are found.  default = "./TB"
48
#                  are found.  default = "./TB"
56
#   -DTEST         Displays evaluation table after each move (in the logfile)
49
#   -DTEST         Displays evaluation table after each move (in the logfile)
57
#   -DTRACE        This enables the "trace" command so that the search tree
50
#   -DTRACE        This enables the "trace" command so that the search tree
58
#                  can be dumped while running.
51
#                  can be dumped while running.
59
#   -DUNIX         This identifies the target O/S as being Unix-based, if this
52
#   -DUNIX         This identifies the target O/S as being Unix-based, if this
60
#                  option is omitted, windows is assumed.
53
#                  option is omitted, windows is assumed.
61
 
54
#
62
#	$(MAKE) -j unix-gcc
55
#    Note:         If you compile on a machine with the hardware popcnt
-
 
56
#                  instruction, you should use the -mpopcnt compiler option
-
 
57
#                  to make the built-in intrinsic use the hardware rather than
-
 
58
#                  the "folding" approach.  That is the default in this
-
 
59
#                  Makefile so if you do NOT have hardware popcnt, remove all
-
 
60
#                  of the -mpopcnt strings in the Makefile lines below.
-
 
61
#
63
default:
62
default:
64
	$(MAKE) -j unix-clang
63
	$(MAKE) -j unix-clang
65
help:
64
help:
66
	@echo "You must specify the system which you want to compile for:"
65
	@echo "You must specify the system which you want to compile for:"
67
	@echo ""
66
	@echo ""
-
 
67
	@echo "make unix-clang       Unix w/clang compiler (MacOS usually)"
68
	@echo "make unix-gcc         Unix w/gcc compiler"
68
	@echo "make unix-gcc         Unix w/gcc compiler"
69
	@echo "make unix-icc         Unix w/icc compiler"
69
	@echo "make unix-icc         Unix w/icc compiler"
70
	@echo "make profile          profile-guided-optimizations"
70
	@echo "make profile          profile-guided-optimizations"
71
	@echo "                      (edit Makefile to make the profile"
71
	@echo "                      (edit Makefile to make the profile"
72
	@echo "                      option use the right compiler)"
72
	@echo "                      option use the right compiler)"
73
	@echo ""
73
	@echo ""
-
 
74
 
74
 
75
 
75
quick:
76
quick:
76
	$(MAKE) target=UNIX \
77
	$(MAKE) target=UNIX \
77
		CC=gcc CXX=g++ \
78
		CC=clang \
78
		opt='-DTEST -DTRACE -DINLINEASM -DPOPCNT -DCPUS=4' \
79
 		opt='-DSYZYGY -DTEST -DTRACE -DCPUS=4' \
79
		CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -pthread' \
80
		CFLAGS='-mpopcnt -Wall -Wno-array-bounds -pipe -O3' \
80
		CXFLAGS='-Wall -Wno-array-bounds -pipe -O3 -pthread' \
-
 
81
		LDFLAGS='$(LDFLAGS) -lstdc++' \
81
		LDFLAGS='$(LDFLAGS) -lstdc++' \
82
		crafty-make
82
		crafty-make
83
 
83
 
84
unix-gcc:
84
unix-gcc:
85
	$(MAKE) -j target=UNIX \
85
	$(MAKE) -j target=UNIX \
86
		CC=gcc CXX=g++ \
86
		CC=gcc \
87
		opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \
87
		opt='-DSYZYGY -DTEST -DCPUS=4' \
88
		CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-use \
88
		CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-use \
89
		-fprofile-correction -pthread' \
-
 
90
		CXFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-use \
-
 
91
		-fprofile-correction -pthread' \
89
		-mpopcnt -fprofile-correction -pthread' \
92
		LDFLAGS='$(LDFLAGS) -fprofile-use -pthread -lstdc++' \
90
		LDFLAGS='$(LDFLAGS) -fprofile-use -pthread -lstdc++' \
93
		crafty-make
91
		crafty-make
94
 
92
 
95
unix-gcc-profile:
93
unix-gcc-profile:
96
	$(MAKE) -j target=UNIX \
94
	$(MAKE) -j target=UNIX \
97
		CC=gcc CXX=g++ \
95
		CC=gcc \
98
		opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \
96
		opt='-DSYZYGY -DTEST -DCPUS=4' \
99
		CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-arcs \
97
		CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-arcs \
100
		-pthread' \
-
 
101
		CXFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-arcs \
-
 
102
		-pthread' \
98
		-mpopcnt -pthread' \
103
		LDFLAGS='$(LDFLAGS) -fprofile-arcs -pthread -lstdc++ ' \
99
		LDFLAGS='$(LDFLAGS) -fprofile-arcs -pthread -lstdc++ ' \
104
		crafty-make
100
		crafty-make
105
 
101
 
106
unix-clang:
102
unix-clang:
107
	@/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata merge -output=crafty.profdata *.profraw
103
	@/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata merge -output=crafty.profdata *.profraw
108
	$(MAKE) -j target=UNIX \
104
	$(MAKE) -j target=UNIX \
109
		CC=clang CXX=clang++ \
105
		CC=clang \
110
		opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \
106
		opt='-DSYZYGY -DTEST -DCPUS=4' \
111
		CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \
107
		CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \
112
			-fprofile-instr-use=crafty.profdata' \
-
 
113
		CXFLAGS='-Wall -Wno-array-bounds -pipe -O3 \
-
 
114
			-fprofile-instr-use=crafty.profdata' \
108
			-mpopcnt -fprofile-instr-use=crafty.profdata' \
115
		LDFLAGS='$(LDFLAGS) -fprofile-use -lstdc++' \
109
		LDFLAGS='$(LDFLAGS) -fprofile-use -lstdc++' \
116
		crafty-make
110
		crafty-make
117
 
111
 
118
unix-clang-profile:
112
unix-clang-profile:
119
	$(MAKE) -j target=UNIX \
113
	$(MAKE) -j target=UNIX \
120
		CC=clang CXX=clang++ \
114
		CC=clang \
121
		opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \
115
		opt='-DSYZYGY -DTEST -DCPUS=4' \
122
		CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \
116
		CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \
123
			-fprofile-instr-generate' \
-
 
124
		CXFLAGS='-Wall -Wno-array-bounds -pipe -O3 \
-
 
125
			-fprofile-instr-generate' \
117
			-mpopcnt -fprofile-instr-generate' \
126
		LDFLAGS='$(LDFLAGS) -fprofile-instr-generate -lstdc++ ' \
118
		LDFLAGS='$(LDFLAGS) -fprofile-instr-generate -lstdc++ ' \
127
		crafty-make
119
		crafty-make
128
 
120
 
129
unix-icc:
121
unix-icc:
130
	$(MAKE) -j target=UNIX \
122
	$(MAKE) -j target=UNIX \
131
		CC=icc CXX=icc \
123
		CC=icc \
132
		opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \
124
		opt='-DSYZYGY -DTEST -DCPUS=4' \
133
		CFLAGS='-Wall -w -O2 -prof_use -prof_dir ./prof -fno-alias \
125
		CFLAGS='-Wall -w -O2 -prof_use -prof_dir ./prof -fno-alias \
134
                        -pthread' \
126
                        -mpopcnt -pthread' \
135
		CXFLAGS='-Wall -w -O2 -prof_use -prof_dir ./prof -pthread' \
-
 
136
		LDFLAGS='$(LDFLAGS) -pthread -lstdc++' \
127
		LDFLAGS='$(LDFLAGS) -pthread -lstdc++' \
137
		crafty-make
128
		crafty-make
138
 
129
 
139
unix-icc-profile:
130
unix-icc-profile:
140
	$(MAKE) -j target=UNIX \
131
	$(MAKE) -j target=UNIX \
141
		CC=icc CXX=icc \
132
		CC=icc \
142
		opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \
133
		opt='-DSYZYGY -DTEST -DCPUS=4' \
143
		CFLAGS='-Wall -w -O2 -prof_gen -prof_dir ./prof -fno-alias \
134
		CFLAGS='-Wall -w -O2 -prof_gen -prof_dir ./prof -fno-alias \
144
                        -pthread' \
135
                        -mpopcnt -pthread' \
145
		CXFLAGS='-Wall -w -O2 -prof_gen -prof_dir ./prof -pthread' \
-
 
146
		LDFLAGS='$(LDFLAGS) -pthread -lstdc++ ' \
136
		LDFLAGS='$(LDFLAGS) -pthread -lstdc++ ' \
147
		crafty-make
137
		crafty-make
148
 
138
 
149
profile:
139
profile:
150
	@rm -rf *.o
140
	@rm -rf *.o
151
	@rm -rf log.*
141
	@rm -rf log.*
152
	@rm -rf game.*
142
	@rm -rf game.*
153
	@rm -rf prof
143
	@rm -rf prof
154
	@rm -rf *.gcda
144
	@rm -rf *.gcda
155
	@mkdir prof
145
	@mkdir prof
156
	@touch *.c *.cpp *.h
146
	@touch *.c *.h
157
	$(MAKE) -j unix-clang-profile
147
	$(MAKE) -j unix-clang-profile
158
	@echo "#!/bin/csh" > runprof
148
	@echo "#!/bin/csh" > runprof
159
	@echo "./crafty <<EOF" >>runprof
149
	@echo "./crafty <<EOF" >>runprof
160
	@echo "pgo -1" >>runprof
150
	@echo "bench" >>runprof
161
	@echo "mt=0" >>runprof
151
	@echo "mt=0" >>runprof
162
	@echo "quit" >>runprof
152
	@echo "quit" >>runprof
163
	@echo "EOF" >>runprof
153
	@echo "EOF" >>runprof
164
	@chmod +x runprof
154
	@chmod +x runprof
165
	@./runprof
155
	@./runprof
166
	@rm runprof
156
	@rm runprof
167
	@touch *.c *.cpp *.h
157
	@touch *.c *.h
168
	$(MAKE) -j unix-clang
158
	$(MAKE) -j unix-clang
169
 
159
 
170
 
160
 
171
#
161
#
172
#  one of the two following definitions for "objects" should be used.  The
162
#  one of the two following definitions for "objects" should be used.  The
Line 176... Line 166...
176
#  compiler max opportunity to inline functions as appropriate.  You should try
166
#  compiler max opportunity to inline functions as appropriate.  You should try
177
#  compiling both ways to see which way produces the fastest code.
167
#  compiling both ways to see which way produces the fastest code.
178
#
168
#
179
 
169
 
180
#objects = main.o iterate.o time.o search.o quiesce.o evaluate.o thread.o \
170
#objects = main.o iterate.o time.o search.o quiesce.o evaluate.o thread.o \
181
       repeat.o hash.o next.o history.o movgen.o make.o unmake.o attacks.o \
171
        repeat.o hash.o next.o history.o movgen.o make.o unmake.o attacks.o \
182
       see.o boolean.o utility.o probe.o book.o drawn.o epd.o epdglue.o \
172
        see.o tbprobe.o boolean.o utility.o book.o drawn.o epd.o \
183
       init.o input.o autotune.o interrupt.o option.o output.o ponder.o \
173
        epdglue.o init.o input.o autotune.o interrupt.o option.o output.o \
184
       resign.o root.o learn.o setboard.o test.o validate.o annotate.o \
174
        ponder.o resign.o root.o learn.o setboard.o test.o validate.o \
185
       analyze.o evtest.o bench.o edit.o data.o
175
        annotate.o analyze.o evtest.o bench.o edit.o data.o
186
 
176
 
187
objects = crafty.o
177
objects = crafty.o
188
 
178
 
189
# Do not change anything below this line!
179
# Do not change anything below this line!
190
 
180
 
191
opts = $(opt) -D$(target)
181
opts = $(opt) -D$(target)
192
 
182
 
193
#	@$(MAKE) -j opt='$(opt)' CXFLAGS='$(CXFLAGS)' CFLAGS='$(CFLAGS)' crafty
-
 
194
crafty-make:
183
crafty-make:
195
	@$(MAKE) opt='$(opt)' CXFLAGS='$(CXFLAGS)' CFLAGS='$(CFLAGS)' crafty
184
	@$(MAKE) opt='$(opt)' CFLAGS='$(CFLAGS)' crafty
196
 
185
 
197
crafty.o: *.c *.h
186
crafty.o: *.c *.h
198
 
187
 
199
crafty:	$(objects) egtb.o
188
crafty:	$(objects)
200
	$(CC) $(LDFLAGS) -o crafty $(objects) egtb.o -lm  $(LIBS)
189
	$(CC) $(LDFLAGS) -g -o crafty $(objects) -lm  $(LIBS)
201
 
190
 
202
evaluate.o: evaluate.h
191
evaluate.o: evaluate.h
203
 
192
 
204
egtb.o: egtb.cpp
-
 
205
	$(CXX) -c $(CXFLAGS) $(opts) egtb.cpp
-
 
206
clean:
193
clean:
207
	-rm -f *.o crafty
194
	-rm -f *.o crafty
208
 
195
 
209
$(objects): chess.h data.h
196
$(objects): chess.h data.h
210
 
197