[pipepar] Improve benchmark run

* Ensure benchmarks run with warm cache
* Run benchmarks 10 times
* Log benchmarks
* Factorize code by using macro
This commit is contained in:
Thomas Preud'homme 2012-09-03 11:47:26 +02:00
parent a578c33577
commit 3d17a4db90
1 changed files with 29 additions and 7 deletions

View File

@ -1,41 +1,63 @@
CFLAGS?=-Wall -Wextra
ifeq ($(shell perf --help 2>/dev/null >/dev/null && echo y),y)
runntimes = perf stat -r $(1) $(2)
runntimesandlog = script -a -c "$(runntimes)" $(3)
else
# Run a command several times
# @param N Number of time to run the command
# @param cmd Command to run
# @result Run command cmd N times
runntimes = for runi in $$(seq $(1)) ; do time $(2) ; done
runntimesandlog = touch $(3) ; { $(runntimes) } >>$(3) 2>&1
endif
test:
$(call runntimes,5,echo toto)
$(call runntimesandlog,5,echo toto,tototest)
all: allfmr alllattice alltemplate
allfmr: fmr_omp-str_base-prog fmr_omp-str_base-prog-fopenmp
alllattice: lattice-prog-1 lattice-prog-fopenmp-2 lattice-prog-fopenmp-4 lattice-prog-fopenmp-8
alllattice: lattice-prog-1 lattice-prog-fopenmp-2 lattice-prog-fopenmp-4 lattice-prog-fopenmp-8 lattice-prog-fopenmp-12
alltemplate: pipeline_template-prog-1 pipeline_template-prog-fopenmp-2 pipeline_template-prog-fopenmp-4 pipeline_template-prog-fopenmp-8
alltemplate: pipeline_template-prog-1 pipeline_template-prog-fopenmp-2 pipeline_template-prog-fopenmp-4 pipeline_template-prog-fopenmp-8 pipeline_template-prog-fopenmp-12
runall: runallfmr runalllattice runalltemplate
runallfmr: runfmrprog runfmrprog-fopenmp
runalllattice: runlatticeprog-1 runlatticeprog-fopenmp-2 runlatticeprog-fopenmp-4 runlatticeprog-fopenmp-8
runalllattice: runlatticeprog-1 runlatticeprog-fopenmp-2 runlatticeprog-fopenmp-4 runlatticeprog-fopenmp-8 runlatticeprog-fopenmp-12
runalltemplate: runtemplateprog-1 runtemplateprog-fopenmp-2 runtemplateprog-fopenmp-4 runtemplateprog-fopenmp-8
runalltemplate: runtemplateprog-1 runtemplateprog-fopenmp-2 runtemplateprog-fopenmp-4 runtemplateprog-fopenmp-8 runtemplateprog-fopenmp-12
fmr_omp-str_base-%: fmr_omp-str_base.c
gcc $(CFLAGS) $(subst prog,,$*) -o $@ $< -lm
runfmr%: fmr_omp-str_base-%
script -c "perf stat -r 10 ./$< input_20.dat" logs/$<-$$(date +%Y-%m-%d_%H-%M-%S).log
mkdir -p logs
./$< input_20.dat 2>/dev/null
$(call runntimesandlog,10,./$< input_20.dat,logs/$<-$$(date +%Y-%m-%d_%H-%M-%S).log)
rm fmr_omp-str_base-$*.txt
lattice-prog-%: lattice.c
NUM=$*;OPT=-$*;gcc $(CFLAGS) -DNB_CORES=$${NUM##*-} $${OPT%-*} -o $@ $<
runlattice%: lattice-%
script -c "perf stat -r 10 ./$< -p 50" logs/$<-$$(date +%Y-%m-%d_%H-%M-%S).log
mkdir -p logs
./$< -p 50 2>/dev/null
$(call runntimesandlog,10,./$< -p 50,logs/$<-$$(date +%Y-%m-%d_%H-%M-%S).log)
pipeline_template-prog-%: pipeline_template.c
NUM=$*;OPT=-$*;gcc $(CFLAGS) -DNB_CORES=$${NUM##*-} $${OPT%-*} -o $@ $< -lrt
runtemplate%: pipeline_template-%
mkdir -p logs
./$< -p 12500 2>/dev/null
logFile=logs/$<-$$(date +%Y-%m-%d_%H-%M-%S).log ; touch $$logFile ; \
for pkts in 12500 25000 50000 100000 200000 400000 800000 1600000 3200000 6400000 12800000 25600000 51200000 ; \
do script -a -c "perf stat -r 10 ./$< -p $$pkts" $$logFile ; \
do $(call runntimesandlog,10,./$< -p $$pkts,$$logFile) ; \
done
.PHONY: all allfmr alllattice runall runfmr runfmr% runlattice runlattice%