Update release_notes.md
[platform/upstream/caffeonacl.git] / Makefile
index 787b0e8..2d5d305 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,12 @@ $(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.)
 endif
 include $(CONFIG_FILE)
 
+ifeq ($(CPU_ONLY),1)
+       USE_CUDA := 0
+endif
+ifeq ($(USE_ACL),1)
+       USE_CUDA := 0
+endif
 BUILD_DIR_LINK := $(BUILD_DIR)
 ifeq ($(RELEASE_BUILD_DIR),)
        RELEASE_BUILD_DIR := .$(BUILD_DIR)_release
@@ -34,7 +40,7 @@ LIB_BUILD_DIR := $(BUILD_DIR)/lib
 STATIC_NAME := $(LIB_BUILD_DIR)/lib$(LIBRARY_NAME).a
 DYNAMIC_VERSION_MAJOR          := 1
 DYNAMIC_VERSION_MINOR          := 0
-DYNAMIC_VERSION_REVISION       := 0-rc3
+DYNAMIC_VERSION_REVISION       := 0-rc5
 DYNAMIC_NAME_SHORT := lib$(LIBRARY_NAME).so
 #DYNAMIC_SONAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR)
 DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
@@ -172,13 +178,13 @@ endif
 CUDA_LIB_DIR += $(CUDA_DIR)/lib
 
 INCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include
-ifneq ($(CPU_ONLY), 1)
+ifeq ($(USE_CUDA), 1)
        INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)
        LIBRARY_DIRS += $(CUDA_LIB_DIR)
        LIBRARIES := cudart cublas curand
 endif
 
-LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
+LIBRARIES += glog gflags protobuf boost_system boost_filesystem m 
 
 # handle IO dependencies
 USE_LEVELDB ?= 1
@@ -192,12 +198,12 @@ ifeq ($(USE_LMDB), 1)
        LIBRARIES += lmdb
 endif
 ifeq ($(USE_OPENCV), 1)
-       LIBRARIES += opencv_core opencv_highgui opencv_imgproc 
+       LIBRARIES += opencv_core opencv_highgui opencv_imgproc
 
        ifeq ($(OPENCV_VERSION), 3)
                LIBRARIES += opencv_imgcodecs
        endif
-               
+
 endif
 PYTHON_LIBRARIES ?= boost_python python2.7
 WARNINGS := -Wall -Wno-sign-compare
@@ -248,6 +254,8 @@ ifeq ($(UNAME), Linux)
        LINUX := 1
 else ifeq ($(UNAME), Darwin)
        OSX := 1
+       OSX_MAJOR_VERSION := $(shell sw_vers -productVersion | cut -f 1 -d .)
+       OSX_MINOR_VERSION := $(shell sw_vers -productVersion | cut -f 2 -d .)
 endif
 
 # Linux
@@ -269,24 +277,35 @@ endif
 # libstdc++ for NVCC compatibility on OS X >= 10.9 with CUDA < 7.0
 ifeq ($(OSX), 1)
        CXX := /usr/bin/clang++
-       ifneq ($(CPU_ONLY), 1)
-               CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release \d' | grep -o '\d')
+       ifeq ($(USE_CUDA), 1)
+               CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release [0-9.]*' | tr -d '[a-z ]')
                ifeq ($(shell echo | awk '{exit $(CUDA_VERSION) < 7.0;}'), 1)
                        CXXFLAGS += -stdlib=libstdc++
                        LINKFLAGS += -stdlib=libstdc++
                endif
                # clang throws this warning for cuda headers
                WARNINGS += -Wno-unneeded-internal-declaration
+               # 10.11 strips DYLD_* env vars so link CUDA (rpath is available on 10.5+)
+               OSX_10_OR_LATER   := $(shell [ $(OSX_MAJOR_VERSION) -ge 10 ] && echo true)
+               OSX_10_5_OR_LATER := $(shell [ $(OSX_MINOR_VERSION) -ge 5 ] && echo true)
+               ifeq ($(OSX_10_OR_LATER),true)
+                       ifeq ($(OSX_10_5_OR_LATER),true)
+                               LDFLAGS += -Wl,-rpath,$(CUDA_LIB_DIR)
+                       endif
+               endif
        endif
        # gtest needs to use its own tuple to not conflict with clang
        COMMON_FLAGS += -DGTEST_USE_OWN_TR1_TUPLE=1
        # boost::thread is called boost_thread-mt to mark multithreading on OS X
        LIBRARIES += boost_thread-mt
        # we need to explicitly ask for the rpath to be obeyed
-       DYNAMIC_FLAGS := -install_name @rpath/libcaffe.so
        ORIGIN := @loader_path
-       VERSIONFLAGS += -Wl,-install_name,$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
+       VERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
 else
+       ifeq (${USE_OPENMP}, 1)
+               CXXFLAGS += -fopenmp
+               LINKFLAGS += -fopenmp
+       endif
        ORIGIN := \$$ORIGIN
 endif
 
@@ -319,6 +338,33 @@ ifeq ($(USE_CUDNN), 1)
        COMMON_FLAGS += -DUSE_CUDNN
 endif
 
