-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (85 loc) · 2.3 KB
/
Copy pathMakefile
File metadata and controls
102 lines (85 loc) · 2.3 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
ifeq ($(OS),Windows_NT)
EXE := Obsidian.exe
else
EXE := Obsidian
endif
DEFAULT_NET = net89perm.bin
ifndef EVALFILE
EVALFILE = $(DEFAULT_NET)
DOWNLOAD_NET = true
endif
M64 = -m64 -mpopcnt
MSSE2 = $(M64) -msse -msse2
MSSSE3 = $(MSSE2) -mssse3
MAVX2 = $(MSSSE3) -msse4.1 -mbmi -mfma -mavx2
MAVX512 = $(MAVX2) -mavx512f -mavx512bw
FILES = $(wildcard src/*.cpp) src/fathom/src/tbprobe.c
OBJS = $(FILES:.cpp=.o)
OBJS := $(OBJS:.c=.o)
OPTIMIZE = -O3 -fno-stack-protector -fno-math-errno -funroll-loops -fno-exceptions -flto -flto-partition=one
FLAGS = -s -pthread -std=c++17 -DNDEBUG -DEvalFile=\"$(EVALFILE)\" $(OPTIMIZE)
ifeq ($(OS),Windows_NT)
FLAGS += -static
endif
ifeq ($(build),)
build = native
endif
ifeq ($(build), native)
FLAGS += -march=native
else ifeq ($(findstring sse2, $(build)), sse2)
FLAGS += $(MSSE2)
else ifeq ($(findstring ssse3, $(build)), ssse3)
FLAGS += $(MSSSE3)
else ifeq ($(findstring avx2, $(build)), avx2)
FLAGS += $(MAVX2)
else ifeq ($(findstring avx512, $(build)), avx512)
FLAGS += $(MAVX512)
endif
ifeq ($(build), native)
PROPS = $(shell echo | $(CC) -march=native -E -dM -)
ifneq ($(findstring __BMI2__, $(PROPS)),)
ifeq ($(findstring __znver1, $(PROPS)),)
ifeq ($(findstring __znver2, $(PROPS)),)
FLAGS += -DUSE_PEXT
else ifeq ($(shell uname), Linux)
ifneq ($(findstring AMD EPYC 7B, $(shell lscpu)),)
FLAGS += -DUSE_PEXT
endif
endif
endif
endif
else ifeq ($(findstring avx512, $(build)), avx512)
FLAGS += -DUSE_PEXT -mbmi2
else ifeq ($(findstring pext, $(build)), pext)
FLAGS += -DUSE_PEXT -mbmi2
endif
%.o: %.cpp
g++ $(FLAGS) -c $< -o $@
%.o: %.c
gcc $(FLAGS) -c $< -o $@
make: download-net $(FILES)
g++ $(FLAGS) $(FILES) -o $(EXE) -fprofile-generate="obs_pgo"
ifeq ($(OS),Windows_NT)
$(EXE) bench
else
./$(EXE) bench
endif
g++ $(FLAGS) $(FILES) -o $(EXE) -fprofile-use="obs_pgo"
ifeq ($(OS),Windows_NT)
powershell.exe -Command "Remove-Item -Recurse -Force obs_pgo"
else
rm -rf obs_pgo
endif
nopgo: download-net $(OBJS)
g++ $(FLAGS) $(OBJS) -o $(EXE)
clean:
rm -f $(OBJS)
download-net:
ifdef DOWNLOAD_NET
@if test -f "$(EVALFILE)"; then \
echo "File $(EVALFILE) already exists, skipping download."; \
else \
echo Downloading net; \
curl -sOL https://github.com/gab8192/Obsidian-nets/releases/download/nets/$(EVALFILE); \
fi
endif