Ignore:
Timestamp:
Jun 4, 2025, 1:43:34 PM (6 months ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
master
Children:
f858ca5
Parents:
c8bdbaf
Message:

Recent rework of string benchmarks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/mike_brooks_MMath/benchmarks/string/Makefile

    rc8bdbaf re0350e0  
    1010# make measurement4 CFA_APILEVELS=ll OPERATIONS='pall' PLATFORMS=stl CFA_EXPANSIONS=-1.0                       CORPORI='corpus-1-*-1.txt'       # allocate-attrib-stl
    1111
    12 CFABUILD = ~/cfa2/build-perf
    13 LIBCFA = $(CFABUILD)/libcfa/*/src/.libs/libcfa.so
    14 
    15 CFA = $(CFABUILD)/driver/cfa
     12LIBCFA = $(cfabuild)/libcfa/*/src/.libs/libcfa.so
     13
     14CFA = $(cfabuild)/driver/cfa
    1615PERFFLAGS_CFA = -nodebug -O2
    1716PERFFLAGS_CXX = -DNDEBUG -O2 -Wl,--no-as-needed -ldl
     
    2019# function: convert to upper case
    2120define uc
    22 $(shell echo $(1) | tr  '[:lower:]' '[:upper:]')
     21$(shell echo $1 | tr  '[:lower:]' '[:upper:]')
     22endef
     23
     24# function: project numbered element of filename named by any-delimited tuple
     25# (call proj,q-w-e-r.txt,-,4) is 4.txt
     26# (call proj,q-w-e-r.foo.txt,.,1) is q-w-e-r
     27define proj
     28$(word $3,$(subst $2, ,$1))
    2329endef
    2430
    2531# function: project numbered element of filename named by hyphen-delimited tuple
    26 # (call hyphProj,q-w-e-r.txt,1) is Q
    27 define ucHyphProj
    28 $(call uc,$(word $(2),$(subst -, ,$(basename $(1)))))
     32# (call hyphProj,q-w-e-r.txt,4) is r.txt
     33define hyphProj
     34$(call proj,$1,-,$2)
     35endef
     36
     37# function: drop file extension and project element
     38# (call bnHyphProj,q-w-e-r.txt,4) is r
     39define bnHyphProj
     40$(call hyphProj,$(basename $1),$2)
     41endef
     42
     43# function: drop file extension, project element and uppercase it
     44# (call ucBnhyphProj,q-w-e-r.txt,4) is R
     45define ucBnHyphProj
     46$(call uc,$(call bnHyphProj,$1,$2))
     47endef
     48
     49# function: cross two lists, adding given delimiters
     50# (call delCross,+,a b c,1 2) is a+1 a+2 b+1 b+2 c+1 c+2
     51define delCross
     52$(foreach x,$2,$(foreach xs,$3,$(x)$1$(xs)))
     53endef
     54
     55define delCross3
     56$(call delCross,$1,$2,$(call delCross,$1,$3,$4))
     57endef
     58
     59define delCross4
     60$(call delCross,$1,$2,$(call delCross3,$1,$3,$4,$5))
     61endef
     62
     63define delCross5
     64$(call delCross,$1,$2,$(call delCross4,$1,$3,$4,$5,$6))
    2965endef
    3066
     
    3268# (call hyphCross,a b c,1 2) is a-1 a-2 b-1 b-2 c-1 c-2
    3369define hyphCross
    34 $(foreach x,$(1),$(foreach xs,$(2),$(x)-$(xs)))
     70$(call delCross,-,$1,$2)
    3571endef
    3672
    3773define hyphCross3
    38 $(call hyphCross,$(1),$(call hyphCross,$(2),$(3)))
     74$(call delCross3,-,$1,$2,$3)
    3975endef
    4076
    4177define hyphCross4
    42 $(call hyphCross,$(1),$(call hyphCross3,$(2),$(3),$(4)))
     78$(call delCross4,-,$1,$2,$3,$4)
    4379endef
    4480
    4581define hyphCross5
    46 $(call hyphCross,$(1),$(call hyphCross4,$(2),$(3),$(4),$(5)))
    47 endef
    48 
    49 OPERATIONS=pta peq pbv pall #pno
    50 ALLOCS=reuse fresh
    51 CFA_APILEVELS=hl ll
    52 CFA_SHARINGS=share noshare
    53 PLATFORMS=cfa stl #buhr94
     82$(call delCross5,-,$1,$2,$3,$4,$5)
     83endef
     84
     85OPERATIONS?=pta peq pbv pall #pno
     86ALLOCS?=reuse fresh
     87CFA_APILEVELS?=hl ll
     88CFA_SHARINGS?=share noshare
     89PLATFORMS?=cfa stl #buhr94
    5490
    5591ifneq ($(filter cfa,$(PLATFORMS)),)
     
    69105OPERATIONS_USING_ALLOCS=pta peq
    70106define enrichOperationsAllocs
    71 $(call hyphCross3,$(filter peq pta,$(OPERATIONS)),$(1),$(ALLOCS)) $(call hyphCross3,$(filter-out peq pta,$(OPERATIONS)),$(1),na)
     107$(call hyphCross3,$(filter peq pta,$(OPERATIONS)),$1,$(ALLOCS)) $(call hyphCross3,$(filter-out peq pta,$(OPERATIONS)),$1,na)
    72108endef
    73109
     
    84120        echo -e '$(PP_SPLIT)'
    85121
    86 perfexp-%.o: API=$(call ucHyphProj,$@,2)
    87 perfexp-%.o: OPERATION=$(call ucHyphProj,$@,3)
    88 perfexp-%.o: CFA_APILEVEL=$(call ucHyphProj,$@,4)
    89 perfexp-%.o: CFA_SHARING=$(call ucHyphProj,$@,5)
    90 perfexp-%.o: ALLOC=$(call ucHyphProj,$@,6)
     122perfexp-%.o: API=$(call ucBnHyphProj,$@,2)
     123perfexp-%.o: OPERATION=$(call ucBnHyphProj,$@,3)
     124perfexp-%.o: CFA_APILEVEL=$(call ucBnHyphProj,$@,4)
     125perfexp-%.o: CFA_SHARING=$(call ucBnHyphProj,$@,5)
     126perfexp-%.o: ALLOC=$(call ucBnHyphProj,$@,6)
    91127perfexp-%.o: SCENARIO_SWITCH=-DIMPL_$(API)_$(CFA_APILEVEL)_$(CFA_SHARING) -DOP_$(OPERATION) -DALLOC_$(ALLOC)
    92128
     
    150186
    151187MEASURE = $(PERFPROGS)
    152 CORPORI = corpus-100-*-1.txt
     188
     189CORPUS_MEANLEN_MODE?=auto #manual
     190CORPUS_MEANLEN_START?=1
     191CORPUS_MEANLEN_END?=500
     192CORPUS_MEANLEN_STEPS_PER_DOUBLE?=1
     193CORPUS_MEANLEN_MANVALS?=20 50 100 200 500
     194COPRUS_NSTRSS?=100
     195CORPUS_RELSCALES?=1.0
     196CORPUS_SEEDS?=9876
     197CORPUS_OFFSET_INSTRS?=t0
     198
     199CORPUS_MEANLENS_AUTO=${shell python3 gen-size-steps.py ${CORPUS_MEANLEN_START} ${CORPUS_MEANLEN_END} ${CORPUS_MEANLEN_STEPS_PER_DOUBLE}}
     200CORPUS_MEANLENS=\
     201        $(if $(filter auto,$(CORPUS_MEANLEN_MODE)),$(CORPUS_MEANLENS_AUTO), \
     202        $(if $(filter manual,$(CORPUS_MEANLEN_MODE)),$(CORPUS_MEANLEN_MANVALS), \
     203        ERROR))
     204CORPUS_SERIES_IDS=$(call delCross3,+,$(CORPUS_RELSCALES),$(CORPUS_SEEDS),$(CORPUS_OFFSET_INSTRS))
     205CORPUS_SLUGS=$(call hyphCross4,corpus,$(COPRUS_NSTRSS),$(CORPUS_MEANLENS),$(CORPUS_SERIES_IDS))
     206CORPORI=$(call delCross,.,$(CORPUS_SLUGS),txt)
     207
     208# function to interpret an offset instruction for a given mean-length,
     209# producing the pair of arguments for locn and offset
     210#
     211# An offset instruction is an opcode and natural-number argument.
     212# The opcode is either (t)ake or (l)eave.
     213# The argument is how much length to take from / leave behind.
     214# The resulting amount is deducted from the mean-length and returned in offset.
     215# The remaining mean-length is returned in locn.
     216#
     217# $(call interpOffsetInstr,20,l1) = 1 19 (i.e. constant-length 20)
     218# $(call interpOffsetInstr,20,l5) = 5 15
     219# $(call interpOffsetInstr,20,t5) = 15 5
     220# $(call interpOffsetInstr,20,t0) = 20 0 (i.e. full variability)
     221define interpOffsetInstr
     222$(strip
     223        $(eval qty := $(subst t,,$(subst l,,$2)))
     224        $(if $(filter t%,$2), $(shell expr $1 - $(qty)) $(qty),
     225        $(if $(filter l%,$2), $(qty) $(shell expr $1 - $(qty)),
     226        ERROR))
     227)
     228endef
     229
     230corpori: $(CORPORI)
     231
     232make-corpus: make-corpus.cfa
     233        $(CFA) $< -o $@
     234
     235corpus-%.txt: COPRUS_NSTRS=$(call bnHyphProj,$@,2)
     236corpus-%.txt: CORPUS_MEANLEN=$(call bnHyphProj,$@,3)
     237corpus-%.txt: CORPUS_SERIES_ID=$(call bnHyphProj,$@,4)
     238corpus-%.txt: CORPUS_RELSCALE=$(call proj,$(CORPUS_SERIES_ID),+,1)
     239corpus-%.txt: CORPUS_SEED=$(call proj,$(CORPUS_SERIES_ID),+,2)
     240corpus-%.txt: CORPUS_OFFSET_INSTR=$(call proj,$(CORPUS_SERIES_ID),+,3)
     241corpus-%.txt: make-corpus
     242        $(eval CORPUS_OFFSET_INTERPD := $(call interpOffsetInstr,$(CORPUS_MEANLEN),$(CORPUS_OFFSET_INSTR)))
     243        $(eval CORPUS_LOCN := $(word 1,$(CORPUS_OFFSET_INTERPD)))
     244        $(eval CORPUS_OFFSET := $(word 2,$(CORPUS_OFFSET_INTERPD)))
     245        ./$< $(COPRUS_NSTRS) $(CORPUS_LOCN) $(CORPUS_RELSCALE) $(CORPUS_SEED) $(CORPUS_OFFSET) > $@
    153246
    154247RUN_TASKSET_CPULIST=6
    155248
     249# both ?= and :=
     250ifeq ($(origin MEASUREMENT_TOFILE), undefined)
     251MEASUREMENT_TOFILE:=measurement-$(shell date '+%F--%H-%M-%S').output
     252endif
     253
    156254# General timing
    157 # Output file gets concatenation of program outputs
    158 measurement: $(MEASURE)
    159         tofile=measurement-`date '+%F--%H-%M-%S'`.csv ; \
    160         echo $$tofile ; \
    161         for prog in $(MEASURE) ; do \
     255# Output file gets concatenation of program outputs (one line per run)
     256measurement: $(MEASURE) corpori
     257        @echo "running $(words $(MEASURE)) programs:" $(MEASURE)
     258        @echo "... on $(words $(CORPORI)) corpori:" $(CORPORI)
     259        @echo "... for $(shell expr $(words $(MEASURE)) "*" $(words $(CORPORI))) rows into:" $(MEASUREMENT_TOFILE)
     260        @for prog in $(MEASURE) ; do \
    162261            for corpus in $(CORPORI) ; do \
    163262                        corpusbody=`cat $$corpus` ; \
    164263                        resulttext=`taskset --cpu-list $(RUN_TASKSET_CPULIST) ./$$prog 100 10 $$corpusbody` ; \
    165                         echo $$prog,$$corpus,$$resulttext  >>  $$tofile ; \
     264                        echo $$prog,$$corpus,$$resulttext  >>  $(MEASUREMENT_TOFILE) ; \
    166265                        echo $$prog,$$corpus,$$resulttext  ; \
    167266                done ; \
    168267        done
    169268
    170 CFA_EXPANSIONS=0.02 0.05 0.1 0.2 0.4 0.5 0.9 0.98
     269CFA_EXPANSIONS?=0.02 0.05 0.1 0.2 0.4 0.5 0.9 0.98
    171270
    172271# Special-case timing with extra IV for CFA_EXPANSIONS
    173272# Output file gets concatenation of program outputs (one line per run)
    174 measurement2: $(MEASURE)
    175         tofile=measurement-`date '+%F--%H-%M-%S'`.csv ; \
    176         for prog in $(MEASURE) ; do \
    177             for corpus in $(CORPORI) ; do \
    178                         for expansion in $(CFA_EXPANSIONS) ; do \
    179                                 corpusbody= ; \
    180                                 echo ./$$prog 1000 1.006 $$expansion 10 \`cat $$corpus\` ; \
    181                         done ; \
    182                 done ; \
    183         done ; \
    184         echo $$tofile ; \
    185         for prog in $(MEASURE) ; do \
     273measurement2: $(MEASURE) corpori
     274        @echo "running $(words $(MEASURE)) programs:" $(MEASURE)
     275        @echo "... on $(words $(CORPORI)) corpori:" $(CORPORI)
     276        @echo "... with $(words $(CFA_EXPANSIONS)) expansions:" $(CFA_EXPANSIONS)
     277        @echo "... for $(shell expr $(words $(MEASURE)) "*" $(words $(CORPORI)) "*" $(words $(CFA_EXPANSIONS))) rows into:" $(MEASUREMENT_TOFILE)
     278        @for prog in $(MEASURE) ; do \
    186279            for corpus in $(CORPORI) ; do \
    187280                        for expansion in $(CFA_EXPANSIONS) ; do \
    188281                                corpusbody=`cat $$corpus` ; \
    189                                 printed=`./$$prog 1000 1.006 $$expansion 10 $$corpusbody` ; \
    190                                 echo $$prog,$$corpus,$$expansion,$$printed  >>  $$tofile ; \
     282                                printed=`taskset --cpu-list $(RUN_TASKSET_CPULIST) ./$$prog 1000 1.006 $$expansion 10 $$corpusbody` ; \
     283                                echo $$prog,$$corpus,$$expansion,$$printed  >>  $(MEASUREMENT_TOFILE) ; \
    191284                                echo $$prog,$$corpus,$$expansion,$$printed  ; \
    192285                        done ; \
     
    195288
    196289# Space, with the IV for CFA_EXPANSIONS
    197 # Runs Mubeen's malloc interceptor to get malloc-request state
     290# Runs Mubeen's malloc interceptor to get malloc-request stats
    198291# Output file gets concatenation of the interceptor's output (one line per run); program's output ignorred
    199292# Expect and ignore crashes; they're during shutdown, after everything we care about is over
    200 measurement3: $(MEASURE)
    201         tofile=measurement-`date '+%F--%H-%M-%S'`.ssv ; \
    202         for prog in $(MEASURE) ; do \
     293measurement3: $(MEASURE) corpori
     294        @echo "running $(words $(MEASURE)) programs:" $(MEASURE)
     295        @echo "... on $(words $(CORPORI)) corpori:" $(CORPORI)
     296        @echo "... with $(words $(CFA_EXPANSIONS)) expansions:" $(CFA_EXPANSIONS)
     297        @echo "... for $(shell expr $(words $(MEASURE)) "*" $(words $(CORPORI))) rows into:" $(MEASUREMENT_TOFILE)
     298        @for prog in $(MEASURE) ; do \
    203299            for corpus in $(CORPORI) ; do \
    204300                        for expansion in $(CFA_EXPANSIONS) ; do \
     
    206302                                LD_PRELOAD=~/plg2/mubeen-stat-shim/malloc/mallocWrappers.so ./$$prog 1000 1.006 $$expansion 10 $$corpusbody ; \
    207303                                printed=`tail -n 1 preload_dump.txt` ; \
    208                                 echo $$prog $$corpus $$expansion $$printed  >>  $$tofile ; \
     304                                echo $$prog $$corpus $$expansion $$printed  >>  $(MEASUREMENT_TOFILE) ; \
    209305                                echo $$prog $$corpus $$expansion $$printed  ; \
    210306                                rm preload_dump.txt ; \
     
    217313# Output file gets concatenation of perf summaries (several lines per run); program's output ignorred
    218314# Expect and ignore output "addr2line: DWARF error: section .debug_info is larger than its filesize!"
    219 measurement4: $(MEASURE)
    220         RUNID=`date '+%F--%H-%M-%S'` ; \
    221         tofile=measurement-$$RUNID.ssv ; \
    222         echo $$tofile ; \
     315measurement4: $(MEASURE) corpori
     316        @echo "running $(words $(MEASURE)) programs:" $(MEASURE)
     317        @echo "... on $(words $(CORPORI)) corpori:" $(CORPORI)
     318        @echo "... with $(words $(CFA_EXPANSIONS)) expansions:" $(CFA_EXPANSIONS)
     319        @echo "... for $(shell expr $(words $(MEASURE)) "*" $(words $(CORPORI))) rows into:" $(MEASUREMENT_TOFILE)
     320        @RUNID=`date '+%F--%H-%M-%S'` ; \
    223321        for prog in $(MEASURE) ; do \
    224322            for corpus in $(CORPORI) ; do \
     
    231329                                ~/flamegraph/FlameGraph/stackcollapse-perf.pl $$SLUG.perf > $$SLUG.folded ; \
    232330                                ~/flamegraph/FlameGraph/flamegraph.pl $$SLUG.folded > $$SLUG.svg ; \
    233                                 python3 process-allocn-attrib.py $$SLUG.folded | xargs -L1 echo $$prog $$corpus $$expansion >> $$tofile ; \
     331                                python3 process-allocn-attrib.py $$SLUG.folded | xargs -L1 echo $$prog $$corpus $$expansion >> $(MEASUREMENT_TOFILE) ; \
    234332                        done ; \
    235333                done ; \
    236334        done
     335
     336
     337#
     338# Experiment-specific "summary" targets
     339#
     340
     341# These all use recursive make invocations, after setting the scoping variables.
     342# Recursive invocation necessary to recompute dependencies like corpori -> $(CORPORI).
     343# In the top-level make, the extent of the dependency is computed upfront, using
     344# default values, overridden by CLI-provided values.
     345# Setting the value per-target makes it available to other targets' bodies, but it
     346# does not affect the previously-computed dependencies.
     347# Exporting the values and working through a child make has the child intialize its
     348# dependencies using the summary-target-provided values.
     349# For that to work, the exported variable default values given above must use ?=.
     350
     351.PHONY: result-append-pbv.csv result-allocate-speed-%.csv result-allocate-speed-cfa.csv
     352
     353export OPERATIONS
     354export ALLOCS
     355export CFA_APILEVELS
     356export CFA_SHARINGS
     357export PLATFORMS
     358export CFA_EXPANSIONS
     359
     360export CORPUS_MEANLEN_MODE
     361export CORPUS_MEANLEN_START
     362export CORPUS_MEANLEN_END
     363export CORPUS_MEANLEN_STEPS_PER_DOUBLE
     364export CORPUS_MEANLEN_MANVALS
     365export COPRUS_NSTRSS
     366export CORPUS_RELSCALES
     367export CORPUS_SEEDS
     368export CORPUS_OFFSET_INSTRS
     369
     370
     371export MEASUREMENT_TOFILE
     372
     373result-ANY:
     374        $(MAKE) $(SUBTARGET)
     375
     376result-append-pbv.csv: CFA_APILEVELS=ll
     377result-append-pbv.csv: OPERATIONS=pta peq pbv
     378result-append-pbv.csv: CORPUS_OFFSET_INSTRS=t0 l1
     379result-append-pbv.csv: CORPUS_MEANLEN_STEPS_PER_DOUBLE=4
     380result-append-pbv.csv: CORPUS_SEEDS=501 502
     381result-append-pbv.csv: SUBTARGET=measurement
     382result-append-pbv.csv: result-ANY
     383        cp $(MEASUREMENT_TOFILE) $@
     384
     385result-allocate-ANY: OPERATIONS=pall
     386result-allocate-ANY: CORPUS_OFFSET_INSTRS=l15
     387result-allocate-ANY: CORPUS_MEANLEN_MODE=manual
     388result-allocate-ANY: CFA_SHARINGS=share
     389result-allocate-ANY: CORPUS_SEEDS=101 102 103 104 105
     390result-allocate-ANY: CFA_APILEVELS=ll
     391result-allocate-ANY: result-ANY
     392
     393result-allocate-ANY-cfa: PLATFORMS=cfa
     394result-allocate-ANY-cfa: result-allocate-ANY
     395
     396result-allocate-ANY-stl: PLATFORMS=stl
     397result-allocate-ANY-stl: CFA_EXPANSIONS=-1.0
     398result-allocate-ANY-stl: result-allocate-ANY
     399
     400
     401
     402
     403
     404
     405result-allocate-speed-cfa.csv: SUBTARGET=measurement2
     406result-allocate-speed-cfa.csv: result-allocate-ANY-cfa
     407        cp $(MEASUREMENT_TOFILE) $@
     408
     409result-allocate-speed-stl.csv: SUBTARGET=measurement2
     410result-allocate-speed-stl.csv: result-allocate-ANY-stl
     411        cp $(MEASUREMENT_TOFILE) $@
     412
     413# result-allocate-space-cfa.ssv: SUBTARGET=measurement3
     414# result-allocate-space-cfa.ssv: result-allocate-ANY-cfa
     415#       cp $(MEASUREMENT_TOFILE) $@
     416
     417# result-allocate-space-stl.ssv: SUBTARGET=measurement3
     418# result-allocate-space-stl.ssv: result-allocate-ANY-stl
     419#       cp $(MEASUREMENT_TOFILE) $@
     420
     421# result-allocate-attrib-cfa.ssv: SUBTARGET=measurement4
     422# result-allocate-attrib-cfa.ssv: result-allocate-ANY-cfa
     423#       cp $(MEASUREMENT_TOFILE) $@
     424
     425# result-allocate-attrib-stl.ssv: SUBTARGET=measurement4
     426# result-allocate-attrib-stl.ssv: result-allocate-ANY-stl
     427#       cp $(MEASUREMENT_TOFILE) $@
     428
     429
     430
     431
     432
     433
     434
     435# result-allocate-speed-%.csv: SUBTARGET=measurement2
     436# result-allocate-speed-%.csv: result-allocate-ANY-%
     437#       cp $(MEASUREMENT_TOFILE) $@
     438
     439result-allocate-space-%.ssv: SUBTARGET=measurement3
     440result-allocate-space-%.ssv: result-allocate-ANY-%
     441        cp $(MEASUREMENT_TOFILE) $@
     442
     443result-allocate-attrib-%.ssv: SUBTARGET=measurement4
     444result-allocate-attrib-%.ssv: result-allocate-ANY-%
     445        cp $(MEASUREMENT_TOFILE) $@
     446
     447
     448
     449
     450
     451
     452# .PHONY result-append-pbv.csv result-allocate-ANY-cfa result-allocate-speed-stl.csv
     453# result-allocate-space-cfa.csv
     454# result-allocate-space-stl.csv
     455# result-allocate-attrib-cfa.csv
     456# result-allocate-attrib-stl.csv
Note: See TracChangeset for help on using the changeset viewer.