VC4CL icon indicating copy to clipboard operation
VC4CL copied to clipboard

OpenCL support for Raspberry pi 4 GPU (VideoCore VI)

Open sandyz1000 opened this issue 4 years ago • 13 comments

First of all thank you for building OpenCL compiler for VideoCoreIV GPUs. Just wanted to know is there is possibility to support for VC6 GPU devices.

sandyz1000 avatar Nov 17 '19 19:11 sandyz1000

Short answer: no, see also #79. The VideoCore VI GPU is a very different architecture (e.g. with MMU, without 2 separate register files AFAIK), so supporting it require rewriting most of the compiler. Also, I don't know of any publicly available hardware and instruction set documentation.

doe300 avatar Nov 18 '19 07:11 doe300

@doe300 As I see Eben Upton co-founder of the Raspberry Pi Foundation, has announced open source Vulkan graphics driver for the Raspberry Pi 4 family. So I guess He can share VideoCore VI specs with you as well.

antonakv avatar Feb 12 '20 10:02 antonakv

Does anyone refer to Idein's py-videocore6? https://github.com/Idein/py-videocore6 It may be useful for VC6CL.

thortex avatar Sep 10 '20 13:09 thortex

First of all thank you for building OpenCL compiler up to RPi3. Also can’t wait to see OpenCL support on the RaspberryPi 4.

May it helps https://www.raspberrypi.com/news/vulkan-update-version-1-1-conformance-for-raspberry-pi-4/ ?

iDoka avatar Oct 26 '21 15:10 iDoka

Maybe there is a way to use Vulkan 1.1 on Rpi4 for Machine Learning instead of OpenCL ?

antonakv avatar Oct 28 '21 06:10 antonakv

If Raspberry Pi 4 has Vulkan, then they can use https://github.com/kpet/clvk to get OpenCL out of Vulkan

truboxl avatar Oct 28 '21 07:10 truboxl

That's amazing news @truboxl So ticket can be closed then.

antonakv avatar Oct 28 '21 09:10 antonakv

I tried to get this working: https://github.com/kpet/clvk But first off it needs a whole lot of ram to build (4gb ram + 6 gb swap for me). And unfortunately failed to build. Installing Vulkan on RPi isn't straightforward either. I'm not in urgent need to run OpenCL on RPi, but wanted to post this to point out that this ticket probably can't be closed. (Unless I missed something and recent developments have led to a better working approach?)

MartijnGevaert avatar Jan 01 '22 18:01 MartijnGevaert

I can confirm that CLVK in combination with the latest version of Mesa's v3dv Vulkan driver, you can get OpenCL on a rPi4.

Unfortunately, important extensions are missing. The v3dv Vulkan driver can't do FP16 (16 bit floats.) Nor can it do 8 bits integers. This limits the usefulness for me personally, as my kernels are written to operate on FP16 values.

If your kernels don't use FP16 / INT8, you may have better luck than me, though.

stolk avatar Jun 02 '23 23:06 stolk

I suspect the best way to get a decent supported OpenCL will be using the mesa gallium driver in conjunction with the new mesa rusticl opencl stack. rusticl is being actively developed and a there has been support added for a bunch of other arm GPUs that support opencl (panfrost for MALI, etnaviv for Vivante).

nullr0ute avatar Jun 08 '23 10:06 nullr0ute

the new mesa rusticl opencl stack.

It can find the rusticl platform.

$ clinfo --list
Platform #0: Clover
Platform #1: rusticl

But it cannot find any devices:

$ clinfo 
Number of platforms                               2
  Platform Name                                   Clover
  Platform Vendor                                 Mesa
  Platform Version                                OpenCL 1.1 Mesa 23.0.2
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd
  Platform Extensions function suffix             MESA

  Platform Name                                   rusticl
  Platform Vendor                                 Mesa/X.org
  Platform Version                                OpenCL 3.0 
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd
  Platform Extensions with Version                cl_khr_icd                                                       0x400000 (1.0.0)
  Platform Numeric Version                        0xc00000 (3.0.0)
  Platform Extensions function suffix             MESA
  Platform Host timer resolution                  0ns

  Platform Name                                   Clover
Number of devices                                 0

  Platform Name                                   rusticl
Number of devices                                 0
...

This is with Ubuntu 23.04 on rPi-400.

$ inxi -G
Graphics:
  Device-1: bcm2711-hdmi0 driver: vc4_hdmi v: N/A
  Device-2: bcm2711-hdmi1 driver: vc4_hdmi v: N/A
  Device-3: bcm2711-vc5 driver: vc4_drm v: N/A
  Display: wayland server: X.Org v: 1.22.1.8 with: Xwayland v: 22.1.8
    compositor: gnome-shell v: 44.0 driver: X: loaded: modesetting
    unloaded: fbdev dri: vc4
    gpu: vc4-drm,vc4_crtc,vc4_dpi,vc4_dsi,vc4_firmware_kms,vc4_hdmi,vc4_hvs,vc4_txp,vc4_v3d,vc4_vec
    resolution: 1280x768~60Hz
  API: OpenGL v: 2.1 Mesa 23.0.2 renderer: V3D 4.2

stolk avatar Jun 09 '23 18:06 stolk

the new mesa rusticl opencl stack.

It can find the rusticl platform.

$ clinfo --list
Platform #0: Clover
Platform #1: rusticl

But it cannot find any devices:

There's probably some driver work required, but ultimately that will be the best/quickest way to get GPU HW OpenCL on the rpi4

nullr0ute avatar Jun 10 '23 10:06 nullr0ute

I can confirm that CLVK in combination with the latest version of Mesa's v3dv Vulkan driver, you can get OpenCL on a rPi4.

Unfortunately, important extensions are missing. The v3dv Vulkan driver can't do FP16 (16 bit floats.) Nor can it do 8 bits integers. This limits the usefulness for me personally, as my kernels are written to operate on FP16 values.

If your kernels don't use FP16 / INT8, you may have better luck than me, though.

Can I make a build in docker on the amd64 platform with arm64 emulation ? It might to decrease building time

Pepslee avatar Jun 16 '23 10:06 Pepslee