Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
110 | 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 | # WARNING: know what you are doing before using this. If |
||
14 | # you test multiple copies of Crafty (each copy using just |
||
15 | # one thread) you can have bogus results because if compiled |
||
16 | # with -DAFFINITY, even a single-cpu execution will lock led |
||
17 | # itself onto processor zero (since it only has thread #0) |
||
18 | # which is probably NOT what you want. This is intended to |
||
19 | # be used when you run Crafty using a complete dedicated |
||
20 | # machine with nothing else running at the same time. |
||
21 | # -DBOOKDIR Path to the directory containing the book binary files. |
||
22 | # The default for all such path values is "." if you don't |
||
23 | # specify a path with this macro definition. |
||
24 | # -DCPUS=n Defines the maximum number of CPUS Crafty will be able |
||
25 | # to use in a SMP system. Note that this is the max you |
||
26 | # will be able to use. You need to use the smpmt=n command |
||
27 | # to make crafty use more than the default 1 process. |
||
28 | # -DDEBUG This is used for testing changes. Enabling this option |
||
29 | # greatly slows Crafty down, but every time a move is made, |
||
30 | # the corresponding position is checked to make sure all of |
||
31 | # the bitboards are set correctly. |
||
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 |
||
38 | # game.nnn files. |
||
39 | # -DNODES This enables the sn=x command. Crafty will search until |
||
40 | # exactly X nodes have been searched, then the search |
||
41 | # 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 |
||
47 | # it creates a book. I use this to create positions to use |
||
48 | # for cluster testing. |
||
49 | # -DRCDIR Path to the directory where we look for the .craftyrc or |
||
50 | # crafty.rc (windows) file. |
||
51 | # -DSKILL Enables the "skill" command which allows you to arbitrarily |
||
52 | # lower Crafty's playing skill so it does not seem so |
||
53 | # invincible to non-GM-level players. |
||
54 | # -DTBDIR Path to the directory where the endgame tablebase files |
||
55 | # are found. default = "./TB" |
||
56 | # -DTEST Displays evaluation table after each move (in the logfile) |
||
57 | # -DTRACE This enables the "trace" command so that the search tree |
||
58 | # can be dumped while running. |
||
59 | # -DUNIX This identifies the target O/S as being Unix-based, if this |
||
60 | # option is omitted, windows is assumed. |
||
61 | |||
62 | # $(MAKE) -j unix-gcc |
||
63 | default: |
||
64 | $(MAKE) -j unix-clang |
||
65 | help: |
||
66 | @echo "You must specify the system which you want to compile for:" |
||
67 | @echo "" |
||
68 | @echo "make unix-gcc Unix w/gcc compiler" |
||
69 | @echo "make unix-icc Unix w/icc compiler" |
||
70 | @echo "make profile profile-guided-optimizations" |
||
71 | @echo " (edit Makefile to make the profile" |
||
72 | @echo " option use the right compiler)" |
||
73 | @echo "" |
||
74 | |||
75 | quick: |
||
76 | $(MAKE) target=UNIX \ |
||
77 | CC=gcc CXX=g++ \ |
||
78 | opt='-DTEST -DTRACE -DINLINEASM -DPOPCNT -DCPUS=4' \ |
||
79 | CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -pthread' \ |
||
80 | CXFLAGS='-Wall -Wno-array-bounds -pipe -O3 -pthread' \ |
||
81 | LDFLAGS='$(LDFLAGS) -lstdc++' \ |
||
82 | crafty-make |
||
83 | |||
84 | unix-gcc: |
||
85 | $(MAKE) -j target=UNIX \ |
||
86 | CC=gcc CXX=g++ \ |
||
87 | opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \ |
||
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' \ |
||
92 | LDFLAGS='$(LDFLAGS) -fprofile-use -pthread -lstdc++' \ |
||
93 | crafty-make |
||
94 | |||
95 | unix-gcc-profile: |
||
96 | $(MAKE) -j target=UNIX \ |
||
97 | CC=gcc CXX=g++ \ |
||
98 | opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \ |
||
99 | CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-arcs \ |
||
100 | -pthread' \ |
||
101 | CXFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-arcs \ |
||
102 | -pthread' \ |
||
103 | LDFLAGS='$(LDFLAGS) -fprofile-arcs -pthread -lstdc++ ' \ |
||
104 | crafty-make |
||
105 | |||
106 | unix-clang: |
||
107 | @/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata merge -output=crafty.profdata *.profraw |
||
108 | $(MAKE) -j target=UNIX \ |
||
109 | CC=clang CXX=clang++ \ |
||
110 | opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \ |
||
111 | 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' \ |
||
115 | LDFLAGS='$(LDFLAGS) -fprofile-use -lstdc++' \ |
||
116 | crafty-make |
||
117 | |||
118 | unix-clang-profile: |
||
119 | $(MAKE) -j target=UNIX \ |
||
120 | CC=clang CXX=clang++ \ |
||
121 | opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \ |
||
122 | CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \ |
||
123 | -fprofile-instr-generate' \ |
||
124 | CXFLAGS='-Wall -Wno-array-bounds -pipe -O3 \ |
||
125 | -fprofile-instr-generate' \ |
||
126 | LDFLAGS='$(LDFLAGS) -fprofile-instr-generate -lstdc++ ' \ |
||
127 | crafty-make |
||
128 | |||
129 | unix-icc: |
||
130 | $(MAKE) -j target=UNIX \ |
||
131 | CC=icc CXX=icc \ |
||
132 | opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \ |
||
133 | CFLAGS='-Wall -w -O2 -prof_use -prof_dir ./prof -fno-alias \ |
||
134 | -pthread' \ |
||
135 | CXFLAGS='-Wall -w -O2 -prof_use -prof_dir ./prof -pthread' \ |
||
136 | LDFLAGS='$(LDFLAGS) -pthread -lstdc++' \ |
||
137 | crafty-make |
||
138 | |||
139 | unix-icc-profile: |
||
140 | $(MAKE) -j target=UNIX \ |
||
141 | CC=icc CXX=icc \ |
||
142 | opt='-DTEST -DINLINEASM -DPOPCNT -DCPUS=4' \ |
||
143 | CFLAGS='-Wall -w -O2 -prof_gen -prof_dir ./prof -fno-alias \ |
||
144 | -pthread' \ |
||
145 | CXFLAGS='-Wall -w -O2 -prof_gen -prof_dir ./prof -pthread' \ |
||
146 | LDFLAGS='$(LDFLAGS) -pthread -lstdc++ ' \ |
||
147 | crafty-make |
||
148 | |||
149 | profile: |
||
150 | @rm -rf *.o |
||
151 | @rm -rf log.* |
||
152 | @rm -rf game.* |
||
153 | @rm -rf prof |
||
154 | @rm -rf *.gcda |
||
155 | @mkdir prof |
||
156 | @touch *.c *.cpp *.h |
||
157 | $(MAKE) -j unix-clang-profile |
||
158 | @echo "#!/bin/csh" > runprof |
||
159 | @echo "./crafty <<EOF" >>runprof |
||
160 | @echo "pgo -1" >>runprof |
||
161 | @echo "mt=0" >>runprof |
||
162 | @echo "quit" >>runprof |
||
163 | @echo "EOF" >>runprof |
||
164 | @chmod +x runprof |
||
165 | @./runprof |
||
166 | @rm runprof |
||
167 | @touch *.c *.cpp *.h |
||
168 | $(MAKE) -j unix-clang |
||
169 | |||
170 | |||
171 | # |
||
172 | # one of the two following definitions for "objects" should be used. The |
||
173 | # default is to compile everything separately. However, if you use the |
||
174 | # definition that refers to crafty.o, that will compile using the file crafty.c |
||
175 | # which #includes every source file into one large glob. This gives the |
||
176 | # compiler max opportunity to inline functions as appropriate. You should try |
||
177 | # compiling both ways to see which way produces the fastest code. |
||
178 | # |
||
179 | |||
180 | #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 \ |
||
182 | see.o boolean.o utility.o probe.o book.o drawn.o epd.o epdglue.o \ |
||
183 | init.o input.o autotune.o interrupt.o option.o output.o ponder.o \ |
||
184 | resign.o root.o learn.o setboard.o test.o validate.o annotate.o \ |
||
185 | analyze.o evtest.o bench.o edit.o data.o |
||
186 | |||
187 | objects = crafty.o |
||
188 | |||
189 | # Do not change anything below this line! |
||
190 | |||
191 | opts = $(opt) -D$(target) |
||
192 | |||
193 | # @$(MAKE) -j opt='$(opt)' CXFLAGS='$(CXFLAGS)' CFLAGS='$(CFLAGS)' crafty |
||
194 | crafty-make: |
||
195 | @$(MAKE) opt='$(opt)' CXFLAGS='$(CXFLAGS)' CFLAGS='$(CFLAGS)' crafty |
||
196 | |||
197 | crafty.o: *.c *.h |
||
198 | |||
199 | crafty: $(objects) egtb.o |
||
200 | $(CC) $(LDFLAGS) -o crafty $(objects) egtb.o -lm $(LIBS) |
||
201 | |||
202 | evaluate.o: evaluate.h |
||
203 | |||
204 | egtb.o: egtb.cpp |
||
205 | $(CXX) -c $(CXFLAGS) $(opts) egtb.cpp |
||
206 | clean: |
||
207 | -rm -f *.o crafty |
||
208 | |||
209 | $(objects): chess.h data.h |
||
210 | |||
211 | .c.o: |
||
212 | $(CC) $(CFLAGS) $(opts) -c $*.c |
||
213 | |||
214 | .s.o: |
||
215 | $(AS) $(AFLAGS) -o $*.o $*.s |