FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

1. Porting Caffe onto ARM Compute Library. · csuhawk/CaffeOnACL@89a4228 · GitHub

Repository navigation

Commit 89a4228

Browse files
Yao Honggui
committed
1. Porting Caffe onto ARM Compute Library.
2. The release version is 0.2.0
1 parent 0a7c22b commit 89a4228

72 files changed

Lines changed: 8287 additions & 10 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Makefile‎

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ $(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.)
77
endif
88
include $(CONFIG_FILE)
99

10+
ifeq ($(CPU_ONLY),1)
11+
USE_CUDA := 0
12+
endif
13+
ifeq ($(USE_ACL),1)
14+
USE_CUDA := 0
15+
endif
1016
BUILD_DIR_LINK := $(BUILD_DIR)
1117
ifeq ($(RELEASE_BUILD_DIR),)
1218
RELEASE_BUILD_DIR := .$(BUILD_DIR)_release
@@ -172,13 +178,13 @@ endif
172178
CUDA_LIB_DIR += $(CUDA_DIR)/lib
173179

174180
INCLUDE_DIRS += $(BUILD_INCLUDE_DIR) ./src ./include
175-
ifneq ($(CPU_ONLY), 1)
181+
ifeq ($(USE_CUDA), 1)
176182
INCLUDE_DIRS += $(CUDA_INCLUDE_DIR)
177183
LIBRARY_DIRS += $(CUDA_LIB_DIR)
178184
LIBRARIES := cudart cublas curand
179185
endif
180186

181-
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m hdf5_hl hdf5
187+
LIBRARIES += glog gflags protobuf boost_system boost_filesystem m
182188

183189
# handle IO dependencies
184190
USE_LEVELDB ?= 1
@@ -271,7 +277,7 @@ endif
271277
# libstdc++ for NVCC compatibility on OS X >= 10.9 with CUDA < 7.0
272278
ifeq ($(OSX), 1)
273279
CXX := /usr/bin/clang++
274-
ifneq ($(CPU_ONLY), 1)
280+
ifeq ($(USE_CUDA), 1)
275281
CUDA_VERSION := $(shell $(CUDA_DIR)/bin/nvcc -V | grep -o 'release [0-9.]*' | tr -d '[a-z ]')
276282
ifeq ($(shell echo | awk '{exit $(CUDA_VERSION) < 7.0;}'), 1)
277283
CXXFLAGS += -stdlib=libstdc++
@@ -296,6 +302,10 @@ ifeq ($(OSX), 1)
296302
ORIGIN := @loader_path
297303
VERSIONFLAGS += -Wl,-install_name,@rpath/$(DYNAMIC_VERSIONED_NAME_SHORT) -Wl,-rpath,$(ORIGIN)/../../build/lib
298304
else
305+
ifeq (${USE_OPENMP}, 1)
306+
CXXFLAGS += -fopenmp
307+
LINKFLAGS += -fopenmp
308+
endif
299309
ORIGIN := \$$ORIGIN
300310
endif
301311

@@ -334,6 +344,27 @@ ifeq ($(USE_NCCL), 1)
334344
COMMON_FLAGS += -DUSE_NCCL
335345
endif
336346

347+
# ACL acceleration configuration
348+
ifeq ($(USE_ACL), 1)
349+
LIBRARY_DIRS += $(ACL_LIBS_DIR)
350+
LIBRARIES += $(ACL_LIBS)
351+
INCLUDE_DIRS +=$(ACL_INCS)
352+
COMMON_FLAGS += -DUSE_ACL -std=c++11
353+
endif
354+
355+
#USE_PROFILING -- get profiling informations, is controled by LOGACL
356+
#LAYER_PERF_STAT -- haitao's net profiling information
357+
ifeq ($(USE_PROFILING), 1)
358+
COMMON_FLAGS += -DUSE_PROFILING -DLAYER_PERF_STAT
359+
endif
360+
#HDF5
361+
ifeq ($(USE_HDF5), 1)
362+
LIBRARY_DIRS += $(HDF5_LIBRARY_DIRS)
363+
LIBRARIES += $(HDF5_LIBRARIES)
364+
INCLUDE_DIRS +=$(HDF5_INCLUDE_DIRS)
365+
COMMON_FLAGS += -DUSE_HDF5
366+
endif
367+
337368
# configure IO libraries
338369
ifeq ($(USE_OPENCV), 1)
339370
COMMON_FLAGS += -DUSE_OPENCV
@@ -358,14 +389,24 @@ ifeq ($(CPU_ONLY), 1)
358389
COMMON_FLAGS += -DCPU_ONLY
359390
endif
360391

