NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Template:Psdkla opencv opencl

From Texas Instruments Wiki
Jump to: navigation, search

Testing OpenCL[edit]

NOTE! Support for OpenCL is available only upto K4.4 releases. Check the release notes to see if this feature is available on the Processor SDK Linux Automotive release you are using.


OpenCL is supported in the SDK from the 3.02 release. To test OpenCL, please follow the below steps.

  1. OpenCL requires reserving areas of memory to allow transfer of data between A15 and DSP. To reserve memory, apply the below kernel patch, rebuild the device tree file and boot with the updated device tree.

    http://review.omapzoom.org/38240 dra7xx: dts: reserve memory for opencl

  2. Ensure that the OpenCL firmware is loaded to the DSP. In the default PSDKLA filesystem, OpenCL firmware is not loaded by default. Follow the below steps to select the right firmware and reboot.

    <source lang="bash">root@dra7xx-evm:~# cd /lib/firmware/ root@dra7xx-evm:/lib/firmware# ls -la *dsp*-fw.xe66 lrwxrwxrwx 1 1000 pulse 55 Feb 13 2017 dra7-dsp1-fw.xe66 -> ipc/ti_platforms_evmDRA7XX_dsp1/test_omx_dsp1_vayu.xe66 lrwxrwxrwx 1 1000 pulse 55 Feb 13 2017 dra7-dsp2-fw.xe66 -> ipc/ti_platforms_evmDRA7XX_dsp2/test_omx_dsp2_vayu.xe66 root@dra7xx-evm:/lib/firmware# rm dra7-dsp1-fw.xe66 dra7-dsp2-fw.xe66 root@dra7xx-evm:/lib/firmware# ln -s dra7-dsp1-fw.xe66.opencl-monitor dra7-dsp1-fw.xe66 root@dra7xx-evm:/lib/firmware# ln -s dra7-dsp2-fw.xe66.opencl-monitor dra7-dsp2-fw.xe66 root@dra7xx-evm:/lib/firmware# ls -la *dsp*-fw.xe66 lrwxrwxrwx 1 root root 32 Feb 24 2017 dra7-dsp1-fw.xe66 -> dra7-dsp1-fw.xe66.opencl-monitor lrwxrwxrwx 1 root root 32 Feb 24 2017 dra7-dsp2-fw.xe66 -> dra7-dsp2-fw.xe66.opencl-monitor

    root@dra7xx-evm:/lib/firmware# sync</source>
  3. Ensure that the cmemk module is inserted in the kernel.

    <source lang="bash">root@dra7xx-evm:~# lsmod | grep cmemk

    cmemk 35110 2</source>
  4. Ensure that CMEM memory reservations are in effect. Link

    <source lang="bash">root@dra7xx-evm:~# cat /proc/iomem | grep -i cmem 40500000-405fffff : CMEM

    a0000000-abffffff : CMEM</source>
  5. OpenCL examples are present in the filesystem in /usr/share/ti/examples/opencl. The examples are prebuilt and can be executed on the target.

    <source lang="bash">root@dra7xx-evm:/usr/share/ti/examples/opencl# ls Makefile dgemm float_compute monte_carlo offline_embed sgemm vecadd_openmp buffer dsplib_fft make.inc null ooo_callback simple vecadd_openmp_t ccode edmamgr matmpy offline platforms vecadd

    root@dra7xx-evm:/usr/share/ti/examples/opencl# cd platforms/ root@dra7xx-evm:/usr/share/ti/examples/opencl/platforms# ls Makefile Makefile.rtos main.cpp main.o platforms

    root@dra7xx-evm:/usr/share/ti/examples/opencl/platforms# ./platforms PLATFORM: TI AM57x Version: OpenCL 1.1 TI product version 01.01.11.2 (Feb 19 2017 21:41:17) Vendor : Texas Instruments, Inc. Profile: FULL_PROFILE

       DEVICE: TI Multicore C66 DSP
       Type       : ACCELERATOR
       CompUnits  : 2
       Frequency  : 0.6 GHz
       Glb Mem    :  163840 KB
       GlbExt1 Mem:       0 KB
       GlbExt2 Mem:       0 KB
       Msmc Mem   :    1024 KB
       Loc Mem    :     128 KB
       Max Alloc  :  147456 KB
    

    root@dra7xx-evm:/usr/share/ti/examples/opencl/platforms# cd ../vecadd root@dra7xx-evm:/usr/share/ti/examples/opencl/vecadd# ./vecadd DEVICE: TI Multicore C66 DSP

    Offloading vector addition of 8192K elements...

    Kernel Exec : Queue to Submit: 13 us Kernel Exec : Submit to Start : 120 us Kernel Exec : Start to End  : 33010 us

    Success! </source>

    Full instructions on building OpenCL examples are here.

    http://downloads.ti.com/mctools/esd/docs/opencl/examples/build_and_run.html

    Instructions on testing OpenCL examples are here. This page also includes a description of each example and the functionality demonstrated by each example.

    http://downloads.ti.com/mctools/esd/docs/opencl/examples/overview.html

