blob: 4d514ea5aefd70acbaa686dd8ac84bf1b288a94d [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/** @mainpage Introduction
2
3@tableofcontents
4
5The Computer Vision and Machine Learning library is a set of functions optimised for both ARM CPUs and GPUs using SIMD technologies.
6
7Several builds of the library are available using various configurations:
8 - OS: Linux, Android or bare metal.
9 - Architecture: armv7a (32bit) or arm64-v8a (64bit)
10 - Technology: NEON / OpenCL / NEON and OpenCL
11 - Debug / Asserts / Release: Use a build with asserts enabled to debug your application and enable extra validation. Once you are sure your application works as expected you can switch to a release build of the library for maximum performance.
12
13@section S0_1_contact Contact / Support
14
15Please email developer@arm.com
16
17In order to facilitate the work of the support team please provide the build information of the library you are using. To get the version of the library you are using simply run:
18
19 $ strings android-armv7a-cl-asserts/libarm_compute.so | grep arm_compute_version
20 arm_compute_version=v16.12 Build options: {'embed_kernels': '1', 'opencl': '1', 'arch': 'armv7a', 'neon': '0', 'asserts': '1', 'debug': '0', 'os': 'android', 'Werror': '1'} Git hash=f51a545d4ea12a9059fe4e598a092f1fd06dc858
21
22@section S1_file_organisation File organisation
23
24This archive contains:
25 - The arm_compute header and source files
26 - The latest Khronos OpenCL 1.2 C headers from the <a href="https://www.khronos.org/registry/cl/">Khronos OpenCL registry</a>
27 - The latest Khronos cl2.hpp from the <a href="https://www.khronos.org/registry/cl/">Khronos OpenCL registry</a> (API version 2.1 when this document was written)
28 - The sources for a stub version of libOpenCL.so to help you build your application.
29 - An examples folder containing a few examples to compile and link against the library.
30 - A @ref utils folder containing headers with some boiler plate code used by the examples.
31 - This documentation.
32
33You should have the following file organisation:
34
35 .
36 ├── arm_compute --> All the arm_compute headers
37 │   ├── core
38 │   │   ├── CL
39 │   │   │   ├── CLKernels.h --> Includes all the OpenCL kernels at once
40 │   │   │   ├── CL specialisation of all the generic objects interfaces (ICLTensor, ICLImage, etc.)
41 │   │   │   ├── kernels --> Folder containing all the OpenCL kernels
42 │   │   │   │   └── CL*Kernel.h
43 │   │   │   └── OpenCL.h --> Wrapper to configure the Khronos OpenCL C++ header
44 │   │ ├── CPP
45 │   │ │   └── kernels --> Folder containing all the CPP kernels
46 │   │   │   │   └── CPP*Kernel.h
47 │   │   ├── NEON
48 │   │   │   ├── kernels --> Folder containing all the NEON kernels
49 │   │   │   │   └── NE*Kernel.h
50 │   │   │   └── NEKernels.h --> Includes all the NEON kernels at once
51 │   │   ├── All common basic types (Types.h, Window, Coordinates, Iterator, etc.)
52 │   │   ├── All generic objects interfaces (ITensor, IImage, etc.)
53 │   │   └── Objects metadata classes (ImageInfo, TensorInfo, MultiImageInfo)
54 │   └── runtime
55 │   ├── CL
56 │   │   ├── CL objects & allocators (CLArray, CLImage, CLTensor, etc.)
57 │   │   ├── functions --> Folder containing all the OpenCL functions
58 │   │   │   └── CL*.h
59 │   │   └── CLFunctions.h --> Includes all the OpenCL functions at once
60 │   ├── CPP
61 │   │   └── Scheduler.h --> Basic pool of threads to execute CPP/NEON code on several cores in parallel
62 │   ├── NEON
63 │   │ ├── functions --> Folder containing all the NEON functions
64 │   │ │   └── NE*.h
65 │   │ └── NEFunctions.h --> Includes all the NEON functions at once
66 │   └── Basic implementations of the generic object interfaces (Array, Image, Tensor, etc.)
67 ├── documentation
68 │   ├── index.xhtml
69 │   └── ...
70 ├── documentation.xhtml -> documentation/index.xhtml
71 ├── examples
72 │   ├── cl_convolution.cpp
73 │   ├── neoncl_scale_median_gaussian.cpp
74 │   ├── neon_convolution.cpp
75 │   └── neon_scale.cpp
76 ├── include
77 │   └── CL
78 │   └── Khronos OpenCL C headers and C++ wrapper
79 ├── opencl-1.2-stubs
80 │ └── opencl_stubs.c
81 ├── src
82 │   ├── core
83 │ │ └── ... (Same structure as headers)
84 │   │ └── CL
85 │   │ └── cl_kernels --> All the OpenCL kernels
86 │ └── runtime
87 │ └── ... (Same structure as headers)
88 ├── tests
89 │   ├── All test related files shared between validation and benchmark
90 │   ├── CL --> OpenCL specific files (shared)
91 │   ├── NEON --> NEON specific files (shared)
92 │   ├── benchmark --> Sources for benchmarking
93 │ │ ├── Benchmark specific files
94 │ │ ├── main.cpp --> Entry point for benchmark test framework
95 │ │ ├── CL --> OpenCL benchmarking tests
96 │ │ └── NEON --> NEON benchmarking tests
97 │   ├── validation --> Sources for validation
98 │ │ ├── Validation specific files
99 │ │ ├── main.cpp --> Entry point for validation test framework
100 │ │ ├── CL --> OpenCL validation tests
101 │ │ ├── NEON --> NEON validation tests
102 │ │ └── UNIT --> Library validation tests
103 │   └── dataset --> Datasets defining common sets of input parameters
104 └── utils --> Boiler plate code used by examples
105 └── Utils.h
106
107@section S2_versions_changelog Release versions and changelog
108
109@subsection S2_1_versions Release versions
110
111All releases are numbered vYY.MM Where YY are the last two digits of the year, and MM the month number.
112If there is more than one release in a month then an extra sequential number is appended at the end:
113
114 v17.03 (First release of March 2017)
115 v17.03.1 (Second release of March 2017)
116 v17.04 (First release of April 2017)
117
118@note We're aiming at releasing one major public release with new features per quarter. All releases in between will only contain bug fixes.
119
120@subsection S2_2_changelog Changelog
121
122v17.06 Public major release
123 - Various bug fixes
124 - Added support for fixed point 8 bit (QS8) to the various NEON machine learning kernels.
125 - Added unit tests and benchmarks (AlexNet, LeNet)
126 - Added support for sub tensors.
127 - Added infrastructure to provide GPU specific optimisation for some OpenCL kernels.
128 - Added @ref arm_compute::OMPScheduler (OpenMP) scheduler for NEON
129 - Added @ref arm_compute::SingleThreadScheduler scheduler for NEON (For bare metal)
130 - User can specify his own scheduler by implementing the @ref arm_compute::IScheduler interface.
131 - New OpenCL kernels / functions:
132 - @ref arm_compute::CLBatchNormalizationLayerKernel / @ref arm_compute::CLBatchNormalizationLayer
133 - @ref arm_compute::CLDepthConcatenateKernel / @ref arm_compute::CLDepthConcatenate
134 - @ref arm_compute::CLHOGOrientationBinningKernel @ref arm_compute::CLHOGBlockNormalizationKernel, @ref arm_compute::CLHOGDetectorKernel / @ref arm_compute::CLHOGDescriptor @ref arm_compute::CLHOGDetector @ref arm_compute::CLHOGGradient @ref arm_compute::CLHOGMultiDetection
135 - @ref arm_compute::CLLocallyConnectedMatrixMultiplyKernel / @ref arm_compute::CLLocallyConnectedLayer
136 - @ref arm_compute::CLWeightsReshapeKernel / @ref arm_compute::CLConvolutionLayerReshapeWeights
137 - New C++ kernels:
138 - @ref arm_compute::CPPDetectionWindowNonMaximaSuppressionKernel
139 - New NEON kernels / functions:
140 - @ref arm_compute::NEBatchNormalizationLayerKernel / @ref arm_compute::NEBatchNormalizationLayer
141 - @ref arm_compute::NEDepthConcatenateKernel / @ref arm_compute::NEDepthConcatenate
142 - @ref arm_compute::NEDirectConvolutionLayerKernel / @ref arm_compute::NEDirectConvolutionLayer
143 - @ref arm_compute::NELocallyConnectedMatrixMultiplyKernel / @ref arm_compute::NELocallyConnectedLayer
144 - @ref arm_compute::NEWeightsReshapeKernel / @ref arm_compute::NEConvolutionLayerReshapeWeights
145
146v17.05 Public bug fixes release
147 - Various bug fixes
148 - Remaining of the functions ported to use accurate padding.
149 - Library does not link against OpenCL anymore (It uses dlopen / dlsym at runtime instead to determine whether or not OpenCL is available).
150 - Added "free" method to allocator.
151 - Minimum version of g++ required for armv7 Linux changed from 4.8 to 4.9
152
153v17.04 Public bug fixes release
154
155 The following functions have been ported to use the new accurate padding:
156 - @ref arm_compute::CLColorConvertKernel
157 - @ref arm_compute::CLEdgeNonMaxSuppressionKernel
158 - @ref arm_compute::CLEdgeTraceKernel
159 - @ref arm_compute::CLGaussianPyramidHorKernel
160 - @ref arm_compute::CLGaussianPyramidVertKernel
161 - @ref arm_compute::CLGradientKernel
162 - @ref arm_compute::NEChannelCombineKernel
163 - @ref arm_compute::NEFillArrayKernel
164 - @ref arm_compute::NEGaussianPyramidHorKernel
165 - @ref arm_compute::NEGaussianPyramidVertKernel
166 - @ref arm_compute::NEHarrisScoreFP16Kernel
167 - @ref arm_compute::NEHarrisScoreKernel
168 - @ref arm_compute::NEHOGDetectorKernel
169 - @ref arm_compute::NELogits1DMaxKernel
170 - @ref arm_compute::NELogits1DShiftExpSumKernel
171 - @ref arm_compute::NELogits1DNormKernel
172 - @ref arm_compute::NENonMaximaSuppression3x3FP16Kernel
173 - @ref arm_compute::NENonMaximaSuppression3x3Kernel
174
175
176v17.03.1 First Major public release of the sources
177 - Renamed the library to arm_compute
178 - New CPP target introduced for C++ kernels shared between NEON and CL functions.
179 - New padding calculation interface introduced and ported most kernels / functions to use it.
180 - New OpenCL kernels / functions:
181 - @ref arm_compute::CLGEMMLowpMatrixMultiplyKernel / @ref arm_compute::CLGEMMLowp
182 - New NEON kernels / functions:
183 - @ref arm_compute::NENormalizationLayerKernel / @ref arm_compute::NENormalizationLayer
184 - @ref arm_compute::NETransposeKernel / @ref arm_compute::NETranspose
185 - @ref arm_compute::NELogits1DMaxKernel, @ref arm_compute::NELogits1DShiftExpSumKernel, @ref arm_compute::NELogits1DNormKernel / @ref arm_compute::NESoftmaxLayer
186 - @ref arm_compute::NEIm2ColKernel, @ref arm_compute::NECol2ImKernel, arm_compute::NEConvolutionLayerWeightsReshapeKernel / @ref arm_compute::NEConvolutionLayer
187 - @ref arm_compute::NEGEMMMatrixAccumulateBiasesKernel / @ref arm_compute::NEFullyConnectedLayer
188 - @ref arm_compute::NEGEMMLowpMatrixMultiplyKernel / @ref arm_compute::NEGEMMLowp
189
190v17.03 Sources preview
191 - New OpenCL kernels / functions:
192 - @ref arm_compute::CLGradientKernel, @ref arm_compute::CLEdgeNonMaxSuppressionKernel, @ref arm_compute::CLEdgeTraceKernel / @ref arm_compute::CLCannyEdge
193 - GEMM refactoring + FP16 support: @ref arm_compute::CLGEMMInterleave4x4Kernel, @ref arm_compute::CLGEMMTranspose1xWKernel, @ref arm_compute::CLGEMMMatrixMultiplyKernel, @ref arm_compute::CLGEMMMatrixAdditionKernel / @ref arm_compute::CLGEMM
194 - @ref arm_compute::CLGEMMMatrixAccumulateBiasesKernel / @ref arm_compute::CLFullyConnectedLayer
195 - @ref arm_compute::CLTransposeKernel / @ref arm_compute::CLTranspose
196 - @ref arm_compute::CLLKTrackerInitKernel, @ref arm_compute::CLLKTrackerStage0Kernel, @ref arm_compute::CLLKTrackerStage1Kernel, @ref arm_compute::CLLKTrackerFinalizeKernel / @ref arm_compute::CLOpticalFlow
197 - @ref arm_compute::CLNormalizationLayerKernel / @ref arm_compute::CLNormalizationLayer
198 - @ref arm_compute::CLLaplacianPyramid, @ref arm_compute::CLLaplacianReconstruct
199 - New NEON kernels / functions:
200 - @ref arm_compute::NEActivationLayerKernel / @ref arm_compute::NEActivationLayer
201 - GEMM refactoring + FP16 support (Requires armv8.2 CPU): @ref arm_compute::NEGEMMInterleave4x4Kernel, @ref arm_compute::NEGEMMTranspose1xWKernel, @ref arm_compute::NEGEMMMatrixMultiplyKernel, @ref arm_compute::NEGEMMMatrixAdditionKernel / @ref arm_compute::NEGEMM
202 - @ref arm_compute::NEPoolingLayerKernel / @ref arm_compute::NEPoolingLayer
203
204v17.02.1 Sources preview
205 - New OpenCL kernels / functions:
206 - @ref arm_compute::CLLogits1DMaxKernel, @ref arm_compute::CLLogits1DShiftExpSumKernel, @ref arm_compute::CLLogits1DNormKernel / @ref arm_compute::CLSoftmaxLayer
207 - @ref arm_compute::CLPoolingLayerKernel / @ref arm_compute::CLPoolingLayer
Gian Marco Iodice5cb4c422017-06-23 10:38:25 +0100208 - @ref arm_compute::CLIm2ColKernel, @ref arm_compute::CLCol2ImKernel, arm_compute::CLConvolutionLayerWeightsReshapeKernel / @ref arm_compute::CLConvolutionLayer
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100209 - @ref arm_compute::CLRemapKernel / @ref arm_compute::CLRemap
210 - @ref arm_compute::CLGaussianPyramidHorKernel, @ref arm_compute::CLGaussianPyramidVertKernel / @ref arm_compute::CLGaussianPyramid, @ref arm_compute::CLGaussianPyramidHalf, @ref arm_compute::CLGaussianPyramidOrb
211 - @ref arm_compute::CLMinMaxKernel, @ref arm_compute::CLMinMaxLocationKernel / @ref arm_compute::CLMinMaxLocation
212 - @ref arm_compute::CLNonLinearFilterKernel / @ref arm_compute::CLNonLinearFilter
213 - New NEON FP16 kernels (Requires armv8.2 CPU)
214 - @ref arm_compute::NEAccumulateWeightedFP16Kernel
215 - @ref arm_compute::NEBox3x3FP16Kernel
216 - @ref arm_compute::NENonMaximaSuppression3x3FP16Kernel
217
218v17.02 Sources preview
219 - New OpenCL kernels / functions:
220 - @ref arm_compute::CLActivationLayerKernel / @ref arm_compute::CLActivationLayer
221 - @ref arm_compute::CLChannelCombineKernel / @ref arm_compute::CLChannelCombine
222 - @ref arm_compute::CLDerivativeKernel / @ref arm_compute::CLChannelExtract
223 - @ref arm_compute::CLFastCornersKernel / @ref arm_compute::CLFastCorners
224 - @ref arm_compute::CLMeanStdDevKernel / @ref arm_compute::CLMeanStdDev
225 - New NEON kernels / functions:
226 - HOG / SVM: @ref arm_compute::NEHOGOrientationBinningKernel, @ref arm_compute::NEHOGBlockNormalizationKernel, @ref arm_compute::NEHOGDetectorKernel, arm_compute::NEHOGNonMaximaSuppressionKernel / @ref arm_compute::NEHOGDescriptor, @ref arm_compute::NEHOGDetector, @ref arm_compute::NEHOGGradient, @ref arm_compute::NEHOGMultiDetection
227 - @ref arm_compute::NENonLinearFilterKernel / @ref arm_compute::NENonLinearFilter
228 - Introduced a CLScheduler to manage the default context and command queue used by the runtime library and create synchronisation events.
229 - Switched all the kernels / functions to use tensors instead of images.
230 - Updated documentation to include instructions to build the library from sources.
231
232v16.12 Binary preview release
233 - Original release
234
235@section S3_how_to_build How to build the library and the examples
236
237@subsection S3_1_build_options Build options
238
239scons 2.3 or above is required to build the library.
240To see the build options available simply run ```scons -h```:
241
Anthony Barbier79c61782017-06-23 11:48:24 +0100242 debug: Debug (yes|no)
243 default: False
244 actual: False
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100245
Anthony Barbier79c61782017-06-23 11:48:24 +0100246 asserts: Enable asserts (this flag is forced to 1 for debug=1) (yes|no)
247 default: False
248 actual: False
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100249
Anthony Barbier79c61782017-06-23 11:48:24 +0100250 arch: Target Architecture (armv7a|arm64-v8a|arm64-v8.2-a|x86_32|x86_64)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100251 default: armv7a
252 actual: armv7a
253
Anthony Barbier79c61782017-06-23 11:48:24 +0100254 os: Target OS (linux|android|bare_metal)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100255 default: linux
256 actual: linux
257
Anthony Barbier79c61782017-06-23 11:48:24 +0100258 build: Build type (native|cross_compile)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100259 default: cross_compile
260 actual: cross_compile
261
Anthony Barbier79c61782017-06-23 11:48:24 +0100262 examples: Build example programs (yes|no)
263 default: True
264 actual: True
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100265
Anthony Barbier79c61782017-06-23 11:48:24 +0100266 Werror: Enable/disable the -Werror compilation flag (yes|no)
267 default: True
268 actual: True
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100269
Anthony Barbier79c61782017-06-23 11:48:24 +0100270 opencl: Enable OpenCL support (yes|no)
271 default: True
272 actual: True
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100273
Anthony Barbier79c61782017-06-23 11:48:24 +0100274 neon: Enable Neon support (yes|no)
275 default: False
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100276 actual: False
277
Anthony Barbier79c61782017-06-23 11:48:24 +0100278 embed_kernels: Embed OpenCL kernels in library binary (yes|no)
279 default: False
280 actual: False
281
282 set_soname: Set the library's soname and shlibversion (requires SCons 2.4 or above) (yes|no)
283 default: False
284 actual: False
285
286 openmp: Enable OpenMP backend (yes|no)
287 default: False
288 actual: False
289
290 cppthreads: Enable C++11 threads backend (yes|no)
291 default: True
292 actual: True
293
294 build_dir: Specify sub-folder for the build ( /path/to/build_dir )
295 default: .
296 actual: .
297
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100298 extra_cxx_flags: Extra CXX flags to be appended to the build command
299 default:
300 actual:
301
Anthony Barbier79c61782017-06-23 11:48:24 +0100302 pmu: Enable PMU counters (yes|no)
303 default: False
304 actual: False
305
306 validation_tests: Build validation test programs (yes|no)
307 default: False
308 actual: False
309
310 benchmark_tests: Build benchmark test programs (yes|no)
311 default: False
312 actual: False
313
314@b debug / @b asserts:
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100315 - With debug=1 asserts are enabled, and the library is built with symbols and no optimisations enabled.
316 - With debug=0 and asserts=1: Optimisations are enabled and symbols are removed, however all the asserts are still present (This is about 20% slower than the release build)
317 - With debug=0 and asserts=0: All optimisations are enable and no validation is performed, if the application misuses the library it is likely to result in a crash. (Only use this mode once you are sure your application is working as expected).
318
Anthony Barbier79c61782017-06-23 11:48:24 +0100319@b arch: The x86_32 and x86_64 targets can only be used with neon=0 and opencl=1.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100320
Anthony Barbier79c61782017-06-23 11:48:24 +0100321@b os: Choose the operating system you are targeting: Linux, Android or bare metal.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100322@note bare metal can only be used for NEON (not OpenCL), only static libraries get built and NEON's multi-threading support is disabled.
323
Anthony Barbier79c61782017-06-23 11:48:24 +0100324@b build: you can either build directly on your device (native) or cross compile from your desktop machine (cross-compile). In both cases make sure the compiler is available in your path.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100325
Anthony Barbier79c61782017-06-23 11:48:24 +0100326@note If you want to natively compile for 32bit on a 64bit ARM device running a 64bit OS then you will have to use cross-compile too.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100327
Anthony Barbier79c61782017-06-23 11:48:24 +0100328@b Werror: If you are compiling using the same toolchains as the ones used in this guide then there shouldn't be any warning and therefore you should be able to keep Werror=1. If with a different compiler version the library fails to build because of warnings interpreted as errors then, if you are sure the warnings are not important, you might want to try to build with Werror=0 (But please do report the issue either on Github or by an email to developer@arm.com so that the issue can be addressed).
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100329
Anthony Barbier79c61782017-06-23 11:48:24 +0100330@b opencl / @b neon: Choose which SIMD technology you want to target. (NEON for ARM Cortex-A CPUs or OpenCL for ARM Mali GPUs)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100331
Anthony Barbier79c61782017-06-23 11:48:24 +0100332@b embed_kernels: For OpenCL only: set embed_kernels=1 if you want the OpenCL kernels to be built in the library's binaries instead of being read from separate ".cl" files. If embed_kernels is set to 0 then the application can set the path to the folder containing the OpenCL kernel files by calling CLKernelLibrary::init(). By default the path is set to "./cl_kernels".
333
334@b set_soname: Do you want to build the versioned version of the library ?
335
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100336If enabled the library will contain a SONAME and SHLIBVERSION and some symlinks will automatically be created between the objects.
337Example:
338 libarm_compute_core.so -> libarm_compute_core.so.1.0.0
339 libarm_compute_core.so.1 -> libarm_compute_core.so.1.0.0
340 libarm_compute_core.so.1.0.0
341
342@note This options is disabled by default as it requires SCons version 2.4 or above.
343
Anthony Barbier79c61782017-06-23 11:48:24 +0100344@b extra_cxx_flags: Custom CXX flags which will be appended to the end of the build command.
345
346@b build_dir: Build the library in a subfolder of the "build" folder. (Allows to build several configurations in parallel).
347
348@b examples: Build or not the examples
349
350@b validation_tests: Enable the build of the validation suite.
351
352@note You will need the Boost Test and Program options headers and libraries to build the validation tests. See @ref building_boost for more information.
353
354@b benchmark_tests: Enable the build of the benchmark tests
355
356@b pmu: Enable the PMU cycle counter to measure execution time in benchmark tests. (Your device needs to support it)
357
Anthony Barbier79c61782017-06-23 11:48:24 +0100358@b openmp Build in the OpenMP scheduler for NEON.
359
360@note Only works when building with g++ not clang++
361
362@b cppthreads Build in the C++11 scheduler for NEON.
363
364@sa arm_compute::Scheduler::set
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100365
Moritz Pflanzer07674de2017-07-21 09:39:36 +0100366@subsection S3_2_linux Building for Linux
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100367
368@subsubsection S3_2_1_library How to build the library ?
369
370For Linux, the library was successfully built and tested using the following Linaro GCC toolchain:
371
372 - gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux
373 - gcc-linaro-4.9-2016.02-x86_64_aarch64-linux-gnu
374 - gcc-linaro-6.3.1-2017.02-i686_aarch64-linux-gnu
375
376@note If you are building with opencl=1 then scons will expect to find libOpenCL.so either in the current directory or in "build" (See the section below if you need a stub OpenCL library to link against)
377
378To cross-compile the library in debug mode, with NEON only support, for Linux 32bit:
379
380 scons Werror=1 -j8 debug=1 neon=1 opencl=0 os=linux arch=armv7a
381
382To cross-compile the library in asserts mode, with OpenCL only support, for Linux 64bit:
383
384 scons Werror=1 -j8 debug=0 asserts=1 neon=0 opencl=1 embed_kernels=1 os=linux arch=arm64-v8a
385
386You can also compile the library natively on an ARM device by using <b>build=native</b>:
387
388 scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux arch=arm64-v8a build=native
389 scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux arch=armv7a build=native
390
391@note g++ for ARM is mono-arch, therefore if you want to compile for Linux 32bit on a Linux 64bit platform you will have to use a cross compiler.
392
393For example on a 64bit Debian based system you would have to install <b>g++-arm-linux-gnueabihf</b>
394
395 apt-get install g++-arm-linux-gnueabihf
396
397Then run
398
399 scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux arch=armv7a build=cross_compile
400
401or simply remove the build parameter as build=cross_compile is the default value:
402
403 scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux arch=armv7a
404
405@attention To cross compile with opencl=1 you need to make sure to have a version of libOpenCL matching your target architecture.
406
407@subsubsection S3_2_2_examples How to manually build the examples ?
408
409The examples get automatically built by scons as part of the build process of the library described above. This section just describes how you can build and link your own application against our library.
410
411@note The following command lines assume the arm_compute and libOpenCL binaries are present in the current directory or in the system library path. If this is not the case you can specify the location of the pre-built library with the compiler option -L. When building the OpenCL example the commands below assume that the CL headers are located in the include folder where the command is executed.
412
413To cross compile a NEON example for Linux 32bit:
414
415 arm-linux-gnueabihf-g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -std=c++11 -mfpu=neon -L. -larm_compute -o neon_convolution
416
417To cross compile a NEON example for Linux 64bit:
418
419 aarch64-linux-gnu-g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -std=c++11 -L. -larm_compute -o neon_convolution
420
421(notice the only difference with the 32 bit command is that we don't need the -mfpu option and the compiler's name is different)
422
423To cross compile an OpenCL example for Linux 32bit:
424
Anthony Barbier15d5ac82017-07-17 15:22:17 +0100425 arm-linux-gnueabihf-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -mfpu=neon -L. -larm_compute -lOpenCL -o cl_convolution -DARM_COMPUTE_CL
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100426
427To cross compile an OpenCL example for Linux 64bit:
428
Anthony Barbier15d5ac82017-07-17 15:22:17 +0100429 aarch64-linux-gnu-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -L. -larm_compute -lOpenCL -o cl_convolution -DARM_COMPUTE_CL
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100430
431(notice the only difference with the 32 bit command is that we don't need the -mfpu option and the compiler's name is different)
432
433To compile natively (i.e directly on an ARM device) for NEON for Linux 32bit:
434
435 g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -std=c++11 -mfpu=neon -larm_compute -o neon_convolution
436
437To compile natively (i.e directly on an ARM device) for NEON for Linux 64bit:
438
439 g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -std=c++11 -larm_compute -o neon_convolution
440
441(notice the only difference with the 32 bit command is that we don't need the -mfpu option)
442
443To compile natively (i.e directly on an ARM device) for OpenCL for Linux 32bit or Linux 64bit:
444
Anthony Barbier15d5ac82017-07-17 15:22:17 +0100445 g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute -lOpenCL -o cl_convolution -DARM_COMPUTE_CL
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100446
447
448@note These two commands assume libarm_compute.so is available in your library path, if not add the path to it using -L
449
450To run the built executable simply run:
451
452 LD_LIBRARY_PATH=build ./neon_convolution
453
454or
455
456 LD_LIBRARY_PATH=build ./cl_convolution
457
458@note If you built the library with support for both OpenCL and NEON you will need to link against OpenCL even if your application only uses NEON.
459
Moritz Pflanzer07674de2017-07-21 09:39:36 +0100460@subsection S3_3_android Building for Android
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100461
462For Android, the library was successfully built and tested using Google's standalone toolchains:
463 - arm-linux-androideabi-4.9 for armv7a (clang++)
464 - aarch64-linux-android-4.9 for arm64-v8a (g++)
465
466Here is a guide to <a href="https://developer.android.com/ndk/guides/standalone_toolchain.html">create your Android standalone toolchains from the NDK</a>
467
468- Download the NDK r14 from here: https://developer.android.com/ndk/downloads/index.html
469- Make sure you have Python 2 installed on your machine.
470- Generate the 32 and/or 64 toolchains by running the following commands:
471
472
473 $NDK/build/tools/make_standalone_toolchain.py --arch arm64 --install-dir $MY_TOOLCHAINS/aarch64-linux-android-4.9 --stl gnustl
474 $NDK/build/tools/make_standalone_toolchain.py --arch arm --install-dir $MY_TOOLCHAINS/arm-linux-androideabi-4.9 --stl gnustl
475
476@attention Due to some NDK issues make sure you use g++ & gnustl for aarch64 and clang++ & gnustl for armv7
477
478@note Make sure to add the toolchains to your PATH: export PATH=$PATH:$MY_TOOLCHAINS/aarch64-linux-android-4.9/bin:$MY_TOOLCHAINS/arm-linux-androideabi-4.9/bin
479
480@subsubsection S3_3_1_library How to build the library ?
481
482@note If you are building with opencl=1 then scons will expect to find libOpenCL.so either in the current directory or in "build" (See the section below if you need a stub OpenCL library to link against)
483
484To cross-compile the library in debug mode, with NEON only support, for Android 32bit:
485
486 CXX=clang++ CC=clang scons Werror=1 -j8 debug=1 neon=1 opencl=0 os=android arch=armv7a
487
488To cross-compile the library in asserts mode, with OpenCL only support, for Android 64bit:
489
490 scons Werror=1 -j8 debug=0 asserts=1 neon=0 opencl=1 embed_kernels=1 os=android arch=arm64-v8a
491
492@subsubsection S3_3_2_examples How to manually build the examples ?
493
494The examples get automatically built by scons as part of the build process of the library described above. This section just describes how you can build and link your own application against our library.
495
Anthony Barbierfabb0382017-06-23 14:42:52 +0100496@note The following command lines assume the arm_compute and libOpenCL binaries are present in the current directory or in the system library path. If this is not the case you can specify the location of the pre-built library with the compiler option -L. When building the OpenCL example the commands below assume that the CL headers are located in the include folder where the command is executed.
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100497
498Once you've got your Android standalone toolchain built and added to your path you can do the following:
499
500To cross compile a NEON example:
501
502 #32 bit:
Anthony Barbierfabb0382017-06-23 14:42:52 +0100503 arm-linux-androideabi-clang++ examples/neon_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o neon_convolution_arm -static-libstdc++ -pie
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100504 #64 bit:
Anthony Barbierfabb0382017-06-23 14:42:52 +0100505 aarch64-linux-android-g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o neon_convolution_aarch64 -static-libstdc++ -pie
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100506
507To cross compile an OpenCL example:
508
509 #32 bit:
Anthony Barbier15d5ac82017-07-17 15:22:17 +0100510 arm-linux-androideabi-clang++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o cl_convolution_arm -static-libstdc++ -pie -lOpenCL -DARM_COMPUTE_CL
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100511 #64 bit:
Anthony Barbier15d5ac82017-07-17 15:22:17 +0100512 aarch64-linux-android-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o cl_convolution_aarch64 -static-libstdc++ -pie -lOpenCL -DARM_COMPUTE_CL
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100513
514@note Due to some issues in older versions of the Mali OpenCL DDK (<= r13p0), we recommend to link arm_compute statically on Android.
515
516Then you need to do is upload the executable and the shared library to the device using ADB:
517
518 adb push neon_convolution_arm /data/local/tmp/
519 adb push cl_convolution_arm /data/local/tmp/
520 adb shell chmod 777 -R /data/local/tmp/
521
522And finally to run the example:
523
524 adb shell /data/local/tmp/neon_convolution_arm
525 adb shell /data/local/tmp/cl_convolution_arm
526
527For 64bit:
528
529 adb push neon_convolution_aarch64 /data/local/tmp/
530 adb push cl_convolution_aarch64 /data/local/tmp/
531 adb shell chmod 777 -R /data/local/tmp/
532
533And finally to run the example:
534
535 adb shell /data/local/tmp/neon_convolution_aarch64
536 adb shell /data/local/tmp/cl_convolution_aarch64
537
Moritz Pflanzer07674de2017-07-21 09:39:36 +0100538@subsection S3_4_windows_host Building on a Windows host system
539
540Using `scons` directly from the Windows command line is known to cause
541problems. The reason seems to be that if `scons` is setup for cross-compilation
542it gets confused about Windows style paths (using backslashes). Thus it is
543recommended to follow one of the options outlined below.
544
545@subsubsection S3_4_1_ubuntu_on_windows Bash on Ubuntu on Windows
546
547The best and easiest option is to use
548<a href="https://msdn.microsoft.com/en-gb/commandline/wsl/about">Ubuntu on Windows</a>.
549This feature is still marked as *beta* and thus might not be available.
550However, if it is building the library is as simple as opening a *Bash on
551Ubuntu on Windows* shell and following the general guidelines given above.
552
553@subsubsection S3_4_2_cygwin Cygwin
554
555If the Windows subsystem for Linux is not available <a href="https://www.cygwin.com/">Cygwin</a>
556can be used to install and run `scons`. In addition to the default packages
557installed by Cygwin `scons` has to be selected in the installer. (`git` might
558also be useful but is not strictly required if you already have got the source
559code of the library.) Linaro provides pre-built versions of
560<a href="http://releases.linaro.org/components/toolchain/binaries/">GCC cross-compilers</a>
561that can be used from the Cygwin terminal. When building for Android the
562compiler is included in the Android standalone toolchain. After everything has
563been set up in the Cygwin terminal the general guide on building the library
564can be followed.
565
566@subsection S3_5_cl_stub_library The OpenCL stub library
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100567
568In the opencl-1.2-stubs folder you will find the sources to build a stub OpenCL library which then can be used to link your application or arm_compute against.
569
570If you preferred you could retrieve the OpenCL library from your device and link against this one but often this library will have dependencies on a range of system libraries forcing you to link your application against those too even though it is not using them.
571
572@warning This OpenCL library provided is a stub and *not* a real implementation. You can use it to resolve OpenCL's symbols in arm_compute while building the example but you must make sure the real libOpenCL.so is in your PATH when running the example or it will not work.
573
574To cross-compile the stub OpenCL library simply run:
575
576 <target-prefix>-gcc -o libOpenCL.so -Iinclude opencl-1.2-stubs/opencl_stubs.c -fPIC -shared
577
578For example:
579
580 <target-prefix>-gcc -o libOpenCL.so -Iinclude opencl-1.2-stubs/opencl_stubs.c -fPIC -shared
581 #Linux 32bit
582 arm-linux-gnueabihf-gcc -o libOpenCL.so -Iinclude opencl-1.2-stubs/opencl_stubs.c -fPIC -shared
583 #Linux 64bit
584 aarch64-linux-gnu-gcc -o libOpenCL.so -Iinclude -shared opencl-1.2-stubs/opencl_stubs.c -fPIC
585 #Android 32bit
586 arm-linux-androideabi-clang -o libOpenCL.so -Iinclude -shared opencl-1.2-stubs/opencl_stubs.c -fPIC -shared
587 #Android 64bit
588 aarch64-linux-android-gcc -o libOpenCL.so -Iinclude -shared opencl-1.2-stubs/opencl_stubs.c -fPIC -shared
589*/