1 | # For correctness, see test-correctness.sh. |
---|
2 | # For performance: |
---|
3 | # pushd ~/cfax |
---|
4 | # ~/setcfa build-fast |
---|
5 | # popd |
---|
6 | # make perfprogs CFA=$cfa -j8 MODE=performance |
---|
7 | # make results-latest.csv RUNARGS=5 RUN_NUM_REPS=5 |
---|
8 | |
---|
9 | |
---|
10 | CFA = cfa |
---|
11 | CXX = g++-11 |
---|
12 | UXX = ~/u++/u++-7.0.0/bin/u++ |
---|
13 | |
---|
14 | MODE=performance |
---|
15 | EXTRA_COMP_FLAGS= |
---|
16 | RUN_NUM_REPS=3 |
---|
17 | RUNARGS= |
---|
18 | |
---|
19 | ifeq "$(MODE)" "performance" |
---|
20 | PERFFLAGS_CFA = -nodebug -O3 |
---|
21 | PERFFLAGS_CC = -DNDEBUG -O3 |
---|
22 | else ifeq "$(MODE)" "correctness" |
---|
23 | PERFFLAGS_CFA = -debug -O0 -g |
---|
24 | PERFFLAGS_CC = -O0 -g |
---|
25 | else |
---|
26 | $(error Bad MODE ($(MODE)); should be performance or correctness) |
---|
27 | endif |
---|
28 | |
---|
29 | PERFFLAGS_CXX = $(PERFFLAGS_CC) |
---|
30 | PERFFLAGS_UXX = $(PERFFLAGS_CC) |
---|
31 | |
---|
32 | SHELL = /usr/bin/bash |
---|
33 | |
---|
34 | # function: project an element from a filename that contains a delimited tuple |
---|
35 | # (call proj,-,a-b-c.hfa,3) |
---|
36 | # is |
---|
37 | # c |
---|
38 | define proj |
---|
39 | $(word $(3),$(subst $(1), ,$(basename $(2)))) |
---|
40 | endef |
---|
41 | |
---|
42 | # functions: cross two lists, adding given delimiter between |
---|
43 | # (call cross,-,a b c,1 2) |
---|
44 | # is |
---|
45 | # a-1 a-2 b-1 b-2 c-1 c-2 |
---|
46 | define cross |
---|
47 | $(foreach x,$(2),$(foreach xs,$(3),$(x)$(1)$(xs))) |
---|
48 | endef |
---|
49 | define cross3 |
---|
50 | $(call cross,$(1),$(2),$(call cross,$(1),$(3),$(4))) |
---|
51 | endef |
---|
52 | define cross4 |
---|
53 | $(call cross,$(1),$(2),$(call cross3,$(1),$(3),$(4),$(5))) |
---|
54 | endef |
---|
55 | define cross5 |
---|
56 | $(call cross,$(1),$(2),$(call cross4,$(1),$(3),$(4),$(5),$(6))) |
---|
57 | endef |
---|
58 | |
---|
59 | OP_MOVEMENTS=stack queue |
---|
60 | OP_POLARITIES=insfirst inslast |
---|
61 | OP_ACCESSORS=allhead inselem remelem |
---|
62 | FX_SOLUTIONS=lq-tailq lq-list cfa-cfa upp-upp cpp-stlref |
---|
63 | |
---|
64 | OPS=$(call cross3,-,$(OP_MOVEMENTS),$(OP_POLARITIES),$(OP_ACCESSORS)) |
---|
65 | FXS=$(FX_SOLUTIONS) |
---|
66 | |
---|
67 | all : perfprogs results-latest.csv |
---|
68 | |
---|
69 | # Want to add functional dependency: |
---|
70 | # if current FX_SOLUTION is lq-list then |
---|
71 | # current OP_MOVEMENT must be stack and |
---|
72 | # current OP_POLARITY must be insfirst |
---|
73 | LQ_LIST_INCOMPAT_OP_MOVEMENTS=$(filter-out stack,$(OP_MOVEMENTS)) |
---|
74 | LQ_LIST_INCOMPAT_OP_POLARITIES=$(filter-out insfirst,$(OP_POLARITIES)) |
---|
75 | LQ_LIST_INCOMPAT_OPS=$(call cross3,-,$(LQ_LIST_INCOMPAT_OP_MOVEMENTS),$(OP_POLARITIES),$(OP_ACCESSORS)) \ |
---|
76 | $(call cross3,-,$(OP_MOVEMENTS),$(LQ_LIST_INCOMPAT_OP_POLARITIES),$(OP_ACCESSORS)) |
---|
77 | INCOMPAT=$(call cross,--,lq-list,$(LQ_LIST_INCOMPAT_OPS)) |
---|
78 | define filterFds |
---|
79 | $(filter-out $(INCOMPAT),$(1)) |
---|
80 | endef |
---|
81 | |
---|
82 | |
---|
83 | CORES_FULL=$(call cross,--,$(FXS),$(OPS)) # lq-tailq--stack-inslast-allhead |
---|
84 | CORES=$(call filterFds,$(CORES_FULL)) # lq-tailq--stack-inslast-allhead |
---|
85 | |
---|
86 | |
---|
87 | PERFPROGS=$(call cross,--,perfexp,$(CORES)) |
---|
88 | |
---|
89 | perfprogs : $(PERFPROGS) |
---|
90 | |
---|
91 | perfexp--% driver--%.o result--%.1csv : FX=$(call proj,--,$@,2) |
---|
92 | perfexp--% driver--%.o result--%.1csv : FX_COARSE=$(call proj,-,$(FX),1) |
---|
93 | perfexp--% driver--%.o result--%.1csv : OP=$(call proj,--,$@,3) |
---|
94 | perfexp--% driver--%.o result--%.1csv : OP_MOVEMENT=$(call proj,-,$(OP),1) |
---|
95 | perfexp--% driver--%.o result--%.1csv : OP_POLARITY=$(call proj,-,$(OP),2) |
---|
96 | perfexp--% driver--%.o result--%.1csv : OP_ACCESSOR=$(call proj,-,$(OP),3) |
---|
97 | perfexp--% driver--%.o result--%.1csv : OP_DEFINES=-DOP_MOVEMENT=$(OP_MOVEMENT) -DOP_POLARITY=$(OP_POLARITY) -DOP_ACCESSOR=$(OP_ACCESSOR) |
---|
98 | |
---|
99 | perfexp--cfa-% driver--cfa-%.o : COMPILER=$(CFA) $(PERFFLAGS_CFA) |
---|
100 | perfexp--lq-% driver--lq-%.o : COMPILER=$(CC) $(PERFFLAGS_CC) |
---|
101 | perfexp--cpp-% driver--cpp-%.o : COMPILER=$(CXX) $(PERFFLAGS_CXX) |
---|
102 | perfexp--upp-% driver--upp-%.o : COMPILER=$(UXX) $(PERFFLAGS_UXX) |
---|
103 | perfexp--% driver--%.o : COMPILER=NO-COMPILER-FOR-$(FX_COARSE) |
---|
104 | |
---|
105 | perfexp--% : driver--%.o observation.o |
---|
106 | $(COMPILER) $(EXTRA_COMP_FLAGS) $^ -o $@ |
---|
107 | |
---|
108 | driver--%.o : driver.c |
---|
109 | $(COMPILER) $(EXTRA_COMP_FLAGS) -c $< $(OP_DEFINES) -include op-$(OP).h -include fx-$(FX).h -o $@ -MMD |
---|
110 | |
---|
111 | sayhi: |
---|
112 | echo $(PERFPROGS) |
---|
113 | |
---|
114 | |
---|
115 | RUN_REP_IDS=$(shell echo {1..$(RUN_NUM_REPS)}) # 1 2 3 |
---|
116 | RUN_REP_EXTS=$(call cross3,,run,$(RUN_REP_IDS),.1csv) # run1.1csv run2.1cav run3.1csv |
---|
117 | |
---|
118 | RESULT1S=$(call cross,.,$(CORES),$(RUN_REP_EXTS)) # lq-tailq--stack-inslast-allhead.run2.1csv |
---|
119 | |
---|
120 | RESULT1S_SHUFD=$(shell shuf -e $(RESULT1S)) |
---|
121 | |
---|
122 | %.1csv : CORE=$(basename $(basename $@)) |
---|
123 | %.1csv : REP_ID=$(subst .run,,$(suffix $(basename $@))) |
---|
124 | %.1csv : REP_TIME=$(shell date '+%F %H:%M:%S') |
---|
125 | %.1csv : perfprogs FORCE |
---|
126 | ./perfexp--$(CORE) $(RUNARGS) | xargs -n 1 printf '%s,%s,%s\n' "$(REP_TIME)" "$(REP_ID)" | tee $@ |
---|
127 | |
---|
128 | BATCHTIME=$(shell date '+%F--%H-%M-%S') |
---|
129 | |
---|
130 | results--$(BATCHTIME).csv : $(RESULT1S_SHUFD) |
---|
131 | cat $^ | tee $@ |
---|
132 | rm $^ |
---|
133 | |
---|
134 | results-latest.csv : results--$(BATCHTIME).csv |
---|
135 | rm -f $@ |
---|
136 | ln -s $< $@ |
---|
137 | |
---|
138 | |
---|
139 | |
---|
140 | clean : |
---|
141 | rm -f *.o *.d perfexp--* |
---|
142 | |
---|
143 | # The FORCE business means any target that mentions it is also phony |
---|
144 | # https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html says: To always rebuild a pattern rule consider using a “force target” (see [https://www.gnu.org/software/make/manual/html_node/Force-Targets.html]). |
---|
145 | .PHONY: all perfprogs results-latest.csv clean |
---|
146 | FORCE: |
---|
147 | |
---|
148 | .PRECIOUS: result--%.1csv driver--%.o perfexp--% %.o |
---|
149 | |
---|
150 | -include *.d |
---|