cleanup
This commit is contained in:
51
Makefile
51
Makefile
@@ -41,7 +41,7 @@ OBJ := $(addprefix $(OBJDIR)/,$(SRC_FN:.c=.o))
|
|||||||
TSTSRC := $(wildcard $(TSTDIR)/*.c)
|
TSTSRC := $(wildcard $(TSTDIR)/*.c)
|
||||||
|
|
||||||
LIB := br_$(shell uname -m) # library name
|
LIB := br_$(shell uname -m) # library name
|
||||||
LIBS := $(strip -l$(LIB) -lreadline)
|
LIBS := $(strip -l$(LIB) -lreadline -lncurses -ltinfo)
|
||||||
|
|
||||||
DEP_FN := $(SRC_FN)
|
DEP_FN := $(SRC_FN)
|
||||||
DEP := $(addprefix $(DEPDIR)/,$(DEP_FN:.c=.d))
|
DEP := $(addprefix $(DEPDIR)/,$(DEP_FN:.c=.d))
|
||||||
@@ -52,8 +52,38 @@ TARGET := $(addprefix $(BINDIR)/,$(TARGET_FN))
|
|||||||
ASMFILES := $(SRC:.c=.s) $(TSTSRC:.c=.s)
|
ASMFILES := $(SRC:.c=.s) $(TSTSRC:.c=.s)
|
||||||
CPPFILES := $(SRC:.c=.i) $(TSTSRC:.c=.i)
|
CPPFILES := $(SRC:.c=.i) $(TSTSRC:.c=.i)
|
||||||
|
|
||||||
|
##################################### set a version string
|
||||||
|
# inspired from:
|
||||||
|
# https://eugene-babichenko.github.io/blog/2019/09/28/nightly-versions-makefiles/
|
||||||
|
|
||||||
|
# default empty version
|
||||||
|
#VERSION :=
|
||||||
|
|
||||||
|
# last commit and date
|
||||||
|
COMMIT := $(shell git rev-parse --short HEAD)
|
||||||
|
DATE := $(shell git log -1 --format=%cd --date=format:"%Y%m%d")
|
||||||
|
|
||||||
|
# get last commit w/ tag & associated tag, if any
|
||||||
|
TAG_COMM := $(shell git rev-list --abbrev-commit --tags --max-count=1)
|
||||||
|
ifneq ($(TAG_COMMIT),)
|
||||||
|
TAG := $(shell git describe --abbrev=0 --tags ${TG_COMM} 2>/dev/null || true)
|
||||||
|
VERSION := $(TAG:v%=%)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# if no version, use last commit and date.
|
||||||
|
# else, if last commit != last tag commit, add commit and date to version number
|
||||||
|
ifeq ($(VERSION),)
|
||||||
|
VERSION := build-$(COMMIT)-$(DATE)
|
||||||
|
else ifneq ($(COMMIT), $(TAG_COMMIT))
|
||||||
|
VERSION := $(VERSION)-next-$(COMMIT)-$(DATE)
|
||||||
|
endif
|
||||||
|
# if uncommited changes, add "dirty" indicator
|
||||||
|
ifneq ($(shell git status --porcelain),)
|
||||||
|
VERSION := $(VERSION)-dirty
|
||||||
|
endif
|
||||||
|
|
||||||
##################################### pre-processor flags
|
##################################### pre-processor flags
|
||||||
CPPFLAGS := -I$(BRINCDIR) -I$(INCDIR)
|
CPPFLAGS := -I$(BRINCDIR) -I$(INCDIR) -DVERSION=\"$(VERSION)\"
|
||||||
|
|
||||||
CPPFLAGS += -DNDEBUG # assert (unused)
|
CPPFLAGS += -DNDEBUG # assert (unused)
|
||||||
CPPFLAGS += -DWARN_ON # brlib bug.h
|
CPPFLAGS += -DWARN_ON # brlib bug.h
|
||||||
@@ -319,7 +349,7 @@ $(CCLSROOT):
|
|||||||
# maybe run cleanobj cleanlibobj in commands ?
|
# maybe run cleanobj cleanlibobj in commands ?
|
||||||
$(CCLSFILE): cleanobj cleanbrlib libs | $(CCLSROOT)
|
$(CCLSFILE): cleanobj cleanbrlib libs | $(CCLSROOT)
|
||||||
@echo "Generating ccls compile commands file ($@)."
|
@echo "Generating ccls compile commands file ($@)."
|
||||||
@$(BEAR) -- $(MAKE) testing
|
@$(BEAR) -- $(MAKE)
|
||||||
|
|
||||||
##################################### valgrind (mem check)
|
##################################### valgrind (mem check)
|
||||||
.PHONY: memcheck
|
.PHONY: memcheck
|
||||||
@@ -404,12 +434,13 @@ bin/tt-test: test/tt-test.c test/common-test.h $(TT_OBJS)
|
|||||||
##################################### Makefile debug
|
##################################### Makefile debug
|
||||||
.PHONY: showflags wft
|
.PHONY: showflags wft
|
||||||
|
|
||||||
showflags:
|
info:
|
||||||
@echo CFLAGS: "$(CFLAGS)"
|
@printf "CFLAGS: +%s+\n" "$(CFLAGS)"
|
||||||
@echo CPPFLAGS: $(CPPFLAGS)
|
@printf "CPPFLAGS: +%s+\n" "$(CPPFLAGS)"
|
||||||
@echo DEPFLAGS: $(DEPFLAGS)
|
@printf "DEPFLAGS: +%s+\n" "$(DEPFLAGS)"
|
||||||
@echo LDFLAGS: $(LDFLAGS)
|
@printf "LDFLAGS: +%s+\n" "$(LDFLAGS)"
|
||||||
@echo DEPFLAGS: $(DEPFLAGS)
|
@printf "DEPFLAGS: +%s+\n" "$(DEPFLAGS)"
|
||||||
|
@printf "VERSION: +%s+\n" "$(VERSION)"
|
||||||
|
|
||||||
wtf:
|
wtf:
|
||||||
@printf "BRLIBDIR=%s\n" "$(BRLIBDIR)"
|
@printf "BRLIBDIR=%s\n" "$(BRLIBDIR)"
|
||||||
@@ -422,7 +453,7 @@ wtf:
|
|||||||
@#echo LIBSRC=$(LIBSRC)
|
@#echo LIBSRC=$(LIBSRC)
|
||||||
|
|
||||||
zob:
|
zob:
|
||||||
$(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $< $(LIBS) src/util.c -o util
|
@#$(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $< $(LIBS) src/util.c -o util
|
||||||
|
|
||||||
##################################### End of multi-targets
|
##################################### End of multi-targets
|
||||||
endif
|
endif
|
||||||
|
@@ -191,7 +191,6 @@ int tt_create(s32 sizemb)
|
|||||||
if (sizemb <= 0)
|
if (sizemb <= 0)
|
||||||
sizemb = HASH_SIZE_DEFAULT;
|
sizemb = HASH_SIZE_DEFAULT;
|
||||||
sizemb = clamp(sizemb, HASH_SIZE_MIN, HASH_SIZE_MAX);
|
sizemb = clamp(sizemb, HASH_SIZE_MIN, HASH_SIZE_MAX);
|
||||||
//printf("-> %'6d ", sizemb);
|
|
||||||
|
|
||||||
bytes = sizemb * 1024ull * 1024ull; /* bytes wanted */
|
bytes = sizemb * 1024ull * 1024ull; /* bytes wanted */
|
||||||
target_nbuckets = bytes / sizeof(bucket_t); /* target buckets */
|
target_nbuckets = bytes / sizeof(bucket_t); /* target buckets */
|
||||||
@@ -199,7 +198,7 @@ int tt_create(s32 sizemb)
|
|||||||
nbits = msb64(target_nbuckets); /* adjust to power of 2 */
|
nbits = msb64(target_nbuckets); /* adjust to power of 2 */
|
||||||
|
|
||||||
if (hash_tt.nbits != nbits) {
|
if (hash_tt.nbits != nbits) {
|
||||||
if (hash_tt.nbits)
|
if (hash_tt.keys)
|
||||||
tt_delete();
|
tt_delete();
|
||||||
|
|
||||||
hash_tt.nbits = nbits;
|
hash_tt.nbits = nbits;
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
#define ENTRIES_PER_BUCKET 4 /* buckets per hash table entry */
|
#define ENTRIES_PER_BUCKET 4 /* buckets per hash table entry */
|
||||||
|
|
||||||
#define HASH_SIZE_DEFAULT 32 /* default: 32Mb */
|
#define HASH_SIZE_DEFAULT 32 /* default: 32Mb */
|
||||||
#define HASH_SIZE_MIN 4
|
#define HASH_SIZE_MIN 1
|
||||||
#define HASH_SIZE_MAX 32768 /* 32Gb */
|
#define HASH_SIZE_MAX 32768 /* 32Gb */
|
||||||
|
|
||||||
#define TT_MISS NULL
|
#define TT_MISS NULL
|
||||||
|
@@ -70,7 +70,7 @@ u64 perft(pos_t *pos, int depth, int ply, bool output)
|
|||||||
movelist_t movelist2;
|
movelist_t movelist2;
|
||||||
pos_set_checkers_pinners_blockers(pos);
|
pos_set_checkers_pinners_blockers(pos);
|
||||||
subnodes = pos_legal(pos, pos_gen_pseudo(pos, &movelist2))->nmoves;
|
subnodes = pos_legal(pos, pos_gen_pseudo(pos, &movelist2))->nmoves;
|
||||||
} else if (ply >= 4) {
|
} else if (ply >= 3) {
|
||||||
hentry_t *entry = tt_probe_perft(pos->key, depth);
|
hentry_t *entry = tt_probe_perft(pos->key, depth);
|
||||||
if (entry != TT_MISS) {
|
if (entry != TT_MISS) {
|
||||||
subnodes = HASH_PERFT_VAL(entry->data);
|
subnodes = HASH_PERFT_VAL(entry->data);
|
||||||
|
@@ -43,6 +43,31 @@ struct fentest {
|
|||||||
* },
|
* },
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* { __LINE__, MOVEGEN | MOVEDO | PERFT,
|
||||||
|
* "from https://talkchess.com/viewtopic.php?t=74153",
|
||||||
|
* "8/p7/8/1P6/K1k3p1/6P1/7P/8 w - - 0 1", // Perft(8) == 8,103,790
|
||||||
|
* },
|
||||||
|
* 8/5p2/8/2k3P1/p3K3/8/1P6/8 b - - // Perft(8) == 64,451,405
|
||||||
|
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* { __LINE__, MOVEGEN | MOVEDO | PERFT,
|
||||||
|
* "from https://talkchess.com/viewtopic.php?t=74153",
|
||||||
|
* "n1n5/PPPk4/8/8/8/8/4Kppp/5N1N b - - 0 1" // Perft(6) == 71,179,139
|
||||||
|
* },
|
||||||
|
* { __LINE__, MOVEGEN | MOVEDO | PERFT,
|
||||||
|
* "from https://talkchess.com/viewtopic.php?t=74153",
|
||||||
|
* "r3k2r/p6p/8/B7/1pp1p3/3b4/P6P/R3K2R w KQkq - 0 1" // Perft(6) == 77,054,993
|
||||||
|
* },
|
||||||
|
*/
|
||||||
|
{ __LINE__, FEN | MOVEGEN | MOVEDO | PERFT,
|
||||||
|
"from https://www.talkchess.com/forum/viewtopic.php?t=42463",
|
||||||
|
"rnbqkb1r/pp1p1ppp/2p5/4P3/2B5/8/PPP1NnPP/RNBQK2R w KQkq - 0 6"
|
||||||
|
},
|
||||||
|
/*
|
||||||
|
r3k2r/pb3p2/5npp/n2p4/1p1PPB2/6P1/P2N1PBP/R3K2R w KQkq - // Perft(5) == 29,179,893
|
||||||
|
*/
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* DO NOT DELETE NEXT LINE - sentinel entry for temp tests above. *
|
* DO NOT DELETE NEXT LINE - sentinel entry for temp tests above. *
|
||||||
* ignored if first array entry. *
|
* ignored if first array entry. *
|
||||||
@@ -249,12 +274,16 @@ struct fentest {
|
|||||||
"",
|
"",
|
||||||
"6k1/6pp/R2p4/p1p5/8/1P1r3P/6P1/6K1 b - - 3 3"
|
"6k1/6pp/R2p4/p1p5/8/1P1r3P/6P1/6K1 b - - 3 3"
|
||||||
},
|
},
|
||||||
|
{ __LINE__, FEN | MOVEGEN | MOVEDO | PERFT,
|
||||||
|
"from https://www.talkchess.com/forum/viewtopic.php?t=42463",
|
||||||
|
"rnbqkb1r/pp1p1ppp/2p5/4P3/2B5/8/PPP1NnPP/RNBQK2R w KQkq - 0 6"
|
||||||
|
},
|
||||||
|
|
||||||
// some of tests below are from:
|
// some of tests below are from:
|
||||||
// - Rodent IV
|
// - Rodent IV
|
||||||
// - https://www.chessprogramming.net/perfect-perft/
|
// - https://www.chessprogramming.net/perfect-perft/
|
||||||
{ __LINE__, FEN | MOVEGEN | MOVEDO | PERFT,
|
{ __LINE__, FEN | MOVEGEN | MOVEDO | PERFT,
|
||||||
"",
|
"\"kiwipete\"",
|
||||||
"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1"
|
"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1"
|
||||||
},
|
},
|
||||||
{ __LINE__, FEN | MOVEGEN | MOVEDO | PERFT,
|
{ __LINE__, FEN | MOVEGEN | MOVEDO | PERFT,
|
||||||
|
@@ -277,7 +277,7 @@ int main(int ac, char**av)
|
|||||||
movelist_t fishmoves;
|
movelist_t fishmoves;
|
||||||
FILE *outfd = NULL;
|
FILE *outfd = NULL;
|
||||||
s64 ms, lps;
|
s64 ms, lps;
|
||||||
int opt, depth = 6, run = 3, tt = 32, newtt = 32;
|
int opt, depth = 6, run = 3, tt, newtt = HASH_SIZE_DEFAULT;
|
||||||
struct {
|
struct {
|
||||||
s64 count, ms;
|
s64 count, ms;
|
||||||
s64 minlps, maxlps;
|
s64 minlps, maxlps;
|
||||||
@@ -321,9 +321,12 @@ int main(int ac, char**av)
|
|||||||
}
|
}
|
||||||
|
|
||||||
init_all();
|
init_all();
|
||||||
if (newtt != 32 && newtt > 1) {
|
tt = hash_tt.mb;
|
||||||
printf("changing TT size from %d to %d\n", tt, newtt);
|
|
||||||
|
if (run & 1 && newtt != tt) {
|
||||||
tt_create(newtt);
|
tt_create(newtt);
|
||||||
|
|
||||||
|
printf("changing TT size from %d to %d\n", tt, newtt);
|
||||||
tt = newtt;
|
tt = newtt;
|
||||||
}
|
}
|
||||||
printf("%s: depth:%d tt_size:%d run:%x SF:%s\n",
|
printf("%s: depth:%d tt_size:%d run:%x SF:%s\n",
|
||||||
@@ -334,8 +337,6 @@ int main(int ac, char**av)
|
|||||||
tt_info();
|
tt_info();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
printf("move_t size:%lu\n", sizeof(move_t));
|
|
||||||
|
|
||||||
if (sf_run)
|
if (sf_run)
|
||||||
outfd = open_stockfish();
|
outfd = open_stockfish();
|
||||||
|
|
||||||
@@ -346,11 +347,10 @@ int main(int ac, char**av)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
curtest++;
|
curtest++;
|
||||||
printf("test:%d line:%d", curtest, cur_line());
|
printf("test:%d line:%d fen:%s\n", curtest, cur_line(), fen);
|
||||||
if (comment)
|
if (comment)
|
||||||
printf(" comment:%s\n",
|
printf("\t\"%s\"\n",
|
||||||
*cur_comment()? cur_comment(): "no test desc");
|
*cur_comment()? cur_comment(): "no test desc");
|
||||||
printf("\t%s\n", fen);
|
|
||||||
|
|
||||||
tt_clear();
|
tt_clear();
|
||||||
|
|
||||||
@@ -432,7 +432,7 @@ int main(int ac, char**av)
|
|||||||
if (sf_run) {
|
if (sf_run) {
|
||||||
if (!res[2].ms)
|
if (!res[2].ms)
|
||||||
res[2].ms = 1;
|
res[2].ms = 1;
|
||||||
printf("total Stockfish : perft:%'lums ms:%'lums lps:%'lu min:%'lu max:%'lu "
|
printf("total Stockfish : perft:%'lu ms:%'lu lps:%'lu min:%'lu max:%'lu "
|
||||||
"(skipped %d/%d)\n",
|
"(skipped %d/%d)\n",
|
||||||
res[2].count, res[2].ms,
|
res[2].count, res[2].ms,
|
||||||
res[2].count * 1000l / res[2].ms,
|
res[2].count * 1000l / res[2].ms,
|
||||||
@@ -442,7 +442,7 @@ int main(int ac, char**av)
|
|||||||
if (run & 1) {
|
if (run & 1) {
|
||||||
if (!res[0].ms)
|
if (!res[0].ms)
|
||||||
res[0].ms = 1;
|
res[0].ms = 1;
|
||||||
printf("total perft : perft:%'lums ms:%'lums lps:%'lu min:%'lu max:%'lu "
|
printf("total perft : perft:%'lu ms:%'lu lps:%'lu min:%'lu max:%'lu "
|
||||||
"(skipped %d/%d)\n",
|
"(skipped %d/%d)\n",
|
||||||
res[0].count, res[0].ms,
|
res[0].count, res[0].ms,
|
||||||
res[0].count * 1000l / res[0].ms,
|
res[0].count * 1000l / res[0].ms,
|
||||||
@@ -452,7 +452,7 @@ int main(int ac, char**av)
|
|||||||
if (run & 2) {
|
if (run & 2) {
|
||||||
if (!res[1].ms)
|
if (!res[1].ms)
|
||||||
res[1].ms = 1;
|
res[1].ms = 1;
|
||||||
printf("total perft_alt : perft:%'lums ms:%'lums lps:%'lu min:%'lu max:%'lu "
|
printf("total perft_alt : perft:%'lu ms:%'lu lps:%'lu min:%'lu max:%'lu "
|
||||||
"(skipped %d/%d)\n",
|
"(skipped %d/%d)\n",
|
||||||
res[1].count, res[1].ms,
|
res[1].count, res[1].ms,
|
||||||
res[1].count * 1000l / res[1].ms,
|
res[1].count * 1000l / res[1].ms,
|
||||||
|
Reference in New Issue
Block a user