-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (83 loc) · 2.97 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
#
# CS 179 Final Project
# Bhairav Chidambaram and Connor Soohoo
#
# Directories
OBJDIR = obj
SRCDIR = src
# Product Names
CUDA_OBJ = cuda.o
# Input Names
CUDA_FILES = KNN_GPU.cu
CPP_FILES = main.cpp KNN.cpp MovieLensParser.cpp
# ------------------------------------------------------------------------------
# CUDA Compiler and Flags
CUDA_PATH = /usr/local/cuda
CUDA_INC_PATH = $(CUDA_PATH)/include
CUDA_BIN_PATH = $(CUDA_PATH)/bin
CUDA_LIB_PATH = $(CUDA_PATH)/lib64
NVCC = $(CUDA_BIN_PATH)/nvcc
# OS-architecture specific flags
# OS-architecture specific flags
ifeq ($(OS_SIZE),32)
NVCC_FLAGS := -m32
else
NVCC_FLAGS := -m64
endif
NVCC_FLAGS += -g -dc -Wno-deprecated-gpu-targets --std=c++11 \
--expt-relaxed-constexpr
NVCC_INCLUDE =
NVCC_LIBS =
NVCC_GENCODES = -gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_52,code=sm_52 \
-gencode arch=compute_60,code=sm_60 \
-gencode arch=compute_61,code=sm_61 \
-gencode arch=compute_61,code=compute_61
# ------------------------------------------------------------------------------
# CUDA Linker and Flags
CUDA_LINK_FLAGS = -dlink -Wno-deprecated-gpu-targets
# ------------------------------------------------------------------------------
# C++ Compiler and Flags
GPP = g++
FLAGS = -g -Wall -D_REENTRANT -std=c++0x -pthread
INCLUDE = -I$(CUDA_INC_PATH)
LIBS = -L$(CUDA_LIB_PATH) -lcudart -lcufft -lsndfile
# ------------------------------------------------------------------------------
# Object files
# ------------------------------------------------------------------------------
# CUDA Object Files
CUDA_OBJ = $(OBJDIR)/cuda.o
CUDA_OBJ_FILES = $(addprefix $(OBJDIR)/, $(addsuffix .o, $(CUDA_FILES)))
# C++ Object Files
CPP_OBJ = $(addprefix $(OBJDIR)/, $(addsuffix .o, $(CPP_FILES)))
# ------------------------------------------------------------------------------
# Make rules
# ------------------------------------------------------------------------------
# Top level rules
all: knn
# knn-cpu <-- need to fix
knn: $(CPP_OBJ) $(CUDA_OBJ) $(CUDA_OBJ_FILES)
$(GPP) $(FLAGS) -o knn $(INCLUDE) $^ $(LIBS)
knn-cpu: $(CPP_OBJ)
$(GPP) $(FLAGS) -o knn-cpu $^
# Compile C++ Source Files
$(CPP_OBJ): $(OBJDIR)/%.o : $(SRCDIR)/%
$(GPP) $(FLAGS) -c -o $@ $(INCLUDE) $<
# Compile CUDA Source Files
$(CUDA_OBJ_FILES): $(OBJDIR)/%.cu.o : $(SRCDIR)/%.cu
$(NVCC) $(NVCC_FLAGS) $(NVCC_GENCODES) -c -o $@ $(NVCC_INCLUDE) $<
cuda: $(CUDA_OBJ_FILES) $(CUDA_OBJ)
# Make linked device code
$(CUDA_OBJ): $(CUDA_OBJ_FILES)
$(NVCC) $(CUDA_LINK_FLAGS) $(NVCC_GENCODES) -o $@ $(NVCC_INCLUDE) $^
clean:
rm -f knn knn-cpu obj/*.o
# OLD:
# KNN.o:
# $(GPP) $(FLAGS) -c src/KNN.cpp -o $(OBJDIR)/KNN.o
# MovieLensParser.o:
# $(GPP) $(FLAGS) -c src/MovieLensParser.cpp -o $(OBJDIR)/MovieLensParser.o
# main.o:
# $(GPP) $(FLAGS) -c src/main.cpp -o $(OBJDIR)/main.o