1 | # For correctness, see test-correctness.sh. |
---|
2 | # For performance: |
---|
3 | # pushd ~/cfax |
---|
4 | # . ~/setcfa build-fast |
---|
5 | # popd |
---|
6 | # make perfprogs CFA=$cfa -j8 MODE=performance |
---|
7 | # make results-latest.csv RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=common5 |
---|
8 | # cp results-latest.csv results-baseline.csv |
---|
9 | # make results-latest.csv OP_MOVEMENTS=stack OP_POLARITIES=insfirst OP_ACCESSORS=allhead RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=thorough |
---|
10 | # cp results-latest.csv results-sizing.csv |
---|
11 | |
---|
12 | CFA = cfa |
---|
13 | CXX = g++-11 |
---|
14 | UXX = ~/u++/u++-7.0.0/bin/u++ |
---|
15 | |
---|
16 | MODE=performance |
---|
17 | EXTRA_COMP_FLAGS= |
---|
18 | RUN_NUM_REPS=3 |
---|
19 | RUN_DATA_SIZE_MODE=none |
---|
20 | RUN_DURATION_SEC=5 |
---|
21 | RUN_TASKSET_CPULIST=6 |
---|
22 | |
---|
23 | ifeq "$(MODE)" "performance" |
---|
24 | PERFFLAGS_CFA = -DNDEBUG -O3 -nodebug |
---|
25 | PERFFLAGS_CC = -DNDEBUG -O3 |
---|
26 | else ifeq "$(MODE)" "correctness" |
---|
27 | PERFFLAGS_CFA = -O0 -g -debug |
---|
28 | PERFFLAGS_CC = -O0 -g |
---|
29 | else |
---|
30 | $(error Bad MODE ($(MODE)); should be performance or correctness) |
---|
31 | endif |
---|
32 | |
---|
33 | PERFFLAGS_CXX = $(PERFFLAGS_CC) |
---|
34 | PERFFLAGS_UXX = $(PERFFLAGS_CFA) |
---|
35 | |
---|
36 | CFLAGS=$(PERFFLAGS_CC) $(EXTRA_COMP_FLAGS) |
---|
37 | |
---|
38 | SHELL = /usr/bin/bash |
---|
39 | |
---|
40 | # function: project an element from a filename that contains a delimited tuple |
---|
41 | # (call proj,-,a-b-c.hfa,3) |
---|
42 | # is |
---|
43 | # c |
---|
44 | define proj |
---|
45 | $(word $(3),$(subst $(1), ,$(basename $(2)))) |
---|
46 | endef |
---|
47 | |
---|
48 | # functions: cross two lists, adding given delimiter between |
---|
49 | # (call cross,-,a b c,1 2) |
---|
50 | # is |
---|
51 | # a-1 a-2 b-1 b-2 c-1 c-2 |
---|
52 | define cross |
---|
53 | $(foreach x,$(2),$(foreach xs,$(3),$(x)$(1)$(xs))) |
---|
54 | endef |
---|
55 | define cross3 |
---|
56 | $(call cross,$(1),$(2),$(call cross,$(1),$(3),$(4))) |
---|
57 | endef |
---|
58 | define cross4 |
---|
59 | $(call cross,$(1),$(2),$(call cross3,$(1),$(3),$(4),$(5))) |
---|
60 | endef |
---|
61 | define cross5 |
---|
62 | $(call cross,$(1),$(2),$(call cross4,$(1),$(3),$(4),$(5),$(6))) |
---|
63 | endef |
---|
64 | |
---|
65 | OP_MOVEMENTS=stack queue |
---|
66 | OP_POLARITIES=insfirst inslast |
---|
67 | OP_ACCESSORS=allhead inselem remelem |
---|
68 | FX_SOLUTIONS=lq-tailq lq-list cfa-cfa upp-upp cpp-stlref |
---|
69 | |
---|
70 | OPS=$(call cross3,-,$(OP_MOVEMENTS),$(OP_POLARITIES),$(OP_ACCESSORS)) |
---|
71 | FXS=$(FX_SOLUTIONS) |
---|
72 | |
---|
73 | all : perfprogs results-latest.csv |
---|
74 | |
---|
75 | # Want to add functional dependency: |
---|
76 | # if current FX_SOLUTION is lq-list then |
---|
77 | # current OP_MOVEMENT must be stack and |
---|
78 | # current OP_POLARITY must be insfirst |
---|
79 | LQ_LIST_INCOMPAT_OP_MOVEMENTS=$(filter-out stack,$(OP_MOVEMENTS)) |
---|
80 | LQ_LIST_INCOMPAT_OP_POLARITIES=$(filter-out insfirst,$(OP_POLARITIES)) |
---|
81 | LQ_LIST_INCOMPAT_OPS=$(call cross3,-,$(LQ_LIST_INCOMPAT_OP_MOVEMENTS),$(OP_POLARITIES),$(OP_ACCESSORS)) \ |
---|
82 | $(call cross3,-,$(OP_MOVEMENTS),$(LQ_LIST_INCOMPAT_OP_POLARITIES),$(OP_ACCESSORS)) |
---|
83 | INCOMPAT=$(call cross,--,lq-list,$(LQ_LIST_INCOMPAT_OPS)) |
---|
84 | define filterFds |
---|
85 | $(filter-out $(INCOMPAT),$(1)) |
---|
86 | endef |
---|
87 | |
---|
88 | |
---|
89 | CORES_FULL=$(call cross,--,$(FXS),$(OPS)) # lq-tailq--stack-inslast-allhead |
---|
90 | CORES=$(call filterFds,$(CORES_FULL)) # lq-tailq--stack-inslast-allhead |
---|
91 | |
---|
92 | |
---|
93 | PERFPROGS=$(call cross,--,perfexp,$(CORES)) |
---|
94 | |
---|
95 | perfprogs : $(PERFPROGS) |
---|
96 | |
---|
97 | perfexp--% driver--%.o result--%.1csv : FX=$(call proj,--,$@,2) |
---|
98 | perfexp--% driver--%.o result--%.1csv : FX_COARSE=$(call proj,-,$(FX),1) |
---|
99 | perfexp--% driver--%.o result--%.1csv : OP=$(call proj,--,$@,3) |
---|
100 | perfexp--% driver--%.o result--%.1csv : OP_MOVEMENT=$(call proj,-,$(OP),1) |
---|
101 | perfexp--% driver--%.o result--%.1csv : OP_POLARITY=$(call proj,-,$(OP),2) |
---|
102 | perfexp--% driver--%.o result--%.1csv : OP_ACCESSOR=$(call proj,-,$(OP),3) |
---|
103 | perfexp--% driver--%.o result--%.1csv : OP_DEFINES=-DOP_MOVEMENT=$(OP_MOVEMENT) -DOP_POLARITY=$(OP_POLARITY) -DOP_ACCESSOR=$(OP_ACCESSOR) |
---|
104 | |
---|
105 | perfexp--cfa-% driver--cfa-%.o : COMPILER=$(CFA) $(PERFFLAGS_CFA) |
---|
106 | perfexp--lq-% driver--lq-%.o : COMPILER=$(CC) $(PERFFLAGS_CC) |
---|
107 | perfexp--cpp-% driver--cpp-%.o : COMPILER=$(CXX) $(PERFFLAGS_CXX) |
---|
108 | perfexp--upp-% driver--upp-%.o : COMPILER=$(UXX) $(PERFFLAGS_UXX) |
---|
109 | perfexp--% driver--%.o : COMPILER=NO-COMPILER-FOR-$(FX_COARSE) |
---|
110 | |
---|
111 | # Without this %.d rule, ordinary make runs have noise about the recipe for driver--%.o being ill-formed when called on a *.d. |
---|
112 | # https://stackoverflow.com/questions/3714041/why-does-this-makefile-execute-a-target-on-make-clean |
---|
113 | # Whatever you -include gets called as a target first. |
---|
114 | # One such example is driver--upp-upp--stack-insfirst-allhead.d |
---|
115 | # Without this %.d rule, `make make driver--upp-upp--stack-insfirst-allhead.d` leads to the rule for driver--%.o firing. |
---|
116 | # Though my dumb human eyes don't see the pattern as matching. |
---|
117 | %.d: |
---|
118 | @touch $@ |
---|
119 | |
---|
120 | perfexp--% : driver--%.o observation.o |
---|
121 | $(COMPILER) $(EXTRA_COMP_FLAGS) $^ -o $@ |
---|
122 | |
---|
123 | driver--%.o : driver.c |
---|
124 | $(COMPILER) $(EXTRA_COMP_FLAGS) -c $< $(OP_DEFINES) -include op-$(OP).h -include fx-$(FX).h -o $@ -MMD |
---|
125 | |
---|
126 | sayhi: |
---|
127 | echo $(PERFPROGS) |
---|
128 | |
---|
129 | |
---|
130 | ifeq "$(RUN_DATA_SIZE_MODE)" "common5" |
---|
131 | RUN_DATA_SIZES=\ |
---|
132 | 7-1000000 \ |
---|
133 | 71-100000 \ |
---|
134 | 809-10000 \ |
---|
135 | 9051-1000 \ |
---|
136 | 72421-100 |
---|
137 | else ifeq "$(RUN_DATA_SIZE_MODE)" "thorough" |
---|
138 | RUN_DATA_SIZES=\ |
---|
139 | 7-1000000 \ |
---|
140 | 11-100000 \ |
---|
141 | 13-100000 \ |
---|
142 | 19-100000 \ |
---|
143 | 29-100000 \ |
---|
144 | 37-100000 \ |
---|
145 | 53-100000 \ |
---|
146 | 71-100000 \ |
---|
147 | 101-10000 \ |
---|
148 | 149-10000 \ |
---|
149 | 211-10000 \ |
---|
150 | 283-10000 \ |
---|
151 | 401-10000 \ |
---|
152 | 569-10000 \ |
---|
153 | 809-10000 \ |
---|
154 | 1151-1000 \ |
---|
155 | 1601-1000 \ |
---|
156 | 2267-1000 \ |
---|
157 | 3203-1000 \ |
---|
158 | 4547-1000 \ |
---|
159 | 6473-1000 \ |
---|
160 | 9051-1000 \ |
---|
161 | 12809-100 \ |
---|
162 | 18119-100 \ |
---|
163 | 25601-100 \ |
---|
164 | 36209-100 \ |
---|
165 | 51203-100 \ |
---|
166 | 72421-100 \ |
---|
167 | 102407-10 \ |
---|
168 | 144817-10 \ |
---|
169 | 204803-10 \ |
---|
170 | 289637-10 \ |
---|
171 | 409609-10 \ |
---|
172 | 579263-10 \ |
---|
173 | 819229-10 \ |
---|
174 | 1158613-1 \ |
---|
175 | 1638431-1 \ |
---|
176 | 2317057-1 \ |
---|
177 | 3276803-1 \ |
---|
178 | 4634111-1 \ |
---|
179 | 6553621-1 \ |
---|
180 | 9268211-1 |
---|
181 | else ifeq "$(RUN_DATA_SIZE_MODE)" "manual" |
---|
182 | ifeq "$(RUN_DATA_SIZES)" "" |
---|
183 | $(error RUN_DATA_SIZE_MODE is manual but RUN_DATA_SIZES not given) |
---|
184 | endif |
---|
185 | else ifeq "$(RUN_DATA_SIZE_MODE)" "none" |
---|
186 | # Assume user manages RUN_ARGS; empty RUN_ARGS just means run with compiled-in defaults |
---|
187 | RUN_DATA_SIZES=none |
---|
188 | else |
---|
189 | $(error Bad RUN_DATA_SIZE_MODE ($(RUN_DATA_SIZE_MODE)); should be common5, thorough or manual) |
---|
190 | endif |
---|
191 | |
---|
192 | RUN_REP_IDS=$(shell echo {1..$(RUN_NUM_REPS)}) # 1 2 3 |
---|
193 | RUN_REP_EXTS=$(call cross3,,run,$(RUN_REP_IDS),.1csv) # run1.1csv run2.1cav run3.1csv |
---|
194 | |
---|
195 | RUN_LAUNCHES=$(call cross,--,$(RUN_DATA_SIZES),$(RUN_REP_EXTS)) |
---|
196 | |
---|
197 | |
---|
198 | |
---|
199 | RESULT1S=$(call cross,.,$(CORES),$(RUN_LAUNCHES)) # lq-tailq--stack-inslast-allhead.run2.1csv |
---|
200 | |
---|
201 | |
---|
202 | RESULT1S_SHUFD=$(shell shuf -e $(RESULT1S)) |
---|
203 | |
---|
204 | %.1csv : CORE=$(basename $(basename $@)) |
---|
205 | %.1csv : LAUNCH=$(subst .,,$(suffix $(basename $@))) |
---|
206 | %.1csv : SIZING=$(call proj,--,$(LAUNCH),1) |
---|
207 | %.1csv : NUMNODES=$(call proj,-,$(SIZING),1) |
---|
208 | %.1csv : CHECKDONE=$(call proj,-,$(SIZING),2) |
---|
209 | %.1csv : REP_ID=$(subst run,,$(call proj,--,$(LAUNCH),2)) |
---|
210 | %.1csv : RUN_ARGS=$(if $(filter none,$(SIZING)),,$(RUN_DURATION_SEC) $(CHECKDONE) $(NUMNODES) -1 $(REP_ID)) # use REP_ID as seed |
---|
211 | %.1csv : REP_TIME=$(shell date '+%F %H:%M:%S') |
---|
212 | %.1csv : perfprogs FORCE |
---|
213 | taskset --cpu-list $(RUN_TASKSET_CPULIST) ./perfexp--$(CORE) $(RUN_ARGS) | xargs -n 1 printf '%s,%s,%s,%s\n' "$(REP_TIME)" "$(REP_ID)" "$(RUN_ARGS)" | tee $@ |
---|
214 | |
---|
215 | |
---|
216 | BATCHTIME=$(shell date '+%F--%H-%M-%S') |
---|
217 | |
---|
218 | results--$(BATCHTIME).csv : $(RESULT1S_SHUFD) |
---|
219 | cat $^ | tee $@ |
---|
220 | rm $^ |
---|
221 | |
---|
222 | results-latest.csv : results--$(BATCHTIME).csv |
---|
223 | rm -f $@ |
---|
224 | ln -s $< $@ |
---|
225 | |
---|
226 | |
---|
227 | |
---|
228 | clean : |
---|
229 | rm -f *.o *.d perfexp--* |
---|
230 | |
---|
231 | # The FORCE business means any target that mentions it is also phony |
---|
232 | # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html says: To always rebuild a pattern rule consider using a “force target” (see [https://www.gnu.org/software/make/manual/html_node/Force-Targets.html]). |
---|
233 | .PHONY: all perfprogs results-latest.csv clean |
---|
234 | FORCE: |
---|
235 | |
---|
236 | .PRECIOUS: result--%.1csv driver--%.o perfexp--% %.o |
---|
237 | |
---|
238 | -include *.d |
---|