2015-04-05 23:28:16 +03:00
|
|
|
# WORK IN PROGRESS, not currently complete nor usable
|
|
|
|
|
2015-06-23 02:29:36 +03:00
|
|
|
# NOTE: We are in the process of consolidating all Makefile's into a single one,
|
|
|
|
# with different build options. In the meantime, all active work will go into Makefile.gpu
|
|
|
|
# and other Makefile's, like this one, may fall behind.
|
|
|
|
|
2015-04-05 23:28:16 +03:00
|
|
|
# makefile for a Linux/GCC build of CNTK
|
|
|
|
# This needs ACML_PATH. E.g. in tcsh, say: setenv ACML_PATH C:/AMD/acml5.3.1/ifort64_mp
|
|
|
|
|
|
|
|
# This is work in progress and not at all complete or usable.
|
|
|
|
#
|
|
|
|
# The Linux and Windows versions are not different branches, but rather build off the same
|
|
|
|
# source files, using different makefiles. This current makefile has the purpose of enabling
|
|
|
|
# work to make all sources compile with GCC, and also to check for GCC-compat regressions due to
|
|
|
|
# modifications which are currently done under Windows.
|
|
|
|
#
|
|
|
|
# The planned steps are:
|
|
|
|
# - runnable non-GPU GCC-built version under Cygwin
|
|
|
|
# - get all CPU-only sources to compile with GCC/x64 under Cygwin --currently ongoing work
|
|
|
|
# - port the dynamic-loading mechanism
|
|
|
|
# - runnable non-GPU version on actual Linux
|
|
|
|
# - enable CUDA on Linux (=makefile code and figuring out the right compiler options)
|
|
|
|
#
|
|
|
|
# Any help is welcome, of course!
|
|
|
|
#
|
|
|
|
# This makefile will be extended/completed as we go.
|
|
|
|
#
|
|
|
|
# You may need to do the following or something similar for all this to work
|
|
|
|
# export LD_LIBRARY_PATH=/usr/local/acml5.3.0/gfortran64/lib:/usr/local/cuda/lib64:/usr/local/lib
|
|
|
|
# export PATH=$PATH:/usr/local/bin:/usr/local/cuda/bin
|
2015-06-12 17:21:21 +03:00
|
|
|
#
|
2015-06-05 21:22:11 +03:00
|
|
|
# WARNING:
|
|
|
|
# Since we now compile against Kaldi lattices, which depend on OpenFst, you
|
|
|
|
# will have to re-compile Kaldi with OpenFst 1.4.1 (lower version of OpenFst
|
|
|
|
# does not support c++11). You can do the following:
|
|
|
|
# 1. In kaldi-trunk/tools/Makefile, uncomment # OPENFST_VERSION = 1.4.1, and
|
|
|
|
# re-install OpenFst using the makefile.
|
|
|
|
# 2. In kaldi-trunk/src/, do ./configure --shared; make depend -j 8; make -j 8;
|
|
|
|
# and re-compile Kaldi.
|
2015-06-12 17:21:21 +03:00
|
|
|
#
|
|
|
|
# Besides, if you compile Kaldi with -O4 option instead of -g, it will be faster
|
|
|
|
# in sequence training.
|
2015-06-05 21:22:11 +03:00
|
|
|
|
2015-04-05 23:28:16 +03:00
|
|
|
CC = g++-4.8
|
|
|
|
ARCH = x86_64
|
|
|
|
DEVICE = cpu
|
|
|
|
#BUILDTYPE = debug
|
|
|
|
BUILDTYPE = release
|
|
|
|
# comment following and uncomment the next one to enable MKL library
|
2015-07-06 11:04:26 +03:00
|
|
|
#MATHLIB = acml
|
|
|
|
MATHLIB = mkl
|
2015-04-05 23:28:16 +03:00
|
|
|
# modify relevant path below for your system
|
|
|
|
MKL_PATH = /usr/users/chiaying/intel/composer_xe_2013.2.146
|
|
|
|
ACML_PATH = /usr/users/yzhang87/code/acml/gfortran64
|
|
|
|
#######
|
|
|
|
|
|
|
|
BUILDFOR = $(ARCH).$(DEVICE).$(BUILDTYPE).$(MATHLIB)
|
|
|
|
|
|
|
|
OBJDIR = .build/$(BUILDFOR)
|
|
|
|
BINDIR = bin/$(BUILDFOR)
|
|
|
|
|
|
|
|
ifeq ($(BUILDTYPE),debug)
|
|
|
|
BUILDTYPE_OPT = -g
|
|
|
|
else
|
|
|
|
BUILDTYPE_OPT = -O4
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(MATHLIB),mkl)
|
|
|
|
MATHLIB_INCLUDE = $(MKL_PATH)/mkl/include
|
|
|
|
MATHLIB_LIB = -L$(MKL_PATH)/compiler/lib/intel64 -L$(MKL_PATH)/mkl/lib/intel64 -L$(MKL_PATH)/compiler/lib/mic -L$(MKL_PATH)/mkl/lib/mic -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lm -liomp5 -lpthread
|
|
|
|
MATHLIB_DEFINE = -DUSE_MKL
|
|
|
|
else
|
|
|
|
MATHLIB_INCLUDE = $(ACML_PATH)/include
|
|
|
|
MATHLIB_LIB = -L$(ACML_PATH)/lib -lacml -lm -lpthread
|
|
|
|
MATHLIB_DEFINE = -DUSE_ACML
|
|
|
|
endif
|
|
|
|
# Add KALDI (you need to add your Kaldi path into this file)
|
2015-04-06 08:22:28 +03:00
|
|
|
include kaldi_vars.mk
|
2015-04-05 23:28:16 +03:00
|
|
|
|
2015-05-28 20:15:53 +03:00
|
|
|
INCFLAGS = -I Common/Include -I Math/Math -I MachineLearning/CNTK -I $(MATHLIB_INCLUDE) $(KALDI_INCLUDES)
|
2015-04-05 23:28:16 +03:00
|
|
|
|
|
|
|
|
2015-06-04 21:32:39 +03:00
|
|
|
CFLAGS = -msse3 -std=c++0x -std=c++11 -DCPUONLY -D_POSIX_SOURCE -D_XOPEN_SOURCE=600 -D__USE_XOPEN2K $(KALDI_DEFINES) $(MATHLIB_DEFINE) -fopenmp -fpermissive -fPIC
|
2015-04-05 23:28:16 +03:00
|
|
|
|
|
|
|
COMMON_SRC = Common/fileutil.cpp Common/DataWriter.cpp Common/ConfigFile.cpp Common/DataReader.cpp \
|
|
|
|
Common/Eval.cpp Common/File.cpp Common/BestGpu.cpp Common/TimerUtility.cpp
|
|
|
|
|
|
|
|
MATH_SRC = Math/Math/Matrix.cpp Math/Math/CPUMatrix.cpp Math/Math/CPUSparseMatrix.cpp Math/Math/NoGPU.cpp
|
2015-05-28 20:15:53 +03:00
|
|
|
CN_SRC = MachineLearning/CNTK/NetworkDescriptionLanguage.cpp MachineLearning/CNTK/CNTK.cpp MachineLearning/CNTK/ComputationNode.cpp \
|
2015-06-29 05:17:21 +03:00
|
|
|
MachineLearning/CNTK/ModelEditLanguage.cpp MachineLearning/CNTK/Profiler.cpp \
|
2015-07-06 06:51:40 +03:00
|
|
|
MachineLearning/CNTK/SimpleNetworkBuilder.cpp \
|
2015-07-06 08:28:21 +03:00
|
|
|
MachineLearning/CNTK/Profiler.cpp MachineLearning/CNTK/tests.cpp MachineLearning/CNTKEval/CNTKEval.cpp
|
2015-04-05 23:28:16 +03:00
|
|
|
BINARYREADER_SRC = DataReader/BinaryReader/BinaryWriter.cpp DataReader/BinaryReader/BinaryReader.cpp DataReader/BinaryReader/BinaryFile.cpp
|
|
|
|
HTKMLFREADER_SRC = DataReader/HTKMLFReader_linux/HTKMLFWriter.cpp DataReader/HTKMLFReader_linux/DataWriter.cpp DataReader/HTKMLFReader_linux/DataReader.cpp DataReader/HTKMLFReader_linux/HTKMLFReader.cpp
|
|
|
|
KALDIREADER_SRC = DataReader/KaldiReader/HTKMLFWriter.cpp DataReader/KaldiReader/DataWriter.cpp DataReader/KaldiReader/DataReader.cpp DataReader/KaldiReader/HTKMLFReader.cpp
|
2015-07-29 06:30:56 +03:00
|
|
|
KALDI2READER_SRC = DataReader/Kaldi2Reader/HTKMLFWriter.cpp DataReader/Kaldi2Reader/DataWriter.cpp DataReader/Kaldi2Reader/DataReader.cpp DataReader/Kaldi2Reader/HTKMLFReader.cpp DataReader/Kaldi2Reader/UtteranceDerivativeBuffer.cpp DataReader/Kaldi2Reader/KaldiSequenceTrainingDerivative.cpp
|
2015-04-05 23:28:16 +03:00
|
|
|
SEQUENCEREADER_SRC = DataReader/LMSequenceReader/SequenceReader.cpp DataReader/LMSequenceReader/SequenceParser.cpp DataReader/LMSequenceReader/Exports.cpp
|
|
|
|
LUSEQUENCEREADER_SRC = DataReader/LUSequenceReader/LUSequenceReader.cpp DataReader/LUSequenceReader/LUSequenceParser.cpp DataReader/LUSequenceReader/Exports.cpp
|
|
|
|
UCIFASTREADER_SRC = DataReader/UCIFastReader/UCIParser.cpp DataReader/UCIFastReader/UCIFastReader.cpp DataReader/UCIFastReader/Exports.cpp
|
|
|
|
READER_SRC = $(UCIFASTREADER_SRC) $(LUSEQUENCEREADER_SRC) $(HTKMLFREADER_SRC) $(SEQUENCEREADER_SRC) $(BINARYREADER_SRC) $(KALDIREADER_SRC) $(KALDI2READER_SRC)
|
|
|
|
CORE_SRC = $(CN_SRC) $(MATH_SRC) $(COMMON_SRC)
|
|
|
|
SRC = $(READER_SRC) $(CORE_SRC)
|
|
|
|
|
|
|
|
VPATH := $(sort $(dir $(SRC)))
|
|
|
|
|
|
|
|
OBJ := $(patsubst %.cpp, $(OBJDIR)/%.o, $(SRC))
|
|
|
|
CORE_OBJ := $(patsubst %.cpp, $(OBJDIR)/%.o, $(CORE_SRC))
|
|
|
|
UCIFASTREADER_OBJ := $(patsubst %.cpp, $(OBJDIR)/%.o, $(UCIFASTREADER_SRC))
|
|
|
|
LUSEQUENCEREADER_OBJ := $(patsubst %.cpp, $(OBJDIR)/%.o, $(LUSEQUENCEREADER_SRC))
|
|
|
|
HTKMLFREADER_OBJ := $(patsubst %.cpp, $(OBJDIR)/%.o, $(HTKMLFREADER_SRC))
|
|
|
|
BINARYREADER_OBJ := $(patsubst %.cpp, $(OBJDIR)/%.o, $(BINARYREADER_SRC))
|
|
|
|
SEQUENCEREADER_OBJ := $(patsubst %.cpp, $(OBJDIR)/%.o, $(SEQUENCEREADER_SRC))
|
|
|
|
KALDIREADER_OBJ := $(patsubst %.cpp, $(OBJDIR)/%.o, $(KALDIREADER_SRC))
|
|
|
|
KALDI2READER_OBJ := $(patsubst %.cpp, $(OBJDIR)/%.o, $(KALDI2READER_SRC))
|
|
|
|
|
|
|
|
DEP := $(patsubst %.o, %.d, $(OBJ))
|
|
|
|
|
|
|
|
SEPARATOR = "=-----------------------------------------------------------="
|
|
|
|
|
|
|
|
#all: $(BINDIR)/cn.exe $(BINDIR)/UCIFastReader.so $(BINDIR)/SequenceReader.so $(BINDIR)/LUSequenceReader.so $(BINDIR)/HTKMLFReader.so $(BINDIR)/BinaryReader.so
|
2015-05-28 20:15:53 +03:00
|
|
|
all: $(BINDIR)/cntk $(BINDIR)/UCIFastReader.so $(BINDIR)/LMSequenceReader.so $(BINDIR)/LUSequenceReader.so $(BINDIR)/HTKMLFReader.so $(BINDIR)/Kaldi2Reader.so
|
2015-04-05 23:28:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
ln -sf $(CURDIR)/$(BINDIR)/* bin
|
|
|
|
|
|
|
|
$(BINDIR)/UCIFastReader.so: $(UCIFASTREADER_OBJ) $(CORE_OBJ)
|
|
|
|
@echo $(SEPARATOR)
|
|
|
|
$(CC) $(BUILDTYPE_OPT) -fPIC -shared -o $@ $^
|
|
|
|
|
|
|
|
$(BINDIR)/LMSequenceReader.so: $(SEQUENCEREADER_OBJ) $(CORE_OBJ)
|
|
|
|
@echo $(SEPARATOR)
|
|
|
|
$(CC) $(BUILDTYPE_OPT) -fPIC -shared -o $@ $^
|
|
|
|
|
|
|
|
$(BINDIR)/LUSequenceReader.so: $(LUSEQUENCEREADER_OBJ) $(CORE_OBJ)
|
|
|
|
@echo $(SEPARATOR)
|
|
|
|
$(CC) $(BUILDTYPE_OPT) -fPIC -shared -o $@ $^
|
|
|
|
|
|
|
|
$(BINDIR)/HTKMLFReader.so: $(HTKMLFREADER_OBJ) $(CORE_OBJ)
|
|
|
|
@echo $(SEPARATOR)
|
|
|
|
$(CC) $(BUILDTYPE_OPT) -fPIC -shared -o $@ $^
|
|
|
|
|
|
|
|
$(BINDIR)/BinaryReader.so: $(BINARYREADER_OBJ) $(CORE_OBJ)
|
|
|
|
@echo $(SEPARATOR)
|
|
|
|
$(CC) $(BUILDTYPE_OPT) -fPIC -shared -o $@ $^
|
|
|
|
|
|
|
|
$(BINDIR)/KaldiReader.so: $(KALDIREADER_OBJ) $(CORE_OBJ)
|
|
|
|
@echo $(SEPARATOR)
|
|
|
|
$(CC) $(BUILDTYPE_OPT) -fPIC -shared -o $@ $^ $(KALDI_LIBS)
|
|
|
|
|
|
|
|
$(BINDIR)/Kaldi2Reader.so: $(KALDI2READER_OBJ) $(CORE_OBJ)
|
|
|
|
@echo $(SEPARATOR)
|
|
|
|
$(CC) $(BUILDTYPE_OPT) -fPIC -shared -o $@ $^ $(KALDI_LIBS)
|
|
|
|
|
|
|
|
|
2015-05-28 20:15:53 +03:00
|
|
|
$(BINDIR)/cntk: $(CORE_OBJ)
|
2015-04-05 23:28:16 +03:00
|
|
|
@echo $(SEPARATOR)
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@echo building output for $(ARCH) with build type $(BUILDTYPE) ...
|
|
|
|
$(CC) $(BUILDTYPE_OPT) -o $@ $^ $(MATHLIB_LIB) -fopenmp -ldl
|
|
|
|
|
|
|
|
-include $(DEP)
|
|
|
|
|
|
|
|
$(OBJDIR)/%.o : %.cpp Makefile
|
|
|
|
@echo $(SEPARATOR)
|
|
|
|
@echo creating $@ for $(ARCH) with build type $(BUILDTYPE)
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(CC) -c $< -o $@ $(BUILDTYPE_OPT) $(CPPFLAGS) $(CFLAGS) $(INCFLAGS) -MD -MP -MF ${@:.o=.d}
|
|
|
|
$(OBJDIR)/%.o : %.cc Makefile
|
|
|
|
@echo $(SEPARATOR)
|
|
|
|
@echo creating $@ for $(ARCH) with build type $(BUILDTYPE)
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
$(CC) -c $< -o $@ $(BUILDTYPE_OPT) $(CPPFLAGS) $(CFLAGS) $(INCFLAGS) -fPIC -MD -MP -MF ${@:.o=.d}
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(OBJDIR)
|
|
|
|
rm -rf $(BINDIR)
|