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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# Defaults that can be overridden by local.mk
CC = arm-linux-gnueabi-gcc
RUNFLAGS = --root
RUN = scripts/run-ssh.sh $(RUNFLAGS) $(BOARD)
TCL = expect
CPU = cortex-a8
CARCH = -mcpu=$(CPU) -mfpu=neon -mfloat-abi=softfp
CFLAGS = -std=c99 -W -Wall -Werror -D_GNU_SOURCE
COPT = -O2 -ffast-math -funsafe-loop-optimizations -ftree-vectorize
LIBS = -lm -lrt
EXTRA_COPT =
-include local.mk
TESTS := $(sort $(patsubst spec/%.txt, %, \
$(shell find spec -name '*.txt')))
OPTIMISED := $(patsubst %, obj/autosrc/%/compare.o, $(TESTS)) \
$(patsubst %, obj/autosrc/%/peak.o, $(TESTS)) \
obj/src/main.o
UNOPTIMISED := $(patsubst %, obj/autosrc/%/base.o, $(TESTS))
BINARIES := $(patsubst %, bin/%, $(TESTS))
RESULTS := $(patsubst %, results/%.txt, $(TESTS))
.PHONY: all bin run rerun clean distclean collect
all: bin
@make -j1 run
bin: $(BINARIES)
run: $(RESULTS)
rerun:
@rm -rf results
@make -j1 run
# Leave the binaries. If the binaries don't change next time, there's not
# point running the test again.
clean:
@rm -rf obj
distclean:
@rm -rf obj bin autosrc results
collect:
@echo "Time: $(shell date)"
@echo "CPU: $(CPU)"
@echo "Board: $(BOARD)"
@echo "Flags: $(COPT) $(EXTRA_COPT)"
@echo
@for x in $(TESTS); do \
echo "$$x: `cat results/$$x.txt`"; \
done
$(patsubst %,autosrc/%/test.h,$(TESTS)): \
autosrc/%/test.h: autosrc/%/stamp; @true
$(patsubst %,autosrc/%/compare.c,$(TESTS)): \
autosrc/%/compare.c: autosrc/%/stamp; @true
$(patsubst %,autosrc/%/base.c,$(TESTS)): \
autosrc/%/base.c: autosrc/%/stamp; @true
$(patsubst %,autosrc/%/peak.c,$(TESTS)): \
autosrc/%/peak.c: autosrc/%/stamp; @true
$(patsubst %,autosrc/%/stamp,$(TESTS)): \
autosrc/%/stamp: spec/%.txt scripts/generate.tcl
$(TCL) scripts/generate.tcl $*
@date > $@
$(patsubst %,obj/autosrc/%/compare.o,$(TESTS)): \
obj/autosrc/%/compare.o: autosrc/%/test.h
$(patsubst %,obj/autosrc/%/base.o,$(TESTS)): \
obj/autosrc/%/base.o: autosrc/%/test.h
$(patsubst %,obj/autosrc/%/peak.o,$(TESTS)): \
obj/autosrc/%/peak.o: autosrc/%/test.h
$(OPTIMISED): obj/%.o: %.c
@mkdir -p $(dir $@)
$(CC) -c $(CARCH) $(CFLAGS) $(COPT) $(EXTRA_COPT) $< -o $@
$(UNOPTIMISED): obj/%.o: %.c
@mkdir -p $(dir $@)
$(CC) -c $(CARCH) $(CFLAGS) $< -o $@
$(BINARIES): bin/%: bin/%.stamp; @true
$(patsubst %,%.stamp,$(BINARIES)): \
bin/%.stamp: \
obj/src/main.o obj/autosrc/%/compare.o obj/autosrc/%/base.o \
obj/autosrc/%/peak.o
@mkdir -p $(dir $@)
@rm -f bin/$*.new
$(CC) -o bin/$*.new $^ $(LIBS)
if ! cmp -s bin/$* bin/$*.new; then \
rm -f bin/$*; \
mv bin/$*.new bin/$*; \
fi
@date > $@
$(RESULTS): results/%.txt: bin/%
@mkdir -p $(dir $@)
$(RUN) $< > $@ 2>&1
|