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