add perf target

This commit is contained in:
2024-06-23 19:16:05 +02:00
parent 84b6c41107
commit a7311a546f

View File

@@ -19,7 +19,7 @@ ifeq ($(CC),cc)
CC = gcc CC = gcc
endif endif
ifeq ($(BUILD),) ifeq ($(BUILD),)
BUILD = release BUILD = perf
endif endif
BEAR := bear BEAR := bear
@@ -49,7 +49,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 -lncurses -ltinfo) LIBS := $(strip -l$(LIB))
DEP_FN := $(SRC_FN) DEP_FN := $(SRC_FN)
DEP := $(addprefix $(DEPDIR)/,$(DEP_FN:.c=.d)) DEP := $(addprefix $(DEPDIR)/,$(DEP_FN:.c=.d))
@@ -92,7 +92,7 @@ CPPFLAGS := -I$(BRINCDIR) -I$(INCDIR) -DVERSION=\"$(VERSION)\"
ifeq ($(BUILD),release) ifeq ($(BUILD),release)
CPPFLAGS += -DNDEBUG # assert (unused) CPPFLAGS += -DNDEBUG # assert (unused)
else ifeq ($(BUILD),dev) else # ifeq ($(BUILD),dev)
CPPFLAGS += -DWARN_ON # brlib bug.h CPPFLAGS += -DWARN_ON # brlib bug.h
CPPFLAGS += -DBUG_ON # brlib bug.h CPPFLAGS += -DBUG_ON # brlib bug.h
@@ -127,18 +127,27 @@ CFLAGS += -Wall
CFLAGS += -Wextra CFLAGS += -Wextra
CFLAGS += -Wshadow CFLAGS += -Wshadow
CFLAGS += -Wmissing-declarations CFLAGS += -Wmissing-declarations
CFLAGS += -march=native
### dev OR release ### dev OR release
ifeq ($(BUILD),release) ifeq ($(BUILD),release)
CFLAGS += -O3 CFLAGS += -O3
CFLAGS += -g
CFLAGS += -march=native CFLAGS += -ginline-points # inlined funcs debug info
CFLAGS += -flto
CFLAGS += -funroll-loops CFLAGS += -funroll-loops
CFLAGS += -flto
else ifeq ($(BUILD),dev) else ifeq ($(BUILD),dev)
CFLAGS += -Og CFLAGS += -Og
CFLAGS += -g # symbols (gdb, perf, etc.) CFLAGS += -g # symbols (gdb, perf, etc.)
CFLAGS += -ginline-points # inlined funcs debug info CFLAGS += -ginline-points # inlined funcs debug info
#CFLAGS += -pg # gprof
# Next one may be useful for valgrind (when invalid instructions)
#CFLAGS += -mno-tbm
else ifeq ($(BUILD),perf)
CFLAGS += -O3
CFLAGS += -g # symbols (gdb, perf, etc.)
CFLAGS += -ginline-points # inlined funcs debug info
CFLAGS += -funroll-loops
# for gprof # for gprof
#CFLAGS += -pg #CFLAGS += -pg
# Next one may be useful for valgrind (when invalid instructions) # Next one may be useful for valgrind (when invalid instructions)
@@ -198,7 +207,7 @@ $(sort all $(MAKECMDGOALS)):
else else
##################################### General targets ##################################### General targets
.PHONY: all release dev compile clean cleanall .PHONY: all release dev perf compile clean cleanall
all: testing $(TARGET) all: testing $(TARGET)
@@ -208,6 +217,9 @@ release:
dev: dev:
$(MAKE) BUILD=dev clean all $(MAKE) BUILD=dev clean all
perf:
$(MAKE) BUILD=perf clean all
compile: brlib objs compile: brlib objs
libs: brlib libs: brlib
@@ -337,7 +349,7 @@ cleanasmcpp:
%.s: %.c %.s: %.c
@echo "generating $@ (asm)." @echo "generating $@ (asm)."
@$(CC) -S -fverbose-asm $(CPPFLAGS) $(CFLAGS) $< -o $@ $(CC) -S -fverbose-asm $(CPPFLAGS) $(CFLAGS) $< -o $@
##################################### LSP (ccls) ##################################### LSP (ccls)
.PHONY: ccls .PHONY: ccls
@@ -380,11 +392,11 @@ TEST += movedo-test perft-test tt-test
PIECE_OBJS := piece.o PIECE_OBJS := piece.o
FEN_OBJS := $(PIECE_OBJS) fen.o position.o bitboard.o board.o \ FEN_OBJS := $(PIECE_OBJS) fen.o position.o bitboard.o board.o \
hyperbola-quintessence.o attack.o hash.o init.o hyperbola-quintessence.o attack.o hash.o init.o misc.o
BB_OBJS := $(FEN_OBJS) BB_OBJS := $(FEN_OBJS)
MOVEGEN_OBJS := $(BB_OBJS) move.o move-gen.o MOVEGEN_OBJS := $(BB_OBJS) move.o move-gen.o
ATTACK_OBJS := $(MOVEGEN_OBJS) ATTACK_OBJS := $(MOVEGEN_OBJS)
MOVEDO_OBJS := $(ATTACK_OBJS) move-do.o misc.o MOVEDO_OBJS := $(ATTACK_OBJS) move-do.o
PERFT_OBJS := $(MOVEDO_OBJS) search.o PERFT_OBJS := $(MOVEDO_OBJS) search.o
TT_OBJS := $(MOVEDO_OBJS) TT_OBJS := $(MOVEDO_OBJS)