OpenCL support on ROCK5

I just receive my pre-order board today.

Everything is working well on 20.04 systems except for OpenCL.

When I search about it, Rock4 should download OpenCL library with apt but there are no package for rock5 at now.

Some people said that another RK3588 SBC already has their own library for OpenCL (libOpenCL.so, or libmali.so) in factory rom status but I can’t find it in my system.

Is there any support for OpenCL in ROCK5 20.04 system ?

OpenCL does appear to work with the mali blob, and eventually Rusticl in Mesa will also become usable.

ixn@rock-5b:~$ clinfo
Number of platforms                               1
  Platform Name                                   ARM Platform
  Platform Vendor                                 ARM
  Platform Version                                OpenCL 2.1 v1.g6p0-01eac0.ba52c908d926792b8f5fe28f383a2b03
  Platform Profile                                FULL_PROFILE
  Platform Extensions function suffix             ARM
  Platform Host timer resolution                  1ns

  Platform Name                                   ARM Platform
Number of devices                                 1
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '6'.
  Device Name                                     Mali-LODX r0p0
  Device Vendor                                   ARM
  Device Vendor ID                                0xa8670000
  Device Version                                  OpenCL 2.1 v1.g6p0-01eac0.ba52c908d926792b8f5fe28f383a2b03

Does clinfo already work for you?

If not:

  • You need to have the the Mali blob drivers installed. If you don’t already see libmali.so somewhere in /usr/lib, you can download one of the g610 blobs.
  • You need to have the firmware installed. If /lib/firmware/mali_csffw.bin does not exist, download the file and place it there.
  • The blob drivers need to be registered as an OpenCL implementation. Make sure the directory /etc/OpenCL/vendors exists, then create a file mali.icd inside which contains the full path to the libmali library, so for me that shows:
ixn@rock-5b:~$ cat /etc/OpenCL/vendors/mali.icd
/home/ixn/libmali/libmali-valhall-g610-g6p0-wayland-gbm.so
1 Like

Oh…I see.

On ubuntu 20.04 nothing is bundled. When I try clinfo at debian xface rom, everythin is fine.

Your guide is very informative to me. Thanks !!

Brilliant as was just asking in the debug if that works as ArmNN with the Mali might be interesting.

https://developer.arm.com/documentation/102603/2108/Device-specific-installation/Install-on-Odroid-N2-Plus

The wav2letter model is pretty ropey but for an example its ok and off to give it a go.

[edit] Not what I was expecting

time python3 run_audio_file.py --audio_file_path tests/testdata/quick_brown_fox_16000khz.wav --model_file_path tflite_int8/wav2letter_int8.tflite  --preferred_backends CpuAcc CpuRef
Your ArmNN library instance does not support Onnx models parser functionality.  Skipped IOnnxParser import.
Preferred backends: ['CpuAcc', 'CpuRef']
IDeviceSpec { supportedBackends: [CpuAcc, CpuRef]}
Optimization warnings: ()
Processing Audio Frames...
the quick brown fox juhmpe over the llazy dag

real    0m2.724s
user    0m8.195s
sys     0m0.293s
(venv) rock@rock-5b:~/workspace/armnn/python/pyarmnn/examples/speech_recognition$ time python3 run_audio_file.py --audio_file_path tests/testdata/quick_brown_fox_16000khz.wav --model_file_path tflite_int8/wav2letter_int8.tflite  --preferred_backends GpuAcc CpuRef
Your ArmNN library instance does not support Onnx models parser functionality.  Skipped IOnnxParser import.
Preferred backends: ['GpuAcc', 'CpuRef']
IDeviceSpec { supportedBackends: [CpuAcc, CpuRef]}
Optimization warnings: ()
Processing Audio Frames...
the quick brown fox juhmped over the llazy dag

real    1m25.357s
user    1m29.172s
sys     0m0.474s

Its just running on CpuRef but at least shows what the neon does with CpuAcc but dunno why ArmNN is reporting
IDeviceSpec { supportedBackends: [CpuAcc, CpuRef]}

as

 clinfo
