-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (41 loc) · 1.64 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
CC=gcc
CFLAGS_release = -O3 -fomit-frame-pointer -g
CFLAGS_debug = -O0 -g -fno-omit-frame-pointer
BUILD=release
ARCH=native
USE_AVX=avx2
N_BENCHMARKS=5
ifeq ($(USE_AVX), avx2)
AVX_FLAGS=-mavx2 -mno-avx512f
endif
ifeq ($(USE_AVX), avx512)
AVX_FLAGS=-mavx2 -mavx512f
endif
CFLAGS=-Wall -std=c17 ${CFLAGS_${BUILD}} -mbmi2 ${AVX_FLAGS} -march=${ARCH} -fopenmp -I ./src/inc -Lbuild
BUILD_DIR=build
$(shell mkdir -p ${BUILD_DIR})
SRC_DIR=src
.PHONY: all
all: pad statistics checker
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
pad: $(BUILD_DIR)/solver.o $(BUILD_DIR)/board.o $(BUILD_DIR)/piece.o $(BUILD_DIR)/problem.o $(BUILD_DIR)/utils.o $(BUILD_DIR)/printing.o $(BUILD_DIR)/pad.o
$(CC) $(CFLAGS) -o $@ $^
statistics: $(BUILD_DIR)/solver.o $(BUILD_DIR)/board.o $(BUILD_DIR)/piece.o $(BUILD_DIR)/problem.o $(BUILD_DIR)/utils.o $(BUILD_DIR)/printing.o $(BUILD_DIR)/statistics.o
$(CC) $(CFLAGS) -o $@ $^
checker: $(BUILD_DIR)/solver.o $(BUILD_DIR)/board.o $(BUILD_DIR)/piece.o $(BUILD_DIR)/problem.o $(BUILD_DIR)/utils.o $(BUILD_DIR)/printing.o $(BUILD_DIR)/checker.o
$(CC) $(CFLAGS) -o $@ $^
.PHONY: benchmark
benchmark: statistics
@echo "Statistics"
@bash -c "TIMEFORMAT='real:%Es user:%Us sys:%Ss'; for i in {1..${N_BENCHMARKS}}; do time ./statistics noprint; done"
@echo "Checker"
@bash -c "TIMEFORMAT='real:%Es user:%Us sys:%Ss'; for i in {1..${N_BENCHMARKS}}; do time ./checker > /dev/null; done"
.PHONY: test
test: statistics
@echo "Expect:"
@echo 8780a56f0a41807851df53042d245a92b36fde872d9970ff270172f1e1c2f821
@bash -c ./statistics | sort | sha256sum
.PHONY: clean
clean:
rm -f *.o build/* pad statistics checker analyze_pieces