392+
ifeq ($(USE_ACL), 1)
393+
OBJS := $(PROTO_OBJS) $(CXX_OBJS)
394+
TEST_OBJS := $(TEST_CXX_OBJS)
395+
TEST_BINS := $(TEST_CXX_BINS)
396+
ALL_WARNS := $(ALL_CXX_WARNS)
397+
TEST_FILTER := --gtest_filter="-*GPU*"
398+
COMMON_FLAGS += -DCPU_ONLY
399+
endif
400+
361401
# Python layer support
362402
ifeq ($(WITH_PYTHON_LAYER), 1)
363403
COMMON_FLAGS += -DWITH_PYTHON_LAYER
364404
LIBRARIES += $(PYTHON_LIBRARIES)
365405
endif
366406

367407
# BLAS configuration (default = ATLAS)
368-
BLAS ?= atlas
408+
#BLAS ?= atlas
409+
BLAS ?= open
369410
ifeq ($(BLAS), mkl)
370411
# MKL
371412
LIBRARIES += mkl_rt

‎Makefile.config.acl‎

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
## Refer to http://caffe.berkeleyvision.org/installation.html
2+
# Contributions simplifying and improving our build system are welcome!
3+
4+
# cuDNN acceleration switch (uncomment to build with cuDNN).
5+
# USE_CUDNN := 1
6+
7+
# CPU-only switch (uncomment to build without GPU support).
8+
CPU_ONLY := 1
9+
10+
USE_PROFILING := 0
11+
12+
USE_ACL :=1
13+
ACL_ROOT :=/home/firefly/ComputeLibrary
14+
ACL_INCS :=$(ACL_ROOT)/include
15+
ACL_INCS +=$(ACL_ROOT)
16+
ACL_LIBS_DIR :=$(ACL_ROOT)/build
17+
ACL_LIBS_DIR +=$(ACL_ROOT)/build/arm_compute
18+
ACL_LIBS :=arm_compute OpenCL
19+
20+
# uncomment to disable IO dependencies and corresponding data layers
21+
# USE_OPENCV := 0
22+
# USE_LEVELDB := 0
23+
# USE_LMDB := 0
24+
25+
# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
26+
# You should not set this flag if you will be reading LMDBs with any
27+
# possibility of simultaneous read and write
28+
# ALLOW_LMDB_NOLOCK := 1
29+
30+
# Uncomment if you're using OpenCV 3
31+
# OPENCV_VERSION := 3
32+
33+
# To customize your choice of compiler, uncomment and set the following.
34+
# N.B. the default for Linux is g++ and the default for OSX is clang++
35+
# CUSTOM_CXX := g++
36+
#CUSTOM_CXX := aarch64-linux-gnu-g++
37+
#os :=linux
38+
#arch :=arm64-v8a
39+
40+
# CUDA directory contains bin/ and lib/ directories that we need.
41+
CUDA_DIR := /usr/local/cuda
42+
# On Ubuntu 14.04, if cuda tools are installed via
43+
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
44+
# CUDA_DIR := /usr
45+
46+
# CUDA architecture setting: going with all of them.
47+
# For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility.
48+
# For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility.
49+
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
50+
-gencode arch=compute_20,code=sm_21 \
51+
-gencode arch=compute_30,code=sm_30 \
52+
-gencode arch=compute_35,code=sm_35 \
53+
-gencode arch=compute_50,code=sm_50 \
54+
-gencode arch=compute_52,code=sm_52 \
55+
-gencode arch=compute_60,code=sm_60 \
56+
-gencode arch=compute_61,code=sm_61 \
57+
-gencode arch=compute_61,code=compute_61
58+
59+
# BLAS choice:
60+
# atlas for ATLAS (default)
61+
# mkl for MKL
62+
# open for OpenBlas
63+
#BLAS := atlas
64+
BLAS := open
65+
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
66+
# Leave commented to accept the defaults for your choice of BLAS
67+
# (which should work)!
68+
# BLAS_INCLUDE := /path/to/your/blas
69+
# BLAS_LIB := /path/to/your/blas
70+
71+
# Homebrew puts openblas in a directory that is not on the standard search path
72+
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
73+
# BLAS_LIB := $(shell brew --prefix openblas)/lib
74+
75+
# This is required only if you will compile the matlab interface.
76+
# MATLAB directory should contain the mex binary in /bin.
77+
# MATLAB_DIR := /usr/local
78+
# MATLAB_DIR := /Applications/MATLAB_R2012b.app
79+
80+
# NOTE: this is required only if you will compile the python interface.
81+
# We need to be able to find Python.h and numpy/arrayobject.h.
82+
PYTHON_INCLUDE := /usr/include/python2.7 \
83+
/usr/lib/python2.7/dist-packages/numpy/core/include
84+
# Anaconda Python distribution is quite popular. Include path:
85+
# Verify anaconda location, sometimes it's in root.
86+
# ANACONDA_HOME := $(HOME)/anaconda
87+
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
88+
# $(ANACONDA_HOME)/include/python2.7 \
89+
# $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include
90+
91+
# Uncomment to use Python 3 (default is Python 2)
92+
# PYTHON_LIBRARIES := boost_python3 python3.5m
93+
# PYTHON_INCLUDE := /usr/include/python3.5m \
94+
# /usr/lib/python3.5/dist-packages/numpy/core/include
95+
96+
# We need to be able to find libpythonX.X.so or .dylib.
97+
PYTHON_LIB := /usr/lib
98+
# PYTHON_LIB := $(ANACONDA_HOME)/lib
99+
100+
# Homebrew installs numpy in a non standard path (keg only)
101+
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
102+
# PYTHON_LIB += $(shell brew --prefix numpy)/lib
103+
104+
# Uncomment to support layers written in Python (will link against Python libs)
105+
# WITH_PYTHON_LAYER := 1
106+
107+
# Whatever else you find you need goes here.
108+
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
109+
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
110+
111+
# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
112+
# INCLUDE_DIRS += $(shell brew --prefix)/include
113+
# LIBRARY_DIRS += $(shell brew --prefix)/lib
114+
115+
# NCCL acceleration switch (uncomment to build with NCCL)
116+
# https://github.com/NVIDIA/nccl (last tested version: v1.2.3-1+cuda8.0)
117+
# USE_NCCL := 1
118+
119+
# Uncomment to use `pkg-config` to specify OpenCV library paths.
120+
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
121+
# USE_PKG_CONFIG := 1
122+
123+
# N.B. both build and distribute dirs are cleared on `make clean`
124+
BUILD_DIR := build
125+
DISTRIBUTE_DIR := distribute
126+
127+
#HDF5
128+
USE_HDF5 := 1
129+
HDF5_INCLUDE_DIRS := /usr/include/hdf5/serial
130+
HDF5_LIBRARY_DIRS := /usr/lib/aarch64-linux-gnu/hdf5/serial
131+
HDF5_LIBRARIES :=hdf5_hl hdf5
132+
133+
# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
134+
# DEBUG := 1
135+
136+
# The ID of the GPU that 'make runtest' will use to run unit tests.
137+
TEST_GPUID := 0
138+
139+
# enable pretty build (comment to see full commands)
140+
Q ?= @

