Update ACL pin to 8abbabd6ad946441c8ef1a03896fa98f7801af1f
[platform/upstream/armnn.git] / BuildGuideCrossCompilation.md
index ec85526..6b03f13 100644 (file)
@@ -1,12 +1,11 @@
 # How to Cross-Compile ArmNN on x86_64 for arm64
 
 *  [Introduction](#introduction)
+*  [Cross-compiling ToolChain](#installCCT)
 *  [Build and install Google's Protobuf library](#buildProtobuf)
 *  [Build Caffe for x86_64](#buildCaffe)
-*  [Cross-compiling ToolChain](#installCCT)
 *  [Build Boost library for arm64](#installBaarch)
 *  [Build Compute Library](#buildCL)
-*  [Build Compute Library](#buildCL)
 *  [Build ArmNN](#buildANN)
 *  [Run Unit Tests](#unittests)
 *  [Troubleshooting and Errors](#troubleshooting)
 These are the step by step instructions on Cross-Compiling ArmNN under an x86_64 system to target an Arm64 system. This build flow has been tested with Ubuntu 16.04.
 The instructions show how to build the ArmNN core library and the Boost, Protobuf, Caffe and Compute Libraries necessary for compilation.
 
+#### <a name="installCCT">Cross-compiling ToolChain</a>
+* Install the standard cross-compilation libraries for arm64:
+    ```
+    sudo apt install crossbuild-essential-arm64
+    ```
+
 #### <a name="buildProtobuf">Build and install Google's Protobuf library</a>
 
 * Get protobuf-all-3.5.1.tar.gz from here: https://github.com/protocolbuffers/protobuf/releases/tag/v3.5.1
@@ -37,8 +42,8 @@ The instructions show how to build the ArmNN core library and the Boost, Protobu
     ```
     mkdir arm64_build
     cd arm64_build
-    CC=aarch64-linux-gnu-gcc \
-    CXX=aarch64-linux-gnu-g++ \
+    export CC=aarch64-linux-gnu-gcc \
+    export CXX=aarch64-linux-gnu-g++ \
     ../configure --host=aarch64-linux \
     --prefix=$HOME/armnn-devenv/google/arm64_pb_install \
     --with-protoc=$HOME/armnn-devenv/google/x86_64_pb_install/bin/protoc
@@ -62,15 +67,14 @@ The instructions show how to build the ArmNN core library and the Boost, Protobu
     cd caffe
     cp Makefile.config.example Makefile.config
     ```
-* Adjust Makefile.config (for example, if using Anaconda Python, or if cuDNN is desired):
+* Adjust Makefile.config as necessary for your environment, for example:
     ```
-    CPU only version -
+    #CPU only version:
     CPU_ONLY := 1
-    Add hdf5 and protobuf include and library directories (Replace $HOME with your actual /home/username dir)
-        INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/ $HOME/armnn-devenv/google/x86_64_pb_install/include/
-        LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/ $HOME/armnn-devenv/google/x86_64_pb_install/lib/
-    g++ need to be version 5
-    CUSTOM_CXX := g++-5
+
+    #Add hdf5 and protobuf include and library directories (Replace $HOME with explicit /home/username dir):
+    INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/ $HOME/armnn-devenv/google/x86_64_pb_install/include/
+    LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/ $HOME/armnn-devenv/google/x86_64_pb_install/lib/
     ```
 * Setup environment:
     ```bash
@@ -86,15 +90,10 @@ The instructions show how to build the ArmNN core library and the Boost, Protobu
     These should all run without errors
 * caffe.pb.h and caffe.pb.cc will be needed when building ArmNN's Caffe Parser
 
-#### <a name="installCCT">Cross-compiling ToolChain</a>
-* Install the standard cross-compilation libraries for arm64:
-   ```
-   sudo apt install crossbuild-essential-arm64
-   ```
 #### <a name="installBaarch">Build Boost library for arm64</a>
 * Build Boost library for arm64
     Download Boost version 1.64 from http://www.boost.org/doc/libs/1_64_0/more/getting_started/unix-variants.html
-    Version 1.66 is not supported.
+    Using any version of Boost greater than 1.64 will fail to build ArmNN, due to different dependency issues.
     ```bash
     tar -zxvf boost_1_64_0.tar.gz
     cd boost_1_64_0
@@ -123,27 +122,59 @@ The instructions show how to build the ArmNN core library and the Boost, Protobu
 * Use CMake to configure your build environment, update the following script and run it from the armnn/build directory to set up the armNN build:
     ```bash
     #!/bin/bash
-    CXX=aarch64-linux-gnu-g++ \
-    CC=aarch64-linux-gnu-gcc \
+    export CXX=aarch64-linux-gnu-g++ \
+    export CC=aarch64-linux-gnu-gcc \
     cmake .. \
     -DARMCOMPUTE_ROOT=$HOME/armnn-devenv/ComputeLibrary \
     -DARMCOMPUTE_BUILD_DIR=$HOME/armnn-devenv/ComputeLibrary/build/ \
     -DBOOST_ROOT=$HOME/armnn-devenv/boost_arm64_install/ \
-    -DARMCOMPUTENEON=1  -DARMCOMPUTECL=1 \
+    -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 -DARMNNREF=1 \
     -DCAFFE_GENERATED_SOURCES=$HOME/armnn-devenv/caffe/build/src \
     -DBUILD_CAFFE_PARSER=1 \
     -DPROTOBUF_ROOT=$HOME/armnn-devenv/google/x86_64_pb_install/ \
     -DPROTOBUF_LIBRARY_DEBUG=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.15.0.1 \
     -DPROTOBUF_LIBRARY_RELEASE=$HOME/armnn-devenv/google/arm64_pb_install/lib/libprotobuf.so.15.0.1
     ```
+
+* If you want to include standalone sample dynamic backend tests, add the argument to enable the tests and the dynamic backend path to the CMake command:
+    ```bash
+    -DSAMPLE_DYNAMIC_BACKEND=1 \
+    -DDYNAMIC_BACKEND_PATHS=$SAMPLE_DYNAMIC_BACKEND_PATH
+    ```
 * Run the build
     ```bash
     make -j32
     ```
 
+#### <a name="buildStandaloneBackend">Build Standalone Sample Dynamic Backend</a>
+* The sample dynamic backend is located in armnn/src/dynamic/sample
+    ```bash
+    mkdir build
+    cd build
+    ```
+
+* Use CMake to configure your build environment, update the following script and run it from the armnn/src/dynamic/sample/build directory to set up the armNN build:
+    ```bash
+    #!/bin/bash
+    export CXX=aarch64-linux-gnu-g++ \
+    export CC=aarch64-linux-gnu-gcc \
+    cmake .. \
+    -DCMAKE_CXX_FLAGS=--std=c++14 \
+    -DBOOST_ROOT=$HOME/armnn-devenv/boost_arm64_install/ \
+    -DBoost_SYSTEM_LIBRARY=$HOME/armnn-devenv/boost_arm64_install/lib/libboost_system.a \
+    -DBoost_FILESYSTEM_LIBRARY=$HOME/armnn-devenv/boost_arm64_install/lib/libboost_filesystem.a \
+    -DARMNN_PATH=$HOME/armnn-devenv/armnn/build/libarmnn.so
+    ```
+
+* Run the build
+    ```bash
+    make
+    ```
+
 #### <a name="unittests">Run Unit Tests</a>
 * Copy the build folder to an arm64 linux machine
 * Copy the libprotobuf.so.15.0.1 library file to the build folder
+* If you enable the standalone sample dynamic tests, also copy libArm_SampleDynamic_backend.so library file to the folder specified as $SAMPLE_DYNAMIC_BACKEND_PATH when you build ArmNN 
 * cd to the build folder on your arm64 machine and set your LD_LIBRARY_PATH to its current location:
     ```
     cd build/
@@ -216,9 +247,9 @@ The instructions show how to build the ArmNN core library and the Boost, Protobu
 * If apt-get update returns 404 errors for arm64 repos refer to section 5 below.
 * Alternatively the missing arm64 version of libz.so.1 can be downloaded and installed from a .deb package here:
       https://launchpad.net/ubuntu/wily/arm64/zlib1g/1:1.2.8.dfsg-2ubuntu4
-  ```bash
-  sudo dpkg -i zlib1g_1.2.8.dfsg-2ubuntu4_arm64.deb
-  ```
+    ```bash
+    sudo dpkg -i zlib1g_1.2.8.dfsg-2ubuntu4_arm64.deb
+    ```
 ##
 #### Unable to install arm64 packages after adding arm64 architecture
 * Using sudo apt-get update should add all of the required repos for arm64 but if it does not or you are getting 404 errors the following instructions can be used to add the repos manually: