source: doc/theses/mike_brooks_MMath/benchmarks/string/Makefile@ 7592f42

Last change on this file since 7592f42 was 7d02d35, checked in by Mike Brooks <mlbrooks@…>, 4 months ago

Include benchmark changes for data production in string-plot data WIP. Missing from 2410424.

  • Property mode set to 100644
File size: 8.6 KB
Line 
1# Usage
2# $cfabuild/driver/cfa -nodebug -quiet -c -x c /dev/null && rm null.o || echo Need to fix \$cfabuild
3# make CFABUILD=$cfabuild -j8 # compile
4# make measurement CFA_APILEVELS=ll OPERATIONS='pta peq pbv' CORPORI='corpus-100-*-1.txt corpus-1-*-1.txt' # append-pbv
5# make measurement2 CFA_APILEVELS=ll OPERATIONS='pall' PLATFORMS=cfa CFA_SHARINGS=share CORPORI='corpus-1-*-1.txt' # allocate-speed-cfa
6# make measurement2 CFA_APILEVELS=ll OPERATIONS='pall' PLATFORMS=stl CFA_EXPANSIONS=-1.0 CORPORI='corpus-1-*-1.txt' # allocate-speed-stl
7# make measurement3 CFA_APILEVELS=ll OPERATIONS='pall' PLATFORMS=cfa CFA_SHARINGS=share CORPORI='corpus-1-*-1.txt' # allocate-space-cfa
8# make measurement3 CFA_APILEVELS=ll OPERATIONS='pall' PLATFORMS=stl CFA_EXPANSIONS=-1.0 CORPORI='corpus-1-*-1.txt' # allocate-space-stl
9# make measurement4 CFA_APILEVELS=ll OPERATIONS='pall' PLATFORMS=cfa CFA_EXPANSIONS=0.2 CFA_SHARINGS=share CORPORI='corpus-1-*-1.txt' # allocate-attrib-cfa
10# make measurement4 CFA_APILEVELS=ll OPERATIONS='pall' PLATFORMS=stl CFA_EXPANSIONS=-1.0 CORPORI='corpus-1-*-1.txt' # allocate-attrib-stl
11
12CFABUILD = ~/cfa2/build-perf
13LIBCFA = $(CFABUILD)/libcfa/*/src/.libs/libcfa.so
14
15CFA = $(CFABUILD)/driver/cfa
16PERFFLAGS_CFA = -nodebug -O2
17PERFFLAGS_CXX = -DNDEBUG -O2 -Wl,--no-as-needed -ldl
18
19
20# function: convert to upper case
21define uc
22$(shell echo $(1) | tr '[:lower:]' '[:upper:]')
23endef
24
25# function: project numbered element of filename named by hyphen-delimited tuple
26# (call hyphProj,q-w-e-r.txt,1) is Q
27define ucHyphProj
28$(call uc,$(word $(2),$(subst -, ,$(basename $(1)))))
29endef
30
31# function: cross two lists, adding hyphen delimiters
32# (call hyphCross,a b c,1 2) is a-1 a-2 b-1 b-2 c-1 c-2
33define hyphCross
34$(foreach x,$(1),$(foreach xs,$(2),$(x)-$(xs)))
35endef
36
37define hyphCross3
38$(call hyphCross,$(1),$(call hyphCross,$(2),$(3)))
39endef
40
41define hyphCross4
42$(call hyphCross,$(1),$(call hyphCross3,$(2),$(3),$(4)))
43endef
44
45define hyphCross5
46$(call hyphCross,$(1),$(call hyphCross4,$(2),$(3),$(4),$(5)))
47endef
48
49OPERATIONS=pta peq pbv pall #pno
50ALLOCS=reuse fresh
51CFA_APILEVELS=hl ll
52CFA_SHARINGS=share noshare
53PLATFORMS=cfa stl #buhr94
54
55ifneq ($(filter cfa,$(PLATFORMS)),)
56 CFA_APIS=$(call hyphCross,$(CFA_APILEVELS),$(CFA_SHARINGS))
57endif
58
59ifneq ($(filter stl,$(PLATFORMS)),)
60 STL_APIS=na-na
61endif
62
63ifneq ($(filter buhr94,$(PLATFORMS)),)
64 BUHR94_APIS=na-na
65endif
66
67APIS = $(CFA_APIS) $(STL_APIS) $(BUHR94_APIS)
68
69OPERATIONS_USING_ALLOCS=pta peq
70define enrichOperationsAllocs
71$(call hyphCross3,$(filter peq pta,$(OPERATIONS)),$(1),$(ALLOCS)) $(call hyphCross3,$(filter-out peq pta,$(OPERATIONS)),$(1),na)
72endef
73
74CFA_PERFPROGS=$(call hyphCross,perfexp-cfa,$(call enrichOperationsAllocs,$(CFA_APIS)))
75STL_PERFPROGS=$(call hyphCross,perfexp-stl,$(call enrichOperationsAllocs,$(STL_APIS)))
76BUHR94_PERFPROGS=$(call hyphCross,perfexp-buhr94,$(call enrichOperationsAllocs,$(BUHR94_APIS)))
77
78PERFPROGS = $(CFA_PERFPROGS) $(STL_PERFPROGS) $(BUHR94_PERFPROGS)
79
80all : $(PERFPROGS)
81
82PP_SPLIT := $(shell echo "${PERFPROGS}" | sed -e 's/ /\\n/g')
83echoPerfProgs:
84 echo -e '$(PP_SPLIT)'
85
86perfexp-%.o: API=$(call ucHyphProj,$@,2)
87perfexp-%.o: OPERATION=$(call ucHyphProj,$@,3)
88perfexp-%.o: CFA_APILEVEL=$(call ucHyphProj,$@,4)
89perfexp-%.o: CFA_SHARING=$(call ucHyphProj,$@,5)
90perfexp-%.o: ALLOC=$(call ucHyphProj,$@,6)
91perfexp-%.o: SCENARIO_SWITCH=-DIMPL_$(API)_$(CFA_APILEVEL)_$(CFA_SHARING) -DOP_$(OPERATION) -DALLOC_$(ALLOC)
92
93perfexp-cfa-%.o: CMD=$(CFA) -c $(PERFFLAGS_CFA) $< -o $@ $(SCENARIO_SWITCH)
94perfexp-stl-%.o: CMD=$(CXX) -c -xc++ $(PERFFLAGS_CXX) $< -o $@ $(SCENARIO_SWITCH)
95perfexp-buhr94-%.o: CMD=$(CXX) -xc++ -c $(PERFFLAGS_CXX) $< -o $@ $(SCENARIO_SWITCH)
96
97perfexp-cfa-peq-%.o: prog.cfa $(LIBCFA)
98 $(CMD)
99perfexp-cfa-pta-%.o: prog.cfa $(LIBCFA)
100 $(CMD)
101perfexp-cfa-pbv-%.o: prog-passbyval.cfa $(LIBCFA)
102 $(CMD)
103perfexp-cfa-pb%.o: prog-passbyX.cfa $(LIBCFA)
104 $(CMD)
105perfexp-cfa-pfi-%.o: prog-find.cfa $(LIBCFA)
106 $(CMD)
107perfexp-cfa-pall-%.o: prog-allocn.cfa $(LIBCFA)
108 $(CMD)
109perfexp-cfa-pno-%.o: prog-normalize.cfa $(LIBCFA)
110 $(CMD)
111perfexp-stl-peq-%.o: prog.cfa
112 $(CMD)
113perfexp-stl-pta-%.o: prog.cfa
114 $(CMD)
115perfexp-stl-pbv-%.o: prog-passbyval.cfa
116 $(CMD)
117perfexp-stl-pfi-%.o: prog-find.cfa
118 $(CMD)
119perfexp-stl-pall-%.o: prog-allocn.cfa
120 $(CMD)
121perfexp-stl-pno-%.o: prog-normalize.cfa
122 $(CMD)
123perfexp-buhr94-peq-%.o: prog.cfa buhr94-string.o buhr94-VbyteSM.o
124 $(CMD)
125perfexp-buhr94-pta-%.o: prog.cfa buhr94-string.o buhr94-VbyteSM.o
126 $(CMD)
127perfexp-buhr94-pta-%.o: prog-passbyval.cfa buhr94-string.o buhr94-VbyteSM.o
128 $(CMD)
129perfexp-buhr94-pall-%.o: prog-allocn.cfa buhr94-string.o buhr94-VbyteSM.o
130 $(CMD)
131perfexp-buhr94-pno-%.o: prog-normalize.cfa buhr94-string.o buhr94-VbyteSM.o
132 $(CMD)
133
134# one of the pbx cases also needs to link with not_string_res.o (handling manually)
135perfexp-cfa-%: perfexp-cfa-%.o $(LIBCFA)
136 $(CFA) $(PERFFLAGS_CFA) $< -o $@
137perfexp-stl-%: perfexp-stl-%.o $(LIBCFA)
138 $(CFA) $(PERFFLAGS_CFA) $< /lib/x86_64-linux-gnu/libstdc++.so.6 -o $@
139perfexp-buhr94-% : perfexp-buhr94-%.o buhr94-string.o buhr94-VbyteSM.o
140 $(CXX) $(PERFFLAGS_CXX) $^ -o $@
141
142buhr94-string.o:
143 $(CXX) -xc++ -c $(PERFFLAGS_CXX) ~/usys1/sm/string/StringSharing/src/string.cc -o $@
144
145buhr94-VbyteSM.o:
146 $(CXX) -xc++ -c $(PERFFLAGS_CXX) ~/usys1/sm/string/StringSharing/src/VbyteSM.cc -o $@
147
148clean:
149 rm -f *.o perfexp*
150
151MEASURE = $(PERFPROGS)
152CORPORI = corpus-100-*-1.txt
153
154RUN_TASKSET_CPULIST=6
155
156# General timing
157# Output file gets concatenation of program outputs
158measurement: $(MEASURE)
159 tofile=measurement-`date '+%F--%H-%M-%S'`.csv ; \
160 echo $$tofile ; \
161 for prog in $(MEASURE) ; do \
162 for corpus in $(CORPORI) ; do \
163 corpusbody=`cat $$corpus` ; \
164 resulttext=`taskset --cpu-list $(RUN_TASKSET_CPULIST) ./$$prog 100 10 $$corpusbody` ; \
165 echo $$prog,$$corpus,$$resulttext >> $$tofile ; \
166 echo $$prog,$$corpus,$$resulttext ; \
167 done ; \
168 done
169
170CFA_EXPANSIONS=0.02 0.05 0.1 0.2 0.4 0.5 0.9 0.98
171
172# Special-case timing with extra IV for CFA_EXPANSIONS
173# Output file gets concatenation of program outputs (one line per run)
174measurement2: $(MEASURE)
175 tofile=measurement-`date '+%F--%H-%M-%S'`.csv ; \
176 for prog in $(MEASURE) ; do \
177 for corpus in $(CORPORI) ; do \
178 for expansion in $(CFA_EXPANSIONS) ; do \
179 corpusbody= ; \
180 echo ./$$prog 1000 1.006 $$expansion 10 \`cat $$corpus\` ; \
181 done ; \
182 done ; \
183 done ; \
184 echo $$tofile ; \
185 for prog in $(MEASURE) ; do \
186 for corpus in $(CORPORI) ; do \
187 for expansion in $(CFA_EXPANSIONS) ; do \
188 corpusbody=`cat $$corpus` ; \
189 printed=`./$$prog 1000 1.006 $$expansion 10 $$corpusbody` ; \
190 echo $$prog,$$corpus,$$expansion,$$printed >> $$tofile ; \
191 echo $$prog,$$corpus,$$expansion,$$printed ; \
192 done ; \
193 done ; \
194 done
195
196# Space, with the IV for CFA_EXPANSIONS
197# Runs Mubeen's malloc interceptor to get malloc-request state
198# Output file gets concatenation of the interceptor's output (one line per run); program's output ignorred
199# Expect and ignore crashes; they're during shutdown, after everything we care about is over
200measurement3: $(MEASURE)
201 tofile=measurement-`date '+%F--%H-%M-%S'`.ssv ; \
202 for prog in $(MEASURE) ; do \
203 for corpus in $(CORPORI) ; do \
204 for expansion in $(CFA_EXPANSIONS) ; do \
205 corpusbody=`cat $$corpus` ; \
206 LD_PRELOAD=~/plg2/mubeen-stat-shim/malloc/mallocWrappers.so ./$$prog 1000 1.006 $$expansion 10 $$corpusbody ; \
207 printed=`tail -n 1 preload_dump.txt` ; \
208 echo $$prog $$corpus $$expansion $$printed >> $$tofile ; \
209 echo $$prog $$corpus $$expansion $$printed ; \
210 rm preload_dump.txt ; \
211 done ; \
212 done ; \
213 done
214
215# Time attribution, with the IV for CFA_EXPANSIONS
216# Runs the SUT under perf, then crunches the perf result
217# Output file gets concatenation of perf summaries (several lines per run); program's output ignorred
218# Expect and ignore output "addr2line: DWARF error: section .debug_info is larger than its filesize!"
219measurement4: $(MEASURE)
220 RUNID=`date '+%F--%H-%M-%S'` ; \
221 tofile=measurement-$$RUNID.ssv ; \
222 echo $$tofile ; \
223 for prog in $(MEASURE) ; do \
224 for corpus in $(CORPORI) ; do \
225 for expansion in $(CFA_EXPANSIONS) ; do \
226 SLUG=measurement--$$prog--$$corpus--$$expansion--$$RUNID ; \
227 corpusbody=`cat $$corpus` ; \
228 perf record --call-graph dwarf -m16M ./$$prog 1000 1.006 $$expansion 10 $$corpusbody ; \
229 mv perf.data $$SLUG.data ; \
230 perf script -i $$SLUG.data > $$SLUG.perf ; \
231 ~/flamegraph/FlameGraph/stackcollapse-perf.pl $$SLUG.perf > $$SLUG.folded ; \
232 ~/flamegraph/FlameGraph/flamegraph.pl $$SLUG.folded > $$SLUG.svg ; \
233 python3 process-allocn-attrib.py $$SLUG.folded | xargs -L1 echo $$prog $$corpus $$expansion >> $$tofile ; \
234 done ; \
235 done ; \
236 done
Note: See TracBrowser for help on using the repository browser.