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