| 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 | # Without this %.d rule, ordinary make runs have noise about the recipe for driver--%.o being ill-formed when called on a *.d.
|
|---|
| 106 | # https://stackoverflow.com/questions/3714041/why-does-this-makefile-execute-a-target-on-make-clean
|
|---|
| 107 | # Whatever you -include gets called as a target first.
|
|---|
| 108 | # One such example is driver--upp-upp--stack-insfirst-allhead.d
|
|---|
| 109 | # Without this %.d rule, `make make driver--upp-upp--stack-insfirst-allhead.d` leads to the rule for driver--%.o firing.
|
|---|
| 110 | # Though my dumb human eyes don't see the pattern as matching.
|
|---|
| 111 | %.d:
|
|---|
| 112 | @touch $@
|
|---|
| 113 |
|
|---|
| 114 | perfexp--% : driver--%.o observation.o
|
|---|
| 115 | $(COMPILER) $(EXTRA_COMP_FLAGS) $^ -o $@
|
|---|
| 116 |
|
|---|
| 117 | driver--%.o : driver.c
|
|---|
| 118 | $(COMPILER) $(EXTRA_COMP_FLAGS) -c $< $(OP_DEFINES) -include op-$(OP).h -include fx-$(FX).h -o $@ -MMD
|
|---|
| 119 |
|
|---|
| 120 | sayhi:
|
|---|
| 121 | echo $(PERFPROGS)
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 | RUN_REP_IDS=$(shell echo {1..$(RUN_NUM_REPS)}) # 1 2 3
|
|---|
| 125 | RUN_REP_EXTS=$(call cross3,,run,$(RUN_REP_IDS),.1csv) # run1.1csv run2.1cav run3.1csv
|
|---|
| 126 |
|
|---|
| 127 | RESULT1S=$(call cross,.,$(CORES),$(RUN_REP_EXTS)) # lq-tailq--stack-inslast-allhead.run2.1csv
|
|---|
| 128 |
|
|---|
| 129 | RESULT1S_SHUFD=$(shell shuf -e $(RESULT1S))
|
|---|
| 130 |
|
|---|
| 131 | %.1csv : CORE=$(basename $(basename $@))
|
|---|
| 132 | %.1csv : REP_ID=$(subst .run,,$(suffix $(basename $@)))
|
|---|
| 133 | %.1csv : REP_TIME=$(shell date '+%F %H:%M:%S')
|
|---|
| 134 | %.1csv : perfprogs FORCE
|
|---|
| 135 | ./perfexp--$(CORE) $(RUNARGS) | xargs -n 1 printf '%s,%s,%s\n' "$(REP_TIME)" "$(REP_ID)" | tee $@
|
|---|
| 136 |
|
|---|
| 137 | BATCHTIME=$(shell date '+%F--%H-%M-%S')
|
|---|
| 138 |
|
|---|
| 139 | results--$(BATCHTIME).csv : $(RESULT1S_SHUFD)
|
|---|
| 140 | cat $^ | tee $@
|
|---|
| 141 | rm $^
|
|---|
| 142 |
|
|---|
| 143 | results-latest.csv : results--$(BATCHTIME).csv
|
|---|
| 144 | rm -f $@
|
|---|
| 145 | ln -s $< $@
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 | clean :
|
|---|
| 150 | rm -f *.o *.d perfexp--*
|
|---|
| 151 |
|
|---|
| 152 | # The FORCE business means any target that mentions it is also phony
|
|---|
| 153 | # 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]).
|
|---|
| 154 | .PHONY: all perfprogs results-latest.csv clean
|
|---|
| 155 | FORCE:
|
|---|
| 156 |
|
|---|
| 157 | .PRECIOUS: result--%.1csv driver--%.o perfexp--% %.o
|
|---|
| 158 |
|
|---|
| 159 | -include *.d
|
|---|