-
Notifications
You must be signed in to change notification settings - Fork 49
/
Makefile
236 lines (181 loc) · 7.37 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# user can do CXX=g++ make
# It's more fexlible to change from command line
# The make builtin rule states CXX to be g++.
.PHONY: all help clean build-all \
x86 avx avx2 arm \
speed verify \
speed_avx verify_avx \
speed_avx2 verify_avx2 \
speed_avx512bw verify_avx512bw \
speed_avx512vbmi verify_avx512vbmi \
speed_avx512vpopcnt verify_avx512vpopcnt \
speed_arm verify_arm \
speed_aarch64 verify_aarch64 \
speed_rvv verify_rvv
COMPILER=$(notdir $(CXX))
FLAGS=-std=c++17 -O2 -Wall -pedantic -Wextra -Wfatal-errors
FLAGS_INTEL=$(FLAGS) -mpopcnt -fabi-version=6
FLAGS_ARM=$(FLAGS) -mfpu=neon -DHAVE_NEON_INSTRUCTIONS
# It seems that for AArch64 no extra flags are needed (NEON is always available)
FLAGS_AARCH64=$(FLAGS) -DHAVE_NEON_INSTRUCTIONS -DHAVE_AARCH64_ARCHITECTURE
# note: static is needed by Spike emulator
FLAGS_RVV=$(FLAGS) -march=rv64gcv -DHAVE_RVV_INSTRUCTIONS -static
FLAGS_SSE=$(FLAGS_INTEL) -mssse3 -DHAVE_SSE_INSTRUCTIONS
FLAGS_AVX=$(FLAGS_INTEL) -mavx -DHAVE_AVX_INSTRUCTIONS
FLAGS_AVX2=$(FLAGS_INTEL) -mavx2 -DHAVE_AVX2_INSTRUCTIONS
FLAGS_AVX512BW=$(FLAGS_INTEL) -mavx512bw -DHAVE_AVX512BW_INSTRUCTIONS
FLAGS_AVX512VBMI=$(FLAGS_INTEL) -mavx512vbmi -DHAVE_AVX512BW_INSTRUCTIONS -DHAVE_AVX512VBMI_INSTRUCTIONS
FLAGS_AVX512VPOPCNT=$(FLAGS_INTEL) -mavx512bw -mavx512vpopcntdq -DHAVE_AVX512VPOPCNT_INSTRUCTIONS
DEPS=popcnt-*.cpp function_registry.cpp sse_operators.cpp config.h
ALL=speed_$(COMPILER) verify_$(COMPILER)
ALL_AVX=speed_avx_$(COMPILER) verify_avx_$(COMPILER)
ALL_AVX2=speed_avx2_$(COMPILER) verify_avx2_$(COMPILER)
ALL_AVX512BW=speed_avx512bw_$(COMPILER) verify_avx512bw_$(COMPILER)
ALL_AVX512VBMI=speed_avx512vbmi_$(COMPILER) verify_avx512vbmi_$(COMPILER)
ALL_AVX512VPOPCNT=speed_avx512vpopcnt_$(COMPILER) verify_avx512vpopcnt_$(COMPILER)
ALL_ARM=speed_arm_$(COMPILER) verify_arm_$(COMPILER)
ALL_AARCH64=speed_aarch64_$(COMPILER) verify_aarch64_$(COMPILER)
ALL_RVV=speed_rvv_$(COMPILER) verify_rvv_$(COMPILER)
ALL_TARGETS=$(ALL) $(ALL_AVX) $(ALL_AVX2) $(ALL_AVX512) $(ALL_AVX512BW) $(ALL_AVX512VPOPCNT) $(ALL_RVV)
all: $(ALL)
help:
@echo "Intel targets:"
@echo "x86 - makes programs verify & speed (the default target)"
@echo "run - runs benchmark program"
@echo "run_verify - runs verification program"
@echo
@echo "avx - makes programs verify_avx & speed_avx"
@echo "run_avx - runs benchmark program"
@echo "run_verify_avx - runs verification program"
@echo
@echo "avx2 - makes programs verify_avx2 & speed_avx2"
@echo "run_avx2 - runs benchmark program"
@echo "run_verify_avx2 - runs verification program"
@echo
@echo "avx512bw - makes programs verify_avx512bw & speed_avx512bw"
@echo "run_avx512bw - runs benchmark program"
@echo "run_verify_avx512bw - runs verification program"
@echo
@echo "avx512vbmi - makes programs verify_avx512vbmi & speed_avx512vbmi"
@echo "run_avx512vbmi - runs benchmark program"
@echo "run_verify_avx512vbmi - runs verification program"
@echo
@echo "avx512vpopcnt - makes programs verify_avx512vpopcnt & speed_avx512vpopcnt"
@echo "run_avx512vpopcnt - runs benchmark program"
@echo "run_verify_avx512vpopcnt - runs verification program"
@echo
@echo "ARM Neon target:"
@echo "arm - makes programs verify_arm & speed_arm (using Neon instructions)"
@echo "run_arm - runs benchmark program"
@echo "run_verify_arm - runs verification program"
@echo
@echo "RVV target:"
@echo "run_verify_rvv - runs verification program"
x86: $(ALL)
avx: $(ALL_AVX)
avx2: $(ALL_AVX2)
arm: $(ALL_ARM)
aarch64: $(ALL_AARCH64)
avx512bw: $(ALL_AVX512BW)
avx512vbmi: $(ALL_AVX512VBMI)
avx512vpopcnt: $(ALL_AVX512VPOPCNT)
speed_$(COMPILER): $(DEPS) speed.cpp
$(CXX) $(FLAGS_SSE) speed.cpp -o $@
verify_$(COMPILER): $(DEPS) verify.cpp
$(CXX) $(FLAGS_SSE) verify.cpp -o $@
speed_avx_$(COMPILER): $(DEPS) speed.cpp
$(CXX) $(FLAGS_AVX) speed.cpp -o $@
verify_avx_$(COMPILER): $(DEPS) verify.cpp
$(CXX) $(FLAGS_AVX) verify.cpp -o $@
speed_avx2_$(COMPILER): $(DEPS) speed.cpp
$(CXX) $(FLAGS_AVX2) speed.cpp -o $@
verify_avx2_$(COMPILER): $(DEPS) verify.cpp
$(CXX) $(FLAGS_AVX2) verify.cpp -o $@
speed_avx512bw_$(COMPILER): $(DEPS) speed.cpp
$(CXX) $(FLAGS_AVX512BW) speed.cpp -o $@
verify_avx512bw_$(COMPILER): $(DEPS) verify.cpp
$(CXX) $(FLAGS_AVX512BW) verify.cpp -o $@
speed_avx512vbmi_$(COMPILER): $(DEPS) speed.cpp
$(CXX) $(FLAGS_AVX512VBMI) speed.cpp -o $@
verify_avx512vbmi_$(COMPILER): $(DEPS) verify.cpp
$(CXX) $(FLAGS_AVX512VBMI) verify.cpp -o $@
speed_avx512vpopcnt_$(COMPILER): $(DEPS) speed.cpp
$(CXX) $(FLAGS_AVX512VPOPCNT) speed.cpp -o $@
verify_avx512vpopcnt_$(COMPILER): $(DEPS) verify.cpp
$(CXX) $(FLAGS_AVX512VPOPCNT) verify.cpp -o $@
speed_arm_$(COMPILER): $(DEPS) speed.cpp
$(CXX) $(FLAGS_ARM) speed.cpp -o $@
verify_arm_$(COMPILER): $(DEPS) verify.cpp
$(CXX) $(FLAGS_ARM) verify.cpp -o $@
speed_aarch64_$(COMPILER): $(DEPS) speed.cpp
$(CXX) $(FLAGS_AARCH64) speed.cpp -o $@
verify_aarch64_$(COMPILER): $(DEPS) verify.cpp
$(CXX) $(FLAGS_AARCH64) verify.cpp -o $@
speed_rvv_$(COMPILER): $(DEPS) speed.cpp
$(CXX) $(FLAGS_RVV) speed.cpp -o $@
verify_rvv_$(COMPILER): $(DEPS) verify.cpp
$(CXX) $(FLAGS_RVV) verify.cpp -o $@
speed: speed_$(COMPILER)
speed_avx: speed_avx_$(COMPILER)
speed_avx2: speed_avx2_$(COMPILER)
speed_avx512bw: speed_avx512bw_$(COMPILER)
speed_avx512vbmi: speed_avx512vbmi_$(COMPILER)
speed_avx512vpopcnt: speed_avx512vpopcnt_$(COMPILER)
speed_arm: speed_arm_$(COMPILER)
speed_aarch64: speed_aarch64_$(COMPILER)
speed_rvv: speed_rvv_$(COMPILER)
verify: verify_$(COMPILER)
verify_avx: verify_avx_$(COMPILER)
verify_avx2: verify_avx2_$(COMPILER)
verify_avx512bw: verify_avx512bw_$(COMPILER)
verify_avx512vbmi: verify_avx512vbmi_$(COMPILER)
verify_avx512vpopcnt: verify_avx512vpopcnt_$(COMPILER)
verify_arm: verify_arm_$(COMPILER)
verify_aarch64: verify_aarch64_$(COMPILER)
verify_rvv: verify_rvv_$(COMPILER)
build-all: $(ALL_TARGETS)
SIZE=10000000
ITERS=100
run: speed
./speed_$(COMPILER) $(SIZE) $(ITERS)
run_avx: speed_avx
./speed_avx_$(COMPILER) $(SIZE) $(ITERS)
run_avx2: speed_avx2
./speed_avx2_$(COMPILER) $(SIZE) $(ITERS)
run_avx512bw: speed_avx512bw
./speed_avx512bw_$(COMPILER) $(SIZE) $(ITERS)
run_avx512vbmi: speed_avx512vbmi
./speed_avx512vbmi_$(COMPILER) $(SIZE) $(ITERS)
SIZE=1000000
ITERS=100
run_arm: speed_arm
./speed_arm_$(COMPILER) $(SIZE) $(ITERS)
run_aarch64: speed_aarch64
./speed_aarch64_$(COMPILER) $(SIZE) $(ITERS)
run_verify: verify_$(COMPILER)
./$^
run_verify_avx: verify_avx_$(COMPILER)
./$^
run_verify_avx2: verify_avx2_$(COMPILER)
./$^
run_verify_avx512bw: verify_avx512bw_$(COMPILER)
./$^
run_verify_avx512vbmi: verify_avx512vbmi_$(COMPILER)
./$^
run_verify_avx512vpopcnt: verify_avx512vpopcnt_$(COMPILER)
./$^
run_verify_arm: verify_arm_$(COMPILER)
./$^
SPIKE_ISA=rv64gcv_Zicntr
run_verify_rvv: verify_rvv_$(COMPILER)
# test for VLENB=16
spike --isa=$(SPIKE_ISA) `which pk` $^
# test for VLENB=128
spike --isa=$(SPIKE_ISA) --varch=vlen:512,elen:64 `which pk` $^
run_speed_rvv: speed_rvv_$(COMPILER)
# test for VLENB=16
spike --isa=$(SPIKE_ISA) `which pk` $^ $(SIZE) $(ITERS)
# test for VLENB=128
spike --isa=$(SPIKE_ISA) --varch=vlen:512,elen:64 `which pk` $^ $(SIZE) $(ITERS)
clean:
rm -f $(ALL_TARGETS) $(ALL_ARM)