Changeset 08ed947 for tests/zombies/string-perf
- Timestamp:
- Feb 23, 2022, 6:13:02 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- afe9e45, c5af4f9
- Parents:
- cc7bbe6
- Location:
- tests/zombies/string-perf
- Files:
-
- 13 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/zombies/string-perf/.gitignore
rcc7bbe6 r08ed947 1 1 !Makefile 2 2 perfexp-* 3 make-corpus 4 corpus-*.txt 5 corpusx-*.txt 6 measurement-*.csv -
tests/zombies/string-perf/Makefile
rcc7bbe6 r08ed947 5 5 CFA = $(CFABUILD)/driver/cfa 6 6 PERFFLAGS_CFA = -nodebug -O2 7 PERFFLAGS_CXX = -DNDEBUG -O2 7 PERFFLAGS_CXX = -DNDEBUG -O2 -Wl,--no-as-needed -ldl 8 8 9 9 … … 37 37 endef 38 38 39 OPERATIONS=pta peq 39 OPERATIONS=pta peq pbv pall pno 40 40 ALLOCS=reuse fresh 41 41 CFA_APILEVELS=hl ll … … 44 44 45 45 ifneq ($(filter cfa,$(PLATFORMS)),) 46 CFA_PERFPROGS=$(call hyphCross5,perfexp-cfa,$(CFA_APILEVELS),$(OPERATIONS),$(CFA_SHARINGS),$(ALLOCS))46 CFA_APIS=$(call hyphCross,$(CFA_APILEVELS),$(CFA_SHARINGS)) 47 47 endif 48 48 49 49 ifneq ($(filter stl,$(PLATFORMS)),) 50 STL_PERFPROGS=$(call hyphCross3,perfexp-stl,$(OPERATIONS),$(ALLOCS)) 50 STL_APIS=na-na 51 51 endif 52 52 53 53 ifneq ($(filter buhr94,$(PLATFORMS)),) 54 BUHR94_PERFPROGS=$(call hyphCross3,perfexp-buhr94,$(OPERATIONS),$(ALLOCS)) 54 BUHR94_APIS=na-na 55 55 endif 56 57 APIS = $(CFA_APIS) $(STL_APIS) $(BUHR94_APIS) 58 59 OPERATIONS_USING_ALLOCS=pta peq 60 define enrichOperationsAllocs 61 $(call hyphCross3,$(filter peq pta,$(OPERATIONS)),$(1),$(ALLOCS)) $(call hyphCross3,$(filter-out peq pta,$(OPERATIONS)),$(1),na) 62 endef 63 64 CFA_PERFPROGS=$(call hyphCross,perfexp-cfa,$(call enrichOperationsAllocs,$(CFA_APIS))) 65 STL_PERFPROGS=$(call hyphCross,perfexp-stl,$(call enrichOperationsAllocs,$(STL_APIS))) 66 BUHR94_PERFPROGS=$(call hyphCross,perfexp-buhr94,$(call enrichOperationsAllocs,$(BUHR94_APIS))) 56 67 57 68 PERFPROGS = $(CFA_PERFPROGS) $(STL_PERFPROGS) $(BUHR94_PERFPROGS) … … 59 70 all : $(PERFPROGS) 60 71 72 PP_SPLIT := $(shell echo "${PERFPROGS}" | sed -e 's/ /\\n/g') 73 echoPerfProgs: 74 echo -e '$(PP_SPLIT)' 61 75 76 perfexp-%.o: API=$(call ucHyphProj,$@,2) 77 perfexp-%.o: OPERATION=$(call ucHyphProj,$@,3) 78 perfexp-%.o: CFA_APILEVEL=$(call ucHyphProj,$@,4) 79 perfexp-%.o: CFA_SHARING=$(call ucHyphProj,$@,5) 80 perfexp-%.o: ALLOC=$(call ucHyphProj,$@,6) 81 perfexp-%.o: SCENARIO_SWITCH=-DIMPL_$(API)_$(CFA_APILEVEL)_$(CFA_SHARING) -DOP_$(OPERATION) -DALLOC_$(ALLOC) 62 82 63 perfexp-cfa-%: CFA_APILEVEL=$(call ucHyphProj,$@,3) 64 perfexp-cfa-%: OPERATION=$(call ucHyphProj,$@,4) 65 perfexp-cfa-%: CFA_SHARING=$(call ucHyphProj,$@,5) 66 perfexp-cfa-%: ALLOC=$(call ucHyphProj,$@,6) 67 perfexp-cfa-%: prog.cfa $(LIBCFA) 68 $(CFA) $(PERFFLAGS_CFA) $< -o $@ -DIMPL_CFA_$(CFA_APILEVEL)_$(CFA_SHARING) -DOP_$(OPERATION) -DALLOC_$(ALLOC) 83 perfexp-cfa-%.o: CMD=$(CFA) -c $(PERFFLAGS_CFA) $< -o $@ $(SCENARIO_SWITCH) 84 perfexp-stl-%.o: CMD=$(CXX) -c -xc++ $(PERFFLAGS_CXX) $< -o $@ $(SCENARIO_SWITCH) 85 perfexp-buhr94-%.o: CMD=$(CXX) -xc++ -c $(PERFFLAGS_CXX) $< -o $@ $(SCENARIO_SWITCH) 69 86 70 perfexp-stl-%: OPERATION=$(call ucHyphProj,$@,3) 71 perfexp-stl-%: ALLOC=$(call ucHyphProj,$@,4) 72 perfexp-stl-%: prog.cfa 73 $(CXX) -xc++ $(PERFFLAGS_CXX) $< -o $@ -DIMPL_STL -DOP_$(OPERATION) -DALLOC_$(ALLOC) 87 perfexp-cfa-peq-%.o: prog.cfa $(LIBCFA) 88 $(CMD) 89 perfexp-cfa-pta-%.o: prog.cfa $(LIBCFA) 90 $(CMD) 91 perfexp-cfa-pbv-%.o: prog-passbyval.cfa $(LIBCFA) 92 $(CMD) 93 perfexp-cfa-pb%.o: prog-passbyX.cfa $(LIBCFA) 94 $(CMD) 95 perfexp-cfa-pfi-%.o: prog-find.cfa $(LIBCFA) 96 $(CMD) 97 perfexp-cfa-pall-%.o: prog-allocn.cfa $(LIBCFA) 98 $(CMD) 99 perfexp-cfa-pno-%.o: prog-normalize.cfa $(LIBCFA) 100 $(CMD) 101 perfexp-stl-peq-%.o: prog.cfa 102 $(CMD) 103 perfexp-stl-pta-%.o: prog.cfa 104 $(CMD) 105 perfexp-stl-pbv-%.o: prog-passbyval.cfa 106 $(CMD) 107 perfexp-stl-pfi-%.o: prog-find.cfa 108 $(CMD) 109 perfexp-stl-pall-%.o: prog-allocn.cfa 110 $(CMD) 111 perfexp-stl-pno-%.o: prog-normalize.cfa 112 $(CMD) 113 perfexp-buhr94-peq-%.o: prog.cfa buhr94-string.o buhr94-VbyteSM.o 114 $(CMD) 115 perfexp-buhr94-pta-%.o: prog.cfa buhr94-string.o buhr94-VbyteSM.o 116 $(CMD) 117 perfexp-buhr94-pta-%.o: prog-passbyval.cfa buhr94-string.o buhr94-VbyteSM.o 118 $(CMD) 119 perfexp-buhr94-pall-%.o: prog-allocn.cfa buhr94-string.o buhr94-VbyteSM.o 120 $(CMD) 121 perfexp-buhr94-pno-%.o: prog-normalize.cfa buhr94-string.o buhr94-VbyteSM.o 122 $(CMD) 74 123 75 perfexp-buhr94-%.o: OPERATION=$(call ucHyphProj,$@,3) 76 perfexp-buhr94-%.o: ALLOC=$(call ucHyphProj,$@,4) 77 perfexp-buhr94-%.o: prog.cfa 78 $(CXX) -xc++ -c $(PERFFLAGS_CXX) $< -o $@ -DIMPL_BUHR94 -DOP_$(OPERATION) -DALLOC_$(ALLOC) 124 # one of the pbx cases also needs to link with not_string_res.o (handling manually) 125 perfexp-cfa-%: perfexp-cfa-%.o $(LIBCFA) 126 $(CFA) $(PERFFLAGS_CFA) $< -o $@ 127 perfexp-stl-%: perfexp-stl-%.o $(LIBCFA) 128 $(CFA) $(PERFFLAGS_CFA) $< /lib/x86_64-linux-gnu/libstdc++.so.6 -o $@ 129 perfexp-buhr94-% : perfexp-buhr94-%.o buhr94-string.o buhr94-VbyteSM.o 130 $(CXX) $(PERFFLAGS_CXX) $^ -o $@ 79 131 80 132 buhr94-string.o: … … 83 135 buhr94-VbyteSM.o: 84 136 $(CXX) -xc++ -c $(PERFFLAGS_CXX) ~/usys1/sm/string/StringSharing/src/VbyteSM.cc -o $@ 85 86 perfexp-buhr94-% : perfexp-buhr94-%.o buhr94-string.o buhr94-VbyteSM.o87 $(CXX) $(PERFFLAGS_CXX) $^ -o $@88 137 89 138 clean: … … 104 153 done ; \ 105 154 done 155 # printed=`./$$prog 10000 - 10 $$corpusbody` ; \ 156 157 CFA_EXPANSIONS=0.02 0.05 0.1 0.2 0.5 0.9 158 159 measurement2: $(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 181 measurement3: $(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 -
tests/zombies/string-perf/make-corpus.cfa
rcc7bbe6 r08ed947 3 3 #include <limits.h> 4 4 #include <unistd.h> 5 #include <string.h> 6 7 // U(0,1) 8 static double U() { 9 return (double)rand() / (double)INT_MAX; 10 } 5 11 6 12 // generate random draws from a geometric distribution of the given mean … … 14 20 static int nextGeoRand() { 15 21 // ret = ⌊ln(U)/ln(1−p)⌋ where U ~ U(0, 1) 16 double U = (double)rand() / (double)INT_MAX; 17 return 1 + (int) (log(U) / denom); 22 return 1 + (int) (log(U()) / denom); 18 23 } 19 24 20 // write a randomly generated alphabetic string whose length is drawn fromabove distribution21 static void emit1( ) {22 int lim = nextGeoRand();25 // write a randomly generated alphabetic string whose length is adjused from a draw of the above distribution 26 static void emit1( int offset, double mcfreq, char mchar ) { 27 int lim = offset + nextGeoRand(); 23 28 // printf("==%d\n", lim); 24 29 for (i; lim) { 25 char emit = 'a' + (rand() % ('z'-'a')); 30 char emit; 31 if (U() < mcfreq) emit = mchar; 32 else emit = 'a' + (rand() % ('z'-'a')); 26 33 printf("%c", emit); 27 34 } … … 29 36 } 30 37 31 // usage: ./make-corpus toGen mean 38 // usage: ./make-corpus toGen mean [offset=0] [mcfreq=0.0] [mchar='-'] 39 // 40 // Outputs alphabetic (plus magic-char) strings, one per line. 41 // toGen: number of strings (lines) 42 // 43 // generated length ~ offset + geo(mean) 44 // >= 1 45 // 46 // offset=0, mean=1: constant length 1 47 // offset=0, mean=2: lengths go like number of coin tosses it takes to get heads 48 // offset=0, mean=6: lengths go like number of cube die rolls it takes to get ::: 49 // offset=15, mean=1: constant length 16 50 // offset=15, mean=2: population's minimum is 16 and mean is 17 51 // 52 // Magic Char (mc) does not affect these lengths. Any mc occurrence replaces an alphabetic char. 53 // mcfreq: (in [0,1]) expected fraction of the characters output that are mchar 54 // 32 55 int main(int argc, char ** argv) { 33 assert(argc == 3);34 56 35 int toGen = atoi(argv[1]); 36 assert(toGen > 0); 37 assert(toGen < 1000000); 57 int toGen; 58 int mean; 59 int offset = 0; 60 double mcfreq = 0.0; 61 char mchar = '-'; 38 62 39 int mean = atoi(argv[2]); 40 assert(mean > 0); 41 assert(mean < 1000); 63 assert(argc >= 3 && argc <= 6); 64 switch(argc) { 65 case 6: 66 assert(strlen(argv[5]) == 0); 67 mchar = argv[5][0]; 68 case 5: 69 mcfreq = atof(argv[4]); 70 assert(mcfreq >= 0.0 && mcfreq <= 1.0); 71 case 4: 72 offset = atoi(argv[3]); 73 assert(offset >= 0 && offset < 10000); 74 default: 75 mean = atoi(argv[2]); 76 assert(mean > 0); 77 assert(mean < 1000); 78 toGen = atoi(argv[1]); 79 assert(toGen > 0); 80 assert(toGen < 1000000); 81 } 42 82 43 83 initialize(mean); 44 84 for( i; toGen ) { 45 emit1( );85 emit1(offset, mcfreq, mchar); 46 86 } 47 87 } -
tests/zombies/string-perf/prog.cfa
rcc7bbe6 r08ed947 1 #if defined IMPL_STL_NA_NA 2 #define IMPL_STL 3 #endif 4 5 #if defined IMPL_BUHR94_NA_NA 6 #define IMPL_BUHR94 7 #endif 1 8 2 9 #if defined IMPL_STL … … 52 59 #if defined IMPL_CFA 53 60 #include <math.hfa> 61 extern "C" { 62 void malloc_stats( void ); 63 } 54 64 #elif defined IMPL_CXX 55 65 #include <algorithm> 56 66 using std::min; 67 #include <malloc.h> 57 68 #endif 58 69 … … 114 125 #if defined IMPL_CFA_LL 115 126 #define DECLS \ 116 string_resinitval = "starter"; \117 string_res accum = { initval, COPY_VALUE };127 const char* initval = "starter"; \ 128 string_res accum = initval; 118 129 #else 119 130 #define DECLS \ 120 stringinitval = "starter"; \131 const char* initval = "starter"; \ 121 132 string accum = initval; 122 133 #endif … … 149 160 #elif defined OP_PEQ 150 161 accum += toAppend; 162 #else 163 #error Bad OP_ 151 164 #endif 152 165 } … … 157 170 printf("%d,%d,%f,%d,%f\n", concatsPerReset, corpuslen, meanCorpusLen, concatsDone, elapsed); 158 171 172 // malloc_stats(); 173 159 174 return 0; 160 175 }
Note: See TracChangeset
for help on using the changeset viewer.