Skip to content

Commit

Permalink
#33 preparing for SAC
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ committed Sep 13, 2024
1 parent fbc88e2 commit 2ec60b1
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions c++/jj.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
###############################################################################
# makefile
###############################################################################

.ONESHELL:

###############################################################################

COM = clang++ g++
CSV = $(wildcard *.csv)
EXE = $(basename $(SRC))
OPT = -O2 -O3
OUT = csv
REP = 15
SIZ = 512 1024 2048
SRC = $(wildcard *.cc)
STD = -std=c++17
WRK = g h i

###############################################################################

CXXFLAGS = -flto -march=native -O3 -std=c++17 -Wall $(XTR) $(XT2)

###############################################################################

all: data

att: $(ATT)

clean:
-rm -fv $(CSV) $(EXE) core* nohup.out *~

exe: $(EXE)

perf:
@sudo bash -c "echo -1 > /proc/sys/kernel/perf_event_paranoid"

pre: perf
@for i in $(COM) perf; do
hash $$i || $$(echo "$$i not found!!!" && exit 1)
done

###############################################################################

data:
@make -s exp | tee $${HOSTNAME%%.*}-$$(date '+%Y%m%d-%H%M%S').$(OUT)

exp: pre
@LANG=C
case "$(OUT)" in
csv)
FORMAT='%s;%s;%s;%s;%s;%s;%s;%s\n'
printf $$FORMAT compiler opt std program length work 'energy' 'time'
;;
txt)
FORMAT='#%11s%12s%12s%12s%12s%12s%12s%12s\n'
printf '#%108s\n' | tr ' ' '-'
printf $$FORMAT compiler opt std program length work 'energy(J)' 'time(s)'
printf '#%108s\n' | tr ' ' '-'
FORMAT='%12s%12s%12s%12s%12s%12s%12s%12s\n'
;;
*)
echo "Unknown file extension: '$(OUT)'"
exit 1;
;;
esac
for compiler in $(COM); do
for opt in $(OPT); do
for std in $(STD); do
for exe in $(EXE); do
make -Bs $$exe XTR=$$opt XT2=$$std
for size in $(SIZ); do
for work in $(WRK); do
for run in $$(seq -w 0 $$(( $(REP) - 1 ))); do
-perf stat -a -e power/energy-pkg/ 2> /tmp/stat.txt -- ./$$exe -s $$size -w $$work
energy=$$(sed -n 's/\([[:digit:].,]*\) Joules .*/\1/p' /tmp/stat.txt)
cpu=$$(grep seconds /tmp/stat.txt | tr -s ' ' | cut -d' ' -f2)
printf $$FORMAT $$compiler $$opt $$std $$exe $$size $$work $$energy $$cpu
done
done
done
done
done
done
done

quick:
@make -s data OUT=txt REP=1 SIZ=1

###############################################################################
# pruebas
###############################################################################

xps: vector | pre
@for (( i=0; i<6; ++i )); do
-perf stat -a -e power/energy-cores/,power/energy-gpu/,power/energy-pkg/,power/energy-psys/,power/energy-ram/ -r 10 -- ./$< $$i > /dev/null
done

###############################################################################

.PHONY: all att clean csv data exe exp perf pre quick xps

###############################################################################

0 comments on commit 2ec60b1

Please sign in to comment.