CFA = cfa CXX = g++-11 UXX = ~/u++/u++-7.0.0/bin/u++ MODE = performance RUNARGS= ifeq "$(MODE)" "performance" PERFFLAGS_CFA = -nodebug -O3 PERFFLAGS_CC = -DNDEBUG -O3 else ifeq "$(MODE)" "correctness" PERFFLAGS_CFA = -debug -O0 -g PERFFLAGS_CC = -O0 -g else $(error Bad MODE ($(MODE)); should be performance or correctness) endif PERFFLAGS_CXX = $(PERFFLAGS_CC) PERFFLAGS_UXX = $(PERFFLAGS_CC) SHELL = /usr/bin/bash # function: project an element from a filename that contains a delimited tuple # (call proj,-,a-b-c.hfa,3) # is # c define proj $(word $(3),$(subst $(1), ,$(basename $(2)))) endef # functions: cross two lists, adding given delimiter between # (call cross,-,a b c,1 2) # is # a-1 a-2 b-1 b-2 c-1 c-2 define cross $(foreach x,$(2),$(foreach xs,$(3),$(x)$(1)$(xs))) endef define cross3 $(call cross,$(1),$(2),$(call cross,$(1),$(3),$(4))) endef define cross4 $(call cross,$(1),$(2),$(call cross3,$(1),$(3),$(4),$(5))) endef define cross5 $(call cross,$(1),$(2),$(call cross4,$(1),$(3),$(4),$(5),$(6))) endef OP_MOVEMENTS=stack queue OP_POLARITIES=insfirst inslast OP_ACCESSORS=allhead inselem remelem FX_SOLUTIONS=lq-tailq lq-list cfa-cfa upp-upp cpp-stlref OPS=$(call cross3,-,$(OP_MOVEMENTS),$(OP_POLARITIES),$(OP_ACCESSORS)) FXS=$(FX_SOLUTIONS) all : perfprogs results-latest.csv # Want to add functional dependency: # if current FX_SOLUTION is lq-list then # current OP_MOVEMENT must be stack and # current OP_POLARITY must be insfirst LQ_LIST_INCOMPAT_OP_MOVEMENTS=$(filter-out stack,$(OP_MOVEMENTS)) LQ_LIST_INCOMPAT_OP_POLARITIES=$(filter-out insfirst,$(OP_POLARITIES)) LQ_LIST_INCOMPAT_OPS=$(call cross3,-,$(LQ_LIST_INCOMPAT_OP_MOVEMENTS),$(OP_POLARITIES),$(OP_ACCESSORS)) \ $(call cross3,-,$(OP_MOVEMENTS),$(LQ_LIST_INCOMPAT_OP_POLARITIES),$(OP_ACCESSORS)) INCOMPAT=$(call cross,--,lq-list,$(LQ_LIST_INCOMPAT_OPS)) define filterFds $(filter-out $(INCOMPAT),$(1)) endef CORES_FULL=$(call cross,--,$(FXS),$(OPS)) # lq-tailq--stack-inslast-allhead CORES=$(call filterFds,$(CORES_FULL)) # lq-tailq--stack-inslast-allhead PERFPROGS=$(call cross,--,perfexp,$(CORES)) perfprogs : $(PERFPROGS) perfexp--% driver--%.o result--%.1csv : FX=$(call proj,--,$@,2) perfexp--% driver--%.o result--%.1csv : FX_COARSE=$(call proj,-,$(FX),1) perfexp--% driver--%.o result--%.1csv : OP=$(call proj,--,$@,3) perfexp--% driver--%.o result--%.1csv : OP_MOVEMENT=$(call proj,-,$(OP),1) perfexp--% driver--%.o result--%.1csv : OP_POLARITY=$(call proj,-,$(OP),2) perfexp--% driver--%.o result--%.1csv : OP_ACCESSOR=$(call proj,-,$(OP),3) perfexp--% driver--%.o result--%.1csv : OP_DEFINES=-DOP_MOVEMENT=$(OP_MOVEMENT) -DOP_POLARITY=$(OP_POLARITY) -DOP_ACCESSOR=$(OP_ACCESSOR) perfexp--cfa-% driver--cfa-%.o : COMPILER=$(CFA) $(PERFFLAGS_CFA) perfexp--lq-% driver--lq-%.o : COMPILER=$(CC) $(PERFFLAGS_CC) perfexp--cpp-% driver--cpp-%.o : COMPILER=$(CXX) $(PERFFLAGS_CXX) perfexp--upp-% driver--upp-%.o : COMPILER=$(UXX) $(PERFFLAGS_UXX) perfexp--% driver--%.o : COMPILER=NO-COMPILER-FOR-$(FX_COARSE) perfexp--% : driver--%.o observation.o $(COMPILER) $^ -o $@ driver--%.o : driver.c $(COMPILER) -c $< $(OP_DEFINES) -include op-$(OP).h -include fx-$(FX).h -o $@ -MMD RUN_NUM_REPS=3 RUN_REP_IDS=$(shell echo {1..$(RUN_NUM_REPS)}) # 1 2 3 RUN_REP_EXTS=$(call cross3,,run,$(RUN_REP_IDS),.1csv) # run1.1csv run2.1cav run3.1csv RESULT1S=$(call cross,.,$(CORES),$(RUN_REP_EXTS)) # lq-tailq--stack-inslast-allhead.run2.1csv RESULT1S_SHUFD=$(shell shuf -e $(RESULT1S)) %.1csv : CORE=$(basename $(basename $@)) %.1csv : REP_ID=$(subst .run,,$(suffix $(basename $@))) %.1csv : REP_TIME=$(shell date '+%F %H:%M:%S') %.1csv : perfprogs FORCE ./perfexp--$(CORE) $(RUNARGS) | xargs -n 1 printf '%s,%s,%s\n' "$(REP_TIME)" "$(REP_ID)" | tee $@ BATCHTIME=$(shell date '+%F--%H-%M-%S') results--$(BATCHTIME).csv : $(RESULT1S_SHUFD) cat $^ | tee $@ rm $^ results-latest.csv : results--$(BATCHTIME).csv rm -f $@ ln -s $< $@ clean : rm -f *.o *.d perfexp--* # The FORCE business means any target that mentions it is also phony # 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]). .PHONY: all perfprogs results-latest.csv clean FORCE: .PRECIOUS: result--%.1csv driver--%.o perfexp--% %.o -include *.d