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

ADTast-experimental
Last change on this file since bf0c723 was 0b66ef9, checked in by Michael Brooks <mlbrooks@…>, 15 months ago

Add linked list performance experiment

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