CFABUILD = ~/cfa2/build-perf LIBCFA = $(CFABUILD)/libcfa/*/src/.libs/libcfa.so CFA = $(CFABUILD)/driver/cfa PERFFLAGS_CFA = -nodebug -O2 PERFFLAGS_CXX = -DNDEBUG -O2 -Wl,--no-as-needed -ldl # function: convert to upper case define uc $(shell echo $(1) | tr '[:lower:]' '[:upper:]') endef # function: project numbered element of filename named by hyphen-delimited tuple # (call hyphProj,q-w-e-r.txt,1) is Q define ucHyphProj $(call uc,$(word $(2),$(subst -, ,$(basename $(1))))) endef # function: cross two lists, adding hyphen delimiters # (call hyphCross,a b c,1 2) is a-1 a-2 b-1 b-2 c-1 c-2 define hyphCross $(foreach x,$(1),$(foreach xs,$(2),$(x)-$(xs))) endef define hyphCross3 $(call hyphCross,$(1),$(call hyphCross,$(2),$(3))) endef define hyphCross4 $(call hyphCross,$(1),$(call hyphCross3,$(2),$(3),$(4))) endef define hyphCross5 $(call hyphCross,$(1),$(call hyphCross4,$(2),$(3),$(4),$(5))) endef OPERATIONS=pta peq pbv pall pno ALLOCS=reuse fresh CFA_APILEVELS=hl ll CFA_SHARINGS=share noshare PLATFORMS=cfa stl buhr94 ifneq ($(filter cfa,$(PLATFORMS)),) CFA_APIS=$(call hyphCross,$(CFA_APILEVELS),$(CFA_SHARINGS)) endif ifneq ($(filter stl,$(PLATFORMS)),) STL_APIS=na-na endif ifneq ($(filter buhr94,$(PLATFORMS)),) BUHR94_APIS=na-na endif APIS = $(CFA_APIS) $(STL_APIS) $(BUHR94_APIS) OPERATIONS_USING_ALLOCS=pta peq define enrichOperationsAllocs $(call hyphCross3,$(filter peq pta,$(OPERATIONS)),$(1),$(ALLOCS)) $(call hyphCross3,$(filter-out peq pta,$(OPERATIONS)),$(1),na) endef CFA_PERFPROGS=$(call hyphCross,perfexp-cfa,$(call enrichOperationsAllocs,$(CFA_APIS))) STL_PERFPROGS=$(call hyphCross,perfexp-stl,$(call enrichOperationsAllocs,$(STL_APIS))) BUHR94_PERFPROGS=$(call hyphCross,perfexp-buhr94,$(call enrichOperationsAllocs,$(BUHR94_APIS))) PERFPROGS = $(CFA_PERFPROGS) $(STL_PERFPROGS) $(BUHR94_PERFPROGS) all : $(PERFPROGS) PP_SPLIT := $(shell echo "${PERFPROGS}" | sed -e 's/ /\\n/g') echoPerfProgs: echo -e '$(PP_SPLIT)' perfexp-%.o: API=$(call ucHyphProj,$@,2) perfexp-%.o: OPERATION=$(call ucHyphProj,$@,3) perfexp-%.o: CFA_APILEVEL=$(call ucHyphProj,$@,4) perfexp-%.o: CFA_SHARING=$(call ucHyphProj,$@,5) perfexp-%.o: ALLOC=$(call ucHyphProj,$@,6) perfexp-%.o: SCENARIO_SWITCH=-DIMPL_$(API)_$(CFA_APILEVEL)_$(CFA_SHARING) -DOP_$(OPERATION) -DALLOC_$(ALLOC) perfexp-cfa-%.o: CMD=$(CFA) -c $(PERFFLAGS_CFA) $< -o $@ $(SCENARIO_SWITCH) perfexp-stl-%.o: CMD=$(CXX) -c -xc++ $(PERFFLAGS_CXX) $< -o $@ $(SCENARIO_SWITCH) perfexp-buhr94-%.o: CMD=$(CXX) -xc++ -c $(PERFFLAGS_CXX) $< -o $@ $(SCENARIO_SWITCH) perfexp-cfa-peq-%.o: prog.cfa $(LIBCFA) $(CMD) perfexp-cfa-pta-%.o: prog.cfa $(LIBCFA) $(CMD) perfexp-cfa-pbv-%.o: prog-passbyval.cfa $(LIBCFA) $(CMD) perfexp-cfa-pb%.o: prog-passbyX.cfa $(LIBCFA) $(CMD) perfexp-cfa-pfi-%.o: prog-find.cfa $(LIBCFA) $(CMD) perfexp-cfa-pall-%.o: prog-allocn.cfa $(LIBCFA) $(CMD) perfexp-cfa-pno-%.o: prog-normalize.cfa $(LIBCFA) $(CMD) perfexp-stl-peq-%.o: prog.cfa $(CMD) perfexp-stl-pta-%.o: prog.cfa $(CMD) perfexp-stl-pbv-%.o: prog-passbyval.cfa $(CMD) perfexp-stl-pfi-%.o: prog-find.cfa $(CMD) perfexp-stl-pall-%.o: prog-allocn.cfa $(CMD) perfexp-stl-pno-%.o: prog-normalize.cfa $(CMD) perfexp-buhr94-peq-%.o: prog.cfa buhr94-string.o buhr94-VbyteSM.o $(CMD) perfexp-buhr94-pta-%.o: prog.cfa buhr94-string.o buhr94-VbyteSM.o $(CMD) perfexp-buhr94-pta-%.o: prog-passbyval.cfa buhr94-string.o buhr94-VbyteSM.o $(CMD) perfexp-buhr94-pall-%.o: prog-allocn.cfa buhr94-string.o buhr94-VbyteSM.o $(CMD) perfexp-buhr94-pno-%.o: prog-normalize.cfa buhr94-string.o buhr94-VbyteSM.o $(CMD) # one of the pbx cases also needs to link with not_string_res.o (handling manually) perfexp-cfa-%: perfexp-cfa-%.o $(LIBCFA) $(CFA) $(PERFFLAGS_CFA) $< -o $@ perfexp-stl-%: perfexp-stl-%.o $(LIBCFA) $(CFA) $(PERFFLAGS_CFA) $< /lib/x86_64-linux-gnu/libstdc++.so.6 -o $@ perfexp-buhr94-% : perfexp-buhr94-%.o buhr94-string.o buhr94-VbyteSM.o $(CXX) $(PERFFLAGS_CXX) $^ -o $@ buhr94-string.o: $(CXX) -xc++ -c $(PERFFLAGS_CXX) ~/usys1/sm/string/StringSharing/src/string.cc -o $@ buhr94-VbyteSM.o: $(CXX) -xc++ -c $(PERFFLAGS_CXX) ~/usys1/sm/string/StringSharing/src/VbyteSM.cc -o $@ clean: rm -f *.o perfexp* MEASURE = $(PERFPROGS) CORPORI = corpus-100-*-1.txt measurement: $(MEASURE) tofile=measurement-`date '+%F--%H-%M-%S'`.csv ; \ echo $$tofile ; \ for prog in $(MEASURE) ; do \ for corpus in $(CORPORI) ; do \ corpusbody=`cat $$corpus` ; \ printed=`./$$prog 100 10 $$corpusbody` ; \ echo $$prog,$$corpus,$$printed >> $$tofile ; \ echo $$prog,$$corpus,$$printed ; \ done ; \ done # printed=`./$$prog 10000 - 10 $$corpusbody` ; \ CFA_EXPANSIONS=0.02 0.05 0.1 0.2 0.5 0.9 measurement2: $(MEASURE) tofile=measurement-`date '+%F--%H-%M-%S'`.csv ; \ for prog in $(MEASURE) ; do \ for corpus in $(CORPORI) ; do \ for expansion in $(CFA_EXPANSIONS) ; do \ corpusbody= ; \ echo ./$$prog 1000 1.006 $$expansion 10 \`cat $$corpus\` ; \ done ; \ done ; \ done ; \ echo $$tofile ; \ for prog in $(MEASURE) ; do \ for corpus in $(CORPORI) ; do \ for expansion in $(CFA_EXPANSIONS) ; do \ corpusbody=`cat $$corpus` ; \ printed=`./$$prog 1000 1.006 $$expansion 10 $$corpusbody` ; \ echo $$prog,$$corpus,$$expansion,$$printed >> $$tofile ; \ echo $$prog,$$corpus,$$expansion,$$printed ; \ done ; \ done ; \ done measurement3: $(MEASURE) for prog in $(MEASURE) ; do \ for corpus in $(CORPORI) ; do \ for expansion in $(CFA_EXPANSIONS) ; do \ corpusbody=`cat $$corpus` ; \ LD_PRELOAD=~/plg2/mubeen-stat-shim/malloc/mallocWrappers.so ./$$prog 1000 1.006 $$expansion 1 $$corpusbody ; \ mv preload_dump.txt preload_dump--qrun1--$$corpus--expansion-$$expansion.txt ; \ done ; \ done ; \ done