/
Makefile
159 lines (115 loc) · 5.63 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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
CC=gcc
CXX=g++
NVCC=nvcc
RM=rm
WARNINGS := -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-align \
-Wwrite-strings -Wmissing-declarations -Wredundant-decls \
-Winline -Wno-long-long -Wuninitialized -Wconversion
CWARNINGS := $(WARNINGS) -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes
CXXWARNINGS := $(WARNINGS)
CFLAGS := -g -fPIC -std=c99 $(CWARNINGS)
CXXFLAGS := -g $(CXXWARNINGS)
LDFLAGS := -lcuda -lgtest
CUDAINC=/opt/cuda/include
VALGRINDFLAGS := --error-exitcode=1 --leak-check=full --suppressions=valgrind.suppressions
all: test
# When building CUDA files (as all of these test cases are), nvcc does a better
# job at linking.
test_%: test_%.o
nvcc $(LDFLAGS) -o $@ $<
vtest_%: vtest_%.o
nvcc $(LDFLAGS) -o $@ $<
# This builds the test runner via dependency and runs it with and without
# Panoptes
run_%: %
(test .$<.norm_passed -nt $< ) || ( ./$< && touch .$<.norm_passed)
(test .$<.pano_passed -nt $< && test .$<.pano_passed -nt ../libpanoptes.so) || (LD_PRELOAD="../libpanoptes.so" ./$< && touch .$<.pano_passed)
# This builds the test runner (via the run_%) dependency and then runs it with
# Valgrind as well
vrun_%: % run_%
(test .$<.valg_passed -nt $< && test .$<.valg_passed -nt ../libpanoptes.so) || (LD_PRELOAD="../libpanoptes.so" valgrind $(VALGRINDFLAGS) ./$< && touch .$<.valg_passed)
arun_%: %
(test .$<.apassed -nt $<) || (./$< && touch .$<.apassed)
# Anything prefixed with test_ gets tested. Anything prefixed with vtest_ is
# tested and run under Valgrind. Tests which deliberately cause memory
# errors should not be run under Valgrind.
#
# atest: "Additional" standalone tests.
RUNNERS := $(patsubst %.cu,%,$(wildcard *test_*.cu)) $(patsubst %.cpp,%,$(wildcard *test_*.cpp))
test: $(patsubst %.cu,run_%,$(wildcard test_*.cu)) $(patsubst %.cu,vrun_%,$(wildcard vtest_*.cu)) $(patsubst %.cpp,run_%,$(wildcard test_*.cpp)) $(patsubst %.cpp,vrun_%,$(wildcard vtest_*.cpp)) $(patsubst %,arun_%,$(wildcard atest_*))
%.o: %.c Makefile
$(CC) $(CFLAGS) -fPIC -MMD -MP -c $< -o $@
%.o: %.cpp Makefile
$(CXX) $(CXXFLAGS) -fPIC -MMD -MP -I$(CUDAINC) -c $< -o $@
%.o: %.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@
test_k_assert.o: test_k_assert.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
k_atomic_kernels.o: k_atomic_kernels.cu vtest_k_atomic.h Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_12
k_atomic_kernels_generic.o: k_atomic_kernels_generic.cu vtest_k_atomic.h vtest_k_atomic_generic.h Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_atomic_generic.o: vtest_k_atomic.h vtest_k_atomic_generic.h
vtest_k_atomic_global.o: vtest_k_atomic.h
vtest_k_atomic_shared.o: vtest_k_atomic.h
vtest_k_atomic_generic: vtest_k_atomic_generic.o k_atomic_kernels_generic.o
nvcc -o vtest_k_atomic_generic $^ $(LDFLAGS)
vtest_k_atomic_global: vtest_k_atomic_global.o k_atomic_kernels.o
nvcc -o vtest_k_atomic_global $^ $(LDFLAGS)
vtest_k_atomic_shared: vtest_k_atomic_shared.o k_atomic_kernels.o
nvcc -o vtest_k_atomic_shared $^ $(LDFLAGS)
vtest_k_atomic_shared_offsets.o: vtest_k_atomic_shared_offsets.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_13
vtest_k_ballot.o: vtest_k_ballot.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_bitfield.o: vtest_k_bitfield.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_blas.o: vtest_k_blas.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_block_reductions.o: vtest_k_block_reductions.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_brev.o: vtest_k_brev.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_brkpt.o: vtest_k_brkpt.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_11
vtest_k_carry.o: vtest_k_carry.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_clz.o: vtest_k_clz.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_copysign.o: vtest_k_copysign.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_fma.o: vtest_k_fma.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_global_reductions.o: vtest_k_global_reductions.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_isspacep.o: vtest_k_isspacep.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_mulhi.o: vtest_k_mulhi.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_prefetch.o: vtest_k_prefetch.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_pmevent.o: vtest_k_pmevent.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_printf.o: vtest_k_printf.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_prmt.o: vtest_k_prmt.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_popc.o: vtest_k_popc.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_rsqrt.o: vtest_k_rsqrt.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_testp.o: vtest_k_testp.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_threadfence.o: vtest_k_threadfence.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_tex1d_sm20.o: vtest_k_tex1d_sm20.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_uniform.o: vtest_k_uniform.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_k_vote.o: vtest_k_vote.cu Makefile
$(NVCC) -g $(INCLUDEDIR) -c $< -o $@ -arch sm_20
vtest_threads: vtest_threads.o Makefile
nvcc $(LDFLAGS) -lboost_thread -o $@ $<
clean:
-$(RM) -f *.d *.o .*.*_passed $(RUNNERS) .*.apassed
.PHONY: all clean