‎README.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# CaffeOnACL
2+
[![License](https://img.shields.io/badge/license-BSD-blue.svg)](LICENSE)
3+
4+
CaffeOnACL is a project to use ARM Compute Library (NEON+GPU) to speed up caffe and provide utilities to debug, profile and tune application performance.
5+
6+
Check out the documents for the details like
7+
- [release notes](https://github.com/OAID/caffeOnACL/tree/master/docs/caffeOnACL_release_notes_0_2_0.docx)
8+
- [user guide](https://github.com/OAID/caffeOnACL/tree/master/docs/caffeOnACL_user_guide_0_2_0.docx)
9+
10+
11+
112
# Caffe
213

314
[![Build Status](https://travis-ci.org/BVLC/caffe.svg?branch=master)](https://travis-ci.org/BVLC/caffe)

‎cmake/Dependencies.cmake‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ if(USE_LEVELDB)
6666
list(APPEND Caffe_DEFINITIONS PUBLIC -DUSE_LEVELDB)
6767
endif()
6868

69+
# ---[ ACL
70+
if(USE_ACL)
71+
find_package(ACL REQUIRED)
72+
list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${ACL_INCLUDE})
73+
list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${ACL_INCLUDE}/include)
74+
set(__list ${ACL_LIBRARIES})
75+
separate_arguments(__list)
76+
list(REMOVE_DUPLICATES __list)
77+
foreach(i ${__list})
78+
list(APPEND Caffe_LINKER_LIBS PUBLIC ${i})
79+
endforeach()
80+
list(APPEND Caffe_COMPILE_OPTIONS PRIVATE -std=c++11)
81+
list(APPEND Caffe_DEFINITIONS PUBLIC -DUSE_ACL)
82+
endif()
83+
6984
# ---[ Snappy
7085
if(USE_LEVELDB)
7186
find_package(Snappy REQUIRED)

‎cmake/Modules/FindACL.cmake‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
set(ACL_INC_PATHS
2+
/usr/include
3+
/usr/local/include
4+
/usr/local/acl
5+
$ENV{ACL_DIR}/include
6+
)
7+
8+
set(ACL_LIB_PATHS
9+
/lib
10+
/lib64
11+
/usr/lib
12+
/usr/lib64
13+
/usr/local/lib
14+
/usr/local/lib64
15+
/usr/local/acl/lib
16+
/usr/local/acl/lib64
17+
$ENV{ACL_DIR}/lib
18+
)
19+
20+
find_path(ACL_INCLUDE NAMES arm_compute PATHS ${ACL_INC_PATHS})
21+
find_library(ACL_LIBRARIES NAMES arm_compute-static PATHS ${ACL_LIB_PATHS})
22+
find_library(ACL_CORE_LIBRARIES NAMES arm_compute_core-static PATHS ${ACL_LIB_PATHS})
23+
SET(ACL_LIBRARIES "${ACL_CORE_LIBRARIES} ${ACL_LIBRARIES}")
24+
25+
if(ACL_INCS)
26+
SET(ACL_INCLUDE "${ACL_INCS}")
27+
SET(ACL_LIBRARIES "${ACL_LIBS}")
28+
SET(ACL_FOUND 1)
29+
else ()
30+
include(FindPackageHandleStandardArgs)
31+
find_package_handle_standard_args(ACL DEFAULT_MSG ACL_INCLUDE ACL_LIBRARIES)
32+
endif ()
33+
34+
if (ACL_FOUND)
35+
message(STATUS "Found ACL (include: ${ACL_INCLUDE}, library: ${ACL_LIBRARIES})")
36+
mark_as_advanced(ACL_INCLUDE ACL_LIBRARIES)
37+
endif ()
176 KB
Binary file not shown.
461 KB
Binary file not shown.

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL