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

ADTast-experimental
Last change on this file since fdc042d was fdc042d, checked in by Mike Brooks <mlbrooks@…>, 18 months ago

Fix Makefile noise on LL perf rebuild.

  • Property mode set to 100644
File size: 5.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 RUNARGS=5 RUN_NUM_REPS=5
8
9
10CFA = cfa
11CXX = g++-11
12UXX =  ~/u++/u++-7.0.0/bin/u++
13
14MODE=performance
15EXTRA_COMP_FLAGS=
16RUN_NUM_REPS=3
17RUNARGS=
18
19ifeq "$(MODE)" "performance"
20PERFFLAGS_CFA = -nodebug -O3
21PERFFLAGS_CC  = -DNDEBUG -O3
22else ifeq "$(MODE)" "correctness"
23PERFFLAGS_CFA = -debug -O0 -g
24PERFFLAGS_CC = -O0 -g
25else
26$(error Bad MODE ($(MODE)); should be performance or correctness)
27endif
28
29PERFFLAGS_CXX = $(PERFFLAGS_CC)
30PERFFLAGS_UXX = $(PERFFLAGS_CC)
31
32SHELL = /usr/bin/bash
33
34# function: project an element from a filename that contains a delimited tuple
35# (call proj,-,a-b-c.hfa,3)
36# is
37# c
38define proj
39$(word $(3),$(subst $(1), ,$(basename $(2))))
40endef
41
42# functions: cross two lists, adding given delimiter between
43# (call cross,-,a b c,1 2)
44# is
45# a-1 a-2 b-1 b-2 c-1 c-2
46define cross
47$(foreach x,$(2),$(foreach xs,$(3),$(x)$(1)$(xs)))
48endef
49define cross3
50$(call cross,$(1),$(2),$(call cross,$(1),$(3),$(4)))
51endef
52define cross4
53$(call cross,$(1),$(2),$(call cross3,$(1),$(3),$(4),$(5)))
54endef
55define cross5
56$(call cross,$(1),$(2),$(call cross4,$(1),$(3),$(4),$(5),$(6)))
57endef
58
59OP_MOVEMENTS=stack queue
60OP_POLARITIES=insfirst inslast
61OP_ACCESSORS=allhead inselem remelem
62FX_SOLUTIONS=lq-tailq lq-list cfa-cfa upp-upp cpp-stlref
63
64OPS=$(call cross3,-,$(OP_MOVEMENTS),$(OP_POLARITIES),$(OP_ACCESSORS))
65FXS=$(FX_SOLUTIONS)
66
67all : perfprogs results-latest.csv
68
69# Want to add functional dependency:
70# if current FX_SOLUTION is lq-list then
71# current OP_MOVEMENT must be stack and
72# current OP_POLARITY must be insfirst
73LQ_LIST_INCOMPAT_OP_MOVEMENTS=$(filter-out stack,$(OP_MOVEMENTS))
74LQ_LIST_INCOMPAT_OP_POLARITIES=$(filter-out insfirst,$(OP_POLARITIES))
75LQ_LIST_INCOMPAT_OPS=$(call cross3,-,$(LQ_LIST_INCOMPAT_OP_MOVEMENTS),$(OP_POLARITIES),$(OP_ACCESSORS)) \
76                     $(call cross3,-,$(OP_MOVEMENTS),$(LQ_LIST_INCOMPAT_OP_POLARITIES),$(OP_ACCESSORS))
77INCOMPAT=$(call cross,--,lq-list,$(LQ_LIST_INCOMPAT_OPS))
78define filterFds
79$(filter-out $(INCOMPAT),$(1))
80endef
81
82
83CORES_FULL=$(call cross,--,$(FXS),$(OPS))                # lq-tailq--stack-inslast-allhead
84CORES=$(call filterFds,$(CORES_FULL))                    # lq-tailq--stack-inslast-allhead
85
86
87PERFPROGS=$(call cross,--,perfexp,$(CORES))
88
89perfprogs : $(PERFPROGS)
90
91perfexp--% driver--%.o result--%.1csv : FX=$(call proj,--,$@,2)
92perfexp--% driver--%.o result--%.1csv : FX_COARSE=$(call proj,-,$(FX),1)
93perfexp--% driver--%.o result--%.1csv : OP=$(call proj,--,$@,3)
94perfexp--% driver--%.o result--%.1csv : OP_MOVEMENT=$(call proj,-,$(OP),1)
95perfexp--% driver--%.o result--%.1csv : OP_POLARITY=$(call proj,-,$(OP),2)
96perfexp--% driver--%.o result--%.1csv : OP_ACCESSOR=$(call proj,-,$(OP),3)
97perfexp--% driver--%.o result--%.1csv : OP_DEFINES=-DOP_MOVEMENT=$(OP_MOVEMENT) -DOP_POLARITY=$(OP_POLARITY) -DOP_ACCESSOR=$(OP_ACCESSOR)
98
99perfexp--cfa-% driver--cfa-%.o : COMPILER=$(CFA) $(PERFFLAGS_CFA)
100perfexp--lq-%  driver--lq-%.o  : COMPILER=$(CC)  $(PERFFLAGS_CC)
101perfexp--cpp-% driver--cpp-%.o : COMPILER=$(CXX) $(PERFFLAGS_CXX)
102perfexp--upp-% driver--upp-%.o : COMPILER=$(UXX) $(PERFFLAGS_UXX)
103perfexp--%     driver--%.o     : COMPILER=NO-COMPILER-FOR-$(FX_COARSE)
104
105# Without this %.d rule, ordinary make runs have noise about the recipe for driver--%.o being ill-formed when called on a *.d.
106# https://stackoverflow.com/questions/3714041/why-does-this-makefile-execute-a-target-on-make-clean
107# Whatever you -include gets called as a target first.
108# One such example is driver--upp-upp--stack-insfirst-allhead.d
109# Without this %.d rule, `make make driver--upp-upp--stack-insfirst-allhead.d` leads to the rule for driver--%.o firing.
110# Though my dumb human eyes don't see the pattern as matching.
111%.d:
112        @touch $@
113
114perfexp--% : driver--%.o observation.o
115        $(COMPILER) $(EXTRA_COMP_FLAGS) $^ -o $@
116
117driver--%.o : driver.c
118        $(COMPILER) $(EXTRA_COMP_FLAGS) -c $< $(OP_DEFINES) -include op-$(OP).h -include fx-$(FX).h -o $@ -MMD
119
120sayhi:
121        echo $(PERFPROGS)
122
123
124RUN_REP_IDS=$(shell echo {1..$(RUN_NUM_REPS)})              # 1 2 3
125RUN_REP_EXTS=$(call cross3,,run,$(RUN_REP_IDS),.1csv)       # run1.1csv run2.1cav run3.1csv
126
127RESULT1S=$(call cross,.,$(CORES),$(RUN_REP_EXTS))   # lq-tailq--stack-inslast-allhead.run2.1csv
128
129RESULT1S_SHUFD=$(shell shuf -e $(RESULT1S))
130
131%.1csv : CORE=$(basename $(basename $@))
132%.1csv : REP_ID=$(subst .run,,$(suffix $(basename $@)))
133%.1csv : REP_TIME=$(shell date '+%F %H:%M:%S')
134%.1csv : perfprogs FORCE
135        ./perfexp--$(CORE) $(RUNARGS) | xargs -n 1 printf '%s,%s,%s\n' "$(REP_TIME)" "$(REP_ID)" | tee $@
136
137BATCHTIME=$(shell date '+%F--%H-%M-%S')
138
139results--$(BATCHTIME).csv : $(RESULT1S_SHUFD)
140        cat $^ | tee $@
141        rm $^
142
143results-latest.csv : results--$(BATCHTIME).csv
144        rm -f $@
145        ln -s $< $@
146
147
148
149clean :
150        rm -f *.o *.d perfexp--*
151
152# The FORCE business means any target that mentions it is also phony
153# 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]).
154.PHONY: all perfprogs results-latest.csv clean
155FORCE:
156
157.PRECIOUS: result--%.1csv driver--%.o perfexp--% %.o
158
159-include *.d
Note: See TracBrowser for help on using the repository browser.