source: doc/theses/mike_brooks_MMath/benchmarks/list/Makefile @ f5dbc8d

Last change on this file since f5dbc8d was 2b01f8e, checked in by Mike Brooks <mlbrooks@…>, 20 months ago

Adjust LL perf to use a random layout of nodes in memory

  • Property mode set to 100644
File size: 7.2 KB
Line 
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
12CFA = cfa
13CXX = g++-11
14UXX =  ~/u++/u++-7.0.0/bin/u++
15
16MODE=performance
17EXTRA_COMP_FLAGS=
18RUN_NUM_REPS=3
19RUN_DATA_SIZE_MODE=none
20RUN_DURATION_SEC=5
21RUN_TASKSET_CPULIST=6
22
23ifeq "$(MODE)" "performance"
24PERFFLAGS_CFA = -DNDEBUG -O3 -nodebug
25PERFFLAGS_CC  = -DNDEBUG -O3
26else ifeq "$(MODE)" "correctness"
27PERFFLAGS_CFA = -O0 -g -debug
28PERFFLAGS_CC  = -O0 -g
29else
30$(error Bad MODE ($(MODE)); should be performance or correctness)
31endif
32
33PERFFLAGS_CXX = $(PERFFLAGS_CC)
34PERFFLAGS_UXX = $(PERFFLAGS_CFA)
35
36CFLAGS=$(PERFFLAGS_CC) $(EXTRA_COMP_FLAGS)
37
38SHELL = /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
44define proj
45$(word $(3),$(subst $(1), ,$(basename $(2))))
46endef
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
52define cross
53$(foreach x,$(2),$(foreach xs,$(3),$(x)$(1)$(xs)))
54endef
55define cross3
56$(call cross,$(1),$(2),$(call cross,$(1),$(3),$(4)))
57endef
58define cross4
59$(call cross,$(1),$(2),$(call cross3,$(1),$(3),$(4),$(5)))
60endef
61define cross5
62$(call cross,$(1),$(2),$(call cross4,$(1),$(3),$(4),$(5),$(6)))
63endef
64
65OP_MOVEMENTS=stack queue
66OP_POLARITIES=insfirst inslast
67OP_ACCESSORS=allhead inselem remelem
68FX_SOLUTIONS=lq-tailq lq-list cfa-cfa upp-upp cpp-stlref
69
70OPS=$(call cross3,-,$(OP_MOVEMENTS),$(OP_POLARITIES),$(OP_ACCESSORS))
71FXS=$(FX_SOLUTIONS)
72
73all : 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
79LQ_LIST_INCOMPAT_OP_MOVEMENTS=$(filter-out stack,$(OP_MOVEMENTS))
80LQ_LIST_INCOMPAT_OP_POLARITIES=$(filter-out insfirst,$(OP_POLARITIES))
81LQ_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))
83INCOMPAT=$(call cross,--,lq-list,$(LQ_LIST_INCOMPAT_OPS))
84define filterFds
85$(filter-out $(INCOMPAT),$(1))
86endef
87
88
89CORES_FULL=$(call cross,--,$(FXS),$(OPS))                # lq-tailq--stack-inslast-allhead
90CORES=$(call filterFds,$(CORES_FULL))                    # lq-tailq--stack-inslast-allhead
91
92
93PERFPROGS=$(call cross,--,perfexp,$(CORES))
94
95perfprogs : $(PERFPROGS)
96
97perfexp--% driver--%.o result--%.1csv : FX=$(call proj,--,$@,2)
98perfexp--% driver--%.o result--%.1csv : FX_COARSE=$(call proj,-,$(FX),1)
99perfexp--% driver--%.o result--%.1csv : OP=$(call proj,--,$@,3)
100perfexp--% driver--%.o result--%.1csv : OP_MOVEMENT=$(call proj,-,$(OP),1)
101perfexp--% driver--%.o result--%.1csv : OP_POLARITY=$(call proj,-,$(OP),2)
102perfexp--% driver--%.o result--%.1csv : OP_ACCESSOR=$(call proj,-,$(OP),3)
103perfexp--% driver--%.o result--%.1csv : OP_DEFINES=-DOP_MOVEMENT=$(OP_MOVEMENT) -DOP_POLARITY=$(OP_POLARITY) -DOP_ACCESSOR=$(OP_ACCESSOR)
104
105perfexp--cfa-% driver--cfa-%.o : COMPILER=$(CFA) $(PERFFLAGS_CFA)
106perfexp--lq-%  driver--lq-%.o  : COMPILER=$(CC)  $(PERFFLAGS_CC)
107perfexp--cpp-% driver--cpp-%.o : COMPILER=$(CXX) $(PERFFLAGS_CXX)
108perfexp--upp-% driver--upp-%.o : COMPILER=$(UXX) $(PERFFLAGS_UXX)
109perfexp--%     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
120perfexp--% : driver--%.o observation.o
121        $(COMPILER) $(EXTRA_COMP_FLAGS) $^ -o $@
122
123driver--%.o : driver.c
124        $(COMPILER) $(EXTRA_COMP_FLAGS) -c $< $(OP_DEFINES) -include op-$(OP).h -include fx-$(FX).h -o $@ -MMD
125
126sayhi:
127        echo $(PERFPROGS)
128
129
130ifeq "$(RUN_DATA_SIZE_MODE)" "common5"
131RUN_DATA_SIZES=\
132  7-1000000 \
133  71-100000 \
134  809-10000 \
135  9051-1000 \
136  72421-100
137else ifeq "$(RUN_DATA_SIZE_MODE)" "thorough"
138RUN_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
181else ifeq "$(RUN_DATA_SIZE_MODE)" "manual"
182ifeq "$(RUN_DATA_SIZES)" ""
183$(error RUN_DATA_SIZE_MODE is manual but RUN_DATA_SIZES not given)
184endif
185else ifeq "$(RUN_DATA_SIZE_MODE)" "none"
186# Assume user manages RUN_ARGS; empty RUN_ARGS just means run with compiled-in defaults
187RUN_DATA_SIZES=none
188else
189$(error Bad RUN_DATA_SIZE_MODE ($(RUN_DATA_SIZE_MODE)); should be common5, thorough or manual)
190endif
191
192RUN_REP_IDS=$(shell echo {1..$(RUN_NUM_REPS)})              # 1 2 3
193RUN_REP_EXTS=$(call cross3,,run,$(RUN_REP_IDS),.1csv)       # run1.1csv run2.1cav run3.1csv
194
195RUN_LAUNCHES=$(call cross,--,$(RUN_DATA_SIZES),$(RUN_REP_EXTS))
196
197
198
199RESULT1S=$(call cross,.,$(CORES),$(RUN_LAUNCHES))   # lq-tailq--stack-inslast-allhead.run2.1csv
200
201
202RESULT1S_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
216BATCHTIME=$(shell date '+%F--%H-%M-%S')
217
218results--$(BATCHTIME).csv : $(RESULT1S_SHUFD)
219        cat $^ | tee $@
220        rm $^
221
222results-latest.csv : results--$(BATCHTIME).csv
223        rm -f $@
224        ln -s $< $@
225
226
227
228clean :
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
234FORCE:
235
236.PRECIOUS: result--%.1csv driver--%.o perfexp--% %.o
237
238-include *.d
Note: See TracBrowser for help on using the repository browser.