+# NCCL acceleration configuration
+ifeq ($(USE_NCCL), 1)
+       LIBRARIES += nccl
+       COMMON_FLAGS += -DUSE_NCCL
+endif
+
+# ACL acceleration configuration
+ifeq ($(USE_ACL), 1)
+        LIBRARY_DIRS += $(ACL_LIBS_DIR)
+       LIBRARIES += $(ACL_LIBS)
+       INCLUDE_DIRS +=$(ACL_INCS)
+       COMMON_FLAGS += -DUSE_ACL -std=c++11
+endif
+
+#USE_PROFILING -- get profiling informations, is controled by LOGACL
+#LAYER_PERF_STAT -- haitao's net profiling information
+ifeq ($(USE_PROFILING), 1)
+       COMMON_FLAGS += -DUSE_PROFILING -DLAYER_PERF_STAT
+endif
+#HDF5
+ifeq ($(USE_HDF5), 1)
+        LIBRARY_DIRS += $(HDF5_LIBRARY_DIRS)
+       LIBRARIES += $(HDF5_LIBRARIES)
+       INCLUDE_DIRS +=$(HDF5_INCLUDE_DIRS)
+       COMMON_FLAGS += -DUSE_HDF5
+endif
+
 # configure IO libraries
 ifeq ($(USE_OPENCV), 1)
        COMMON_FLAGS += -DUSE_OPENCV
@@ -343,6 +389,15 @@ ifeq ($(CPU_ONLY), 1)
        COMMON_FLAGS += -DCPU_ONLY
 endif
 
+ifeq ($(USE_ACL), 1)
+       OBJS := $(PROTO_OBJS) $(CXX_OBJS)
+       TEST_OBJS := $(TEST_CXX_OBJS)
+       TEST_BINS := $(TEST_CXX_BINS)
+       ALL_WARNS := $(ALL_CXX_WARNS)
+       TEST_FILTER := --gtest_filter="-*GPU*"
+       COMMON_FLAGS += -DCPU_ONLY
+endif
+
 # Python layer support
 ifeq ($(WITH_PYTHON_LAYER), 1)
        COMMON_FLAGS += -DWITH_PYTHON_LAYER
@@ -350,14 +405,15 @@ ifeq ($(WITH_PYTHON_LAYER), 1)
 endif
 
 # BLAS configuration (default = ATLAS)
-BLAS ?= atlas
+#BLAS ?= atlas
+BLAS ?= open
 ifeq ($(BLAS), mkl)
        # MKL
        LIBRARIES += mkl_rt
        COMMON_FLAGS += -DUSE_MKL
-       MKL_DIR ?= /opt/intel/mkl
-       BLAS_INCLUDE ?= $(MKL_DIR)/include
-       BLAS_LIB ?= $(MKL_DIR)/lib $(MKL_DIR)/lib/intel64
+       MKLROOT ?= /opt/intel/mkl
+       BLAS_INCLUDE ?= $(MKLROOT)/include
+       BLAS_LIB ?= $(MKLROOT)/lib $(MKLROOT)/lib/intel64
 else ifeq ($(BLAS), open)
        # OpenBLAS
        LIBRARIES += openblas
@@ -373,8 +429,11 @@ else
                LIBRARIES += cblas
                # 10.10 has accelerate while 10.9 has veclib
                XCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep 'version' | sed 's/[^0-9]*\([0-9]\).*/\1/')
+               XCODE_CLT_GEQ_7 := $(shell [ $(XCODE_CLT_VER) -gt 6 ] && echo 1)
                XCODE_CLT_GEQ_6 := $(shell [ $(XCODE_CLT_VER) -gt 5 ] && echo 1)
-               ifeq ($(XCODE_CLT_GEQ_6), 1)
+               ifeq ($(XCODE_CLT_GEQ_7), 1)
+                       BLAS_INCLUDE ?= /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$(shell ls /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ | sort | tail -1)/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers
+               else ifeq ($(XCODE_CLT_GEQ_6), 1)
                        BLAS_INCLUDE ?= /System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
                        LDFLAGS += -framework Accelerate
                else
@@ -552,7 +611,7 @@ $(ALL_BUILD_DIRS): | $(BUILD_DIR_LINK)
 
 $(DYNAMIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
        @ echo LD -o $@
-       $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS) $(DYNAMIC_FLAGS)
+       $(Q)$(CXX) -shared -o $@ $(OBJS) $(VERSIONFLAGS) $(LINKFLAGS) $(LDFLAGS)
        @ cd $(BUILD_DIR)/lib; rm -f $(DYNAMIC_NAME_SHORT);   ln -s $(DYNAMIC_VERSIONED_NAME_SHORT) $(DYNAMIC_NAME_SHORT)
 
 $(STATIC_NAME): $(OBJS) | $(LIB_BUILD_DIR)
@@ -601,7 +660,7 @@ $(TEST_CXX_BINS): $(TEST_BIN_DIR)/%.testbin: $(TEST_CXX_BUILD_DIR)/%.o \
 # Target for extension-less symlinks to tool binaries with extension '*.bin'.
 $(TOOL_BUILD_DIR)/%: $(TOOL_BUILD_DIR)/%.bin | $(TOOL_BUILD_DIR)
        @ $(RM) $@
-       @ ln -s $(abspath $<) $@
+       @ ln -s $(notdir $<) $@
 
 $(TOOL_BINS): %.bin : %.o | $(DYNAMIC_NAME)
        @ echo CXX/LD -o $@
@@ -662,6 +721,8 @@ superclean: clean supercleanfiles
 $(DIST_ALIASES): $(DISTRIBUTE_DIR)
 
 $(DISTRIBUTE_DIR): all py | $(DISTRIBUTE_SUBDIRS)
+       # add proto
+       cp -r src/caffe/proto $(DISTRIBUTE_DIR)/
        # add include
        cp -r include $(DISTRIBUTE_DIR)/
        mkdir -p $(DISTRIBUTE_DIR)/include/caffe/proto