R-Car/Boards/Yocto-Gen3/OpenCL

OpenCL support
The meta-opencl layer provides the following packages:


 * cl-gles-user-module - OpenCL/OpenGL user module for Renesas R-Car R8A7795 SoC boards
 * gfortran - GNU Fortran compiler
 * libgfortran - GNU Fortran library
 * gflags - command line flags processing library
 * snappy - fast compressor/decompressor
 * lmdb - Lightning Memory-Mapped Database
 * opencv - Open Computer Vision library
 * openblas - optimized linear algebra library
 * viennacl - linear algebra library for computations on many-core architectures
 * clblas - library containing BLAS functions written in OpenCL
 * caffe - deep learning framework

Note: OpenCL is currently supported on Renesas R-Car R8A7795 SoC boards.

Building Yocto images with OpenCL support
Set up Yocto 2.12 as usual, and use the following steps to enable OpenCL Caffe support before starting the build:  Copy OpenCL/OpenGL binaries to the meta-opencl layer: cp r8a7795_linux_gsx_binaries_cl_gles3.tar.bz2 meta-opencl/recipes-graphics/cl-gles-module/cl-gles-user-module/  Add meta-opencl layer to BBLAYERS in bblayers.conf file: ${TOPDIR}/../meta-opencl \  Add meta-python layer to BBLAYERS in bblayers.conf file: ${TOPDIR}/../meta-openembedded/meta-python \  Replace all occurrences of gles-user-module with cl-gles-user-module, and add PREFERRED_PROVIDER_virtual/opencl variable equal to "cl-gles-user-module" in local.conf: PREFERRED_PROVIDER_virtual/libgles2 = "cl-gles-user-module" PREFERRED_PROVIDER_virtual/egl = "cl-gles-user-module" PREFERRED_PROVIDER_virtual/opencl = "cl-gles-user-module"  Enable cl-gles-user-module instead of gles-user-module in local.conf: PREFERRED_PROVIDER_gles-user-module = "cl-gles-user-module"  Edit local.conf to add Caffe to the rootfs image in local.conf: IMAGE_INSTALL_append = " caffe"  Edit local.conf to add packages necessary for downloading and unpacking Caffe sample models: IMAGE_INSTALL_append = " git python-argparse python-pyyaml python-six"  Start the build as usual: bitbake core-image-weston </li></ol>

If the target board is to be used for natively building OpenCL applications, it might be useful to follow additional configuration steps below.

<ol> Enable Fortran support in local.conf: FORTRAN_forcevariable = ",fortran" RUNTIMETARGET_append_pn-gcc-runtime = " libquadmath libgfortran" IMAGE_INSTALL_append = " gfortran gfortran-symlinks libgfortran libgfortran-dev" </li> Enable cmake in local.conf: IMAGE_INSTALL_append = " cmake" </li> Enable boost development libraries in local.conf: IMAGE_INSTALL_append = " boost-dev boost-staticdev" </li> Enable support development libraries in local.conf: IMAGE_INSTALL_append = " gflags-dev snappy-dev protobuf-dev leveldb-dev lmdb-dev opencv-dev" </li> Enable BLAS development libraries in local.conf: IMAGE_INSTALL_append = " caffe-dev clblas-dev viennacl-dev openblas-dev" </li> Build the SDK image: bitbake core-image-weston-sdk </li></ol>

Note: sample configuration files are available at meta-opencl/docs/sample/conf.

Testing OpenCL
Use the following command to start OpenCL unit tests on the board: ocl_unit_test

The application should perform the unit tests and print results to the console. The last message should indicate the number of passed tests: Finished 31 tests in 171.5 seconds: 31 passed, 0 failed (100.00%)

Testing Caffe
Before Caffe classification test can be started, Caffe model has to be downloaded and unpacked. The next two steps can be done on the target board directly, provided the board is connected to the internet, and DNS is properly set up. Otherwise, the model can be downloaded to the host system and copied to the target rootfs later.

<ol> Download Caffe sources: git clone -b opencl -n git://github.com/BVLC/caffe.git cd caffe git checkout -b tmp e0f77c3b5f4837615f05b097ba3f2a05d7413e58 </li> Download and unpack Caffe model: ./scripts/download_model_binary.py models/bvlc_reference_caffenet ./data/ilsvrc12/get_ilsvrc_aux.sh </li> Run Caffe classification test on the target board from Caffe source directory: classification \ models/bvlc_reference_caffenet/deploy.prototxt \ models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel \ data/ilsvrc12/imagenet_mean.binaryproto \ data/ilsvrc12/synset_words.txt \ examples/images/cat.jpg

The test should detect the cat in the image, and produce the following output to the console: Use GPU with device ID 0 -- Prediction for examples/images/cat.jpg -- 0.3134 - "n02123045 tabby, tabby cat" 0.2380 - "n02123159 tiger cat" 0.1235 - "n02124075 Egyptian cat" 0.1004 - "n02119022 red fox, Vulpes vulpes" 0.0715 - "n02127052 lynx, catamount" </li></ol>