Darktable with OpenCL support

Does anybody succeeded to get OpenCL support for Darktable working? As far as I know, OpenCL support in darktable does work on Apple ARM silicon, so I hope it might be achievable for Rock 5 too. OpenCL seems to be available in my system, clinfo gives the expected output, clpeak measures the performance.

When I launch darktable, it looks fine at the beginning as it finds OpenCL in the system. So far so good. But then it fails to compile the OpenCL kernel, see the output below. And I’m totally out of idea to tell why, because it complains about invalid build options which are out of my control and about failing to open the directory with the CL kernel sources. But this directory does exist and is user accessible.

I’m using the panfork driver and running Wayland. Should I use the ARM blob instead? If so, how to switch?

Many thanks for any idea!

tux@rock5b ~> darktable -d opencl -d verbose
[dt_detect_cpu_features] Not implemented for this architecture.
[dt_detect_cpu_features] Please contribute a patch.
     0.0001 [dt_init] SSE2 is unavailable, some functions will be noticeably slower.
[dt_detect_cpu_features] Not implemented for this architecture.
[dt_detect_cpu_features] Please contribute a patch.
     0,0624 [dt_get_sysresource_level] switched to 3 as `unrestricted'
     0,0624   total mem:       15967MB
     0,0624   mipmap cache:    1995MB
     0,0624   available mem:   255474MB
     0,0624   singlebuff:      15967MB
     0,0624   OpenCL tune mem: OFF
     0,0624   OpenCL pinned:   OFF
[opencl_init] opencl related configuration options:
[opencl_init] opencl: ON
[opencl_init] opencl_scheduling_profile: 'default'
[opencl_init] opencl_library: 'default path'
[opencl_init] opencl_device_priority: '*/!0,*/*/*/!0,*'
[opencl_init] opencl_mandatory_timeout: 400
     0.0636 [dt_dlopencl_init] could not find default opencl runtime library 'libOpenCL'
     0.0637 [dt_dlopencl_init] could not find default opencl runtime library 'libOpenCL.so'
     0.0639 [dt_dlopencl_init] found default opencl runtime library 'libOpenCL.so.1'
[opencl_init] opencl library 'libOpenCL.so.1' found on your system and loaded
arm_release_ver: g13p0-01eac0, rk_so_ver: 3
[opencl_init] found 1 platform
[opencl_init] found 1 device

[dt_opencl_device_init]
     0.0704 [dt_opencl_write_device_config] writing data '0 250 0 16 16 128 0 0 0.000000 0.000' for 'cldevice_v5_armplatformmalig610r0p0'
     0.0704 [dt_opencl_write_device_config] writing data '400' for 'cldevice_v5_armplatformmalig610r0p0_id0'
   DEVICE:                   0: 'Mali-G610 r0p0'
   PLATFORM NAME & VENDOR:   ARM Platform, ARM
   CANONICAL NAME:           armplatformmalig610r0p0
   DRIVER VERSION:           3.0
   DEVICE VERSION:           OpenCL 3.0 v1.g13p0-01eac0.a8b6f0c7e1f83c654c60d1775112dbe4
   DEVICE_TYPE:              GPU
   GLOBAL MEM SIZE:          15960 MB
   MAX MEM ALLOC:            15960 MB
   MAX IMAGE SIZE:           65536 x 65536
   MAX WORK GROUP SIZE:      1024
   MAX WORK ITEM DIMENSIONS: 3
   MAX WORK ITEM SIZES:      [ 1024 1024 1024 ]
   ASYNC PIXELPIPE:          NO
   PINNED MEMORY TRANSFER:   NO
   MEMORY TUNING:            NO
   FORCED HEADROOM:          400
   AVOID ATOMICS:            NO
   MICRO NAP:                250
   ROUNDUP WIDTH:            16
   ROUNDUP HEIGHT:           16
   CHECK EVENT HANDLES:      128
   TILING ADVANTAGE:         0.000
   DEFAULT DEVICE:           NO
   KERNEL BUILD DIRECTORY:   /usr/share/darktable/kernels
   KERNEL DIRECTORY:         /home/tux/.cache/darktable/cached_v1_kernels_for_ARMPlatformMaliG610r0p0_30
   CL COMPILER OPTION:       
     0.0711 [dt_opencl_device_init] testing program `demosaic_ppg.cl' ..
     0.0712 [opencl_fopen_stat] could not open file `/home/tux/.cache/darktable/cached_v1_kernels_for_ARMPlatformMaliG610r0p0_30/demosaic_ppg.cl.bin'!
     0.0712 [opencl_load_program] could not load cached binary program, trying to compile source
     0.0712 [opencl_load_program] successfully loaded program from '/usr/share/darktable/kernels/demosaic_ppg.cl' MD5: 'c88f8c06c59c25137328a7d722d87fc3'
     0.0849 [opencl_build_program] could not build program: CL_INVALID_BUILD_OPTIONS
     0.0849 [opencl_build_program] BUILD STATUS: -2
     0.0849 BUILD LOG:
     0.0849 error: Failed to open directory '"/usr/share/darktable/kernels"'
error: Failed to handle include build options
error: encountered invalid build options

     0.0849 [dt_opencl_device_init] failed to compile program `demosaic_ppg.cl'!
     0.0849 [dt_opencl_write_device_config] writing data '0 250 0 16 16 128 0 0 0.000000 0.000' for 'cldevice_v5_armplatformmalig610r0p0'
     0.0849 [dt_opencl_write_device_config] writing data '400' for 'cldevice_v5_armplatformmalig610r0p0_id0'
[opencl_init] no suitable devices found.
[opencl_init] FINALLY: opencl is NOT AVAILABLE and NOT ENABLED.

(darktable:5662): IBUS-WARNING **: 23:30:10.163: Unable to connect to ibus: Could not connect: Connection refused
tux@rock5b ~>

This means that darktable’s OpenCL build parameters or the kernel itself are not compatible with Mali-G610’s OpenCL runtime. This is a very common thing between different vendors’ hardware. You can open an issue on darktable repo and provide the log so they can analyze it.

Thank you for being interested and your advice. I already made a topic on this on dartable’s github. But unfortunately it seems to me (guessing based on some earlier sporadic discussions on this topic too), that the darktable devs are not much enthusiastic in supporting the ARM silicon. They do not believe that ARM devices are already powerful enough to run darktable…:frowning:

0.0849 BUILD LOG:
0.0849 error: Failed to open directory ‘"/usr/share/darktable/kernels"’
error: Failed to handle include build options
error: encountered invalid build options

Either the kernel dir escaping format is not ok for Mali OpenCL runtime or the user has no permission to access the kernel dir.

1 Like

The kernel dir and the kernel files are user accessible for sure, see:

tux@rock5b ~> head /usr/share/darktable/kernels/demosaic_ppg.cl
/*
    This file is part of darktable,
    copyright (c) 2009--2010 johannes hanika.

    darktable is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    darktable is distributed in the hope that it will be useful,
tux@rock5b ~>

I tried to check the escaping issue in the demosaic kernel file and in the included common.h file, bud didn’t find it. I guess one should look at the place from where kernel build is initiated. But I have no idea where it is.

Thank you for your help for now. I will get back to this in couple of days.

Thank you for your hint! You were right. It is the same dir escaping issue as it was on Mac earlier.

For anybody interested in how to get OpenCL working in darktable, please do refer to the following (and the couple of next) posts describing the (hopefully) temporary workaround. You need to modify one source code file and build darktable yourselves. Hopefully darktable devs will fix it for the future versions.

https://github.com/darktable-org/darktable/issues/15067#issuecomment-1695992515