Blame view

src/kaldi.mk 4.5 KB
8dcb6dfcb   Yannick Estève   first commit
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
111
112
113
114
115
116
117
118
119
120
  # This file was generated using the following command:
  # ./configure --shared
  
  CONFIGURE_VERSION := 11
  
  # Toolchain configuration
  
  CXX = g++
  AR = ar
  AS = as
  RANLIB = ranlib
  
  # Base configuration
  
  KALDI_FLAVOR := dynamic
  KALDILIBDIR := /local_disk/orion/ontrac/yannick/kaldi_20190717/kaldi/src/lib
  DOUBLE_PRECISION = 0
  OPENFSTINC = /local_disk/orion/ontrac/yannick/kaldi_20190717/kaldi/tools/openfst-1.6.7/include
  OPENFSTLIBS = /local_disk/orion/ontrac/yannick/kaldi_20190717/kaldi/tools/openfst-1.6.7/lib/libfst.so
  OPENFSTLDFLAGS = -Wl,-rpath=/local_disk/orion/ontrac/yannick/kaldi_20190717/kaldi/tools/openfst-1.6.7/lib
  
  CUBROOT = /local_disk/orion/ontrac/yannick/kaldi_20190717/kaldi/tools/cub-1.8.0
  MKLROOT = /opt/intel/mkl
  MKLLIB = /opt/intel/mkl/lib/intel64
  
  # MKL specific Linux configuration
  
  # We have tested Kaldi with MKL version 10.2 on Linux/GCC and Intel(R) 64
  # architecture (also referred to as x86_64) with LP64 interface layer.
  
  # The linking flags for MKL will be very different depending on the OS,
  # architecture, compiler, etc. used. The correct flags can be obtained from
  # http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/
  # Use the options obtained from this website to manually configure for other
  # platforms using MKL.
  
  ifndef DOUBLE_PRECISION
  $(error DOUBLE_PRECISION not defined.)
  endif
  ifndef OPENFSTINC
  $(error OPENFSTINC not defined.)
  endif
  ifndef OPENFSTLIBS
  $(error OPENFSTLIBS not defined.)
  endif
  ifndef MKLROOT
  $(error MKLROOT not defined.)
  endif
  
  MKLLIB ?= $(MKLROOT)/lib/intel64
  
  CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
             -Wall -Wno-sign-compare -Wno-unused-local-typedefs \
             -Wno-deprecated-declarations -Winit-self \
             -DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
             -DHAVE_EXECINFO_H=1 -DHAVE_CXXABI_H -DHAVE_MKL -I$(MKLROOT)/include \
             -m64 -msse -msse2 -pthread \
             -g # -O0 -DKALDI_PARANOID
  
  ifeq ($(KALDI_FLAVOR), dynamic)
  CXXFLAGS += -fPIC
  endif
  
  # Compiler specific flags
  COMPILER = $(shell $(CXX) -v 2>&1)
  ifeq ($(findstring clang,$(COMPILER)),clang)
  # Suppress annoying clang warnings that are perfectly valid per spec.
  CXXFLAGS += -Wno-mismatched-tags
  endif
  
  ## Use the following for STATIC LINKING of the SEQUENTIAL version of MKL
  MKL_STA_SEQ = $(MKLLIB)/libmkl_solver_lp64_sequential.a -Wl,--start-group \
  	$(MKLLIB)/libmkl_intel_lp64.a $(MKLLIB)/libmkl_sequential.a \
  	$(MKLLIB)/libmkl_core.a -Wl,--end-group -lpthread
  
  ## Use the following for STATIC LINKING of the MULTI-THREADED version of MKL
  MKL_STA_MUL = $(MKLLIB)/libmkl_solver_lp64.a -Wl,--start-group \
  	$(MKLLIB)/libmkl_intel_lp64.a $(MKLLIB)/libmkl_intel_thread.a \
  	$(MKLLIB)/libmkl_core.a -Wl,--end-group $(MKLLIB)/libiomp5.a -lpthread
  
  ## Use the following for DYNAMIC LINKING of the SEQUENTIAL version of MKL
  MKL_DYN_SEQ = -L$(MKLLIB) -lmkl_solver_lp64_sequential -Wl,--start-group \
  	-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -Wl,--end-group -lpthread
  
  ## Use the following for DYNAMIC LINKING of the MULTI-THREADED version of MKL
  MKL_DYN_MUL = -L$(MKLLIB) -lmkl_solver_lp64 -Wl,--start-group -lmkl_intel_lp64 \
  	-lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -lpthread
  
  # MKLFLAGS = $(MKL_DYN_MUL)
  
  LDFLAGS = $(EXTRA_LDFLAGS) $(OPENFSTLDFLAGS) -rdynamic
  LDLIBS = $(EXTRA_LDLIBS) $(OPENFSTLIBS) $(MKLFLAGS) -lm -lpthread -ldl
  MKLFLAGS = -L/opt/intel/mkl/lib/intel64 -Wl,-rpath=/opt/intel/mkl/lib/intel64 -lmkl_intel_lp64  -lmkl_core  -lmkl_sequential    -ldl -lpthread -lm 
  
  # CUDA configuration
  
  CUDA = true
  CUDATKDIR = /usr/local/cuda
  CUDA_ARCH = -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_70,code=sm_70
  
  ifndef DOUBLE_PRECISION
  $(error DOUBLE_PRECISION not defined.)
  endif
  ifndef CUDATKDIR
  $(error CUDATKDIR not defined.)
  endif
  
  CXXFLAGS += -DHAVE_CUDA -I$(CUDATKDIR)/include -fPIC -pthread -isystem $(OPENFSTINC)
  
  CUDA_INCLUDE= -I$(CUDATKDIR)/include -I$(CUBROOT)
  CUDA_FLAGS = --machine 64 -DHAVE_CUDA \
               -ccbin $(CXX) -DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
               -std=c++11 -DCUDA_API_PER_THREAD_DEFAULT_STREAM  -lineinfo \
               --verbose -Xcompiler "$(CXXFLAGS)"
  
  CUDA_LDFLAGS += -L$(CUDATKDIR)/lib64 -Wl,-rpath,$(CUDATKDIR)/lib64
  CUDA_LDLIBS += -lcublas -lcusparse -lcudart -lcurand -lcufft -lnvToolsExt #LDLIBS : The .so libs are loaded later than static libs in implicit rule
  CUDA_LDLIBS += -lcusolver
  
  # Environment configuration