Rev 110 | Details | Compare with Previous | 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 | # -DLOGDIR Path to the directory where Crafty puts the log.nnn and |
||
| 34 | # game.nnn files. |
||
| 35 | # -DNODES This enables the sn=x command. Crafty will search until |
||
| 36 | # exactly X nodes have been searched, then the search |
||
| 37 | # terminates as if time ran out. |
||
| 38 | # -DPOSITIONS Causes Crafty to emit FEN strings, one per book line, as |
||
| 39 | # it creates a book. I use this to create positions to use |
||
| 40 | # for cluster testing. |
||
| 41 | # -DRCDIR Path to the directory where we look for the .craftyrc or |
||
| 42 | # crafty.rc (windows) file. |
||
| 43 | # -DSKILL Enables the "skill" command which allows you to arbitrarily |
||
| 44 | # lower Crafty's playing skill so it does not seem so |
||
| 45 | # invincible to non-GM-level players. |
||
| 154 | pmbaty | 46 | # -DSYZYGY This enables syzygy endgame tables (both WDL and DTC) |
| 110 | pmbaty | 47 | # -DTBDIR Path to the directory where the endgame tablebase files |
| 48 | # are found. default = "./TB" |
||
| 49 | # -DTEST Displays evaluation table after each move (in the logfile) |
||
| 50 | # -DTRACE This enables the "trace" command so that the search tree |
||
| 51 | # can be dumped while running. |
||
| 52 | # -DUNIX This identifies the target O/S as being Unix-based, if this |
||
| 53 | # option is omitted, windows is assumed. |
||
| 154 | pmbaty | 54 | # |
| 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 | # |
||
| 110 | pmbaty | 62 | default: |
| 63 | $(MAKE) -j unix-clang |
||
| 64 | help: |
||
| 65 | @echo "You must specify the system which you want to compile for:" |
||
| 66 | @echo "" |
||
| 154 | pmbaty | 67 | @echo "make unix-clang Unix w/clang compiler (MacOS usually)" |
| 110 | pmbaty | 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 | |||
| 154 | pmbaty | 75 | |
| 110 | pmbaty | 76 | quick: |
| 77 | $(MAKE) target=UNIX \ |
||
| 154 | pmbaty | 78 | CC=clang \ |
| 79 | opt='-DSYZYGY -DTEST -DTRACE -DCPUS=4' \ |
||
| 80 | CFLAGS='-mpopcnt -Wall -Wno-array-bounds -pipe -O3' \ |
||
| 110 | pmbaty | 81 | LDFLAGS='$(LDFLAGS) -lstdc++' \ |
| 82 | crafty-make |
||
| 83 | |||
| 84 | unix-gcc: |
||
| 85 | $(MAKE) -j target=UNIX \ |
||
| 154 | pmbaty | 86 | CC=gcc \ |
| 87 | opt='-DSYZYGY -DTEST -DCPUS=4' \ |
||
| 110 | pmbaty | 88 | CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-use \ |
| 154 | pmbaty | 89 | -mpopcnt -fprofile-correction -pthread' \ |
| 110 | pmbaty | 90 | LDFLAGS='$(LDFLAGS) -fprofile-use -pthread -lstdc++' \ |
| 91 | crafty-make |
||
| 92 | |||
| 93 | unix-gcc-profile: |
||
| 94 | $(MAKE) -j target=UNIX \ |
||
| 154 | pmbaty | 95 | CC=gcc \ |
| 96 | opt='-DSYZYGY -DTEST -DCPUS=4' \ |
||
| 110 | pmbaty | 97 | CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-arcs \ |
| 154 | pmbaty | 98 | -mpopcnt -pthread' \ |
| 110 | pmbaty | 99 | LDFLAGS='$(LDFLAGS) -fprofile-arcs -pthread -lstdc++ ' \ |
| 100 | crafty-make |
||
| 101 | |||
| 102 | unix-clang: |
||
| 103 | @/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata merge -output=crafty.profdata *.profraw |
||
| 104 | $(MAKE) -j target=UNIX \ |
||
| 154 | pmbaty | 105 | CC=clang \ |
| 106 | opt='-DSYZYGY -DTEST -DCPUS=4' \ |
||
| 110 | pmbaty | 107 | CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \ |
| 154 | pmbaty | 108 | -mpopcnt -fprofile-instr-use=crafty.profdata' \ |
| 110 | pmbaty | 109 | LDFLAGS='$(LDFLAGS) -fprofile-use -lstdc++' \ |
| 110 | crafty-make |
||
| 111 | |||
| 112 | unix-clang-profile: |
||
| 113 | $(MAKE) -j target=UNIX \ |
||
| 154 | pmbaty | 114 | CC=clang \ |
| 115 | opt='-DSYZYGY -DTEST -DCPUS=4' \ |
||
| 110 | pmbaty | 116 | CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \ |
| 154 | pmbaty | 117 | -mpopcnt -fprofile-instr-generate' \ |
| 110 | pmbaty | 118 | LDFLAGS='$(LDFLAGS) -fprofile-instr-generate -lstdc++ ' \ |
| 119 | crafty-make |
||
| 120 | |||
| 121 | unix-icc: |
||
| 122 | $(MAKE) -j target=UNIX \ |
||
| 154 | pmbaty | 123 | CC=icc \ |
| 124 | opt='-DSYZYGY -DTEST -DCPUS=4' \ |
||
| 110 | pmbaty | 125 | CFLAGS='-Wall -w -O2 -prof_use -prof_dir ./prof -fno-alias \ |
| 154 | pmbaty | 126 | -mpopcnt -pthread' \ |
| 110 | pmbaty | 127 | LDFLAGS='$(LDFLAGS) -pthread -lstdc++' \ |
| 128 | crafty-make |
||
| 129 | |||
| 130 | unix-icc-profile: |
||
| 131 | $(MAKE) -j target=UNIX \ |
||
| 154 | pmbaty | 132 | CC=icc \ |
| 133 | opt='-DSYZYGY -DTEST -DCPUS=4' \ |
||
| 110 | pmbaty | 134 | CFLAGS='-Wall -w -O2 -prof_gen -prof_dir ./prof -fno-alias \ |
| 154 | pmbaty | 135 | -mpopcnt -pthread' \ |
| 110 | pmbaty | 136 | LDFLAGS='$(LDFLAGS) -pthread -lstdc++ ' \ |
| 137 | crafty-make |
||
| 138 | |||
| 139 | profile: |
||
| 140 | @rm -rf *.o |
||
| 141 | @rm -rf log.* |
||
| 142 | @rm -rf game.* |
||
| 143 | @rm -rf prof |
||
| 144 | @rm -rf *.gcda |
||
| 145 | @mkdir prof |
||
| 154 | pmbaty | 146 | @touch *.c *.h |
| 110 | pmbaty | 147 | $(MAKE) -j unix-clang-profile |
| 148 | @echo "#!/bin/csh" > runprof |
||
| 149 | @echo "./crafty <<EOF" >>runprof |
||
| 154 | pmbaty | 150 | @echo "bench" >>runprof |
| 110 | pmbaty | 151 | @echo "mt=0" >>runprof |
| 152 | @echo "quit" >>runprof |
||
| 153 | @echo "EOF" >>runprof |
||
| 154 | @chmod +x runprof |
||
| 155 | @./runprof |
||
| 156 | @rm runprof |
||
| 154 | pmbaty | 157 | @touch *.c *.h |
| 110 | pmbaty | 158 | $(MAKE) -j unix-clang |
| 159 | |||
| 160 | |||
| 161 | # |
||
| 162 | # one of the two following definitions for "objects" should be used. The |
||
| 163 | # default is to compile everything separately. However, if you use the |
||
| 164 | # definition that refers to crafty.o, that will compile using the file crafty.c |
||
| 165 | # which #includes every source file into one large glob. This gives the |
||
| 166 | # compiler max opportunity to inline functions as appropriate. You should try |
||
| 167 | # compiling both ways to see which way produces the fastest code. |
||
| 168 | # |
||
| 169 | |||
| 170 | #objects = main.o iterate.o time.o search.o quiesce.o evaluate.o thread.o \ |
||
| 154 | pmbaty | 171 | repeat.o hash.o next.o history.o movgen.o make.o unmake.o attacks.o \ |
| 172 | see.o tbprobe.o boolean.o utility.o book.o drawn.o epd.o \ |
||
| 173 | epdglue.o init.o input.o autotune.o interrupt.o option.o output.o \ |
||
| 174 | ponder.o resign.o root.o learn.o setboard.o test.o validate.o \ |
||
| 175 | annotate.o analyze.o evtest.o bench.o edit.o data.o |
||
| 110 | pmbaty | 176 | |
| 177 | objects = crafty.o |
||
| 178 | |||
| 179 | # Do not change anything below this line! |
||
| 180 | |||
| 181 | opts = $(opt) -D$(target) |
||
| 182 | |||
| 183 | crafty-make: |
||
| 154 | pmbaty | 184 | @$(MAKE) opt='$(opt)' CFLAGS='$(CFLAGS)' crafty |
| 110 | pmbaty | 185 | |
| 186 | crafty.o: *.c *.h |
||
| 187 | |||
| 154 | pmbaty | 188 | crafty: $(objects) |
| 189 | $(CC) $(LDFLAGS) -g -o crafty $(objects) -lm $(LIBS) |
||
| 110 | pmbaty | 190 | |
| 191 | evaluate.o: evaluate.h |
||
| 192 | |||
| 193 | clean: |
||
| 194 | -rm -f *.o crafty |
||
| 195 | |||
| 196 | $(objects): chess.h data.h |
||
| 197 | |||
| 198 | .c.o: |
||
| 199 | $(CC) $(CFLAGS) $(opts) -c $*.c |
||
| 200 | |||
| 201 | .s.o: |
||
| 202 | $(AS) $(AFLAGS) -o $*.o $*.s |