-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (53 loc) · 2.33 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
##############################################################
# Makefile #
# #
# Author : Cristobal Navarro <crinavar@dcc.uchile.cl> #
# Version : 1.0 #
# Date : September 2015 #
# Description : Compiles the program #
##############################################################
# hierarchy, names
BIN := ./bin
OBJ := ./obj
SRC := ./src
DEP := ./dep
EXEC := trueke
CXXFLAGS := -O3 -g -fopenmp
# paths
CUDA_ROOT ?= /opt/cuda
CUDA_INSTALL_PATH ?= $(CUDA_ROOT)
CUDA_SDK_PATH ?= $(CUDA_ROOT)/samples
# compiler, include and lib parameters
NVCC ?= $(CUDA_INSTALL_PATH)/bin/nvcc
INCD = -I"$(CUDA_SDK_PATH)/common/inc" -I"$(CUDA_INSTALL_PATH)/include" -I"./" -I"/usr/include/nvidia/gdk/"
LIBS = -lcuda -L"$(CUDA_INSTALL_PATH)/lib64" -lcudart -L"$(CUDA_SDK_PATH)/common/lib" -lpthread -lnvidia-ml -lgomp
# compiler flags
SPECIAL_FLAGS = --compiler-options -fno-strict-aliasing,-O3,-march=native,-msse4,-mfpmath=sse,-funroll-loops,-finline-functions -Xcompiler -fopenmp -Xcompiler
NVCCFLAGS := -m64 -arch sm_70 -lineinfo -O3 -Xptxas -dlcm=cg ${SPECIAL_FLAGS} -D_FORCE_INLINES
DEBUG_NVCCFLAGS := --ptxas-options=-v -G -g-ccbin /usr/bin/g++ -Xptxas -dlcm=cg
# source files
CPP_SOURCES := $(wildcard $(SRC)/*.cpp)
CPP_HEADERS := $(wildcard $(SRC)/*.h)
CU_SOURCES := $(wildcard $(SRC)/*.cu)
CU_HEADERS := $(wildcard $(SRC)/*.cuh)
# object files
CPP_OBJS := $(patsubst $(SRC)/%.cpp, $(OBJ)/%.o, $(CPP_SOURCES))
CU_OBJS := $(patsubst $(SRC)/%.cu, $(OBJ)/%.cuo, $(CU_SOURCES))
# dependencies
CPP_DEPS := $(patsubst $(OBJ)/%.o, $(DEP)/%.d,$(CPP_OBJS))
CU_DEPS := $(patsubst $(OBJ)/%.cuo, $(DEP)/%.cud,$(CU_OBJS))
all: $(EXEC)
$(OBJ)/%.cuo : $(SRC)/%.cu
$(NVCC) $(NVCCFLAGS) -c $(INCD) -o $@ $<
$(NVCC) $(NVCCFLAGS) $(INCD) -M $(SRC)/$*.cu -MT $(OBJ)/$*.cuo > $(DEP)/$*.cud
$(OBJ)/%.o: $(SRC)/%.cpp
$(CXX) -c $(CXXFLAGS) $(INCD) -o $@ $<
$(CXX) -M $(SRC)/$*.cpp -MT $(OBJ)/$*.o > $(DEP)/$*.d
# rules
$(EXEC): $(CPP_OBJS) $(CU_OBJS)
$(CXX) -o $(BIN)/$(EXEC) $(CU_OBJS) $(CPP_OBJS) $(LDFLAGS) $(INCD) $(LIBS)
clean:
rm -f $(BIN)/$(EXEC) $(OBJ)/*.o $(OBJ)/*.cuo $(DEP)/*.cud $(DEP)/*.d
# include dependency files
-include $(CU_DEPS)
-include $(CPP_DEPS)