How to enable Opencl support on hikey960?

Thanks a lot! :smile:

Thank you for share,I am flashed this Image and connected network via wifi,I config the file wpa_supplicant-wlan0.conf similar as following:
network={
ssid=“HUAWEI-FU8FLWy”
psk="********"
scan_ssid=1
proto=RSN
key_mgmt=WPA-PSK
group=CCMP TKIP
pairwise=CCMP TKIP
priority=5
}

Wired connection not work yet on my hikey960

@flowas does opencl works when you flash debian?

I do not know how to check whether OpenCl works,can you tell me?

I have OpenCL working on that image.

Output from clinfo:

root@hikey960:~# clinfo
Number of platforms 1
Platform Name ARM Platform
Platform Vendor ARM
Platform Version OpenCL 2.0 v1.r9p0-01rel0.37c12a13c46b4c2d9d736e0d5ace2e5e
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_il_program cl_arm_core_id cl_arm_printf cl_arm_thread_limit_hint cl_arm_non_uniform_work_group_size cl_arm_import_memory cl_arm_shared_virtual_memory
Platform Extensions function suffix ARM

Platform Name ARM Platform
Number of devices 1
Device Name Mali-G71
Device Vendor ARM
Device Vendor ID 0x60a00002
Device Version OpenCL 2.0 v1.r9p0-01rel0.37c12a13c46b4c2d9d736e0d5ace2e5e
Driver Version 2.0
Device OpenCL C Version OpenCL C 2.0 v1.r9p0-01rel0.37c12a13c46b4c2d9d736e0d5ace2e5e
Device Type GPU
Device Profile FULL_PROFILE
Max compute units 8
Max clock frequency 5MHz
Device Partition (core)
Max number of sub-devices 0
Supported partition types None
Max work item dimensions 3
Max work item sizes 256x256x256
Max work group size 384
Preferred work group size multiple 4
Preferred / native vector sizes
char 16 / 16
short 8 / 8
int 4 / 4
long 2 / 2
half 8 / 8 (cl_khr_fp16)
float 4 / 4
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
Correctly-rounded divide and sqrt operations 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 3110158336 (2.897GiB)
Error Correction support No
Max memory allocation 777539584 (741.5MiB)
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 524288
Global Memory cache line 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 bytes
Max 2D image size 32768x32768 pixels
Max 3D image size 32768x32768x32768 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 constant buffer size 65536 (64KiB)
Max number of constant args 8
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
printf() buffer size 1048576 (1024KiB)
Built-in kernels
Device Available Yes
Compiler Available Yes
Linker Available Yes
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_il_program cl_arm_core_id cl_arm_printf cl_arm_thread_limit_hint cl_arm_non_uniform_work_group_size cl_arm_import_memory cl_arm_shared_virtual_memory

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_CPU) No devices found in platform
clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU) Success (1)
Platform Name ARM Platform
Device Name Mali-G71
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-G71

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

daedalean_defconfig should work for you. defconfig does not have mali
support enabled.

I flashed the debian9 image. It boots up perfectly. It says clinfo bash command not found. Also could you tell how to connect to the wifi as the network manager isn’t working. I tried to connect with wpa-supplicant.conf and even tried editing etc/network/interface but it didn’t work. Do I need to install clinfo or have you already added it.

  1. apt install clinfo will install it if it isn’t there.
  2. To configure wifi edit /etc/wpa_supplicant/wpa_supplicant-wlan0.conf and
    reboot.

I believe I mentioned in my post with the links to the image how to
configure wifi.

@bvermeul, can you share instructions on how to build the Linux image with the drivers? I’d like to be able to build my own with some modifications to the Linux image. Thanks!

have you actually tried to run an opencl application? I can get clinfo to work on an unpatched kernel as well
but I am unable to run an opencl application on your kernel

----------------------------------------------
           Device Info
----------------------------------------------

Failed creating base context during opening of kernel driver.
Kernel module may not have been loaded
terminate called after throwing an instance of 'viennacl::ocl::out_of_host_memory'
  what():  ViennaCL: FATAL ERROR: CL_OUT_OF_HOST_MEMORY 
