aboutsummaryrefslogtreecommitdiff
path: root/docs/00_introduction.dox
blob: f84e64e9a008bc9e970f395e540d21090064e4fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
/** @mainpage Introduction

@tableofcontents

The Computer Vision and Machine Learning library is a set of functions optimised for both ARM CPUs and GPUs using SIMD technologies.

Several builds of the library are available using various configurations:
 - OS: Linux, Android or bare metal.
 - Architecture: armv7a (32bit) or arm64-v8a (64bit)
 - Technology: NEON / OpenCL / NEON and OpenCL
 - 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.

@section S0_1_contact Contact / Support

Please email developer@arm.com

In 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:

    $ strings android-armv7a-cl-asserts/libarm_compute.so | grep arm_compute_version
    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

@section S1_file_organisation File organisation

This archive contains:
 - The arm_compute header and source files
 - The latest Khronos OpenCL 1.2 C headers from the <a href="https://www.khronos.org/registry/cl/">Khronos OpenCL registry</a>
 - 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)
 - The sources for a stub version of libOpenCL.so to help you build your application.
 - An examples folder containing a few examples to compile and link against the library.
 - A @ref utils folder containing headers with some boiler plate code used by the examples.
 - This documentation.

You should have the following file organisation:

	.
	├── arm_compute --> All the arm_compute headers
	│   ├── core
	│   │   ├── CL
	│   │   │   ├── CLKernels.h --> Includes all the OpenCL kernels at once
	│   │   │   ├── CL specialisation of all the generic objects interfaces (ICLTensor, ICLImage, etc.)
	│   │   │   ├── kernels --> Folder containing all the OpenCL kernels
	│   │   │   │   └── CL*Kernel.h
	│   │   │   └── OpenCL.h --> Wrapper to configure the Khronos OpenCL C++ header
	│   │   ├── CPP
	│   │   │   └── kernels --> Folder containing all the CPP kernels
	│   │   │   │   └── CPP*Kernel.h
	│   │   ├── NEON
	│   │   │   ├── kernels --> Folder containing all the NEON kernels
	│   │   │   │   └── NE*Kernel.h
	│   │   │   └── NEKernels.h --> Includes all the NEON kernels at once
	│   │   ├── All common basic types (Types.h, Window, Coordinates, Iterator, etc.)
	│   │   ├── All generic objects interfaces (ITensor, IImage, etc.)
	│   │   └── Objects metadata classes (ImageInfo, TensorInfo, MultiImageInfo)
	│   └── runtime
	│       ├── CL
	│       │   ├── CL objects & allocators (CLArray, CLImage, CLTensor, etc.)
	│       │   ├── functions --> Folder containing all the OpenCL functions
	│       │   │   └── CL*.h
	│       │   └── CLFunctions.h --> Includes all the OpenCL functions at once
	│       ├── CPP
	│       │   └── Scheduler.h --> Basic pool of threads to execute CPP/NEON code on several cores in parallel
	│       ├── NEON
	│       │   ├── functions --> Folder containing all the NEON functions
	│       │   │   └── NE*.h
	│       │   └── NEFunctions.h --> Includes all the NEON functions at once
	│       └── Basic implementations of the generic object interfaces (Array, Image, Tensor, etc.)
	├── documentation
	│   ├── index.xhtml
	│   └── ...
	├── documentation.xhtml -> documentation/index.xhtml
	├── examples
	│   ├── cl_convolution.cpp
	│   ├── neoncl_scale_median_gaussian.cpp
	│   ├── neon_convolution.cpp
	│   └── neon_scale.cpp
	├── include
	│   └── CL
	│       └── Khronos OpenCL C headers and C++ wrapper
	├── opencl-1.2-stubs
	│   └── opencl_stubs.c
	├── src
	│   ├── core
	│   │   └── ... (Same structure as headers)
	│   │       └── CL
	│   │           └── cl_kernels --> All the OpenCL kernels
	│   └── runtime
	│       └── ... (Same structure as headers)
	├── tests
	│   ├── All test related files shared between validation and benchmark
	│   ├── CL --> OpenCL specific files (shared)
	│   ├── NEON --> NEON specific files (shared)
	│   ├── benchmark --> Sources for benchmarking
	│   │   ├── Benchmark specific files
	│   │   ├── main.cpp --> Entry point for benchmark test framework
	│   │   ├── CL --> OpenCL benchmarking tests
	│   │   └── NEON --> NEON benchmarking tests
	│   ├── validation --> Sources for validation
	│   │   ├── Validation specific files
	│   │   ├── main.cpp --> Entry point for validation test framework
	│   │   ├── CL --> OpenCL validation tests
	│   │   ├── NEON --> NEON validation tests
	│   │   └── UNIT --> Library validation tests
	│   └── dataset --> Datasets defining common sets of input parameters
	└── utils --> Boiler plate code used by examples
	    └── Utils.h

@section S2_versions_changelog Release versions and changelog

@subsection S2_1_versions Release versions

All releases are numbered vYY.MM Where YY are the last two digits of the year, and MM the month number.
If there is more than one release in a month then an extra sequential number is appended at the end:

	v17.03 (First release of March 2017)
	v17.03.1 (Second release of March 2017)
	v17.04 (First release of April 2017)

@note We're aiming at releasing one major public release with new features per quarter. All releases in between will only contain bug fixes.

@subsection S2_2_changelog Changelog

v17.06 Public major release
 - Various bug fixes
 - Added support for fixed point 8 bit (QS8) to the various NEON machine learning kernels.
 - Added unit tests and benchmarks (AlexNet, LeNet)
 - Added support for sub tensors.
 - Added infrastructure to provide GPU specific optimisation for some OpenCL kernels.
 - Added @ref arm_compute::OMPScheduler (OpenMP) scheduler for NEON
 - Added @ref arm_compute::SingleThreadScheduler scheduler for NEON (For bare metal)
 - User can specify his own scheduler by implementing the @ref arm_compute::IScheduler interface.
 - New OpenCL kernels / functions:
    - @ref arm_compute::CLBatchNormalizationLayerKernel / @ref arm_compute::CLBatchNormalizationLayer
    - @ref arm_compute::CLDepthConcatenateKernel / @ref arm_compute::CLDepthConcatenate
    - @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
    - @ref arm_compute::CLLocallyConnectedMatrixMultiplyKernel / @ref arm_compute::CLLocallyConnectedLayer
    - @ref arm_compute::CLWeightsReshapeKernel / @ref arm_compute::CLConvolutionLayerReshapeWeights
 - New C++ kernels:
    - @ref arm_compute::CPPDetectionWindowNonMaximaSuppressionKernel
 - New NEON kernels / functions:
    - @ref arm_compute::NEBatchNormalizationLayerKernel / @ref arm_compute::NEBatchNormalizationLayer
    - @ref arm_compute::NEDepthConcatenateKernel / @ref arm_compute::NEDepthConcatenate
    - @ref arm_compute::NEDirectConvolutionLayerKernel / @ref arm_compute::NEDirectConvolutionLayer
    - @ref arm_compute::NELocallyConnectedMatrixMultiplyKernel / @ref arm_compute::NELocallyConnectedLayer
    - @ref arm_compute::NEWeightsReshapeKernel / @ref arm_compute::NEConvolutionLayerReshapeWeights

v17.05 Public bug fixes release
 - Various bug fixes
 - Remaining of the functions ported to use accurate padding.
 - Library does not link against OpenCL anymore (It uses dlopen / dlsym at runtime instead to determine whether or not OpenCL is available).
 - Added "free" method to allocator.
 - Minimum version of g++ required for armv7 Linux changed from 4.8 to 4.9

v17.04 Public bug fixes release

 The following functions have been ported to use the new accurate padding:
 -  @ref arm_compute::CLColorConvertKernel
 -  @ref arm_compute::CLEdgeNonMaxSuppressionKernel
 -  @ref arm_compute::CLEdgeTraceKernel
 -  @ref arm_compute::CLGaussianPyramidHorKernel
 -  @ref arm_compute::CLGaussianPyramidVertKernel
 -  @ref arm_compute::CLGradientKernel
 -  @ref arm_compute::NEChannelCombineKernel
 -  @ref arm_compute::NEFillArrayKernel
 -  @ref arm_compute::NEGaussianPyramidHorKernel
 -  @ref arm_compute::NEGaussianPyramidVertKernel
 -  @ref arm_compute::NEHarrisScoreFP16Kernel
 -  @ref arm_compute::NEHarrisScoreKernel
 -  @ref arm_compute::NEHOGDetectorKernel
 -  @ref arm_compute::NELogits1DMaxKernel
 -  @ref arm_compute::NELogits1DShiftExpSumKernel
 -  @ref arm_compute::NELogits1DNormKernel
 -  @ref arm_compute::NENonMaximaSuppression3x3FP16Kernel
 -  @ref arm_compute::NENonMaximaSuppression3x3Kernel


v17.03.1 First Major public release of the sources
 - Renamed the library to arm_compute
 - New CPP target introduced for C++ kernels shared between NEON and CL functions.
 - New padding calculation interface introduced and ported most kernels / functions to use it.
 - New OpenCL kernels / functions:
   - @ref arm_compute::CLGEMMLowpMatrixMultiplyKernel / @ref arm_compute::CLGEMMLowp
 - New NEON kernels / functions:
   - @ref arm_compute::NENormalizationLayerKernel / @ref arm_compute::NENormalizationLayer
   - @ref arm_compute::NETransposeKernel / @ref arm_compute::NETranspose
   - @ref arm_compute::NELogits1DMaxKernel, @ref arm_compute::NELogits1DShiftExpSumKernel, @ref arm_compute::NELogits1DNormKernel / @ref arm_compute::NESoftmaxLayer
   - @ref arm_compute::NEIm2ColKernel, @ref arm_compute::NECol2ImKernel, arm_compute::NEConvolutionLayerWeightsReshapeKernel / @ref arm_compute::NEConvolutionLayer
   - @ref arm_compute::NEGEMMMatrixAccumulateBiasesKernel / @ref arm_compute::NEFullyConnectedLayer
   - @ref arm_compute::NEGEMMLowpMatrixMultiplyKernel / @ref arm_compute::NEGEMMLowp

v17.03 Sources preview
 - New OpenCL kernels / functions:
   - @ref arm_compute::CLGradientKernel, @ref arm_compute::CLEdgeNonMaxSuppressionKernel, @ref arm_compute::CLEdgeTraceKernel / @ref arm_compute::CLCannyEdge
   - GEMM refactoring + FP16 support: @ref arm_compute::CLGEMMInterleave4x4Kernel, @ref arm_compute::CLGEMMTranspose1xWKernel, @ref arm_compute::CLGEMMMatrixMultiplyKernel, @ref arm_compute::CLGEMMMatrixAdditionKernel / @ref arm_compute::CLGEMM
   - @ref arm_compute::CLGEMMMatrixAccumulateBiasesKernel / @ref arm_compute::CLFullyConnectedLayer
   - @ref arm_compute::CLTransposeKernel / @ref arm_compute::CLTranspose
   - @ref arm_compute::CLLKTrackerInitKernel, @ref arm_compute::CLLKTrackerStage0Kernel, @ref arm_compute::CLLKTrackerStage1Kernel, @ref arm_compute::CLLKTrackerFinalizeKernel / @ref arm_compute::CLOpticalFlow
   - @ref arm_compute::CLNormalizationLayerKernel / @ref arm_compute::CLNormalizationLayer
   - @ref arm_compute::CLLaplacianPyramid, @ref arm_compute::CLLaplacianReconstruct
 - New NEON kernels / functions:
   - @ref arm_compute::NEActivationLayerKernel / @ref arm_compute::NEActivationLayer
   - 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
   - @ref arm_compute::NEPoolingLayerKernel / @ref arm_compute::NEPoolingLayer

v17.02.1 Sources preview
 - New OpenCL kernels / functions:
   - @ref arm_compute::CLLogits1DMaxKernel, @ref arm_compute::CLLogits1DShiftExpSumKernel, @ref arm_compute::CLLogits1DNormKernel / @ref arm_compute::CLSoftmaxLayer
   - @ref arm_compute::CLPoolingLayerKernel / @ref arm_compute::CLPoolingLayer
   - @ref arm_compute::CLIm2ColKernel, @ref arm_compute::CLCol2ImKernel, @ref arm_compute::CLConvolutionLayerWeightsReshapeKernel / @ref arm_compute::CLConvolutionLayer
   - @ref arm_compute::CLRemapKernel / @ref arm_compute::CLRemap
   - @ref arm_compute::CLGaussianPyramidHorKernel, @ref arm_compute::CLGaussianPyramidVertKernel / @ref arm_compute::CLGaussianPyramid, @ref arm_compute::CLGaussianPyramidHalf, @ref arm_compute::CLGaussianPyramidOrb
   - @ref arm_compute::CLMinMaxKernel, @ref arm_compute::CLMinMaxLocationKernel / @ref arm_compute::CLMinMaxLocation
   - @ref arm_compute::CLNonLinearFilterKernel / @ref arm_compute::CLNonLinearFilter
 - New NEON FP16 kernels (Requires armv8.2 CPU)
   - @ref arm_compute::NEAccumulateWeightedFP16Kernel
   - @ref arm_compute::NEBox3x3FP16Kernel
   - @ref arm_compute::NENonMaximaSuppression3x3FP16Kernel

v17.02 Sources preview
 - New OpenCL kernels / functions:
   - @ref arm_compute::CLActivationLayerKernel / @ref arm_compute::CLActivationLayer
   - @ref arm_compute::CLChannelCombineKernel / @ref arm_compute::CLChannelCombine
   - @ref arm_compute::CLDerivativeKernel / @ref arm_compute::CLChannelExtract
   - @ref arm_compute::CLFastCornersKernel / @ref arm_compute::CLFastCorners
   - @ref arm_compute::CLMeanStdDevKernel / @ref arm_compute::CLMeanStdDev
 - New NEON kernels / functions:
   - 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
   - @ref arm_compute::NENonLinearFilterKernel / @ref arm_compute::NENonLinearFilter
 - Introduced a CLScheduler to manage the default context and command queue used by the runtime library and create synchronisation events.
 - Switched all the kernels / functions to use tensors instead of images.
 - Updated documentation to include instructions to build the library from sources.

v16.12 Binary preview release
 - Original release

@section S3_how_to_build How to build the library and the examples

@subsection S3_1_build_options Build options

scons 2.3 or above is required to build the library.
To see the build options available simply run ```scons -h```:

	debug: Debug (default=0) (0|1)
		default: 0
		actual: 0

	asserts: Enable asserts (This flag is forced to 1 for debug=1) (default=0) (0|1)
		default: 0
		actual: 0

	arch: Target Architecture (default=armv7a) (armv7a|arm64-v8a|arm64-v8.2-a|x86_32|x86_64)
		default: armv7a
		actual: armv7a

	os: Target OS (default=linux) (linux|android|bare_metal)
		default: linux
		actual: linux

	build: Build type: (default=cross_compile) (native|cross_compile)
		default: cross_compile
		actual: cross_compile

	Werror: Enable/disable the -Werror compilation flag (Default=1) (0|1)
		default: 1
		actual: 1

	opencl: Enable OpenCL support(Default=1) (0|1)
		default: 1
		actual: 1

	neon: Enable Neon support(Default=0) (0|1)
		default: 0
		actual: 0

	embed_kernels: Embed OpenCL kernels in library binary(Default=0) (0|1)
		default: 0
		actual: 0

	scheduler: Scheduler backend(Default=cpp) (cpp|pthread|openmp)
		default: cpp
		actual: cpp

	set_soname: Set the library's soname and shlibversion (Requires SCons 2.4 or above) (yes|no)
		default: 0
		actual: False

	extra_cxx_flags: Extra CXX flags to be appended to the build command
		default:
		actual:

Debug / asserts:
 - With debug=1 asserts are enabled, and the library is built with symbols and no optimisations enabled.
 - 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)
 - 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).

Architecture: The x86_32 and x86_64 targets can only be used with neon=0 and opencl=1.

OS: Choose the operating system you are targeting: Linux, Android or bare metal.
@note bare metal can only be used for NEON (not OpenCL), only static libraries get built and NEON's multi-threading support is disabled.

Build type: 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.

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).

OpenCL / NEON: Choose which SIMD technology you want to target. (NEON for ARM Cortex-A CPUs or OpenCL for ARM Mali GPUs)

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".

set_soname: Do you want to build the versioned version of the library ?
If enabled the library will contain a SONAME and SHLIBVERSION and some symlinks will automatically be created between the objects.
Example:
  libarm_compute_core.so -> libarm_compute_core.so.1.0.0
  libarm_compute_core.so.1 -> libarm_compute_core.so.1.0.0
  libarm_compute_core.so.1.0.0

@note This options is disabled by default as it requires SCons version 2.4 or above.

extra_cxx_flags: Custom CXX flags which will be appended to the end of the build command.

@subsection S3_2_linux Linux

@subsubsection S3_2_1_library How to build the library ?

For Linux, the library was successfully built and tested using the following Linaro GCC toolchain:

 - gcc-linaro-arm-linux-gnueabihf-4.9-2014.07_linux
 - gcc-linaro-4.9-2016.02-x86_64_aarch64-linux-gnu
 - gcc-linaro-6.3.1-2017.02-i686_aarch64-linux-gnu

@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)

To cross-compile the library in debug mode, with NEON only support, for Linux 32bit:

	scons Werror=1 -j8 debug=1 neon=1 opencl=0 os=linux arch=armv7a

To cross-compile the library in asserts mode, with OpenCL only support, for Linux 64bit:

	scons Werror=1 -j8 debug=0 asserts=1 neon=0 opencl=1 embed_kernels=1 os=linux arch=arm64-v8a

You can also compile the library natively on an ARM device by using <b>build=native</b>:

	scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux arch=arm64-v8a build=native
	scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux arch=armv7a build=native

@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.

For example on a 64bit Debian based system you would have to install <b>g++-arm-linux-gnueabihf</b>

	apt-get install g++-arm-linux-gnueabihf

Then run

	scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux arch=armv7a build=cross_compile

or simply remove the build parameter as build=cross_compile is the default value:

	scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux arch=armv7a

@attention To cross compile with opencl=1 you need to make sure to have a version of libOpenCL matching your target architecture.

@subsubsection S3_2_2_examples How to manually build the examples ?

The 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.

@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.

To cross compile a NEON example for Linux 32bit:

	arm-linux-gnueabihf-g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -std=c++11 -mfpu=neon -L. -larm_compute -o neon_convolution

To cross compile a NEON example for Linux 64bit:

	aarch64-linux-gnu-g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -std=c++11 -L. -larm_compute -o neon_convolution

(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)

To cross compile an OpenCL example for Linux 32bit:

	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

To cross compile an OpenCL example for Linux 64bit:

	aarch64-linux-gnu-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -L. -larm_compute -lOpenCL -o cl_convolution

(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)

To compile natively (i.e directly on an ARM device) for NEON for Linux 32bit:

	g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -std=c++11 -mfpu=neon -larm_compute -o neon_convolution

To compile natively (i.e directly on an ARM device) for NEON for Linux 64bit:

	g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -std=c++11 -larm_compute -o neon_convolution

(notice the only difference with the 32 bit command is that we don't need the -mfpu option)

To compile natively (i.e directly on an ARM device) for OpenCL for Linux 32bit or Linux 64bit:

	g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute -lOpenCL -o cl_convolution


@note These two commands assume libarm_compute.so is available in your library path, if not add the path to it using -L

To run the built executable simply run:

	LD_LIBRARY_PATH=build ./neon_convolution

or

	LD_LIBRARY_PATH=build ./cl_convolution

@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.

@subsection S3_3_android Android

For Android, the library was successfully built and tested using Google's standalone toolchains:
 - arm-linux-androideabi-4.9 for armv7a (clang++)
 - aarch64-linux-android-4.9 for arm64-v8a (g++)

Here is a guide to <a href="https://developer.android.com/ndk/guides/standalone_toolchain.html">create your Android standalone toolchains from the NDK</a>

- Download the NDK r14 from here: https://developer.android.com/ndk/downloads/index.html
- Make sure you have Python 2 installed on your machine.
- Generate the 32 and/or 64 toolchains by running the following commands:


	$NDK/build/tools/make_standalone_toolchain.py --arch arm64 --install-dir $MY_TOOLCHAINS/aarch64-linux-android-4.9 --stl gnustl
	$NDK/build/tools/make_standalone_toolchain.py --arch arm --install-dir $MY_TOOLCHAINS/arm-linux-androideabi-4.9 --stl gnustl

@attention Due to some NDK issues make sure you use g++ & gnustl for aarch64 and clang++ & gnustl for armv7

@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

@subsubsection S3_3_1_library How to build the library ?

@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)

To cross-compile the library in debug mode, with NEON only support, for Android 32bit:

	CXX=clang++ CC=clang scons Werror=1 -j8 debug=1 neon=1 opencl=0 os=android arch=armv7a

To cross-compile the library in asserts mode, with OpenCL only support, for Android 64bit:

	scons Werror=1 -j8 debug=0 asserts=1 neon=0 opencl=1 embed_kernels=1 os=android arch=arm64-v8a

@subsubsection S3_3_2_examples How to manually build the examples ?

The 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.

@note The following command lines assume the arm_compute binaries are present in the current directory or in the system library path.

Once you've got your Android standalone toolchain built and added to your path you can do the following:

To cross compile a NEON example:

	#32 bit:
	arm-linux-androideabi-clang++ examples/neon_convolution.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o neon_convolution_arm -static-libstdc++ -pie
	#64 bit:
	aarch64-linux-android-g++ examples/neon_convolution.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o neon_convolution_aarch64 -static-libstdc++ -pie

To cross compile an OpenCL example:

	#32 bit:
	arm-linux-androideabi-clang++ examples/cl_convolution.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o cl_convolution_arm -static-libstdc++ -pie -lOpenCL
	#64 bit:
	aarch64-linux-android-g++ examples/cl_convolution.cpp -I. -Iinclude -std=c++11 -larm_compute-static -L. -o cl_convolution_aarch64 -static-libstdc++ -pie -lOpenCL

@note Due to some issues in older versions of the Mali OpenCL DDK (<= r13p0), we recommend to link arm_compute statically on Android.

Then you need to do is upload the executable and the shared library to the device using ADB:

	adb push neon_convolution_arm /data/local/tmp/
	adb push cl_convolution_arm /data/local/tmp/
	adb shell chmod 777 -R /data/local/tmp/

And finally to run the example:

	adb shell /data/local/tmp/neon_convolution_arm
	adb shell /data/local/tmp/cl_convolution_arm

For 64bit:

	adb push neon_convolution_aarch64 /data/local/tmp/
	adb push cl_convolution_aarch64 /data/local/tmp/
	adb shell chmod 777 -R /data/local/tmp/

And finally to run the example:

	adb shell /data/local/tmp/neon_convolution_aarch64
	adb shell /data/local/tmp/cl_convolution_aarch64

@subsection S3_4_cl_stub_library The OpenCL stub library

In 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.

If 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.

@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.

To cross-compile the stub OpenCL library simply run:

	<target-prefix>-gcc -o libOpenCL.so -Iinclude opencl-1.2-stubs/opencl_stubs.c -fPIC -shared

For example:

	<target-prefix>-gcc -o libOpenCL.so -Iinclude opencl-1.2-stubs/opencl_stubs.c -fPIC -shared
	#Linux 32bit
	arm-linux-gnueabihf-gcc -o libOpenCL.so -Iinclude opencl-1.2-stubs/opencl_stubs.c -fPIC -shared
	#Linux 64bit
	aarch64-linux-gnu-gcc -o libOpenCL.so -Iinclude -shared opencl-1.2-stubs/opencl_stubs.c -fPIC
	#Android 32bit
	arm-linux-androideabi-clang -o libOpenCL.so -Iinclude -shared opencl-1.2-stubs/opencl_stubs.c -fPIC -shared
	#Android 64bit
	aarch64-linux-android-gcc -o libOpenCL.so -Iinclude -shared opencl-1.2-stubs/opencl_stubs.c -fPIC -shared
*/