forked from VMML/vmmlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.cublas
100 lines (77 loc) · 2.98 KB
/
Makefile.cublas
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
VMMLIB_UNIT_TESTS =\
tests/unit_test.cpp\
tests/unit_test_globals.cpp\
tests/vector_test.cpp\
tests/matrix_test.cpp\
tests/quaternion_test.cpp\
tests/qr_decomposition_test.cpp\
tests/svd_test.cpp\
tests/lapack_svd_test.cpp\
tests/lapack_linear_least_squares_test.cpp\
tests/lapack_gaussian_elimination_test.cpp\
tests/vmmlib_unit_tests_main.cpp\
tests/lapack_sym_eigs_test.cpp\
tests/tensor3_test.cpp \
tests/tensor3_iterator_test.cpp \
tests/tucker3_tensor_test.cpp \
tests/qtucker3_tensor_test.cpp \
tests/tucker3_exporter_importer_test.cpp \
tests/cp3_tensor_test.cpp \
tests/t3_hosvd_test.cpp \
tests/t3_hooi_test.cpp \
tests/t3_hopm_test.cpp \
tests/t3_ihopm_test.cpp \
tests/t3_ttm_test.cpp \
tests/matrix_pseudoinverse_test.cpp \
tests/blas_dgemm_test.cpp \
tests/blas_dot_test.cpp \
VMMLIB_UNIT_TESTS_OBJECTS = ${VMMLIB_UNIT_TESTS:%.cpp=%.o}
CXXFLAGS += -I. -Iinclude -Itests -include stdint.h
# Mac OS X specific stuff
# on mac we want to use the frameworks, not the unix style libs
ARCH = $(shell uname)
ifeq "$(ARCH)" "Darwin"
CXXFLAGS += -DVMMLIB_USE_CUDA
LDFLAGS += -framework Accelerate
CUDA_INSTALL_PATH = /usr/local/cuda
CUDA_LIB := -L$(CUDA_INSTALL_PATH)/lib
else
# Linux specific stuff
CXXFLAGS += -include f2c.h -include f2c_fix.h
LBITS := $(shell getconf LONG_BIT)
ifeq ($(LBITS),64)
LIBDIR=$(DESTDIR)/usr/lib64
else
LIBDIR=$(DESTDIR)/usr/lib
endif
CXXFLAGS += -DVMMLIB_USE_LAPACK -DVMMLIB_USE_CUDA
LDFLAGS +=
CUDA_INSTALL_PATH = /opt/cuda
CUDA_LIB := -L$(CUDA_INSTALL_PATH)/lib64
# adjust libs depending on your LAPACK and BLAS distribution
LIBS += -lclapack -lf2c -lcblas
# LIBS += -llapack -lblas
endif
### if CUBLAS VMMLIB (update cuda compute compatibility) ####
CUDA_INC := -I$(CUDA_INSTALL_PATH)/include -I.
NVCC = nvcc
# -g -> debug level, -G device-debug; -O optimized level
NVCCFLAGS := -Iinclude -Itests -DVMMLIB_USE_LAPACK -DVMMLIB_USE_CUDA
CUDA_LIBS := $(CUDA_LIB) -lcuda -lcublas -lcudart
ARCHFLAGS := -arch=sm_12 -m64
### endif cublas vmmlib
all: tests/cublas_dgemm_test.o tests/cutensor_tests.o vmmlib_unit_tests
.cpp.o:
$(CXX) $(CXXFLAGS) -c $< -o $@
tests/cublas_dgemm_test.o: tests/cublas_dgemm_test.cpp
$(NVCC) $(NVCCFLAGS) $(CUDA_INC) $(CUDA_LIBS) $(ARCHFLAGS) -c tests/cublas_dgemm_test.cpp -o tests/cublas_dgemm_test.o
tests/cutensor_tests.o: tests/cutensor_tests.cpp
$(NVCC) $(NVCCFLAGS) $(CUDA_INC) $(CUDA_LIBS) $(ARCHFLAGS) -c tests/cutensor_tests.cpp -o tests/cutensor_tests.o
vmmlib_unit_tests: $(VMMLIB_UNIT_TESTS_OBJECTS)
ifeq "$(ARCH)" "Darwin"
$(CXX) $(LDFLAGS) $(CUDA_INC) $(CUDA_LIBS) $(ARCHFLAGS) $(VMMLIB_UNIT_TESTS_OBJECTS) tests/cublas_dgemm_test.o tests/cutensor_tests.o -o $@
else
$(CXX) $(LDFLAGS) $(CUDA_INC) $(CUDA_LIBS) $(ARCHFLAGS) $(VMMLIB_UNIT_TESTS_OBJECTS) $(LIBS) tests/cublas_dgemm_test.o tests/cutensor_tests.o -o $@
endif
clean:
rm -rf $(VMMLIB_UNIT_TESTS_OBJECTS) vmmlib_unit_tests tests/cublas_dgemm_test.o tests/cutensor_tests.o