The host ran out of memory (usually CPU RAM). Please try again on smaller problems.

Hey,

I need help in copying userspace ( .so.1 ) file.

Can you tell me where should i copy this file in ROOT FILE SYSTEM of Ubuntu.

Currently i am trying to enable gpu drivers on hikey 960.

Earlier i tried to copy .so.1 files in
/lib/aarch64-linux-gnu/

but it doesnt works!

You need to copy them to /usr/lib/aarch64-linux-gnu/
You also need to create a mali.icd in /etc/OpenCL/vendors containing
“libmali.so” to make sure the OpenCL icd loader can find it correctly.

Run ldconfig afterwards.

Bas Vermeulen

I have created a rudimentary and incomplete script to create the root filesystems I use.
It is still missing some things (it doesn’t set up /boot, and doesn’t copy kernel/modules), but may still be usefull for someone. Any patches/comments are welcome.

The repository is located on github.

3 Likes

Hey, I have some problems getting opencl to work. I’ve used some parts of bvermeuls script and his defconfig, but i if i run clinfo i get this error:

clinfo: /usr/lib/aarch64-linux-gnu/libOpenCL.so.1: version `OPENCL_1.0’ not found (required by clinfo)

Has anyone ever had this problem?

Hello @Aegir
Can u share how did u flash debian on hikey960.
I tried with https://github.com/96boards/documentation/blob/master/consumer/hikey960/installation/linux-fastboot.md and https://github.com/96boards/documentation/blob/master/consumer/hikey/installation/linux-fastboot.md.
second link work successfuly untill flashing rootfs.
however, problem is hikey does not boot in normal mode.

Installation

  1. Download from http://snapshots.linaro.org/reference-platform/embedded/morty/hikey960/latest/rpb/
    a boot*.img
    a rpb*-image-*hikey960-*.rootfs.img.gz
    bootloader/

  2. On the board: Set the dip-switches to 1 & 2 on, 3 off.
    Make sure fastboot is installed (sudo apt install fastboot if it is not).
    Connect a USB-C to USB-A cable to the laptop + board.
    Check what serial port got added (/dev/ttyUSB?)
    Execute the following commands to bootloader into RAM:
    $ chmod +x hikey_idt
    $ sudo ./hikey_idt -c config -p /dev/ttyUSB?
    You will see some output loading the fastboot bootloader into RAM.

  3. Execute the following commands to flash the bootloader:
    $ sudo fastboot flash ptable prm_ptable.img
    $ sudo fastboot flash xloader sec_xloader.img
    $ sudo fastboot flash fastboot l-loader.bin
    $ sudo fastboot flash fip fip.bin
    If for some reason fastboot doesn’t want to start (it did for me after flashing the bootloader once), set the dip-switches to 1 & 3 on, 2 off, and reset the board’s power supply.

  4. Unzip the rpb-*.img.gz file
    Execute the following commands to flash kernel/rootfs:
    $ sudo fastboot flash boot boot*.img
    $ sudo fastboot flash system rpb-*image*hikey960*.rootfs.img or the debian rootfs image.
    This last command takes about half an hour on USB2 and a few minutes on USB3, so take your time … or a USB3 cable.

  5. Set the dip-switches to 1 on, 2 & 3 off, and reset the board to boot into linux.

Hey baynaa,
bvermeuls answer should help you. I followed the instructions posted here: InstallingDebianOn/96Boards/HiKey960 - Debian Wiki and build my own kernel with the config from bvermeul.

Does the latest RPB image contain package management system like APT???

Not that i know of, but as he suggests:

$ sudo fastboot flash system rpb-imagehikey960*.rootfs.img or the debian rootfs image.

So you can use the debian image from bvermeul or the debian image for the “normal” hikey. But in the latter case you should use a different kernel because otherwise the usb ports won’t work.

No, it does not. That’s why step 4 says to use the rpb image, or the debian rootfs image from one of my previous posts.

Bas Vermeulen