-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (94 loc) · 3.93 KB
/
Copy pathMakefile
File metadata and controls
126 lines (94 loc) · 3.93 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
CC = cc
CXX = c++
CFLAGS = -Wall -Wextra -I.
CXXFLAGS = -Wall -Wextra -I.
LDLIBS = -lm
# Examples
EXAMPLES = $(patsubst %.c,%,$(wildcard examples/*.c))
EXAMPLES_CXX = $(patsubst %.cpp,%,$(wildcard examples/*.cpp))
# Tests
TESTS = $(patsubst %.c,%,$(wildcard tests/*.c))
# ZAP benchmarks
ZAP_BENCH_DIR = tests/bench/zap
ZAP_BENCHES = $(ZAP_BENCH_DIR)/bench_zap_blas1 \
$(ZAP_BENCH_DIR)/bench_zap_blas2 \
$(ZAP_BENCH_DIR)/bench_zap_blas3 \
$(ZAP_BENCH_DIR)/bench_zap_reductions \
$(ZAP_BENCH_DIR)/bench_zap_decomp \
$(ZAP_BENCH_DIR)/bench_zap_solvers \
$(ZAP_BENCH_DIR)/bench_zap_matrix_ops \
$(ZAP_BENCH_DIR)/bench_zap_advanced \
$(ZAP_BENCH_DIR)/bench_zap_trsv \
$(ZAP_BENCH_DIR)/bench_zap_elementwise \
$(ZAP_BENCH_DIR)/bench_zap_stats \
$(ZAP_BENCH_DIR)/bench_zap_norms \
$(ZAP_BENCH_DIR)/bench_zap_misc
.PHONY: all examples test check clean \
bench bench-zap bench-zap-blas1 bench-zap-blas2 bench-zap-blas3 \
bench-zap-reductions bench-zap-decomp bench-zap-solvers \
bench-zap-matrix-ops bench-zap-advanced bench-zap-trsv \
bench-zap-elementwise bench-zap-stats bench-zap-norms bench-zap-misc
all: examples test
examples: $(EXAMPLES) $(EXAMPLES_CXX)
test: $(TESTS)
examples/%: examples/%.c mat.h
$(CC) $(CFLAGS) -o $@ $< $(LDLIBS)
examples/%: examples/%.cpp mat.h
$(CXX) $(CXXFLAGS) -o $@ $< $(LDLIBS)
# Exclude ZAP benchmarks from generic test rule (they need -O3)
tests/%: tests/%.c mat.h
@if echo "$@" | grep -q "bench/zap"; then \
$(CC) $(CFLAGS) -O3 -o $@ $< $(LDLIBS); \
else \
$(CC) $(CFLAGS) -o $@ $< $(LDLIBS); \
fi
check: test
@for t in $(TESTS); do echo "Running $$t..."; ./$$t || exit 1; done
@echo "All tests passed!"
# ZAP benchmark build rules
$(ZAP_BENCH_DIR)/%: $(ZAP_BENCH_DIR)/%.c $(ZAP_BENCH_DIR)/zap.h mat.h
$(CC) $(CFLAGS) -O3 -o $@ $< $(LDLIBS)
# Main benchmark target (uses ZAP)
bench: bench-zap
# ZAP benchmark targets
bench-zap: $(ZAP_BENCHES)
@for b in $(ZAP_BENCHES); do echo "Running $$b..."; ./$$b || exit 1; done
bench-zap-blas1: $(ZAP_BENCH_DIR)/bench_zap_blas1
./$(ZAP_BENCH_DIR)/bench_zap_blas1
bench-zap-blas2: $(ZAP_BENCH_DIR)/bench_zap_blas2
./$(ZAP_BENCH_DIR)/bench_zap_blas2
bench-zap-blas3: $(ZAP_BENCH_DIR)/bench_zap_blas3
./$(ZAP_BENCH_DIR)/bench_zap_blas3
bench-zap-reductions: $(ZAP_BENCH_DIR)/bench_zap_reductions
./$(ZAP_BENCH_DIR)/bench_zap_reductions
bench-zap-decomp: $(ZAP_BENCH_DIR)/bench_zap_decomp
./$(ZAP_BENCH_DIR)/bench_zap_decomp
bench-zap-solvers: $(ZAP_BENCH_DIR)/bench_zap_solvers
./$(ZAP_BENCH_DIR)/bench_zap_solvers
bench-zap-matrix-ops: $(ZAP_BENCH_DIR)/bench_zap_matrix_ops
./$(ZAP_BENCH_DIR)/bench_zap_matrix_ops
bench-zap-advanced: $(ZAP_BENCH_DIR)/bench_zap_advanced
./$(ZAP_BENCH_DIR)/bench_zap_advanced
bench-zap-trsv: $(ZAP_BENCH_DIR)/bench_zap_trsv
./$(ZAP_BENCH_DIR)/bench_zap_trsv
bench-zap-elementwise: $(ZAP_BENCH_DIR)/bench_zap_elementwise
./$(ZAP_BENCH_DIR)/bench_zap_elementwise
bench-zap-stats: $(ZAP_BENCH_DIR)/bench_zap_stats
./$(ZAP_BENCH_DIR)/bench_zap_stats
bench-zap-norms: $(ZAP_BENCH_DIR)/bench_zap_norms
./$(ZAP_BENCH_DIR)/bench_zap_norms
bench-zap-misc: $(ZAP_BENCH_DIR)/bench_zap_misc
./$(ZAP_BENCH_DIR)/bench_zap_misc
# Compare benchmarks (vs Eigen and OpenBLAS)
COMPARE_BENCH_DIR = tests/bench/compare
COMPARE_CXXFLAGS = $(CXXFLAGS) -O3 -I$(COMPARE_BENCH_DIR) -I$(ZAP_BENCH_DIR)
COMPARE_LDLIBS = $(LDLIBS) -lopenblas -llapacke
$(COMPARE_BENCH_DIR)/%: $(COMPARE_BENCH_DIR)/%.cpp $(ZAP_BENCH_DIR)/zap.h mat.h
$(CXX) $(COMPARE_CXXFLAGS) -o $@ $< $(COMPARE_LDLIBS)
bench-compare-eigvals: $(COMPARE_BENCH_DIR)/bench_eigvals
./$(COMPARE_BENCH_DIR)/bench_eigvals
bench-compare-svd: $(COMPARE_BENCH_DIR)/bench_svd
./$(COMPARE_BENCH_DIR)/bench_svd
clean:
find examples tests -type f ! -name "*.c" ! -name "*.cpp" ! -name "*.h" -delete
rm -rf examples/*.dSYM tests/*.dSYM