Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
opencl.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2010-2012, 2016 johannes hanika.
4 Copyright (C) 2010, 2020-2021 Pascal Obry.
5 Copyright (C) 2011 Henrik Andersson.
6 Copyright (C) 2011, 2013-2014, 2016 Tobias Ellinghaus.
7 Copyright (C) 2011-2017 Ulrich Pegelow.
8 Copyright (C) 2012 Michal Babej.
9 Copyright (C) 2012 Richard Wonka.
10 Copyright (C) 2013 Pascal de Bruijn.
11 Copyright (C) 2015, 2019 Dan Torop.
12 Copyright (C) 2016 Roman Lebedev.
13 Copyright (C) 2017-2019 Edgardo Hoszowski.
14 Copyright (C) 2017 luzpaz.
15 Copyright (C) 2019 Heiko Bauke.
16 Copyright (C) 2019 jakubfi.
17 Copyright (C) 2021-2022, 2025-2026 Aurélien PIERRE.
18 Copyright (C) 2021 Hubert Kowalski.
19 Copyright (C) 2022 Hanno Schwalm.
20 Copyright (C) 2022 Martin Bařinka.
21 Copyright (C) 2025 Alynx Zhou.
22 Copyright (C) 2025 Guillaume Stutin.
23
24 darktable is free software: you can redistribute it and/or modify
25 it under the terms of the GNU General Public License as published by
26 the Free Software Foundation, either version 3 of the License, or
27 (at your option) any later version.
28
29 darktable is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 GNU General Public License for more details.
33
34 You should have received a copy of the GNU General Public License
35 along with darktable. If not, see <http://www.gnu.org/licenses/>.
36*/
37
38#pragma once
39
40#ifdef HAVE_CONFIG_H
41#include "config.h"
42#endif
43
44#define DT_OPENCL_MAX_PLATFORMS 5
45#define DT_OPENCL_MAX_PROGRAMS 256
46#define DT_OPENCL_MAX_KERNELS 512
47#define DT_OPENCL_EVENTLISTSIZE 256
48#define DT_OPENCL_EVENTNAMELENGTH 64
49#define DT_OPENCL_MAX_ERRORS 5
50#define DT_OPENCL_MAX_INCLUDES 7
51#define DT_OPENCL_VENDOR_AMD 4098
52#define DT_OPENCL_VENDOR_NVIDIA 4318
53#define DT_OPENCL_VENDOR_INTEL 0x8086u
54#define DT_OPENCL_CBUFFSIZE 1024
55
56// some pseudo error codes in dt opencl usage
57#define DT_OPENCL_DEFAULT_ERROR -999
58#define DT_OPENCL_SYSMEM_ALLOCATION -998
59
60#include "common/darktable.h"
61
62#ifdef HAVE_OPENCL
63
64#include "common/dlopencl.h"
65#include "common/dtpthread.h"
66#include "common/iop_profile.h"
67#include "control/conf.h"
68
69// #pragma GCC diagnostic push
70// #pragma GCC diagnostic ignored "-Wcomment"
71#include <CL/cl.h>
72// #pragma GCC diagnostic
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
78#define ROUNDUP(a, n) ((a) % (n) == 0 ? (a) : ((a) / (n)+1) * (n))
79
80// use per device roundups here
81#define ROUNDUPDWD(a, b) dt_opencl_dev_roundup_width(a, b)
82#define ROUNDUPDHT(a, b) dt_opencl_dev_roundup_height(a, b)
83
84#define DT_OPENCL_BPP_TAG_RGBA8 (1u << 30)
85#define DT_OPENCL_BPP_ENCODE_RGBA8(bpp) ((int)((unsigned int)(bpp) | DT_OPENCL_BPP_TAG_RGBA8))
86#define DT_OPENCL_BPP_IS_RGBA8(bpp) ((((unsigned int)(bpp)) & DT_OPENCL_BPP_TAG_RGBA8) != 0u)
87#define DT_OPENCL_BPP_DECODE(bpp) ((int)(((unsigned int)(bpp)) & ~DT_OPENCL_BPP_TAG_RGBA8))
88
89#define DT_OPENCL_DEFAULT_COMPILE_INTEL ("-cl-fast-relaxed-math -cl-no-signed-zeros -cl-unsafe-math-optimizations")
90#define DT_OPENCL_DEFAULT_COMPILE_AMD ("-cl-fast-relaxed-math -cl-no-signed-zeros -cl-unsafe-math-optimizations")
91#define DT_OPENCL_DEFAULT_COMPILE_NVIDIA ("-cl-fast-relaxed-math -cl-no-signed-zeros -cl-unsafe-math-optimizations")
92#define DT_OPENCL_DEFAULT_COMPILE ("-cl-fast-relaxed-math -cl-no-signed-zeros -cl-unsafe-math-optimizations")
93#define DT_CLDEVICE_HEAD ("cldevice_v4")
94
100
110
117
118// Why an image did (or did not) fit on an OpenCL device. Each non-OK reason maps
119// to a *different* limit, so a caller logging "needs X but limit is Y" must report
120// the quantities that were actually compared for the returned reason -- see
121// dt_opencl_image_fits_device_reason().
123{
124 DT_OPENCL_FIT_OK = 0, // the image fits, the device can process it
125 DT_OPENCL_FIT_DIMENSION, // width/height exceed the device 2D image limits
126 DT_OPENCL_FIT_ALLOC_LIMIT, // a single buffer exceeds CL_DEVICE_MAX_MEM_ALLOC_SIZE
127 DT_OPENCL_FIT_AVAILABLE, // not enough free vRAM headroom for the factored allocation
128 DT_OPENCL_FIT_UNINITED // OpenCL unavailable / invalid device
130
135typedef struct dt_opencl_device_t
136{
137 dt_pthread_mutex_t lock;
138 cl_device_id devid;
139 cl_context context;
140 cl_command_queue cmd_queue;
150 cl_event *eventlist;
161 const char *vendor;
162 const char *name;
163 const char *cname;
164 const char *options;
165 const char *options_md5;
166 cl_int summary;
170
171 // flags detected errors
173 // if set to TRUE darktable will not use OpenCL kernels which contain atomic operations (example bilateral).
174 // pixelpipe processing will be done on CPU for the affected modules.
175 // useful (only for very old devices) if your OpenCL implementation freezes/crashes on atomics or if
176 // they are processed with a bad performance.
178
179 // pause OpenCL processing for this number of microseconds from time to time
181
182 // During tiling huge amounts of memory need to be transferred between host and device.
183 // For some OpenCL implementations direct memory transfers give a drastic performance penalty,
184 // this can often be avoided by using indirect transfers via pinned memory,
185 // other devices have more efficient direct memory transfer implementations.
186 // We can't predict on solid grounds if a device belongs to the first or second group,
187 // also pinned mem transfer requires slightly more ram.
188 // this holds a bitmask defined by dt_opencl_pinmode_t
189 // the device specific conf key might hold
190 // 0 -> disabled by default; might be switched on by tune for performance
191 // 1 -> enabled by default
192 // 2 -> disabled under all circumstances. This could/should be used if we give away / ship specific keys for buggy systems
194
195 // in OpenCL processing round width/height of global work groups to a multiple of these values.
196 // reasonable values are powers of 2. this parameter can have high impact on OpenCL performance.
199
200 // A bitfield that identifies the type of OpenCL device required to test for on-CPU and more.
201 unsigned int cltype;
202
203 // This defines how often should dt_opencl_events_get_slot do a dt_opencl_events_flush.
204 // It should definitely le lower than the number of events that can be handled by the device/driver.
205 // FIXME we should be able to test for that with using >= OpenCl 2.0
207
208 // opencl_events enabled for the device, set internally via event_handles
210
211 // a device might be turned off by force by setting this value to 1
212 // also used for blacklisted drivers
214
215 // CL_DEVICE_HOST_UNIFIED_MEMORY: TRUE for integrated GPUs that share the system's RAM
216 // instead of owning dedicated vRAM. On these devices, "available memory" as reported by
217 // the driver (max_global_mem, max_mem_alloc) and tracked by our own memory_in_use
218 // bookkeeping is a much less reliable estimate of what can actually be allocated: the
219 // whole OS, desktop compositor and every other process compete for that same pool, and we
220 // have no visibility into that competition. Used to pick a larger default forced_headroom
221 // (see dt_opencl_read_device_config()) so a size that our own accounting says "fits" is
222 // less likely to still exceed real availability and abort inside the driver instead of
223 // failing cleanly with CL_OUT_OF_RESOURCES.
225
226 // Some devices are known to be unused by other apps so there is no need to test for available memory at all.
227 // Also some devices might behave badly with the checking code, in this case we could enforce a headroom here.
230
232{
234 char *name;
235 char *cname;
236 unsigned int cltype;
240 // Mirrors dt_opencl_device_t.host_unified_memory -- lets GUI code (preferences) label the
241 // headroom setting accurately for integrated GPUs without reaching into the live device array.
244
247struct dt_dwt_cl_global_t; // wavelet decompose
248struct dt_heal_cl_global_t; // healing
249struct dt_colorspaces_cl_global_t; // colorspaces transform
251
256typedef struct dt_opencl_t
257{
258 dt_pthread_mutex_t lock;
267 uint32_t crc;
268 int mandatory[5];
276
277 // global kernels for blending operations.
279
280 // global kernels for bilateral filtering, to be reused by a few plugins.
282
283 // global kernels for gaussian filtering, to be reused by a few plugins.
285
286 // global kernels for interpolation resampling.
288
289 // global kernels for local laplacian filter.
291
292 // global kernels for dwt filter.
294
295 // global kernels for heal filter.
297
298 // global kernels for colorspaces filter.
300
301 // global kernels for guided filter.
303
304 // Maps every live cl_mem we allocated to the (devid, byte size) we requested,
305 // so memory accounting never has to query the driver (clGetMemObjectInfo) about
306 // a freshly-created object -- some drivers fault on that under vRAM pressure.
307 GHashTable *mem_sizes;
308 dt_pthread_mutex_t mem_sizes_lock;
310
315{
316 const int xoffset;
317 const int xfactor;
318 const int yoffset;
319 const int yfactor;
320 const size_t cellsize;
321 const size_t overhead;
322 int sizex; // initial value and final values after optimization
323 int sizey; // initial value and final values after optimization
325
329int dt_opencl_get_device_info(dt_opencl_t *cl, cl_device_id device, cl_device_info param_name, void **param_value,
330 size_t *param_value_size);
331
333void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl, const gboolean print_statistics);
334
337
340
343int dt_opencl_finish(const int devid);
344
346int dt_opencl_enqueue_barrier(const int devid);
347
349int dt_opencl_lock_device(const int pipetype);
350
352void dt_opencl_unlock_device(const int dev);
353
355void dt_opencl_md5sum(const char **files, char **md5sums);
356
358int dt_opencl_load_program(const int dev, const int prog, const char *filename, const char *binname,
359 const char *cachedir, char *md5sum, char **includemd5, int *loaded_cached);
360
362int dt_opencl_build_program(const int dev, const int prog, const char *binname, const char *cachedir,
363 char *md5sum, int loaded_cached);
364
366int dt_opencl_create_kernel(const int program, const char *name);
367
369void dt_opencl_free_kernel(const int kernel);
370
372int dt_opencl_get_max_work_item_sizes(const int dev, size_t *sizes);
373
375int dt_opencl_get_work_group_limits(const int dev, size_t *sizes, size_t *workgroupsize,
376 unsigned long *localmemsize);
377
379int dt_opencl_get_kernel_work_group_size(const int dev, const int kernel, size_t *kernelworkgroupsize);
380
382int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size,
383 const void *arg);
384
386int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes);
387
389int dt_opencl_enqueue_kernel_2d_with_local(const int dev, const int kernel, const size_t *sizes,
390 const size_t *local);
391
393int dt_opencl_is_inited(void);
394
396int dt_opencl_is_enabled(void);
397
399void dt_opencl_disable(void);
400
403
405int dt_opencl_copy_device_to_host(const int devid, void *host, void *device, const int width,
406 const int height, const int bpp);
407
408int dt_opencl_read_host_from_device(const int devid, void *host, void *device, const int width,
409 const int height, const int bpp);
410
411int dt_opencl_read_host_from_device_rowpitch(const int devid, void *host, void *device, const int width,
412 const int height, const int rowpitch);
413
414int dt_opencl_read_host_from_device_non_blocking(const int devid, void *host, void *device, const int width,
415 const int height, const int bpp);
416
417int dt_opencl_read_host_from_device_rowpitch_non_blocking(const int devid, void *host, void *device,
418 const int width, const int height,
419 const int rowpitch);
420
421int dt_opencl_read_host_from_device_raw(const int devid, void *host, void *device, const size_t *origin,
422 const size_t *region, const int rowpitch, const int blocking);
423
424int dt_opencl_write_host_to_device(const int devid, void *host, void *device, const int width,
425 const int height, const int bpp);
426
427int dt_opencl_write_host_to_device_rowpitch(const int devid, void *host, void *device, const int width,
428 const int height, const int rowpitch);
429
430int dt_opencl_write_host_to_device_non_blocking(const int devid, void *host, void *device, const int width,
431 const int height, const int bpp);
432
433int dt_opencl_write_host_to_device_rowpitch_non_blocking(const int devid, void *host, void *device,
434 const int width, const int height,
435 const int rowpitch);
436
437int dt_opencl_write_host_to_device_raw(const int devid, const void *host, void *device, const size_t *origin,
438 const size_t *region, const int rowpitch, const int blocking);
439
440void *dt_opencl_copy_host_to_device(const int devid, void *host, const int width, const int height,
441 const int bpp);
442
443void *dt_opencl_copy_host_to_device_rowpitch(const int devid, void *host, const int width, const int height,
444 const int bpp, const int rowpitch);
445
446void *dt_opencl_copy_host_to_device_constant(const int devid, const size_t size, void *host);
447
448int dt_opencl_enqueue_copy_image(const int devid, cl_mem src, cl_mem dst, size_t *orig_src, size_t *orig_dst,
449 size_t *region);
450
451void *dt_opencl_alloc_device(const int devid, const int width, const int height, const int bpp);
452
453void *dt_opencl_alloc_device_use_host_pointer(const int devid, const int width, const int height,
454 const int bpp, void *host, const int flags);
455
456int dt_opencl_enqueue_copy_image_to_buffer(const int devid, cl_mem src_image, cl_mem dst_buffer,
457 size_t *origin, size_t *region, size_t offset);
458
459int dt_opencl_enqueue_copy_buffer_to_image(const int devid, cl_mem src_buffer, cl_mem dst_image,
460 size_t offset, size_t *origin, size_t *region);
461
462int dt_opencl_enqueue_copy_buffer_to_buffer(const int devid, cl_mem src_buffer, cl_mem dst_buffer,
463 size_t srcoffset, size_t dstoffset, size_t size);
464
465int dt_opencl_read_buffer_from_device(const int devid, void *host, void *device, const size_t offset,
466 const size_t size, const int blocking);
467
468int dt_opencl_write_buffer_to_device(const int devid, void *host, void *device, const size_t offset,
469 const size_t size, const int blocking);
470
471void *dt_opencl_alloc_device_buffer(const int devid, const size_t size);
472
473void *dt_opencl_alloc_device_buffer_with_flags(const int devid, const size_t size, const int flags, void *host_ptr);
474
475void dt_opencl_release_mem_object(cl_mem mem);
476
477void *dt_opencl_map_buffer(const int devid, cl_mem buffer, const int blocking, const int flags, size_t offset,
478 size_t size);
479
480void *dt_opencl_map_image(const int devid, cl_mem buffer, const int blocking, const int flags, size_t width, size_t height, int bpp);
481
482int dt_opencl_unmap_mem_object(const int devid, cl_mem mem_object, void *mapped_ptr);
483
484size_t dt_opencl_get_mem_object_size(cl_mem mem);
485
486int dt_opencl_get_image_width(cl_mem mem);
487
488int dt_opencl_get_image_height(cl_mem mem);
489
491
492int dt_opencl_get_mem_context_id(cl_mem mem);
493cl_mem_flags dt_opencl_get_mem_flags(cl_mem mem);
494
495// Track a cl_mem allocation/release in the per-device memory accounting.
496// On OPENCL_MEMORY_ADD, pass the byte size that was requested for `mem` on device
497// `devid`; it is recorded so the matching OPENCL_MEMORY_SUB can undo it exactly
498// without ever asking the driver about the object (see mem_sizes in dt_opencl_t).
499// On OPENCL_MEMORY_SUB, `devid` and `size` are ignored -- the recorded values win.
500void dt_opencl_memory_statistics(int devid, cl_mem mem, size_t size, dt_opencl_memory_t action);
501
503gboolean dt_opencl_image_fits_device(const int devid, const size_t width, const size_t height, const unsigned bpp,
504 const float factor, const size_t overhead);
510 const size_t height, const unsigned bpp, const float factor,
511 const size_t overhead, size_t *needed, size_t *limit);
513cl_ulong dt_opencl_get_device_available(const int devid);
514
516void dt_opencl_check_tuning(const int devid);
517
519cl_ulong dt_opencl_get_device_memalloc(const int devid);
520
522int dt_opencl_dev_roundup_width(int size, const int devid);
523int dt_opencl_dev_roundup_height(int size, const int devid);
524
526cl_event *dt_opencl_events_get_slot(const int devid, const char *tag);
527
529void dt_opencl_events_reset(const int devid);
530
533void dt_opencl_events_wait_for(const int devid);
534
537cl_int dt_opencl_events_flush(const int devid, const int reset);
538
540void dt_opencl_events_profiling(const int devid, const int aggregated);
541
543int dt_opencl_local_buffer_opt(const int devid, const int kernel, dt_opencl_local_buffer_t *factors);
544
546void dt_opencl_write_device_config(const int devid);
547gboolean dt_opencl_read_device_config(const int devid);
559gboolean dt_opencl_detected_device_enabled(const int detected);
563int dt_opencl_set_detected_device_enabled(const int detected, const gboolean enabled);
567gboolean dt_opencl_detected_device_pinned_memory(const int detected);
571int dt_opencl_set_detected_device_pinned_memory(const int detected, const gboolean enabled);
575size_t dt_opencl_detected_device_headroom(const int detected);
579int dt_opencl_set_detected_device_headroom(const int detected, const size_t headroom);
580int dt_opencl_avoid_atomics(const int devid);
581int dt_opencl_micro_nap(const int devid);
582gboolean dt_opencl_use_pinned_memory(const int devid);
583gboolean dt_opencl_is_pinned_memory(cl_mem mem);
584
585#ifdef __cplusplus
586}
587#endif
588
589#else
590
591#include "control/conf.h"
592#include <stdlib.h>
593
594#ifdef __cplusplus
595extern "C" {
596#endif
597
598typedef struct dt_opencl_t
599{
600 int inited;
601 int enabled;
602 int stopped;
603 int error_count;
605typedef struct dt_opencl_detected_device_t
606{
607 int config_id;
608 char *name;
609 char *cname;
610 unsigned int cltype;
611 int disabled;
612 int pinned_memory;
613 size_t forced_headroom;
614 // Mirrors dt_opencl_device_t.host_unified_memory -- lets GUI code (preferences) label the
615 // headroom setting accurately for integrated GPUs without reaching into the live device array.
616 gboolean host_unified_memory;
618static inline void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl, const gboolean print_statistics)
619{
620 cl->inited = 0;
621 cl->enabled = 0;
622 cl->stopped = 0;
623 cl->error_count = 0;
624 dt_conf_set_bool("opencl", FALSE);
625 dt_print(DT_DEBUG_OPENCL, "[opencl_init] this version of darktable was built without opencl support\n");
626}
627static inline void dt_opencl_cleanup(dt_opencl_t *cl)
628{
629}
630static inline gboolean dt_opencl_finish(const int devid)
631{
632 return -1;
633}
634static inline int dt_opencl_enqueue_barrier(const int devid)
635{
636 return -1;
637}
638static inline int dt_opencl_lock_device(const int dev)
639{
640 return -1;
641}
642static inline void dt_opencl_unlock_device(const int dev)
643{
644}
645static inline int dt_opencl_load_program(const int dev, const char *filename)
646{
647 return -1;
648}
649static inline int dt_opencl_build_program(const int dev, const int program)
650{
651 return -1;
652}
653static inline int dt_opencl_create_kernel(const int program, const char *name)
654{
655 return -1;
656}
657static inline void dt_opencl_free_kernel(const int kernel)
658{
659}
660static inline int dt_opencl_get_max_work_item_sizes(const int dev, size_t *sizes)
661{
662 return -1;
663}
664static inline int dt_opencl_get_work_group_limits(const int dev, size_t *sizes, size_t *workgroupsize,
665 unsigned long *localmemsize)
666{
667 return -1;
668}
669static inline int dt_opencl_get_kernel_work_group_size(const int dev, const int kernel,
670 size_t *kernelworkgroupsize)
671{
672 return -1;
673}
674static inline int dt_opencl_set_kernel_arg(const int dev, const int kernel, const size_t size, const void *arg)
675{
676 return -1;
677}
678static inline int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
679{
680 return -1;
681}
682static inline int dt_opencl_enqueue_kernel_2d_with_local(const int dev, const int kernel, const size_t *sizes,
683 const size_t *local)
684{
685 return -1;
686}
687static inline int dt_opencl_is_inited(void)
688{
689 return 0;
690}
691static inline int dt_opencl_is_enabled(void)
692{
693 return 0;
694}
695static inline void dt_opencl_disable(void)
696{
697}
698static inline int dt_opencl_update_settings(void)
699{
700 return 0;
701}
702static inline int dt_opencl_get_detected_device_count(void)
703{
704 return 0;
705}
706static inline const dt_opencl_detected_device_t *dt_opencl_get_detected_device(const int detected)
707{
708 return NULL;
709}
710static inline gboolean dt_opencl_detected_device_enabled(const int detected)
711{
712 return FALSE;
713}
714static inline int dt_opencl_set_detected_device_enabled(const int detected, const gboolean enabled)
715{
716 return -1;
717}
718static inline gboolean dt_opencl_detected_device_pinned_memory(const int detected)
719{
720 return FALSE;
721}
722static inline int dt_opencl_set_detected_device_pinned_memory(const int detected, const gboolean enabled)
723{
724 return -1;
725}
726static inline size_t dt_opencl_detected_device_headroom(const int detected)
727{
728 return 0;
729}
730static inline int dt_opencl_set_detected_device_headroom(const int detected, const size_t headroom)
731{
732 return -1;
733}
734static inline gboolean dt_opencl_image_fits_device(const int devid, const size_t width, const size_t height,
735 const unsigned bpp, const float factor, const size_t overhead)
736{
737 return FALSE;
738}
739static inline size_t dt_opencl_get_device_available(const int devid)
740{
741 return 0;
742}
743static inline void dt_opencl_check_tuning(const int devid)
744{
745 return;
746}
747static inline size_t dt_opencl_get_device_memalloc(const int devid)
748{
749 return 0;
750}
751static inline unsigned long dt_opencl_get_mem_flags(void *mem)
752{
753 return 0;
754}
755static inline void dt_opencl_release_mem_object(void *mem)
756{
757}
758static inline void *dt_opencl_events_get_slot(const int devid, const char *tag)
759{
760 return NULL;
761}
762static inline void dt_opencl_events_reset(const int devid)
763{
764}
765static inline void dt_opencl_events_wait_for(const int devid)
766{
767}
768static inline int dt_opencl_events_flush(const int devid, const int reset)
769{
770 return 0;
771}
772static inline void dt_opencl_events_profiling(const int devid, const int aggregated)
773{
774}
775
776#ifdef __cplusplus
777}
778#endif
779
780#endif
781
782// clang-format off
783// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
784// vim: shiftwidth=2 expandtab tabstop=2 cindent
785// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
786// clang-format on
#define FALSE
Definition ashift_lsd.c:158
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
char * name
void dt_conf_set_bool(const char *name, int val)
void reset(dt_view_t *self)
Definition darkroom.c:1062
void dt_print(dt_debug_thread_t thread, const char *msg,...)
Definition darktable.c:1600
@ DT_DEBUG_OPENCL
Definition darktable.h:744
int bpp
static float kernel(const float *x, const float *y)
size_t size
Definition mipmap_cache.c:3
dt_mipmap_buffer_dsc_flags flags
Definition mipmap_cache.c:4
cl_ulong dt_opencl_get_device_available(const int devid)
Definition opencl.c:2740
int dt_opencl_get_kernel_work_group_size(const int dev, const int kernel, size_t *kernelworkgroupsize)
Definition opencl.c:2143
cl_event * dt_opencl_events_get_slot(const int devid, const char *tag)
Definition opencl.c:2891
int dt_opencl_local_buffer_opt(const int devid, const int kernel, dt_opencl_local_buffer_t *factors)
Definition opencl.c:3286
void dt_opencl_unlock_device(const int dev)
Definition opencl.c:1676
int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
Definition opencl.c:2164
void * dt_opencl_alloc_device_buffer(const int devid, const size_t size)
Definition opencl.c:2580
dt_opencl_fit_reason_t dt_opencl_image_fits_device_reason(const int devid, const size_t width, const size_t height, const unsigned bpp, const float factor, const size_t overhead, size_t *needed, size_t *limit)
Definition opencl.c:2759
dt_opencl_memory_t
Definition opencl.h:96
@ OPENCL_MEMORY_ADD
Definition opencl.h:97
@ OPENCL_MEMORY_SUB
Definition opencl.h:98
int dt_opencl_read_host_from_device_rowpitch(const int devid, void *host, void *device, const int width, const int height, const int rowpitch)
Definition opencl.c:2203
void * dt_opencl_alloc_device_use_host_pointer(const int devid, const int width, const int height, const int bpp, void *host, const int flags)
Definition opencl.c:2527
size_t dt_opencl_get_mem_object_size(cl_mem mem)
Definition opencl.c:2586
gboolean dt_opencl_is_pinned_memory(cl_mem mem)
Definition opencl.c:190
void dt_opencl_cleanup_device(dt_opencl_t *cl, int i)
Definition opencl.c:1261
int dt_opencl_enqueue_copy_buffer_to_image(const int devid, cl_mem src_buffer, cl_mem dst_image, size_t offset, size_t *origin, size_t *region)
Definition opencl.c:2312
void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl, const gboolean print_statistics)
Definition opencl.c:1019
void dt_opencl_events_reset(const int devid)
Definition opencl.c:2989
cl_int dt_opencl_events_flush(const int devid, const int reset)
Definition opencl.c:3084
int dt_opencl_finish(const int devid)
Definition opencl.c:1375
int dt_opencl_copy_device_to_host(const int devid, void *host, void *device, const int width, const int height, const int bpp)
Definition opencl.c:2191
int dt_opencl_lock_device(const int pipetype)
Definition opencl.c:1591
gboolean dt_opencl_read_device_config(const int devid)
Definition opencl.c:246
void dt_opencl_check_tuning(const int devid)
Definition opencl.c:2723
void * dt_opencl_alloc_device(const int devid, const int width, const int height, const int bpp)
Definition opencl.c:2504
int dt_opencl_is_inited(void)
Definition opencl.c:2828
void * dt_opencl_copy_host_to_device_constant(const int devid, const size_t size, void *host)
Definition opencl.c:2360
dt_opencl_pinmode_t
Definition opencl.h:112
@ DT_OPENCL_PINNING_DISABLED
Definition opencl.h:115
@ DT_OPENCL_PINNING_OFF
Definition opencl.h:113
@ DT_OPENCL_PINNING_ON
Definition opencl.h:114
int dt_opencl_dev_roundup_height(int size, const int devid)
Definition opencl.c:2821
void * dt_opencl_copy_host_to_device_rowpitch(const int devid, void *host, const int width, const int height, const int bpp, const int rowpitch)
Definition opencl.c:2381
int dt_opencl_write_host_to_device_rowpitch(const int devid, void *host, void *device, const int width, const int height, const int rowpitch)
Definition opencl.c:2250
int dt_opencl_dev_roundup_width(int size, const int devid)
Definition opencl.c:2816
void dt_opencl_write_device_config(const int devid)
Definition opencl.c:196
int dt_opencl_get_mem_context_id(cl_mem mem)
Definition opencl.c:2596
int dt_opencl_create_kernel(const int program, const char *name)
Definition opencl.c:2058
int dt_opencl_write_host_to_device_non_blocking(const int devid, void *host, void *device, const int width, const int height, const int bpp)
Definition opencl.c:2260
int dt_opencl_load_program(const int dev, const int prog, const char *filename, const char *binname, const char *cachedir, char *md5sum, char **includemd5, int *loaded_cached)
Definition opencl.c:1756
dt_opencl_fit_reason_t
Definition opencl.h:123
@ DT_OPENCL_FIT_ALLOC_LIMIT
Definition opencl.h:126
@ DT_OPENCL_FIT_AVAILABLE
Definition opencl.h:127
@ DT_OPENCL_FIT_DIMENSION
Definition opencl.h:125
@ DT_OPENCL_FIT_UNINITED
Definition opencl.h:128
@ DT_OPENCL_FIT_OK
Definition opencl.h:124
void * dt_opencl_map_buffer(const int devid, cl_mem buffer, const int blocking, const int flags, size_t offset, size_t size)
Definition opencl.c:2428
int dt_opencl_get_image_height(cl_mem mem)
Definition opencl.c:2634
int dt_opencl_read_host_from_device_rowpitch_non_blocking(const int devid, void *host, void *device, const int width, const int height, const int rowpitch)
Definition opencl.c:2220
int dt_opencl_write_buffer_to_device(const int devid, void *host, void *device, const size_t offset, const size_t size, const int blocking)
Definition opencl.c:2348
int dt_opencl_micro_nap(const int devid)
Definition opencl.c:177
int dt_opencl_enqueue_copy_image(const int devid, cl_mem src, cl_mem dst, size_t *orig_src, size_t *orig_dst, size_t *region)
Definition opencl.c:2289
int dt_opencl_set_detected_device_enabled(const int detected, const gboolean enabled)
Definition opencl.c:339
int dt_opencl_read_buffer_from_device(const int devid, void *host, void *device, const size_t offset, const size_t size, const int blocking)
Definition opencl.c:2337
int dt_opencl_build_program(const int dev, const int prog, const char *binname, const char *cachedir, char *md5sum, int loaded_cached)
Definition opencl.c:1930
int dt_opencl_get_max_work_item_sizes(const int dev, size_t *sizes)
Definition opencl.c:2115
int dt_opencl_enqueue_barrier(const int devid)
Definition opencl.c:1389
gboolean dt_opencl_image_fits_device(const int devid, const size_t width, const size_t height, const unsigned bpp, const float factor, const size_t overhead)
Definition opencl.c:2808
int dt_opencl_unmap_mem_object(const int devid, cl_mem mem_object, void *mapped_ptr)
Definition opencl.c:2462
int dt_opencl_read_host_from_device_raw(const int devid, void *host, void *device, const size_t *origin, const size_t *region, const int rowpitch, const int blocking)
Definition opencl.c:2232
gboolean dt_opencl_detected_device_pinned_memory(const int detected)
Definition opencl.c:371
int dt_opencl_set_detected_device_headroom(const int detected, const size_t headroom)
Definition opencl.c:417
int dt_opencl_is_enabled(void)
Definition opencl.c:2835
void dt_opencl_memory_statistics(int devid, cl_mem mem, size_t size, dt_opencl_memory_t action)
Definition opencl.c:2663
void dt_opencl_md5sum(const char **files, char **md5sums)
Definition opencl.c:1702
void dt_opencl_free_kernel(const int kernel)
Definition opencl.c:2101
gboolean dt_opencl_use_pinned_memory(const int devid)
Definition opencl.c:183
void dt_opencl_cleanup(dt_opencl_t *cl)
Definition opencl.c:1310
int dt_opencl_get_image_width(cl_mem mem)
Definition opencl.c:2623
cl_ulong dt_opencl_get_device_memalloc(const int devid)
Definition opencl.c:2753
#define DT_OPENCL_EVENTNAMELENGTH
Definition opencl.h:48
int dt_opencl_read_host_from_device_non_blocking(const int devid, void *host, void *device, const int width, const int height, const int bpp)
Definition opencl.c:2213
int dt_opencl_get_detected_device_count(void)
Definition opencl.c:310
void * dt_opencl_map_image(const int devid, cl_mem buffer, const int blocking, const int flags, size_t width, size_t height, int bpp)
Definition opencl.c:2442
#define DT_OPENCL_MAX_PROGRAMS
Definition opencl.h:45
void * dt_opencl_alloc_device_buffer_with_flags(const int devid, const size_t size, const int flags, void *host_ptr)
Definition opencl.c:2550
int dt_opencl_write_host_to_device_rowpitch_non_blocking(const int devid, void *host, void *device, const int width, const int height, const int rowpitch)
Definition opencl.c:2266
int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size, const void *arg)
Definition opencl.c:2155
int dt_opencl_enqueue_copy_image_to_buffer(const int devid, cl_mem src_image, cl_mem dst_buffer, size_t *origin, size_t *region, size_t offset)
Definition opencl.c:2300
int dt_opencl_update_settings(void)
Definition opencl.c:2852
void dt_opencl_events_wait_for(const int devid)
Definition opencl.c:3027
int dt_opencl_set_detected_device_pinned_memory(const int detected, const gboolean enabled)
Definition opencl.c:384
int dt_opencl_read_host_from_device(const int devid, void *host, void *device, const int width, const int height, const int bpp)
Definition opencl.c:2197
void dt_opencl_events_profiling(const int devid, const int aggregated)
Definition opencl.c:3187
int dt_opencl_get_work_group_limits(const int dev, size_t *sizes, size_t *workgroupsize, unsigned long *localmemsize)
Definition opencl.c:2123
int dt_opencl_enqueue_kernel_2d_with_local(const int dev, const int kernel, const size_t *sizes, const size_t *local)
Definition opencl.c:2170
cl_mem_flags dt_opencl_get_mem_flags(cl_mem mem)
Definition opencl.c:2614
int dt_opencl_enqueue_copy_buffer_to_buffer(const int devid, cl_mem src_buffer, cl_mem dst_buffer, size_t srcoffset, size_t dstoffset, size_t size)
Definition opencl.c:2324
const dt_opencl_detected_device_t * dt_opencl_get_detected_device(const int detected)
Definition opencl.c:318
void * dt_opencl_copy_host_to_device(const int devid, void *host, const int width, const int height, const int bpp)
Definition opencl.c:2375
int dt_opencl_write_host_to_device_raw(const int devid, const void *host, void *device, const size_t *origin, const size_t *region, const int rowpitch, const int blocking)
Definition opencl.c:2277
size_t dt_opencl_detected_device_headroom(const int detected)
Definition opencl.c:405
#define DT_OPENCL_MAX_KERNELS
Definition opencl.h:46
void dt_opencl_release_mem_object(cl_mem mem)
Definition opencl.c:2415
int dt_opencl_get_image_element_size(cl_mem mem)
Definition opencl.c:2645
gboolean dt_opencl_detected_device_enabled(const int detected)
Definition opencl.c:326
int dt_opencl_get_device_info(dt_opencl_t *cl, cl_device_id device, cl_device_info param_name, void **param_value, size_t *param_value_size)
Definition opencl.c:114
int dt_opencl_avoid_atomics(const int devid)
Definition opencl.c:171
int dt_opencl_write_host_to_device(const int devid, void *host, void *device, const int width, const int height, const int bpp)
Definition opencl.c:2244
void dt_opencl_disable(void)
Definition opencl.c:2843
const float factor
Definition pdf.h:90
size_t forced_headroom
Definition opencl.h:228
gboolean host_unified_memory
Definition opencl.h:224
unsigned int cltype
Definition opencl.h:201
const char * name
Definition opencl.h:162
size_t used_available
Definition opencl.h:169
cl_event * eventlist
Definition opencl.h:150
cl_command_queue cmd_queue
Definition opencl.h:140
cl_context context
Definition opencl.h:139
const char * options_md5
Definition opencl.h:165
cl_ulong max_mem_alloc
Definition opencl.h:143
cl_ulong max_global_mem
Definition opencl.h:144
size_t max_image_width
Definition opencl.h:141
cl_ulong used_global_mem
Definition opencl.h:145
cl_device_id devid
Definition opencl.h:138
int program_used[256]
Definition opencl.h:148
dt_pthread_mutex_t lock
Definition opencl.h:137
size_t peak_memory
Definition opencl.h:168
cl_kernel kernel[512]
Definition opencl.h:147
int kernel_used[512]
Definition opencl.h:149
size_t max_image_height
Definition opencl.h:142
cl_program program[256]
Definition opencl.h:146
size_t memory_in_use
Definition opencl.h:167
const char * vendor
Definition opencl.h:161
dt_opencl_eventtag_t * eventtags
Definition opencl.h:151
const char * options
Definition opencl.h:164
const char * cname
Definition opencl.h:163
cl_ulong timelapsed
Definition opencl.h:107
const size_t cellsize
Definition opencl.h:320
const size_t overhead
Definition opencl.h:321
int num_devs
Definition opencl.h:263
int print_statistics
Definition opencl.h:260
struct dt_gaussian_cl_global_t * gaussian
Definition opencl.h:284
int * dev_priority_image
Definition opencl.h:269
int error_count
Definition opencl.h:265
int opencl_synchronization_timeout
Definition opencl.h:266
int * dev_priority_preview
Definition opencl.h:270
dt_opencl_device_t * dev
Definition opencl.h:273
GHashTable * mem_sizes
Definition opencl.h:307
struct dt_bilateral_cl_global_t * bilateral
Definition opencl.h:281
int stopped
Definition opencl.h:262
struct dt_colorspaces_cl_global_t * colorspaces
Definition opencl.h:299
struct dt_guided_filter_cl_global_t * guided_filter
Definition opencl.h:302
int enabled
Definition opencl.h:261
struct dt_interpolation_cl_global_t * interpolation
Definition opencl.h:287
struct dt_local_laplacian_cl_global_t * local_laplacian
Definition opencl.h:290
int mandatory[5]
Definition opencl.h:268
dt_pthread_mutex_t lock
Definition opencl.h:258
struct dt_blendop_cl_global_t * blendop
Definition opencl.h:278
struct dt_dwt_cl_global_t * dwt
Definition opencl.h:293
int * dev_priority_export
Definition opencl.h:271
int inited
Definition opencl.h:259
dt_pthread_mutex_t mem_sizes_lock
Definition opencl.h:308
dt_opencl_detected_device_t * detected_devs
Definition opencl.h:274
dt_dlopencl_t * dlocl
Definition opencl.h:275
int num_detected_devs
Definition opencl.h:264
int * dev_priority_thumbnail
Definition opencl.h:272
uint32_t crc
Definition opencl.h:267
struct dt_heal_cl_global_t * heal
Definition opencl.h:296