-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
58 lines (42 loc) · 1.58 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
CC = nvcc
SOURCEDIR = ./
EXE = main
SOURCES = $(SOURCEDIR)/MTTKRP.cpp \
$(SOURCEDIR)/convert.cpp \
$(SOURCEDIR)/readtensor.cpp \
$(SOURCEDIR)/tensor.cpp
CU_SOURCES = $(SOURCEDIR)/gpuMTTKRP.cu
IDIR = -I/usr/local/cuda/samples/common/inc -I/home/labuser/splatt-1.1.1/include
LDIR = -L/usr/local/cuda/lib64
H_FILES = $(wildcard *.h)
OBJS = $(SOURCES:.cpp=.o)
CU_OBJS=$(CU_SOURCES:.cu=.o)
DOUBLEFLAGS = -DDOUBLE
TYPEFLAGS = -DLONG
#typeflags = -DLONG -DINT -DSHORT -DCHAR
CFLAGS = -O3 -std=c++11 -Xcompiler -fopenmp $(DOUBLEFLAGS) $(TYPEFLAGS)
LFLAGS = -lm -lstdc++ -lsplatt
SMS ?= 35 37 50 52 60
#SMS ?= 20 30 35 37 50 52 60
ifeq ($(SMS),)
$(info >>> WARNING - no SM architectures have been specified - waiving sample <<<)
SAMPLE_ENABLED := 0
endif
ifeq ($(GENCODE_FLAGS),)
# Generate SASS code for each SM architecture listed in $(SMS)
$(foreach sm,$(SMS),$(eval GENCODE_FLAGS += -gencode arch=compute_$(sm),code=sm_$(sm)))
# Generate PTX code from the highest SM architecture in $(SMS) to guarantee forward-compatibility
HIGHEST_SM := $(lastword $(sort $(SMS)))
ifneq ($(HIGHEST_SM),)
GENCODE_FLAGS += -gencode arch=compute_$(HIGHEST_SM),code=compute_$(HIGHEST_SM)
endif
endif
NVCCFLGAS = -O3 -std=c++11 $(DOUBLEFLAGS) $(TYPEFLAGS) -Xptxas -dlcm=ca -Xptxas -v
$(EXE) : $(OBJS) $(CU_OBJS)
$(CC) $(CFLAGS) $(LFLAGS) $(GENCODE_FLAGS) -o $@ $?
$(SOURCEDIR)/%.o: $(SOURCEDIR)/%.cpp $(H_FILES)
$(CC) $(CFLAGS) $(LFLAGS) $(IDIR) -c -o $@ $<
$(SOURCEDIR)/%.o: $(SOURCEDIR)/%.cu $(H_FILES)
$(CC) $(NVCCFLGAS) $(LFLAGS) $(GENCODE_FLAGS) $(IDIR) -c -o $@ $<
clean:
rm -f *.o main