1 | |
---|
2 | CFABUILD = ~/cfa2/build-perf |
---|
3 | LIBCFA = $(CFABUILD)/libcfa/*/src/.libs/libcfa.so |
---|
4 | |
---|
5 | CFA = $(CFABUILD)/driver/cfa |
---|
6 | PERFFLAGS_CFA = -nodebug -O2 |
---|
7 | PERFFLAGS_CXX = -DNDEBUG -O2 |
---|
8 | |
---|
9 | |
---|
10 | # function: convert to upper case |
---|
11 | define uc |
---|
12 | $(shell echo $(1) | tr '[:lower:]' '[:upper:]') |
---|
13 | endef |
---|
14 | |
---|
15 | # function: project numbered element of filename named by hyphen-delimited tuple |
---|
16 | # (call hyphProj,q-w-e-r.txt,1) is Q |
---|
17 | define ucHyphProj |
---|
18 | $(call uc,$(word $(2),$(subst -, ,$(basename $(1))))) |
---|
19 | endef |
---|
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 |
---|
23 | define hyphCross |
---|
24 | $(foreach x,$(1),$(foreach xs,$(2),$(x)-$(xs))) |
---|
25 | endef |
---|
26 | |
---|
27 | define hyphCross3 |
---|
28 | $(call hyphCross,$(1),$(call hyphCross,$(2),$(3))) |
---|
29 | endef |
---|
30 | |
---|
31 | define hyphCross4 |
---|
32 | $(call hyphCross,$(1),$(call hyphCross3,$(2),$(3),$(4))) |
---|
33 | endef |
---|
34 | |
---|
35 | define hyphCross5 |
---|
36 | $(call hyphCross,$(1),$(call hyphCross4,$(2),$(3),$(4),$(5))) |
---|
37 | endef |
---|
38 | |
---|
39 | OPERATIONS=pta peq |
---|
40 | ALLOCS=reuse fresh |
---|
41 | CFA_APILEVELS=hl ll |
---|
42 | CFA_SHARINGS=share noshare |
---|
43 | PLATFORMS=cfa stl buhr94 |
---|
44 | |
---|
45 | ifneq ($(filter cfa,$(PLATFORMS)),) |
---|
46 | CFA_PERFPROGS=$(call hyphCross5,perfexp-cfa,$(CFA_APILEVELS),$(OPERATIONS),$(CFA_SHARINGS),$(ALLOCS)) |
---|
47 | endif |
---|
48 | |
---|
49 | ifneq ($(filter stl,$(PLATFORMS)),) |
---|
50 | STL_PERFPROGS=$(call hyphCross3,perfexp-stl,$(OPERATIONS),$(ALLOCS)) |
---|
51 | endif |
---|
52 | |
---|
53 | ifneq ($(filter buhr94,$(PLATFORMS)),) |
---|
54 | BUHR94_PERFPROGS=$(call hyphCross3,perfexp-buhr94,$(OPERATIONS),$(ALLOCS)) |
---|
55 | endif |
---|
56 | |
---|
57 | PERFPROGS = $(CFA_PERFPROGS) $(STL_PERFPROGS) $(BUHR94_PERFPROGS) |
---|
58 | |
---|
59 | all : $(PERFPROGS) |
---|
60 | |
---|
61 | |
---|
62 | |
---|
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) |
---|
69 | |
---|
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) |
---|
74 | |
---|
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) |
---|
79 | |
---|
80 | buhr94-string.o: |
---|
81 | $(CXX) -xc++ -c $(PERFFLAGS_CXX) ~/usys1/sm/string/StringSharing/src/string.cc -o $@ |
---|
82 | |
---|
83 | buhr94-VbyteSM.o: |
---|
84 | $(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.o |
---|
87 | $(CXX) $(PERFFLAGS_CXX) $^ -o $@ |
---|
88 | |
---|
89 | clean: |
---|
90 | rm -f *.o perfexp* |
---|
91 | |
---|
92 | MEASURE = $(PERFPROGS) |
---|
93 | CORPORI = corpus-100-*-1.txt |
---|
94 | |
---|
95 | measurement: $(MEASURE) |
---|
96 | tofile=measurement-`date '+%F--%H-%M-%S'`.csv ; \ |
---|
97 | echo $$tofile ; \ |
---|
98 | for prog in $(MEASURE) ; do \ |
---|
99 | for corpus in $(CORPORI) ; do \ |
---|
100 | corpusbody=`cat $$corpus` ; \ |
---|
101 | printed=`./$$prog 100 10 $$corpusbody` ; \ |
---|
102 | echo $$prog,$$corpus,$$printed >> $$tofile ; \ |
---|
103 | echo $$prog,$$corpus,$$printed ; \ |
---|
104 | done ; \ |
---|
105 | done |
---|