Skip to content

Commit

Permalink
Refactored Makefile to include defines both to NVCC and g++.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Kamenev committed Feb 12, 2016
1 parent e25e548 commit e8ab337
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ CXX = mpic++

SOURCEDIR:= Source
INCLUDEPATH:= $(addprefix $(SOURCEDIR)/, Common/Include Math CNTK ActionsLib ComputationNetworkLib SGDLib SequenceTrainingLib CNTK/BrainScript Readers/ReaderLib)
CPPFLAGS:= -D_POSIX_SOURCE -D_XOPEN_SOURCE=600 -D__USE_XOPEN2K
CXXFLAGS:= -msse3 -std=c++0x -std=c++11 -fopenmp -fpermissive -fPIC -Werror -fcheck-new
# COMMON_FLAGS include settings that are passed both to NVCC and C++ compilers.
COMMON_FLAGS:= -D_POSIX_SOURCE -D_XOPEN_SOURCE=600 -D__USE_XOPEN2K -std=c++11
CPPFLAGS:=
CXXFLAGS:= -msse3 -std=c++0x -fopenmp -fpermissive -fPIC -Werror -fcheck-new
LIBPATH:=
LIBS:=
LDFLAGS:=
Expand All @@ -78,7 +80,7 @@ SRC:=
all : buildall
# Set up basic nvcc options and add CUDA targets from above
CUFLAGS = -std=c++11 -D_POSIX_SOURCE -D_XOPEN_SOURCE=600 -D__USE_XOPEN2K -m 64
CUFLAGS = -m 64
ifdef CUDA_PATH
ifndef GDK_PATH
Expand Down Expand Up @@ -110,26 +112,26 @@ ifdef CUDA_PATH
INCLUDEPATH += $(CUDNN_PATH)/cuda/include
LIBPATH += $(CUDNN_PATH)/cuda/lib64
LIBS += -lcudnn
CPPFLAGS +=-DUSE_CUDNN
COMMON_FLAGS +=-DUSE_CUDNN
endif
else
DEVICE = cpu
CPPFLAGS +=-DCPUONLY
COMMON_FLAGS +=-DCPUONLY
endif
ifeq ("$(MATHLIB)","acml")
INCLUDEPATH += $(ACML_PATH)/include
LIBPATH += $(ACML_PATH)/lib
LIBS += -lacml_mp -liomp5 -lm -lpthread
CPPFLAGS += -DUSE_ACML
COMMON_FLAGS += -DUSE_ACML
endif
ifeq ("$(MATHLIB)","mkl")
INCLUDEPATH += $(MKL_PATH)/mkl/include
LIBPATH += $(MKL_PATH)/compiler/lib/intel64 $(MKL_PATH)/mkl/lib/intel64 $(MKL_PATH)/compiler/lib/mic $(MKL_PATH)/mkl/lib/mic
LIBS += -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lm -liomp5 -lpthread
CPPFLAGS += -DUSE_MKL
COMMON_FLAGS += -DUSE_MKL
endif
Expand Down Expand Up @@ -161,7 +163,7 @@ ifeq ("$(BUILDTYPE)","debug")
CXXFLAGS += -g
LDFLAGS += -rdynamic
CPPFLAGS += -D_DEBUG
COMMON_FLAGS += -D_DEBUG
CUFLAGS += -O0 -g -use_fast_math -lineinfo $(GENCODE_FLAGS)
endif
Expand All @@ -174,7 +176,7 @@ ifeq ("$(BUILDTYPE)","release")
CXXFLAGS += -g -O4
LDFLAGS += -rdynamic
CPPFLAGS += -DNDEBUG
COMMON_FLAGS += -DNDEBUG
CUFLAGS += -O3 -g -use_fast_math -lineinfo $(GENCODE_FLAGS)
endif
Expand Down Expand Up @@ -245,7 +247,7 @@ MATH_SRC +=\
$(SOURCEDIR)/Math/GPUSparseMatrix.cu \
$(SOURCEDIR)/Math/GPUWatcher.cu \
$(SOURCEDIR)/Math/MatrixQuantizerGPU.cu \
$(SOURCEDIR)/Math/CuDnnConvolutionEngine.cpp \
$(SOURCEDIR)/Math/CuDnnConvolutionEngine.cu \
$(SOURCEDIR)/Math/GPUDataTransferer.cpp \
else
Expand Down Expand Up @@ -469,7 +471,7 @@ endif
INCLUDEPATH += $(SOURCEDIR)/1BitSGD
CPPFLAGS += -DQUANTIZED_GRADIENT_AGGREGATION
COMMON_FLAGS += -DQUANTIZED_GRADIENT_AGGREGATION
endif
########################################
Expand Down Expand Up @@ -549,13 +551,13 @@ $(OBJDIR)/%.o : %.cu Makefile
@echo $(SEPARATOR)
@echo creating $@ for $(ARCH) with build type $(BUILDTYPE)
@mkdir -p $(dir $@)
$(NVCC) -c $< -o $@ $(CUFLAGS) $(INCLUDEPATH:%=-I%) -Xcompiler "-fPIC -Werror"
$(NVCC) -c $< -o $@ $(COMMON_FLAGS) $(CUFLAGS) $(INCLUDEPATH:%=-I%) -Xcompiler "-fPIC -Werror"
$(OBJDIR)/%.o : %.cpp Makefile
@echo $(SEPARATOR)
@echo creating $@ for $(ARCH) with build type $(BUILDTYPE)
@mkdir -p $(dir $@)
$(CXX) -c $< -o $@ $(CPPFLAGS) $(CXXFLAGS) $(INCLUDEPATH:%=-I%) -MD -MP -MF ${@:.o=.d}
$(CXX) -c $< -o $@ $(COMMON_FLAGS) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDEPATH:%=-I%) -MD -MP -MF ${@:.o=.d}
.PHONY: force clean buildall all
Expand Down
4 changes: 2 additions & 2 deletions Source/Math/CuDnnConvolutionEngine.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace Microsoft { namespace MSR { namespace CNTK {
#endif
}

struct Operations
namespace Operations
{
template <typename T>
struct RSqrt
Expand Down Expand Up @@ -147,7 +147,7 @@ namespace Microsoft { namespace MSR { namespace CNTK {
return rsqrt(a);
}
};
};
}

// This function is used to select correct unroll factor.
// REVIEW alexeyk: ask our C++ gurus (Marko/Amit) if there is better way.
Expand Down
2 changes: 1 addition & 1 deletion Source/Math/GPUMatrix.cu
Original file line number Diff line number Diff line change
Expand Up @@ -4300,7 +4300,7 @@ void GPUMatrix<ElemType>::CreateCurandObject(unsigned long seed, const char* cal
if (s_curandGenerator == NULL)
{
unsigned long long cudaSeed = (seed == USE_TIME_BASED_SEED) ? time(NULL) : seed;
fprintf(stderr, "%s (GPU): creating curand object with seed %llu, sizeof(ElemType)==%u\n",
fprintf(stderr, "%s (GPU): creating curand object with seed %llu, sizeof(ElemType)==%lu\n",
caller, cudaSeed, sizeof(ElemType));
s_curandGenerator = new curandGenerator_t;
// Create pseudo-random number generator
Expand Down

0 comments on commit e8ab337

Please sign in to comment.