documents fixed
[platform/upstream/caffeonacl.git] / Makefile
index 568d9c2..783d7c6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,18 @@
 PROJECT := caffe
 
-CONFIG_FILE := Makefile.config
+CONFIG_FILE := Makefile.config.acl
 # Explicitly check for the config file, otherwise make -k will proceed anyway.
 ifeq ($(wildcard $(CONFIG_FILE)),)
 $(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
@@ -271,8 +277,8 @@ 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 [0-9.]*' | grep -o '[0-9.]*')
+       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++
@@ -296,6 +302,10 @@ ifeq ($(OSX), 1)
        ORIGIN := @loader_path
        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,7 +329,7 @@ ifeq ($(DEBUG), 1)
        COMMON_FLAGS += -DDEBUG -g -O0
        NVCCFLAGS += -G
 else
-       COMMON_FLAGS += -DNDEBUG -O2
+       COMMON_FLAGS += -DNDEBUG -O3
 endif
 
 # cuDNN acceleration configuration.
@@ -328,6 +338,37 @@ 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
+
+ifeq ($(USE_OPENCL), 1)
+       COMMON_FLAGS += -DUSE_OPENCL
+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
@@ -352,6 +393,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
@@ -359,7 +409,8 @@ ifeq ($(WITH_PYTHON_LAYER), 1)
 endif
 
 # BLAS configuration (default = ATLAS)
-BLAS ?= atlas
+#BLAS ?= atlas
+BLAS ?= open
 ifeq ($(BLAS), mkl)
        # MKL
        LIBRARIES += mkl_rt
@@ -382,8 +433,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
@@ -400,20 +454,24 @@ LIBRARY_DIRS += $(LIB_BUILD_DIR)
 # Automatic dependency generation (nvcc is handled separately)
 CXXFLAGS += -MMD -MP
 
+USE_PKG_CONFIG ?= 0
+ifeq ($(USE_PKG_CONFIG), 1)
+       PKG_INCLUDE_DIRS :=  `pkg-config opencv --cflags`
+        PKG_CONFIG := `pkg-config opencv --libs`
+else
+        PKG_CONFIG :=
+       PKG_INCLUDE_DIRS :=
+endif
+
 # Complete build flags.
 COMMON_FLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))
+COMMON_FLAGS += $(PKG_INCLUDE_DIRS)
 CXXFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)
 NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)
 # mex may invoke an older gcc that is too liberal with -Wuninitalized
 MATLAB_CXXFLAGS := $(CXXFLAGS) -Wno-uninitialized
 LINKFLAGS += -pthread -fPIC $(COMMON_FLAGS) $(WARNINGS)
 
-USE_PKG_CONFIG ?= 0
-ifeq ($(USE_PKG_CONFIG), 1)
-       PKG_CONFIG := $(shell pkg-config opencv --libs)
-else
-       PKG_CONFIG :=
-endif
 LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir)) $(PKG_CONFIG) \
                $(foreach library,$(LIBRARIES),-l$(library))
 PYTHON_LDFLAGS := $(LDFLAGS) $(foreach library,$(PYTHON_LIBRARIES),-l$(library))
@@ -441,10 +499,15 @@ endif
 ##############################
 .PHONY: all lib test clean docs linecount lint lintclean tools examples $(DIST_ALIASES) \
        py mat py$(PROJECT) mat$(PROJECT) proto runtest \
-       superclean supercleanlist supercleanfiles warn everything
+       superclean supercleanlist supercleanfiles warn everything install
 
 all: lib tools examples
 
+install:
+       install -d $(AIDDIR)/Caffe-HRT
+       cp -rfp ./distribute/* $(AIDDIR)/Caffe-HRT
+       chown -R root:root $(AIDDIR)/Caffe-HRT
+
 lib: $(STATIC_NAME) $(DYNAMIC_NAME)
 
 everything: $(EVERYTHING_TARGETS)