# For correctness, see test-correctness.sh. # For performance: # pushd ~/cfax # . ~/setcfa build-fast # popd # make perfprogs CFA=$cfa -j8 MODE=performance # make results-latest.csv -j4 RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=common5 # cp results-latest.csv results-baseline.csv # make results-latest.csv -j4 OP_MOVEMENTS=stack OP_POLARITIES=insfirst OP_ACCESSORS=allhead RUN_DURATION_SEC=5 RUN_NUM_REPS=5 RUN_DATA_SIZE_MODE=thorough # cp results-latest.csv results-sizing.csv CFA = cfa CXX = g++-11 UXX = ~/u++/u++-7.0.0/bin/u++ MODE=performance EXTRA_COMP_FLAGS= RUN_NUM_REPS=3 RUN_DATA_SIZE_MODE=none RUN_DURATION_SEC=5 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) # Without this %.d rule, ordinary make runs have noise about the recipe for driver--%.o being ill-formed when called on a *.d. # https://stackoverflow.com/questions/3714041/why-does-this-makefile-execute-a-target-on-make-clean # Whatever you -include gets called as a target first. # One such example is driver--upp-upp--stack-insfirst-allhead.d # Without this %.d rule, `make make driver--upp-upp--stack-insfirst-allhead.d` leads to the rule for driver--%.o firing. # Though my dumb human eyes don't see the pattern as matching. %.d: @touch $@ perfexp--% : driver--%.o observation.o $(COMPILER) $(EXTRA_COMP_FLAGS) $^ -o $@ driver--%.o : driver.c $(COMPILER) $(EXTRA_COMP_FLAGS) -c $< $(OP_DEFINES) -include op-$(OP).h -include fx-$(FX).h -o $@ -MMD sayhi: echo $(PERFPROGS) ifeq "$(RUN_DATA_SIZE_MODE)" "common5" RUN_DATA_SIZES=\ 7-1000000 \ 71-100000 \ 809-10000 \ 9051-1000 \ 72421-100 else ifeq "$(RUN_DATA_SIZE_MODE)" "thorough" RUN_DATA_SIZES=\ 7-1000000 \ 11-100000 \ 13-100000 \ 19-100000 \ 29-100000 \ 37-100000 \ 53-100000 \ 71-100000 \ 101-10000 \ 149-10000 \ 211-10000 \ 283-10000 \ 401-10000 \ 569-10000 \ 809-10000 \ 1151-1000 \ 1601-1000 \ 2267-1000 \ 3203-1000 \ 4547-1000 \ 6473-1000 \ 9051-1000 \ 12809-100 \ 18119-100 \ 25601-100 \ 36209-100 \ 51203-100 \ 72421-100 \ 102407-10 \ 144817-10 \ 204803-10 \ 289637-10 \ 409609-10 \ 579263-10 \ 819229-10 \ 1158613-1 \ 1638431-1 \ 2317057-1 \ 3276803-1 \ 4634111-1 \ 6553621-1 \ 9268211-1 else ifeq "$(RUN_DATA_SIZE_MODE)" "manual" ifeq "$(RUN_DATA_SIZES)" "" $(error RUN_DATA_SIZE_MODE is manual but RUN_DATA_SIZES not given) endif else ifeq "$(RUN_DATA_SIZE_MODE)" "none" # Assume user manages RUN_ARGS; empty RUN_ARGS just means run with compiled-in defaults RUN_DATA_SIZES=none else $(error Bad RUN_DATA_SIZE_MODE ($(RUN_DATA_SIZE_MODE)); should be common5, thorough or manual) endif 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 RUN_LAUNCHES=$(call cross,--,$(RUN_DATA_SIZES),$(RUN_REP_EXTS)) RESULT1S=$(call cross,.,$(CORES),$(RUN_LAUNCHES)) # lq-tailq--stack-inslast-allhead.run2.1csv RESULT1S_SHUFD=$(shell shuf -e $(RESULT1S)) %.1csv : CORE=$(basename $(basename $@)) %.1csv : LAUNCH=$(subst .,,$(suffix $(basename $@))) %.1csv : SIZING=$(call proj,--,$(LAUNCH),1) %.1csv : NUMNODES=$(call proj,-,$(SIZING),1) %.1csv : CHECKDONE=$(call proj,-,$(SIZING),2) %.1csv : RUN_ARGS=$(if $(filter none,$(SIZING)),,$(RUN_DURATION_SEC) $(CHECKDONE) $(NUMNODES)) %.1csv : REP_ID=$(subst run,,$(call proj,--,$(LAUNCH),2)) %.1csv : REP_TIME=$(shell date '+%F %H:%M:%S') %.1csv : perfprogs FORCE ./perfexp--$(CORE) $(RUN_ARGS) | xargs -n 1 printf '%s,%s,%s,%s\n' "$(REP_TIME)" "$(REP_ID)" "$(RUN_ARGS)" | 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