source: tests/zombies/string-perf/Makefile

Last change on this file was 08ed947, checked in by Michael Brooks <mlbrooks@…>, 2 years ago

Roll up of string changes for performance testing/improvement, and a couple API features supporting them.

String API changes:
Defining a tuning knob to control the heap growth policy (relapaces former 10% hardcode, downgraded to a default)
Implementing findFrom (allowing find-non-first); leaving find as find-first.

String implementation perf improvements:
Calling C-malloc directly instead of via CFA-alloc.
Replacings loops that copy with memmove calls.
Replacings loops that search for a value with memchr calls.

String perf testing realized:
Makefile supporting several prog-*.cfa, chosen by OPERATION value (implies prog.cfa changes to support the adjusted protocol)
Adjusting the starter/accumulater declarations in PEQ and PTA to behave consistently in cfa v cpp.
Adding tests: allocation, find, normalize, pass-by-val, pass-by-x.
Adding helper shell scripts for: generating flame graphs, collecting/crunching allocation stats using Mubeen's malloc wrappers

  • Property mode set to 100644
File size: 5.7 KB
Line 
1
2CFABUILD = ~/cfa2/build-perf
3LIBCFA = $(CFABUILD)/libcfa/*/src/.libs/libcfa.so
4
5CFA = $(CFABUILD)/driver/cfa
6PERFFLAGS_CFA = -nodebug -O2
7PERFFLAGS_CXX = -DNDEBUG -O2 -Wl,--no-as-needed -ldl
8
9
10# function: convert to upper case
11define uc
12$(shell echo $(1) | tr  '[:lower:]' '[:upper:]')
13endef
14
15# function: project numbered element of filename named by hyphen-delimited tuple
16# (call hyphProj,q-w-e-r.txt,1) is Q
17define ucHyphProj
18$(call uc,$(word $(2),$(subst -, ,$(basename $(1)))))
19endef
20
21# function: cross two lists, adding hyphen delimiters
22# (call hyphCross,a b c,1 2) is a-1 a-2 b-1 b-2 c-1 c-2
23define hyphCross
24$(foreach x,$(1),$(foreach xs,$(2),$(x)-$(xs)))
25endef
26
27define hyphCross3
28$(call hyphCross,$(1),$(call hyphCross,$(2),$(3)))
29endef
30
31define hyphCross4
32$(call hyphCross,$(1),$(call hyphCross3,$(2),$(3),$(4)))
33endef
34
35define hyphCross5
36$(call hyphCross,$(1),$(call hyphCross4,$(2),$(3),$(4),$(5)))
37endef
38
39OPERATIONS=pta peq pbv pall pno
40ALLOCS=reuse fresh
41CFA_APILEVELS=hl ll
42CFA_SHARINGS=share noshare
43PLATFORMS=cfa stl buhr94
44
45ifneq ($(filter cfa,$(PLATFORMS)),)
46    CFA_APIS=$(call hyphCross,$(CFA_APILEVELS),$(CFA_SHARINGS))
47endif
48
49ifneq ($(filter stl,$(PLATFORMS)),)
50    STL_APIS=na-na
51endif
52
53ifneq ($(filter buhr94,$(PLATFORMS)),)
54    BUHR94_APIS=na-na
55endif
56
57APIS = $(CFA_APIS) $(STL_APIS) $(BUHR94_APIS)
58
59OPERATIONS_USING_ALLOCS=pta peq
60define enrichOperationsAllocs
61$(call hyphCross3,$(filter peq pta,$(OPERATIONS)),$(1),$(ALLOCS)) $(call hyphCross3,$(filter-out peq pta,$(OPERATIONS)),$(1),na)
62endef
63
64CFA_PERFPROGS=$(call hyphCross,perfexp-cfa,$(call enrichOperationsAllocs,$(CFA_APIS)))
65STL_PERFPROGS=$(call hyphCross,perfexp-stl,$(call enrichOperationsAllocs,$(STL_APIS)))
66BUHR94_PERFPROGS=$(call hyphCross,perfexp-buhr94,$(call enrichOperationsAllocs,$(BUHR94_APIS)))
67
68PERFPROGS = $(CFA_PERFPROGS) $(STL_PERFPROGS) $(BUHR94_PERFPROGS)
69
70all : $(PERFPROGS)
71
72PP_SPLIT := $(shell echo "${PERFPROGS}" | sed -e 's/ /\\n/g')
73echoPerfProgs:
74        echo -e '$(PP_SPLIT)'
75
76perfexp-%.o: API=$(call ucHyphProj,$@,2)
77perfexp-%.o: OPERATION=$(call ucHyphProj,$@,3)
78perfexp-%.o: CFA_APILEVEL=$(call ucHyphProj,$@,4)
79perfexp-%.o: CFA_SHARING=$(call ucHyphProj,$@,5)
80perfexp-%.o: ALLOC=$(call ucHyphProj,$@,6)
81perfexp-%.o: SCENARIO_SWITCH=-DIMPL_$(API)_$(CFA_APILEVEL)_$(CFA_SHARING) -DOP_$(OPERATION) -DALLOC_$(ALLOC)
82
83perfexp-cfa-%.o: CMD=$(CFA) -c $(PERFFLAGS_CFA) $< -o $@ $(SCENARIO_SWITCH)
84perfexp-stl-%.o: CMD=$(CXX) -c -xc++ $(PERFFLAGS_CXX) $< -o $@ $(SCENARIO_SWITCH)
85perfexp-buhr94-%.o: CMD=$(CXX) -xc++ -c $(PERFFLAGS_CXX) $< -o $@ $(SCENARIO_SWITCH)
86
87perfexp-cfa-peq-%.o: prog.cfa $(LIBCFA)
88        $(CMD)
89perfexp-cfa-pta-%.o: prog.cfa $(LIBCFA)
90        $(CMD)
91perfexp-cfa-pbv-%.o: prog-passbyval.cfa $(LIBCFA)
92        $(CMD)
93perfexp-cfa-pb%.o: prog-passbyX.cfa $(LIBCFA)
94        $(CMD)
95perfexp-cfa-pfi-%.o: prog-find.cfa $(LIBCFA)
96        $(CMD)
97perfexp-cfa-pall-%.o: prog-allocn.cfa $(LIBCFA)
98        $(CMD)
99perfexp-cfa-pno-%.o: prog-normalize.cfa $(LIBCFA)
100        $(CMD)
101perfexp-stl-peq-%.o: prog.cfa
102        $(CMD)
103perfexp-stl-pta-%.o: prog.cfa
104        $(CMD)
105perfexp-stl-pbv-%.o: prog-passbyval.cfa
106        $(CMD)
107perfexp-stl-pfi-%.o: prog-find.cfa
108        $(CMD)
109perfexp-stl-pall-%.o: prog-allocn.cfa
110        $(CMD)
111perfexp-stl-pno-%.o: prog-normalize.cfa
112        $(CMD)
113perfexp-buhr94-peq-%.o: prog.cfa buhr94-string.o buhr94-VbyteSM.o
114        $(CMD)
115perfexp-buhr94-pta-%.o: prog.cfa buhr94-string.o buhr94-VbyteSM.o
116        $(CMD)
117perfexp-buhr94-pta-%.o: prog-passbyval.cfa buhr94-string.o buhr94-VbyteSM.o
118        $(CMD)
119perfexp-buhr94-pall-%.o: prog-allocn.cfa buhr94-string.o buhr94-VbyteSM.o
120        $(CMD)
121perfexp-buhr94-pno-%.o: prog-normalize.cfa buhr94-string.o buhr94-VbyteSM.o
122        $(CMD)
123
124# one of the pbx cases also needs to link with not_string_res.o (handling manually)
125perfexp-cfa-%: perfexp-cfa-%.o $(LIBCFA)
126        $(CFA) $(PERFFLAGS_CFA) $< -o $@ 
127perfexp-stl-%: perfexp-stl-%.o $(LIBCFA)
128        $(CFA) $(PERFFLAGS_CFA) $< /lib/x86_64-linux-gnu/libstdc++.so.6 -o $@
129perfexp-buhr94-% : perfexp-buhr94-%.o buhr94-string.o buhr94-VbyteSM.o
130        $(CXX) $(PERFFLAGS_CXX) $^ -o $@
131
132buhr94-string.o:
133        $(CXX) -xc++ -c $(PERFFLAGS_CXX) ~/usys1/sm/string/StringSharing/src/string.cc -o $@
134
135buhr94-VbyteSM.o:
136        $(CXX) -xc++ -c $(PERFFLAGS_CXX) ~/usys1/sm/string/StringSharing/src/VbyteSM.cc -o $@
137
138clean:
139        rm -f *.o perfexp*
140
141MEASURE = $(PERFPROGS)
142CORPORI = corpus-100-*-1.txt
143
144measurement: $(MEASURE)
145        tofile=measurement-`date '+%F--%H-%M-%S'`.csv ; \
146        echo $$tofile ; \
147        for prog in $(MEASURE) ; do \
148            for corpus in $(CORPORI) ; do \
149                        corpusbody=`cat $$corpus` ; \
150                        printed=`./$$prog 100 10 $$corpusbody` ; \
151                        echo $$prog,$$corpus,$$printed  >>  $$tofile ; \
152                        echo $$prog,$$corpus,$$printed  ; \
153                done ; \
154        done
155#                       printed=`./$$prog 10000 - 10 $$corpusbody` ; \
156
157CFA_EXPANSIONS=0.02 0.05 0.1 0.2 0.5 0.9
158
159measurement2: $(MEASURE)
160        tofile=measurement-`date '+%F--%H-%M-%S'`.csv ; \
161        for prog in $(MEASURE) ; do \
162            for corpus in $(CORPORI) ; do \
163                        for expansion in $(CFA_EXPANSIONS) ; do \
164                                corpusbody= ; \
165                                echo ./$$prog 1000 1.006 $$expansion 10 \`cat $$corpus\` ; \
166                        done ; \
167                done ; \
168        done ; \
169        echo $$tofile ; \
170        for prog in $(MEASURE) ; do \
171            for corpus in $(CORPORI) ; do \
172                        for expansion in $(CFA_EXPANSIONS) ; do \
173                                corpusbody=`cat $$corpus` ; \
174                                printed=`./$$prog 1000 1.006 $$expansion 10 $$corpusbody` ; \
175                                echo $$prog,$$corpus,$$expansion,$$printed  >>  $$tofile ; \
176                                echo $$prog,$$corpus,$$expansion,$$printed  ; \
177                        done ; \
178                done ; \
179        done
180
181measurement3: $(MEASURE)
182        for prog in $(MEASURE) ; do \
183            for corpus in $(CORPORI) ; do \
184                        for expansion in $(CFA_EXPANSIONS) ; do \
185                                corpusbody=`cat $$corpus` ; \
186                                LD_PRELOAD=~/plg2/mubeen-stat-shim/malloc/mallocWrappers.so ./$$prog 1000 1.006 $$expansion 1 $$corpusbody ; \
187                                mv preload_dump.txt preload_dump--qrun1--$$corpus--expansion-$$expansion.txt ; \
188                        done ; \
189                done ; \
190        done
Note: See TracBrowser for help on using the repository browser.