SHOW:
|
|
- or go back to the newest paste.
1 | ################################################################################ | |
2 | # | |
3 | # Copyright 1993-2006 NVIDIA Corporation. All rights reserved. | |
4 | # | |
5 | # NOTICE TO USER: | |
6 | # | |
7 | # This source code is subject to NVIDIA ownership rights under U.S. and | |
8 | # international Copyright laws. | |
9 | # | |
10 | # NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE | |
11 | # CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR | |
12 | # IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH | |
13 | # REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF | |
14 | # MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. | |
15 | # IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, | |
16 | # OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | |
17 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE | |
18 | # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE | |
19 | # OR PERFORMANCE OF THIS SOURCE CODE. | |
20 | # | |
21 | # U.S. Government End Users. This source code is a "commercial item" as | |
22 | # that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of | |
23 | # "commercial computer software" and "commercial computer software | |
24 | # documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) | |
25 | # and is provided to the U.S. Government only as a commercial end item. | |
26 | # Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through | |
27 | # 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the | |
28 | # source code with only those rights set forth herein. | |
29 | # | |
30 | ################################################################################ | |
31 | # | |
32 | # Build script for project | |
33 | # | |
34 | ################################################################################ | |
35 | ||
36 | # Add source files here | |
37 | EXECUTABLE := gpu_md5 | |
38 | # CUDA source files (compiled with cudacc) | |
39 | CUFILES := cuda_md5_gpu.cu | |
40 | # CUDA dependency files | |
41 | CU_DEPS := \ | |
42 | ||
43 | # C++ source files (compiled with gcc for c++) | |
44 | CCFILES := \ | |
45 | cuda_md5.c\ | |
46 | cuda_md5_cpu.c\ | |
47 | \ | |
48 | ||
49 | ################################################################################ | |
50 | # Rules and targets | |
51 | ||
52 | #include common.mk | |
53 | ||
54 | ||
55 | ||
56 | ################################################################################ | |
57 | # | |
58 | # Copyright 1993-2006 NVIDIA Corporation. All rights reserved. | |
59 | # | |
60 | # NOTICE TO USER: | |
61 | # | |
62 | # This source code is subject to NVIDIA ownership rights under U.S. and | |
63 | # international Copyright laws. | |
64 | # | |
65 | # NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE | |
66 | # CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR | |
67 | # IMPLIED WARRANTY OF ANY KIND. NVIDIA DISCLAIMS ALL WARRANTIES WITH | |
68 | # REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF | |
69 | # MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. | |
70 | # IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, | |
71 | # OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS | |
72 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE | |
73 | # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE | |
74 | # OR PERFORMANCE OF THIS SOURCE CODE. | |
75 | # | |
76 | # U.S. Government End Users. This source code is a "commercial item" as | |
77 | # that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting of | |
78 | # "commercial computer software" and "commercial computer software | |
79 | # documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) | |
80 | # and is provided to the U.S. Government only as a commercial end item. | |
81 | # Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through | |
82 | # 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the | |
83 | # source code with only those rights set forth herein. | |
84 | # | |
85 | ################################################################################ | |
86 | # | |
87 | # Common build script | |
88 | # | |
89 | # Modified by TitanMKD for BackTrack4 | |
90 | # | |
91 | ################################################################################ | |
92 | ||
93 | .SUFFIXES : .cu .cu_dbg.o .c_dbg.o .cpp_dbg.o .cu_rel.o .c_rel.o .cpp_rel.o .cubin | |
94 | ||
95 | # Add new SM Versions here as devices with new Compute Capability are released | |
96 | SM_VERSIONS := sm_10 sm_11 sm_12 sm_13 | |
97 | ||
98 | CUDA_INSTALL_PATH ?= /usr/local/cuda | |
99 | ||
100 | ifdef cuda-install | |
101 | CUDA_INSTALL_PATH := $(cuda-install) | |
102 | endif | |
103 | ||
104 | # detect OS | |
105 | OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:]) | |
106 | OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:]) | |
107 | # 'linux' is output for Linux system, 'darwin' for OS X | |
108 | DARWIN = $(strip $(findstring DARWIN, $(OSUPPER))) | |
109 | ||
110 | # Basic directory setup for SDK | |
111 | # (override directories only if they are not already defined) | |
112 | SRCDIR ?= | |
113 | ROOTDIR ?= .. | |
114 | ROOTBINDIR ?= bin | |
115 | BINDIR ?= $(ROOTBINDIR)/$(OSLOWER) | |
116 | ROOTOBJDIR ?= obj | |
117 | LIBDIR := $(ROOTDIR)/../lib64 | |
118 | COMMONDIR := $(ROOTDIR)/../common | |
119 | NVIDIA_SDK_PATH := /opt/cuda/NVIDIA_CUDA_SDK | |
120 | ||
121 | # Compilers | |
122 | NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc | |
123 | CXX := gcc | |
124 | CC := gcc | |
125 | LINK := gcc -fPIC | |
126 | ||
127 | # Includes | |
128 | INCLUDES += -I. -I$(CUDA_INSTALL_PATH)/include -I$(COMMONDIR)/inc -I$(NVIDIA_SDK_PATH)/common/inc -I$(NVIDIA_SDK_PATH)/common | |
129 | ||
130 | # architecture flag for cubin build | |
131 | CUBIN_ARCH_FLAG := -m32 | |
132 | ||
133 | # Warning flags | |
134 | CXXWARN_FLAGS := \ | |
135 | -W \ | |
136 | -Wimplicit \ | |
137 | -Wswitch \ | |
138 | -Wformat \ | |
139 | -Wchar-subscripts \ | |
140 | -Wparentheses \ | |
141 | -Wmultichar \ | |
142 | -Wtrigraphs \ | |
143 | -Wpointer-arith \ | |
144 | -Wcast-align \ | |
145 | -Wreturn-type \ | |
146 | -Wno-unused-function \ | |
147 | $(SPACE) | |
148 | ||
149 | CWARN_FLAGS := $(CXXWARN_FLAGS) \ | |
150 | -Wstrict-prototypes \ | |
151 | -Wmissing-prototypes \ | |
152 | -Wmissing-declarations \ | |
153 | -Wnested-externs \ | |
154 | -Wmain \ | |
155 | ||
156 | # Compiler-specific flags | |
157 | NVCCFLAGS := | |
158 | CXXFLAGS := $(CXXWARN_FLAGS) | |
159 | CFLAGS := $(CWARN_FLAGS) $(CXXWARN_FLAGS) | |
160 | ||
161 | # Common flags | |
162 | COMMONFLAGS += $(INCLUDES) -DUNIX | |
163 | ||
164 | # Debug/release configuration | |
165 | ifeq ($(dbg),1) | |
166 | COMMONFLAGS += -g | |
167 | NVCCFLAGS += -D_DEBUG | |
168 | BINSUBDIR := debug | |
169 | LIBSUFFIX := D | |
170 | else | |
171 | COMMONFLAGS += -O3 | |
172 | BINSUBDIR := release | |
173 | LIBSUFFIX := | |
174 | NVCCFLAGS += --compiler-options -fno-strict-aliasing | |
175 | CXXFLAGS += -fno-strict-aliasing | |
176 | CFLAGS += -fno-strict-aliasing | |
177 | endif | |
178 | ||
179 | # append optional arch/SM version flags (such as -arch sm_11) | |
180 | #NVCCFLAGS += $(SMVERSIONFLAGS) | |
181 | ||
182 | # architecture flag for cubin build | |
183 | CUBIN_ARCH_FLAG := -m32 | |
184 | ||
185 | # detect if 32 bit or 64 bit system | |
186 | HP_64 = $(shell uname -m | grep 64) | |
187 | ||
188 | # OpenGL is used or not (if it is used, then it is necessary to include GLEW) | |
189 | ifeq ($(USEGLLIB),1) | |
190 | ||
191 | ifneq ($(DARWIN),) | |
192 | OPENGLLIB := -L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL -lGLU $(COMMONDIR)/lib/$(OSLOWER)/libGLEW.a | |
193 | else | |
194 | OPENGLLIB := -lGL -lGLU -lX11 -lXi -lXmu | |
195 | ||
196 | ifeq "$(strip $(HP_64))" "" | |
197 | OPENGLLIB += -lGLEW -L/usr/X11R6/lib | |
198 | else | |
199 | OPENGLLIB += -lGLEW_x86_64 -L/usr/X11R6/lib64 | |
200 | endif | |
201 | endif | |
202 | ||
203 | CUBIN_ARCH_FLAG := -m64 | |
204 | endif | |
205 | ||
206 | ifeq ($(USEGLUT),1) | |
207 | ifneq ($(DARWIN),) | |
208 | OPENGLLIB += -framework GLUT | |
209 | else | |
210 | OPENGLLIB += -lglut | |
211 | endif | |
212 | endif | |
213 | ||
214 | ifeq ($(USEPARAMGL),1) | |
215 | PARAMGLLIB := -lparamgl$(LIBSUFFIX) | |
216 | endif | |
217 | ||
218 | ifeq ($(USERENDERCHECKGL),1) | |
219 | RENDERCHECKGLLIB := -lrendercheckgl$(LIBSUFFIX) | |
220 | endif | |
221 | ||
222 | ifeq ($(USECUDPP), 1) | |
223 | ifeq "$(strip $(HP_64))" "" | |
224 | CUDPPLIB := -lcudpp | |
225 | else | |
226 | CUDPPLIB := -lcudpp64 | |
227 | endif | |
228 | ||
229 | CUDPPLIB := $(CUDPPLIB)$(LIBSUFFIX) | |
230 | ||
231 | ifeq ($(emu), 1) | |
232 | CUDPPLIB := $(CUDPPLIB)_emu | |
233 | endif | |
234 | endif | |
235 | ||
236 | # Libs | |
237 | LIB := -L$(CUDA_INSTALL_PATH)/lib64 -L$(LIBDIR) -L$(COMMONDIR)/lib64/$(OSLOWER) -L$(NVIDIA_SDK_PATH)/lib64 | |
238 | ifeq ($(USEDRVAPI),1) | |
239 | LIB += -lcuda ${OPENGLLIB} $(PARAMGLLIB) $(RENDERCHECKGLLIB) $(CUDPPLIB) ${LIB} | |
240 | else | |
241 | LIB += -lcudart ${OPENGLLIB} $(PARAMGLLIB) $(RENDERCHECKGLLIB) $(CUDPPLIB) ${LIB} | |
242 | endif | |
243 | ||
244 | ifeq ($(USECUFFT),1) | |
245 | ifeq ($(emu),1) | |
246 | LIB += -lcufftemu | |
247 | else | |
248 | LIB += -lcufft | |
249 | endif | |
250 | endif | |
251 | ||
252 | ifeq ($(USECUBLAS),1) | |
253 | ifeq ($(emu),1) | |
254 | LIB += -lcublasemu | |
255 | else | |
256 | LIB += -lcublas | |
257 | endif | |
258 | endif | |
259 | ||
260 | # Lib/exe configuration | |
261 | ifneq ($(STATIC_LIB),) | |
262 | TARGETDIR := $(LIBDIR) | |
263 | TARGET := $(subst .a,$(LIBSUFFIX).a,$(LIBDIR)/$(STATIC_LIB)) | |
264 | LINKLINE = ar qv $(TARGET) $(OBJS) | |
265 | else | |
266 | # Device emulation configuration | |
267 | ifeq ($(emu), 1) | |
268 | NVCCFLAGS += -deviceemu | |
269 | CUDACCFLAGS += | |
270 | BINSUBDIR := emu$(BINSUBDIR) | |
271 | # consistency, makes developing easier | |
272 | CXXFLAGS += -D__DEVICE_EMULATION__ | |
273 | CFLAGS += -D__DEVICE_EMULATION__ | |
274 | endif | |
275 | TARGETDIR := $(BINDIR)/$(BINSUBDIR) | |
276 | TARGET := $(TARGETDIR)/$(EXECUTABLE) | |
277 | LINKLINE = $(LINK) -o $(TARGET) $(OBJS) $(LIB) | |
278 | endif | |
279 | ||
280 | # check if verbose | |
281 | ifeq ($(verbose), 1) | |
282 | VERBOSE := | |
283 | else | |
284 | VERBOSE := @ | |
285 | endif | |
286 | ||
287 | ################################################################################ | |
288 | # Check for input flags and set compiler flags appropriately | |
289 | ################################################################################ | |
290 | ifeq ($(fastmath), 1) | |
291 | NVCCFLAGS += -use_fast_math | |
292 | endif | |
293 | ||
294 | ifeq ($(keep), 1) | |
295 | NVCCFLAGS += -keep | |
296 | NVCC_KEEP_CLEAN := *.i* *.cubin *.cu.c *.cudafe* *.fatbin.c *.ptx | |
297 | endif | |
298 | ||
299 | ifdef maxregisters | |
300 | NVCCFLAGS += -maxrregcount $(maxregisters) | |
301 | endif | |
302 | ||
303 | # Add cudacc flags | |
304 | NVCCFLAGS += $(CUDACCFLAGS) | |
305 | ||
306 | # workaround for mac os x cuda 1.1 compiler issues | |
307 | ifneq ($(DARWIN),) | |
308 | NVCCFLAGS += --host-compilation=C | |
309 | endif | |
310 | ||
311 | # Add common flags | |
312 | NVCCFLAGS += $(COMMONFLAGS) | |
313 | CXXFLAGS += $(COMMONFLAGS) | |
314 | CFLAGS += $(COMMONFLAGS) | |
315 | ||
316 | ifeq ($(nvcc_warn_verbose),1) | |
317 | NVCCFLAGS += $(addprefix --compiler-options ,$(CXXWARN_FLAGS)) | |
318 | NVCCFLAGS += --compiler-options -fno-strict-aliasing | |
319 | endif | |
320 | ||
321 | ################################################################################ | |
322 | # Set up object files | |
323 | ################################################################################ | |
324 | OBJDIR := $(ROOTOBJDIR)/$(BINSUBDIR) | |
325 | OBJS += $(patsubst %.cpp,$(OBJDIR)/%.cpp.o,$(notdir $(CCFILES))) | |
326 | OBJS += $(patsubst %.c,$(OBJDIR)/%.c.o,$(notdir $(CFILES))) | |
327 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu.o,$(notdir $(CUFILES))) | |
328 | ||
329 | ################################################################################ | |
330 | # Set up cubin files | |
331 | ################################################################################ | |
332 | CUBINDIR := $(SRCDIR)data | |
333 | CUBINS += $(patsubst %.cu,$(CUBINDIR)/%.cubin,$(notdir $(CUBINFILES))) | |
334 | ||
335 | ################################################################################ | |
336 | # Rules | |
337 | ################################################################################ | |
338 | $(OBJDIR)/%.c.o : $(SRCDIR)%.c $(C_DEPS) | |
339 | $(VERBOSE)$(CC) $(CFLAGS) -o $@ -c $< | |
340 | ||
341 | $(OBJDIR)/%.cpp.o : $(SRCDIR)%.cpp $(C_DEPS) | |
342 | $(VERBOSE)$(CXX) $(CXXFLAGS) -o $@ -c $< | |
343 | ||
344 | $(OBJDIR)/%.cu.o : $(SRCDIR)%.cu $(CU_DEPS) | |
345 | $(VERBOSE)$(NVCC) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -c $< | |
346 | ||
347 | $(CUBINDIR)/%.cubin : $(SRCDIR)%.cu cubindirectory | |
348 | $(VERBOSE)$(NVCC) $(CUBIN_ARCH_FLAG) $(NVCCFLAGS) $(SMVERSIONFLAGS) -o $@ -cubin $< | |
349 | ||
350 | # | |
351 | # The following definition is a template that gets instantiated for each SM | |
352 | # version (sm_10, sm_13, etc.) stored in SMVERSIONS. It does 2 things: | |
353 | # 1. It adds to OBJS a .cu_sm_XX.o for each .cu file it finds in CUFILES_sm_XX. | |
354 | # 2. It generates a rule for building .cu_sm_XX.o files from the corresponding | |
355 | # .cu file. | |
356 | # | |
357 | # The intended use for this is to allow Makefiles that use common.mk to compile | |
358 | # files to different Compute Capability targets (aka SM arch version). To do | |
359 | # so, in the Makefile, list files for each SM arch separately, like so: | |
360 | # | |
361 | # CUFILES_sm_10 := mycudakernel_sm10.cu app.cu | |
362 | # CUFILES_sm_12 := anothercudakernel_sm12.cu | |
363 | # | |
364 | define SMVERSION_template | |
365 | OBJS += $(patsubst %.cu,$(OBJDIR)/%.cu_$(1).o,$(notdir $(CUFILES_$(1)))) | |
366 | $(OBJDIR)/%.cu_$(1).o : $(SRCDIR)%.cu $(CU_DEPS) | |
367 | $(VERBOSE)$(NVCC) -o $$@ -c $$< $(NVCCFLAGS) -arch $(1) | |
368 | endef | |
369 | ||
370 | # This line invokes the above template for each arch version stored in | |
371 | # SM_VERSIONS. The call funtion invokes the template, and the eval | |
372 | # function interprets it as make commands. | |
373 | $(foreach smver,$(SM_VERSIONS),$(eval $(call SMVERSION_template,$(smver)))) | |
374 | ||
375 | $(TARGET): makedirectories $(OBJS) $(CUBINS) Makefile | |
376 | - | echo "$(VERBOSE)$(LINKLINE)" |
376 | + | $(VERBOSE)$(LINKLINE) |
377 | ||
378 | cubindirectory: | |
379 | $(VERBOSE)mkdir -p $(CUBINDIR) | |
380 | ||
381 | makedirectories: | |
382 | $(VERBOSE)mkdir -p $(LIBDIR) | |
383 | $(VERBOSE)mkdir -p $(OBJDIR) | |
384 | $(VERBOSE)mkdir -p $(TARGETDIR) | |
385 | ||
386 | ||
387 | tidy : | |
388 | $(VERBOSE)find . | egrep "#" | xargs rm -f | |
389 | $(VERBOSE)find . | egrep "\~" | xargs rm -f | |
390 | ||
391 | clean : tidy | |
392 | $(VERBOSE)rm -f $(OBJS) | |
393 | $(VERBOSE)rm -f $(CUBINS) | |
394 | $(VERBOSE)rm -f $(TARGET) | |
395 | $(VERBOSE)rm -f $(NVCC_KEEP_CLEAN) | |
396 | ||
397 | clobber : clean | |
398 | $(VERBOSE)rm -rf $(ROOTOBJDIR) |