Information on environment variables controlling the OpenCL runtime are described in the below link. The number of DSP's used for OpenCL and which DSP is used for OpenCL offloading can also be controlled using environment variables described in the below link.

http://downloads.ti.com/mctools/esd/docs/opencl/environment_variables.html

Testing OpenCV[edit]

NOTE! Support for OpenCV is available only upto K4.4 releases. Check the release notes to see if this feature is available on the Processor SDK Linux Automotive release you are using.


The 3.02 release also supports OpenCV. OpenCV is accelerated by using the C66x DSP's through OpenCL. Please follow the steps to validate OpenCL before running the OpenCV tests

  1. Download OpenCV test data from https://github.com/Itseez/opencv_extra/archive/master.zip unzip this file in /usr/share/OpenCV. This will create a directory opencv_extra-master with the below contents.

    <source lang="bash">root@dra7xx-evm # ls /usr/share/OpenCV/opencv_extra-master/ 3d android_manager_internal_docs classifiers gpu_demos_pack learning_opencv_v2 README.md testdata</source>

    The testsuite expects the testdata folder in /usr/share/OpenCV. Create a symbolic link to the testdata folder in /usr/share/OpenCV or move the testdata to the required location.

    <source lang="bash">root@dra7xx-evm:/usr/share/OpenCV# ln -s opencv_extra-master/testdata .</source>
  2. Run the tests with the following commands

    <source lang="bash">root@dra7xx-evm:/usr/share/OpenCV# cd titestsuite/ root@dra7xx-evm:/usr/share/OpenCV/titestsuite# ls runtests setupEnv.sh test_core_ocl test_imgproc_ocl root@dra7xx-evm:/usr/share/OpenCV/titestsuite# source setupEnv.sh root@dra7xx-evm:/usr/share/OpenCV/titestsuite# ./runtests</source>

    The tests run for ~70 mins on DRA75x platform which has 2 DSP's. Processing is offloaded transparently to the DSP where possible.

For more information on OpenCV and accelerating OpenCV using the C66x DSP's via OpenCL, please refer to the below links.

  1. TI Processors Wiki OpenCV page
  2. How to add a new DSP Kernel
  3. Creating OpenCL C Kernel optimized for C66 core

OpenCV can be rebuilt and installed via the yocto pacakge opencv.

Ducati performance measurement[edit]

Ducati performance is assessed by factors like IVA use, IVA fps, cpu load etc. To obtain these values changes are required in ipumm.

Changes to be done in ipumm Makefile[edit]

  1. Open the Makefile in ipumm (under component-sources of installer).
  2. Set PROFILER to ENABLE (by default it's DISABLE).
  3. Make sure that TRACELEVEL is set to 0 during performance measurement (High trace level effects the performance and will not give the best results).
  4. Open ipumm/src/ti/utils/profile.c and set kpi_control=7(default it is set to 0)
  5. Change directory to parent directory of component-sources.
  6. Run make ipumm
  7. dra7-ipu2-fw.xem4 is created in ipumm directory. Copy this to the /lib/firmware of rootfs and reboot
  8. Execute video decode usecase with gstreamer or viddec3test.
  9. Execute cat /sys/kernel/debug/remoteproc/remoteproc1/trace0 . Traces will show the iva load, fps achieved, average and Peak MHz etc.