Skip to content

Commit 660be8b

Browse files
author
luckybulldozer
committed
Adding SiftGPU for CUDA
Very rough… just to see if it works.
1 parent 0ccfc31 commit 660be8b

File tree

1 file changed

+207
-0
lines changed

1 file changed

+207
-0
lines changed

makefileSiftGPU_Cuda

+207
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
#################################################################
2+
# SiftGPU congiruation: CUDA, SSE, TIMING
3+
#################################################################
4+
#enable siftgpu server
5+
siftgpu_enable_server = 0
6+
#enable OpenCL-based SiftGPU? not finished yet; testing purpose
7+
siftgpu_enable_opencl = 0
8+
#------------------------------------------------------------------------------------------------
9+
# enable CUDA-based SiftGPU?
10+
simple_find_cuda = $(shell locate libcudart.so)
11+
ifneq ($(simple_find_cuda), )
12+
siftgpu_enable_cuda = 1
13+
else
14+
siftgpu_enable_cuda = 0
15+
endif
16+
17+
CUDA_INSTALL_PATH = /usr/local/cuda
18+
#change additional settings, like SM version here if it is not 1.0 (eg. -arch sm_13 for GTX280)
19+
#siftgpu_cuda_options = -Xopencc -OPT:unroll_size=200000
20+
#siftgpu_cuda_options = -arch sm_10
21+
#--------------------------------------------------------------------------------------------------
22+
# enable SSE optimization for GL-based implementations
23+
siftgpu_enable_sse = 1
24+
siftgpu_sse_options = -march=core2 -mfpmath=sse
25+
#--------------------------------------------------------------------------------------------------
26+
# openGL context creation. 1 for glut, 0 for xlib
27+
siftgpu_prefer_glut = 1
28+
#whether remove dependency on DevIL (1 to remove, the output libsiftgpu.so still works for VisualSFM)
29+
siftgpu_disable_devil = 0
30+
#------------------------------------------------------------------------------------------------
31+
#whether SimpleSIFT uses runtime loading of libsiftgpu.so or static linking of libsiftgpu.a
32+
simplesift_runtime_load = 1
33+
34+
#################################################################
35+
36+
37+
# cleanup trailing whitespaces for a few settings
38+
siftgpu_enable_cuda := $(strip $(siftgpu_enable_cuda))
39+
siftgpu_disable_devil := $(strip $(siftgpu_disable_devil))
40+
siftgpu_enable_server := $(strip $(siftgpu_enable_server))
41+
siftgpu_enable_opencl := $(strip $(siftgpu_enable_opencl))
42+
siftgpu_prefer_glut := $(strip $(siftgpu_prefer_glut))
43+
simplesift_runtime_load := $(strip $(simplesift_runtime_load))
44+
45+
# detect OS
46+
OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:])
47+
OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:])
48+
DARWIN = $(strip $(findstring DARWIN, $(OSUPPER)))
49+
50+
51+
SHELL = /bin/sh
52+
INC_DIR = include
53+
BIN_DIR = bin
54+
SRC_SIFTGPU = src/SiftGPU
55+
SRC_DRIVER = src/TestWin
56+
SRC_SERVER = src/ServerSiftGPU
57+
CC = g++-4.8
58+
CFLAGS = -I$(INC_DIR) -fPIC -L/usr/lib -L./bin -L./lib -Wall -Wno-deprecated -pthread
59+
60+
#simple hack to repalce the native flat on OSX because gcc version is low
61+
ifneq ($(DARWIN),)
62+
siftgpu_sse_options = -march=core2 -mfpmath=sse
63+
endif
64+
65+
ifneq ($(siftgpu_enable_sse), 0)
66+
CFLAGS += $(siftgpu_sse_options)
67+
endif
68+
69+
ifneq ($(siftgpu_prefer_glut), 0)
70+
CFLAGS += -DWINDOW_PREFER_GLUT
71+
endif
72+
73+
ifneq ($(siftgpu_enable_opencl), 0)
74+
CFLAGS += -DCL_SIFTGPU_ENABLED
75+
endif
76+
77+
ODIR_SIFTGPU = build
78+
79+
80+
# external header files
81+
_HEADER_EXTERNAL = GL/glew.h GL/glut.h IL/il.h
82+
# siftgpu header files
83+
_HEADER_SIFTGPU = FrameBufferObject.h GlobalUtil.h GLTexImage.h ProgramGPU.h ShaderMan.h ProgramGLSL.h SiftGPU.h SiftPyramid.h SiftMatch.h PyramidGL.h LiteWindow.h
84+
# siftgpu library header files for drivers
85+
_HEADER_SIFTGPU_LIB = SiftGPU.h
86+
87+
ifneq ($(DARWIN),)
88+
#librarys for SiftGPU
89+
LIBS_SIFTGPU = -lGLEW -framework GLUT -framework OpenGL
90+
CFLAGS += -L/usr/local/lib
91+
else
92+
#librarys for SiftGPU
93+
LIBS_SIFTGPU = -lGLEW -lglut -lGL -lX11
94+
endif
95+
96+
ifneq ($(siftgpu_disable_devil), 0)
97+
CFLAGS += -DSIFTGPU_NO_DEVIL
98+
else
99+
LIBS_SIFTGPU += -lIL
100+
endif
101+
102+
#Obj files for SiftGPU
103+
_OBJ_SIFTGPU = FrameBufferObject.o GlobalUtil.o GLTexImage.o ProgramGLSL.o ProgramGPU.o ShaderMan.o SiftGPU.o SiftPyramid.o PyramidGL.o SiftMatch.o
104+
105+
#add cuda options
106+
ifneq ($(siftgpu_enable_cuda), 0)
107+
ifdef CUDA_BIN_PATH
108+
NVCC = /Developer/NVIDIA/CUDA-7.0/bin/nvcc
109+
else
110+
NVCC = /Developer/NVIDIA/CUDA-7.0/bin/nvcc
111+
endif
112+
113+
ifndef CUDA_INC_PATH
114+
CUDA_INC_PATH = /Developer/NVIDIA/CUDA-7.0/include
115+
endif
116+
117+
ifndef CUDA_LIB_PATH
118+
CUDA_LIB_PATH = -L/Developer/NVIDIA/CUDA-7.0/lib
119+
endif
120+
121+
CFLAGS += -DCUDA_SIFTGPU_ENABLED -I/Developer/NVIDIA/CUDA-7.0/include -L/Developer/NVIDIA/CUDA-7.0/lib
122+
LIBS_SIFTGPU += -lcudart
123+
_OBJ_SIFTGPU += CuTexImage.o PyramidCU.o SiftMatchCU.o
124+
_HEADER_SIFTGPU += CuTexImage.h ProgramCU.h PyramidCU.h
125+
endif
126+
127+
ifneq ($(siftgpu_enable_opencl), 0)
128+
CFLAGS += -lOpenCL
129+
endif
130+
131+
all: makepath siftgpu server driver
132+
133+
134+
#the dependencies of SiftGPU library
135+
DEPS_SIFTGPU = $(patsubst %, $(SRC_SIFTGPU)/%, $(_HEADER_SIFTGPU))
136+
137+
138+
#rules for the rest of the object files
139+
$(ODIR_SIFTGPU)/%.o: $(SRC_SIFTGPU)/%.cpp $(DEPS_SIFTGPU)
140+
$(CC) -o $@ $< $(CFLAGS) -c
141+
142+
143+
ifneq ($(siftgpu_enable_cuda), 0)
144+
NVCC_FLAGS = -I$(INC_DIR) -I$(CUDA_INC_PATH) -DCUDA_SIFTGPU_ENABLED -O2 -Xcompiler -fPIC
145+
ifdef siftgpu_cuda_options
146+
NVCC_FLAGS += $(siftgpu_cuda_options)
147+
endif
148+
#build rule for CUDA
149+
$(ODIR_SIFTGPU)/ProgramCU.o: $(SRC_SIFTGPU)/ProgramCU.cu $(DEPS_SIFTGPU)
150+
$(NVCC) $(NVCC_FLAGS) -o $@ $< -c
151+
_OBJ_SIFTGPU += ProgramCU.o
152+
endif
153+
154+
155+
ifneq ($(siftgpu_enable_server), 0)
156+
$(ODIR_SIFTGPU)/ServerSiftGPU.o: $(SRC_SERVER)/ServerSiftGPU.cpp $(DEPS_SIFTGPU)
157+
$(CC) -o $@ $< $(CFLAGS) -DSERVER_SIFTGPU_ENABLED -c
158+
_OBJ_SIFTGPU += ServerSiftGPU.o
159+
endif
160+
161+
OBJ_SIFTGPU = $(patsubst %,$(ODIR_SIFTGPU)/%,$(_OBJ_SIFTGPU))
162+
LIBS_DRIVER = $(BIN_DIR)/libsiftgpu.a $(LIBS_SIFTGPU)
163+
SRC_TESTWIN = $(SRC_DRIVER)/TestWinGlut.cpp $(SRC_DRIVER)/BasicTestWin.cpp
164+
DEP_TESTWIN = $(SRC_DRIVER)/TestWinGlut.h $(SRC_DRIVER)/BasicTestwin.h $(SRC_DRIVER)/GLTransform.h
165+
166+
167+
168+
ifneq ($(simplesift_runtime_load), 0)
169+
LIBS_SIMPLESIFT = -ldl -DSIFTGPU_DLL_RUNTIME
170+
else
171+
LIBS_SIMPLESIFT = $(LIBS_DRIVER) -DSIFTGPU_STATIC
172+
endif
173+
174+
siftgpu: makepath $(OBJ_SIFTGPU)
175+
ar rcs $(BIN_DIR)/libsiftgpu.a $(OBJ_SIFTGPU)
176+
$(CC) -o $(BIN_DIR)/libsiftgpu.so $(OBJ_SIFTGPU) $(LIBS_SIFTGPU) $(CFLAGS) -shared -fPIC
177+
178+
driver: makepath
179+
$(CC) -o $(BIN_DIR)/TestWinGlut $(SRC_TESTWIN) $(LIBS_DRIVER) $(CFLAGS)
180+
$(CC) -o $(BIN_DIR)/SimpleSIFT $(SRC_DRIVER)/SimpleSIFT.cpp $(LIBS_SIMPLESIFT) $(CFLAGS)
181+
$(CC) -o $(BIN_DIR)/speed $(SRC_DRIVER)/speed.cpp $(LIBS_DRIVER) $(CFLAGS)
182+
$(CC) -o $(BIN_DIR)/MultiThreadSIFT $(SRC_DRIVER)/MultiThreadSIFT.cpp $(LIBS_DRIVER) $(CFLAGS) -pthread
183+
184+
ifneq ($(siftgpu_enable_server), 0)
185+
server: makepath
186+
$(CC) -o $(BIN_DIR)/server_siftgpu $(SRC_SERVER)/server.cpp $(LIBS_DRIVER) $(CFLAGS)
187+
else
188+
server:
189+
190+
endif
191+
192+
makepath:
193+
mkdir -p $(ODIR_SIFTGPU)
194+
mkdir -p $(BIN_DIR)
195+
sed -i -e 's/\\/\//g' demos/*.bat
196+
197+
clean:
198+
rm -f $(ODIR_SIFTGPU)/*.o
199+
rm -f $(BIN_DIR)/libsiftgpu.a
200+
rm -f $(BIN_DIR)/libsiftgpu.so
201+
rm -f $(BIN_DIR)/TestWinGlut
202+
rm -f $(BIN_DIR)/SimpleSIFT
203+
rm -f $(BIN_DIR)/speed
204+
rm -f $(BIN_DIR)/server_siftgpu
205+
rm -f $(BIN_DIR)/MultiThreadSIFT
206+
rm -f ProgramCU.linkinfo
207+

0 commit comments

Comments
 (0)