Number of platforms                               1
  Platform Name                                   ARM Platform
  Platform Vendor                                 ARM
  Platform Version                                OpenCL 2.1 v1.g6p0-01eac0.efb75e2978d783a80fe78be1bfb0efc1
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp16 cl_khr_icd cl_khr_egl_image cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_subgroups cl_khr_subgroup_extended_types cl_khr_subgroup_non_uniform_vote cl_khr_subgroup_ballot cl_khr_il_program cl_khr_priority_hints cl_khr_create_command_queue cl_khr_spirv_no_integer_wrap_decoration cl_khr_extended_versioning cl_khr_device_uuid cl_arm_core_id cl_arm_printf cl_arm_non_uniform_work_group_size cl_arm_import_memory cl_arm_import_memory_dma_buf cl_arm_import_memory_host cl_arm_integer_dot_product_int8 cl_arm_integer_dot_product_accumulate_int8 cl_arm_integer_dot_product_accumulate_saturate_int8 cl_arm_scheduling_controls cl_arm_controlled_kernel_termination cl_ext_cxx_for_opencl
  Platform Host timer resolution                  1ns
  Platform Extensions function suffix             ARM

  Platform Name                                   ARM Platform
Number of devices                                 1
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '5'.
  Device Name                                     Mali-LODX r0p0
  Device Vendor                                   ARM
  Device Vendor ID                                0xa8670000
  Device Version                                  OpenCL 2.1 v1.g6p0-01eac0.efb75e2978d783a80fe78be1bfb0efc1
  Driver Version                                  2.1
  Device OpenCL C Version                         OpenCL C 2.0 v1.g6p0-01eac0.efb75e2978d783a80fe78be1bfb0efc1
  Device Type                                     GPU
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               4
  Max clock frequency                             1000MHz
  Device Partition                                (core)
    Max number of sub-devices                     0
    Supported partition types                     None
    Supported affinity domains                    (n/a)
  Max work item dimensions                        3
  Max work item sizes                             1024x1024x1024
  Max work group size                             1024
  Preferred work group size multiple              16
  Max sub-groups per work group                   64
  Preferred / native vector sizes
    char                                                16 / 4
    short                                                8 / 2
    int                                                  4 / 1
    long                                                 2 / 1
    half                                                 8 / 2        (cl_khr_fp16)
    float                                                4 / 1
    double                                               0 / 0        (n/a)
  Half-precision Floating-point support           (cl_khr_fp16)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Single-precision Floating-point support         (core)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  No
  Double-precision Floating-point support         (n/a)
  Address bits                                    64, Little-Endian
  Global memory size                              3914665984 (3.646GiB)
  Error Correction support                        No
  Max memory allocation                           3914665984 (3.646GiB)
  Unified memory for Host and Device              Yes
  Shared Virtual Memory (SVM) capabilities        (core)
    Coarse-grained buffer sharing                 Yes
    Fine-grained buffer sharing                   No
    Fine-grained system sharing                   No
    Atomics                                       No
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       1024 bits (128 bytes)
  Preferred alignment for atomics
    SVM                                           0 bytes
    Global                                        0 bytes
    Local                                         0 bytes
  Max size for global variable                    65536 (64KiB)
  Preferred total size of global vars             0
  Global Memory cache type                        Read/Write
  Global Memory cache size                        1048576 (1024KiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             16
    Max size for 1D images from buffer            65536 pixels
    Max 1D or 2D image array size                 2048 images
    Base address alignment for 2D image buffers   32 bytes
    Pitch alignment for 2D image buffers          64 pixels
    Max 2D image size                             65536x65536 pixels
    Max 3D image size                             65536x65536x65536 pixels
    Max number of read image args                 128
    Max number of write image args                64
    Max number of read/write image args           64
  Max number of pipe args                         16
  Max active pipe reservations                    1
  Max pipe packet size                            1024
  Local memory type                               Global
  Local memory size                               32768 (32KiB)
  Max number of constant args                     128
  Max constant buffer size                        3914665984 (3.646GiB)
  Max size of kernel argument                     1024
  Queue properties (on host)
    Out-of-order execution                        Yes
    Profiling                                     Yes
  Queue properties (on device)
    Out-of-order execution                        Yes
    Profiling                                     Yes
    Preferred size                                2097152 (2MiB)
    Max size                                      16777216 (16MiB)
  Max queues on device                            1
  Max events on device                            1024
  Prefer user sync for interop                    No
  Profiling timer resolution                      1000ns
  Execution capabilities
    Run OpenCL kernels                            Yes
    Run native kernels                            No
    Sub-group independent forward progress        Yes
    IL version                                    SPIR-V_1.0
    SPIR versions                                 <printDeviceInfo:161: get CL_DEVICE_SPIR_VERSIONS size : error -30>
  printf() buffer size                            1048576 (1024KiB)
  Built-in kernels                                (n/a)
  Device Extensions                               cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_3d_image_writes cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp16 cl_khr_icd cl_khr_egl_image cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_subgroups cl_khr_subgroup_extended_types cl_khr_subgroup_non_uniform_vote cl_khr_subgroup_ballot cl_khr_il_program cl_khr_priority_hints cl_khr_create_command_queue cl_khr_spirv_no_integer_wrap_decoration cl_khr_extended_versioning cl_khr_device_uuid cl_arm_core_id cl_arm_printf cl_arm_non_uniform_work_group_size cl_arm_import_memory cl_arm_import_memory_dma_buf cl_arm_import_memory_host cl_arm_integer_dot_product_int8 cl_arm_integer_dot_product_accumulate_int8 cl_arm_integer_dot_product_accumulate_saturate_int8 cl_arm_scheduling_controls cl_arm_controlled_kernel_termination cl_ext_cxx_for_opencl

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  ARM Platform
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   Success [ARM]
  clCreateContext(NULL, ...) [default]            Success [ARM]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 ARM Platform
    Device Name                                   Mali-LODX r0p0
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  Success (1)
    Platform Name                                 ARM Platform
    Device Name                                   Mali-LODX r0p0
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 ARM Platform
    Device Name                                   Mali-LODX r0p0

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.2.11
  ICD loader Profile                              OpenCL 2.1

Finally got it working but much less than I expected

 time python3 run_audio_file.py --audio_file_path tests/testdata/quick_brown_fox_16000khz.wav --model_file_path tflite_int8/wav2letter_int8.tflite  --preferred_backends GpuAcc CpuAcc CpuRef
Your ArmNN library instance does not support Onnx models parser functionality.  Skipped IOnnxParser import.
Can't load libOpenCL.so: libOpenCL.so: cannot open shared object file: No such file or directory
Can't load libGLES_mali.so: libGLES_mali.so: cannot open shared object file: No such file or directory
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '5'.
Preferred backends: ['GpuAcc', 'CpuAcc', 'CpuRef']
IDeviceSpec { supportedBackends: [CpuAcc, CpuRef, GpuAcc]}
Optimization warnings: ()
Processing Audio Frames...
the quick brown fox juhmpe over the llazy dag

real    0m8.221s
user    0m13.379s
sys     0m0.397s
(venv) rock@rock-5b:~/workspace/armnn/python/pyarmnn/examples/speech_recognition$ time python3 run_audio_file.py --audio_file_path tests/testdata/quick_brown_fox_16000khz.wav --model_file_path tflite_int8/wav2letter_int8.tflite  --preferred_backends CpuAcc CpuRef
Your ArmNN library instance does not support Onnx models parser functionality.  Skipped IOnnxParser import.
Can't load libOpenCL.so: libOpenCL.so: cannot open shared object file: No such file or directory
Can't load libGLES_mali.so: libGLES_mali.so: cannot open shared object file: No such file or directory
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '5'.
Preferred backends: ['CpuAcc', 'CpuRef']
IDeviceSpec { supportedBackends: [CpuAcc, CpuRef, GpuAcc]}
Optimization warnings: ()
Processing Audio Frames...
the quick brown fox juhmpe over the llazy dag

real    0m2.998s
user    0m8.936s
sys     0m0.345s

Dunno whats happening really as seems like a slow initialisation that I can view and then with a bigger wav the Mali start sto catch up.

time python3 run_audio_file.py --audio_file_path gb0.wav --model_file_path tflite_int8/wav2letter_int8.tflite  --preferred_backends CpuAcc CpuAcc                               Your ArmNN library instance does not support Onnx models parser functionality.  Skipped IOnnxParser import.
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '5'.
Preferred backends: ['CpuAcc', 'CpuAcc']
IDeviceSpec { supportedBackends: [CpuAcc, CpuRef, GpuAcc]}
Optimization warnings: ()
Processing Audio Frames...
 morning this teuesidy is a election day after much ovspiritid banevigors cam paigning the time has come from americas to make importaant d ecisions ta matter nation's future and courage al americans to go tothe pols and vote lesct oin ses in brings oapvt e  s pbird of competitionn between oer bpolitical parties  in that competitionn is in a ssential ppart of a healthy doemarcracy but as the campanes come to  a clothes were publicaanis demogrants ind inddependence ccan find common ground on leaset one  point our system of reppresented democracy is one of  americaus greates strength he nied staye  was fantid on the belief that all men re greet y equal every election daay meionss of americans o ae rraces religions anmbagarouom step ind efmoting boose through outd the nation whether the a richrrd poor olver young each oof them as an eqqual shar and choosing the path an our country will take  n every baweaed they cast  is reminder that are founding principlles for alive and weal boading his wene a great brilges of ammericans citizenshipp and ris  always required braave defenders as you head of the polse next week  remember the sacriffices that had been made by generatiions of americans in uniform tto preserve eor way off life from buacker hgald o bagdad the men and women of americann on forces had been devoted guardians of hoar democracy all of au sow them in ther familes a sspecial donae ratituude on aelection dvay merica shuld alson remember the importning  example that ar eletion said throughout the woorld  youngermocracyes from georgianiu grained of nanistdane in a rack and looked the unianed states or proof this sholve ggovernment can enddoure and nationss an still af under tyyornyn oppression con fiund hope in his viration in oaur commitment de liberty for more than two centuries a americans hof demmonstrated the ability of free people to chhoese their own leaders or nationn hais flourihed becauuse of ith commentdement to tresting the wisdom off our citizenry ind thes yeaars election  we will see thi traditiion continued and we will bee reminded once againn that we are blessed o live in a free nationn guided by the will of the people thank you frliishning

real    0m42.802s
user    2m58.349s
sys     0m0.540s
(venv) rock@rock-5b:~/workspace/armnn/python/pyarmnn/examples/speech_recognition$ time python3 run_audio_file.py --audio_file_path gb0.wav --model_file_path tflite_int8/wav2letter_int8.tflite  --preferred_backends GpuAcc CpuAcc
Your ArmNN library instance does not support Onnx models parser functionality.  Skipped IOnnxParser import.
arm_release_ver of this libmali is 'g6p0-01eac0', rk_so_ver is '5'.
Preferred backends: ['GpuAcc', 'CpuAcc']
IDeviceSpec { supportedBackends: [CpuAcc, CpuRef, GpuAcc]}
Optimization warnings: ()
Processing Audio Frames...
 morning this teuesidy is a election day after much ovspiritid banevigors cam paigning the time has come from americas to make importaant d ecisions ta matter nation's future and courage al americans to go tothe pols and vote lesct oin ses in brings oapvt e  s pbird of competitionn between oer bpolitical parties  in that competitionn is in a ssential ppart of a healthy doemarcracy but as the campanes come to  a clothes were publicaanis demogrants ind inddependence ccan find common ground on leaset one  point our system of reppresented democracy is one of  americaus greates strength he nied staye  was fantid on the belief that all men re greet y equal every election daay meionss of americans o ae rraces religions anmbagarouom step ind efmoting boose through outd the nation whether the a richrrd poor olver young each oof them as an eqqual shar and choosing the path an our country will take  n every baweaed they cast  is reminder that are founding principlles for alive and weal boading his wene a great brilges of ammericans citizenshipp and ris  always required braave defenders as you head of the polse next week  remember the sacriffices that had been made by generatiions of americans in uniform tto preserve eor way off life from buacker hgald o bagdad the men and women of americann on forces had been devoted guardians of hoar democracy all of au sow them in ther familes a sspecial donae ratituude on aelection dvay merica shuld alson remember the importning  example that ar eletion said throughout the woorld  youngermocracyes from georgianiu grained of nanistdane in a rack and looked the unianed states or proof this sholve ggovernment can enddoure and nationss an still af under tyyornyn oppression con fiund hope in his viration in oaur commitment de liberty for more than two centuries a americans hof demmonstrated the ability of free people to chhoese their own leaders or nationn hais flourihed becauuse of ith commentdement to tresting the wisdom off our citizenry ind thes yeaars election  we will see thi traditiion continued and we will bee reminded once againn that we are blessed o live in a free nationn guided by the will of the people thank you frliishning

real    0m46.379s
user    2m39.762s
sys     0m0.648s

Is there anyway to still do this with the repo gone?

The repo has been moved to https://github.com/JeffyCN/mirrors/tree/libmali/lib/aarch64-linux-gnu

1 Like