Increase default value of opencl_mandatory_timeout #10828
Description
Is your feature request related to a problem? Please describe.
With increasing image sizes and increasingly complex algorithms, darktable may give up on waiting for a GPU to become available and fall back to CPU processing (often much slower).
Even if GPU processing is marked as mandatory (opencl_scheduling_profile=very fast GPU or set to default and opencl_device_priority uses + markers to force GPU processing), darktable will give up (if using defaults) after 1 second (200 x 5 ms):
https://github.com/darktable-org/darktable/blob/master/data/darktableconfig.xml.in#L257
For example, processing a 100 MPixel image from https://www.dpreview.com/reviews/fujifilm-gfx-100s-review using diffuse or sharpen's simulate line drawing preset, such a fallback is triggered using my GTX 1060, leading to increased overall processing times when processing one of the pipelines on the Ryzen 5 5600X CPU.
With fallback:
13.437192 [dev] took 0.000 secs (0.000 CPU) to load the image.
13.437234 [pixelpipe_process] [full] using device 0
...
14.450213 [pixelpipe_process] [preview] using device -1
...
14.594750 [opencl_profiling] profiling device 0 ('NVIDIA GeForce GTX 1060 6GB'):
...
14.594818 [opencl_profiling] spent 0.9391 seconds totally in command queue (with 0 events missing)
14.595304 [dev_process_image] pixel pipeline processing took 1.158 secs (1.915 CPU)
...
16.519961 [dev_process_preview] pixel pipeline processing took 3.083 secs (23.190 CPU)
(about 3 seconds between first and last log line)
Processed fully on the GPU, using longer timeout:
10.807399 [dev] took 0.000 secs (0.000 CPU) to load the image.
10.807422 [pixelpipe_process] [preview] using device 0
...
11.262728 [dev_pixelpipe] took 0.443 secs (0.396 CPU) processed `diffuse or sharpen' on GPU, blended on GPU [preview]
11.323344 [opencl_profiling] profiling device 0 ('NVIDIA GeForce GTX 1060 6GB'):
...
11.323386 [opencl_profiling] spent 0.4462 seconds totally in command queue (with 0 events missing)
11.323739 [dev_process_preview] pixel pipeline processing took 0.516 secs (0.937 CPU)
11.323761 [pixelpipe_process] [full] using device 0
...
12.463185 [opencl_profiling] profiling device 0 ('NVIDIA GeForce GTX 1060 6GB'):
12.463229 [opencl_profiling] spent 0.9350 seconds totally in command queue (with 0 events missing)
12.463556 [dev_process_image] pixel pipeline processing took 1.656 secs (2.067 CPU)
(less than 2 seconds between first and last log line)
Using high iteration counts with diffuse and sharpen can lead to drastically longer processing times, even with more modestly sized images, see https://discuss.pixls.us/t/opencl-is-mandatory-yet-cpu-is-used-solved/28740/
Describe the solution you'd like
- Increase default value of
opencl_mandatory_timeout - Possibly force it to a high value when using
opencl_scheduling_profile=very fast GPU, like how the synchronisation timeout is also forced to a hard-coded value:
https://github.com/darktable-org/darktable/blob/master/src/common/opencl.c#L2608 - Log a warning on the console / display a message on the UI when the fallback occurs, prompting the user to increase the timeout in the config if they want (the prompting would, of course, would only make sense if
opencl_scheduling_profile=very fast GPUdoes not force a value that the user cannot override from the config). This could have cut down on the time I spent investigating my own config. :-)