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
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)
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
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
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
# 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
COMMON_FLAGS += -DDEBUG -g -O0
NVCCFLAGS += -G
else
- COMMON_FLAGS += -DNDEBUG -O2
+ COMMON_FLAGS += -DNDEBUG -O3
endif
# cuDNN acceleration configuration.
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
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
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
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
# 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))
##############################
.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)
$(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)
# 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 $@
$(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