-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.in
204 lines (153 loc) · 5.32 KB
/
Makefile.in
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# Control flags
ENABLE_BLAS = @enable_blas@
ENABLE_CUDA = @enable_cuda@
ENABLE_CUBLAS = @enable_cublas@
# Build
SRC = src
INC = inc
OBJDIR = obj
# Toolchain
CPPFLAGS = @DEFS@
CPPFLAGS += @CPPFLAGS@
CPPFLAGS += -I$(INC)
CC = @CC@
CFLAGS = @CFLAGS@
FC = @FC@
FCFLAGS = @FCFLAGS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LDFLAGS += @PTHREAD@
LIBS = @LIBS@
LIBS += @FCLIBS@
# Miscellaneous
# Most of these should probably have been resolved by autoconf, but for now
# they are configured here.
# NVCC: CUDA compiler (if available)
# CC_MAIN: Compiler used with main.o (see below)
NVCC = @NVCC@
CC_MAIN = @CC_MAIN@
CFLAGS_MAIN = $(CFLAGS)
CFLAGS_MAIN += @PTHREAD@
# Paths to platform-specific source
POSIX_TIMER_PATH = $(SRC)/@posix_timer_path@
TSC_TIMER_PATH = $(SRC)/@tsc_timer_path@
SSE_PATH = $(SRC)/@sse_path@
SSE_FMA_PATH = $(SRC)/@sse_fma_path@
AVX_PATH = $(SRC)/@avx_path@
AVX_FMA_PATH = $(SRC)/@avx_fma_path@
AVX512_PATH = $(SRC)/@avx512_path@
BLAS_PATH = $(SRC)/@cblas_path@
# Object files
# TODO: Generate this list
_OBJS = main.o input.o \
stopwatch.o stopwatch_posix.o stopwatch_tsc.o \
simd.o \
sse.o sse_fma.o \
avx.o avx_fma.o \
avx512.o \
roof_daxpy_blas.o roof_dgemm_blas.o roof_dgemm_ref.o \
roof.o kernel.o dummy.o \
gpu_roof.o gpu_simd.o \
gpu_axpy_blas.o gpu_dgemm_blas.o
ifdef ENABLE_BLAS
_OBJS += dgemm.o xerbla.o lsame.o
endif
OBJS = $(addprefix $(OBJDIR)/, $(_OBJS))
## Rules
all: optiflop
# Executable rules
optiflop: $(OBJS)
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
$(OBJS): | $(OBJDIR)
$(OBJDIR):
mkdir -p $(OBJDIR)
# Object rules
# NOTE: If compiled with nvc, then it will use objects unavailable to nvcc.
# So we use $(CC_MAIN) macro to configure this for CUDA builds when needed.
$(OBJDIR)/main.o: $(SRC)/main.c $(INC)/sse.h $(INC)/sse_fma.h $(INC)/avx.h $(INC)/roof.h $(INC)/bench.h
$(CC_MAIN) $(CPPFLAGS) $(CFLAGS_MAIN) -c -o $@ $<
$(OBJDIR)/input.o: $(SRC)/input.c $(INC)/input.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/simd.o: $(SRC)/simd.c $(INC)/bench.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/sse.o: $(SSE_PATH)/sse.c $(INC)/sse.h $(INC)/bench.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/sse_fma.o: $(SSE_FMA_PATH)/sse_fma.c $(INC)/sse_fma.h $(INC)/bench.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/avx.o: $(AVX_PATH)/avx.c $(INC)/avx.h $(INC)/bench.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/avx_fma.o: $(AVX_FMA_PATH)/avx_fma.c $(INC)/bench.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/avx512.o: $(AVX512_PATH)/avx512.c $(INC)/avx512.h $(INC)/bench.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/roof_daxpy_blas.o: $(BLAS_PATH)/roof_daxpy_blas.c $(INC)/roof.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/roof_dgemm_blas.o: $(BLAS_PATH)/roof_dgemm_blas.c $(INC)/roof.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/roof_dgemm_ref.o: $(BLAS_PATH)/roof_dgemm_ref.c $(INC)/roof.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
# dgemm.o xerbla.o lsame.o
$(OBJDIR)/%.o: src/blas/%.f
$(FC) $(FCFLAGS) -c -o $@ $<
$(OBJDIR)/roof.o: $(SRC)/roof.c $(INC)/roof.h $(INC)/bench.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/kernel.o: $(SRC)/kernel.c $(INC)/roof.h $(INC)/bench.h $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/dummy.o: $(SRC)/dummy.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/stopwatch.o: $(SRC)/stopwatch.c $(INC)/stopwatch.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/stopwatch_posix.o: $(POSIX_TIMER_PATH)/stopwatch_posix.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/stopwatch_tsc.o: $(TSC_TIMER_PATH)/stopwatch_tsc.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
ifdef ENABLE_CUDA
$(OBJDIR)/gpu_simd.o: src/cuda/gpu_simd.cu
$(NVCC) $(CPPFLAGS) -c -o $@ $<
$(OBJDIR)/gpu_roof.o: src/cuda/gpu_roof.cu
$(NVCC) $(CPPFLAGS) -c -o $@ $<
else
$(OBJDIR)/gpu_simd.o: src/generic/gpu_simd.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/gpu_roof.o: src/generic/gpu_roof.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
endif
ifdef ENABLE_CUBLAS
$(OBJDIR)/gpu_axpy_blas.o: src/cuda/gpu_axpy_blas.cu
$(NVCC) $(CPPFLAGS) -c -o $@ $<
$(OBJDIR)/gpu_dgemm_blas.o: src/cuda/gpu_dgemm_blas.cu
$(NVCC) $(CPPFLAGS) -c -o $@ $<
else
$(OBJDIR)/gpu_axpy_blas.o: src/generic/gpu_axpy_blas.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
$(OBJDIR)/gpu_dgemm_blas.o: src/generic/gpu_dgemm_blas.c
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
endif
# Update Makefile from template
Makefile: Makefile.in config.status
./config.status
# Build cleanup
clean:
$(RM) optiflop $(OBJDIR)/*.o $(INC)/*.h.gch
$(RM) -r $(OBJDIR)
# Delete any files associated with configuration (including the Makefile).
.PHONY: distclean
distclean: clean
$(RM) inc/config.h
$(RM) config.log
$(RM) config.status
$(RM) Makefile
# This deletes all files generated by autoconf, including configure.
# It is more aggressive than automake's maintainer-clean.
# NOTE: Not a standard GNU target, this is for internal use only.
# Don't be surprised if the name changes or if it disappears someday.
.PHONY: ac-clean
ac-clean: distclean
$(RM) inc/config.h.in
$(RM) inc/config.h.in~
$(RM) aclocal.m4
$(RM) -r autom4te.cache
$(RM) config.guess
$(RM) config.sub
$(RM) configure
$(RM) configure~