-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathMakefile
66 lines (51 loc) · 1.49 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
CC ?= gcc
CFLAGS_common ?= -Wall -std=gnu99
CFLAGS_orig = -O0
CFLAGS_opt = -O0 -pthread -g -pg
ifdef CHECK_LEAK
CFLAGS_common += -fsanitize=address -fno-omit-frame-pointer
endif
ifdef THREAD
CFLAGS_opt += -D THREAD_NUM=${THREAD}
endif
ifeq ($(strip $(DEBUG)),1)
CFLAGS_opt += -DDEBUG -g
endif
EXEC = phonebook_orig phonebook_opt
GIT_HOOKS := .git/hooks/applied
.PHONY: all
all: $(GIT_HOOKS) $(EXEC)
$(GIT_HOOKS):
@scripts/install-git-hooks
@echo
SRCS_common = main.c
tools/text_align: text_align.c tools/tool-text_align.c
$(CC) $(CFLAGS_common) $^ -o $@
phonebook_orig: $(SRCS_common) phonebook_orig.c phonebook_orig.h
$(CC) $(CFLAGS_common) $(CFLAGS_orig) \
-DIMPL="\"[email protected]\"" -o $@ \
$(SRCS_common) [email protected]
phonebook_opt: $(SRCS_common) phonebook_opt.c phonebook_opt.h text_align.c
$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
-DIMPL="\"[email protected]\"" -o $@ \
$(SRCS_common) [email protected] text_align.c
run: $(EXEC)
echo 3 | sudo tee /proc/sys/vm/drop_caches
watch -d -t "./phonebook_orig && echo 3 | sudo tee /proc/sys/vm/drop_caches"
cache-test: $(EXEC)
perf stat --repeat 100 \
-e cache-misses,cache-references,instructions,cycles \
./phonebook_orig
perf stat --repeat 100 \
-e cache-misses,cache-references,instructions,cycles \
./phonebook_opt
output.txt: cache-test calculate
./calculate
plot: output.txt
gnuplot scripts/runtime.gp
calculate: calculate.c
$(CC) $(CFLAGS_common) $^ -o $@
.PHONY: clean
clean:
$(RM) $(EXEC) *.o perf.* \
calculate orig.txt opt.txt output.txt runtime.png align.txt