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
122typedef struct dt_opencl_device_t
123{
124 dt_pthread_mutex_t lock;
125 cl_device_id devid;
126 cl_context context;
127 cl_command_queue cmd_queue;
137 cl_event *eventlist;
148 const char *vendor;
149 const char *name;
150 const char *cname;
151 const char *options;
152 const char *options_md5;
153 cl_int summary;
157
158 // flags detected errors
160 // if set to TRUE darktable will not use OpenCL kernels which contain atomic operations (example bilateral).
161 // pixelpipe processing will be done on CPU for the affected modules.
162 // useful (only for very old devices) if your OpenCL implementation freezes/crashes on atomics or if
163 // they are processed with a bad performance.
165
166 // pause OpenCL processing for this number of microseconds from time to time
168
169 // During tiling huge amounts of memory need to be transferred between host and device.
170 // For some OpenCL implementations direct memory transfers give a drastic performance penalty,
171 // this can often be avoided by using indirect transfers via pinned memory,
172 // other devices have more efficient direct memory transfer implementations.
173 // We can't predict on solid grounds if a device belongs to the first or second group,
174 // also pinned mem transfer requires slightly more ram.
175 // this holds a bitmask defined by dt_opencl_pinmode_t
176 // the device specific conf key might hold
177 // 0 -> disabled by default; might be switched on by tune for performance
178 // 1 -> enabled by default
179 // 2 -> disabled under all circumstances. This could/should be used if we give away / ship specific keys for buggy systems
181
182 // in OpenCL processing round width/height of global work groups to a multiple of these values.
183 // reasonable values are powers of 2. this parameter can have high impact on OpenCL performance.
186
187 // A bitfield that identifies the type of OpenCL device required to test for on-CPU and more.
188 unsigned int cltype;
189
190 // This defines how often should dt_opencl_events_get_slot do a dt_opencl_events_flush.
191 // It should definitely le lower than the number of events that can be handled by the device/driver.
192 // FIXME we should be able to test for that with using >= OpenCl 2.0
194
195 // opencl_events enabled for the device, set internally via event_handles
197
198 // a device might be turned off by force by setting this value to 1
199 // also used for blacklisted drivers
201
202 // Some devices are known to be unused by other apps so there is no need to test for available memory at all.
203 // Also some devices might behave badly with the checking code, in this case we could enforce a headroom here.
206
217
220struct dt_dwt_cl_global_t; // wavelet decompose
221struct dt_heal_cl_global_t; // healing
222struct dt_colorspaces_cl_global_t; // colorspaces transform
224
229typedef struct dt_opencl_t
230{
231 dt_pthread_mutex_t lock;
240 uint32_t crc;
241 int mandatory[5];
249
250 // global kernels for blending operations.
252
253 // global kernels for bilateral filtering, to be reused by a few plugins.
255
256 // global kernels for gaussian filtering, to be reused by a few plugins.
258
259 // global kernels for interpolation resampling.
261
262 // global kernels for local laplacian filter.
264
265 // global kernels for dwt filter.
267
268 // global kernels for heal filter.
270
271 // global kernels for colorspaces filter.
273
274 // global kernels for guided filter.
277
282{
283 const int xoffset;
284 const int xfactor;
285 const int yoffset;
286 const int yfactor;
287 const size_t cellsize;
288 const size_t overhead;
289 int sizex; // initial value and final values after optimization
290 int sizey; // initial value and final values after optimization
292
296int dt_opencl_get_device_info(dt_opencl_t *cl, cl_device_id device, cl_device_info param_name, void **param_value,
297 size_t *param_value_size);
298
300void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl, const gboolean print_statistics);
301
304
307
310int dt_opencl_finish(const int devid);
311
313int dt_opencl_enqueue_barrier(const int devid);
314
316int dt_opencl_lock_device(const int pipetype);
317
319void dt_opencl_unlock_device(const int dev);
320
322void dt_opencl_md5sum(const char **files, char **md5sums);
323
325int dt_opencl_load_program(const int dev, const int prog, const char *filename, const char *binname,
326 const char *cachedir, char *md5sum, char **includemd5, int *loaded_cached);
327
329int dt_opencl_build_program(const int dev, const int prog, const char *binname, const char *cachedir,
330 char *md5sum, int loaded_cached);
331
333int dt_opencl_create_kernel(const int program, const char *name);
334
336void dt_opencl_free_kernel(const int kernel);
337
339int dt_opencl_get_max_work_item_sizes(const int dev, size_t *sizes);
340
342int dt_opencl_get_work_group_limits(const int dev, size_t *sizes, size_t *workgroupsize,
343 unsigned long *localmemsize);
344
346int dt_opencl_get_kernel_work_group_size(const int dev, const int kernel, size_t *kernelworkgroupsize);
347
349int dt_opencl_set_kernel_arg(const int dev, const int kernel, const int num, const size_t size,
350 const void *arg);
351
353int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes);
354
356int dt_opencl_enqueue_kernel_2d_with_local(const int dev, const int kernel, const size_t *sizes,
357 const size_t *local);
358
360int dt_opencl_is_inited(void);
361
363int dt_opencl_is_enabled(void);
364
366void dt_opencl_disable(void);
367
370
372int dt_opencl_copy_device_to_host(const int devid, void *host, void *device, const int width,
373 const int height, const int bpp);
374
375int dt_opencl_read_host_from_device(const int devid, void *host, void *device, const int width,
376 const int height, const int bpp);
377
378int dt_opencl_read_host_from_device_rowpitch(const int devid, void *host, void *device, const int width,
379 const int height, const int rowpitch);
380
381int dt_opencl_read_host_from_device_non_blocking(const int devid, void *host, void *device, const int width,
382 const int height, const int bpp);
383
384int dt_opencl_read_host_from_device_rowpitch_non_blocking(const int devid, void *host, void *device,
385 const int width, const int height,
386 const int rowpitch);
387
388int dt_opencl_read_host_from_device_raw(const int devid, void *host, void *device, const size_t *origin,
389 const size_t *region, const int rowpitch, const int blocking);
390
391int dt_opencl_write_host_to_device(const int devid, void *host, void *device, const int width,
392 const int height, const int bpp);
393
394int dt_opencl_write_host_to_device_rowpitch(const int devid, void *host, void *device, const int width,
395 const int height, const int rowpitch);
396
397int dt_opencl_write_host_to_device_non_blocking(const int devid, void *host, void *device, const int width,
398 const int height, const int bpp);
399
400int dt_opencl_write_host_to_device_rowpitch_non_blocking(const int devid, void *host, void *device,
401 const int width, const int height,
402 const int rowpitch);
403
404int dt_opencl_write_host_to_device_raw(const int devid, const void *host, void *device, const size_t *origin,
405 const size_t *region, const int rowpitch, const int blocking);
406
407void *dt_opencl_copy_host_to_device(const int devid, void *host, const int width, const int height,
408 const int bpp);
409
410void *dt_opencl_copy_host_to_device_rowpitch(const int devid, void *host, const int width, const int height,
411 const int bpp, const int rowpitch);
412
413void *dt_opencl_copy_host_to_device_constant(const int devid, const size_t size, void *host);
414
415int dt_opencl_enqueue_copy_image(const int devid, cl_mem src, cl_mem dst, size_t *orig_src, size_t *orig_dst,
416 size_t *region);
417
418void *dt_opencl_alloc_device(const int devid, const int width, const int height, const int bpp);
419
420void *dt_opencl_alloc_device_use_host_pointer(const int devid, const int width, const int height,
421 const int bpp, void *host, const int flags);
422
423int dt_opencl_enqueue_copy_image_to_buffer(const int devid, cl_mem src_image, cl_mem dst_buffer,
424 size_t *origin, size_t *region, size_t offset);
425
426int dt_opencl_enqueue_copy_buffer_to_image(const int devid, cl_mem src_buffer, cl_mem dst_image,
427 size_t offset, size_t *origin, size_t *region);
428
429int dt_opencl_enqueue_copy_buffer_to_buffer(const int devid, cl_mem src_buffer, cl_mem dst_buffer,
430 size_t srcoffset, size_t dstoffset, size_t size);
431
432int dt_opencl_read_buffer_from_device(const int devid, void *host, void *device, const size_t offset,
433 const size_t size, const int blocking);
434
435int dt_opencl_write_buffer_to_device(const int devid, void *host, void *device, const size_t offset,
436 const size_t size, const int blocking);
437
438void *dt_opencl_alloc_device_buffer(const int devid, const size_t size);
439
440void *dt_opencl_alloc_device_buffer_with_flags(const int devid, const size_t size, const int flags, void *host_ptr);
441
442void dt_opencl_release_mem_object(cl_mem mem);
443
444void *dt_opencl_map_buffer(const int devid, cl_mem buffer, const int blocking, const int flags, size_t offset,
445 size_t size);
446
447void *dt_opencl_map_image(const int devid, cl_mem buffer, const int blocking, const int flags, size_t width, size_t height, int bpp);
448
449int dt_opencl_unmap_mem_object(const int devid, cl_mem mem_object, void *mapped_ptr);
450
451size_t dt_opencl_get_mem_object_size(cl_mem mem);
452
453int dt_opencl_get_image_width(cl_mem mem);
454
455int dt_opencl_get_image_height(cl_mem mem);
456
458
459int dt_opencl_get_mem_context_id(cl_mem mem);
460cl_mem_flags dt_opencl_get_mem_flags(cl_mem mem);
461
462void dt_opencl_memory_statistics(int devid, cl_mem mem, dt_opencl_memory_t action);
463
465gboolean dt_opencl_image_fits_device(const int devid, const size_t width, const size_t height, const unsigned bpp,
466 const float factor, const size_t overhead);
468cl_ulong dt_opencl_get_device_available(const int devid);
469
471void dt_opencl_check_tuning(const int devid);
472
474cl_ulong dt_opencl_get_device_memalloc(const int devid);
475
477int dt_opencl_dev_roundup_width(int size, const int devid);
478int dt_opencl_dev_roundup_height(int size, const int devid);
479
481cl_event *dt_opencl_events_get_slot(const int devid, const char *tag);
482
484void dt_opencl_events_reset(const int devid);
485
488void dt_opencl_events_wait_for(const int devid);
489
492cl_int dt_opencl_events_flush(const int devid, const int reset);
493
495void dt_opencl_events_profiling(const int devid, const int aggregated);
496
498int dt_opencl_local_buffer_opt(const int devid, const int kernel, dt_opencl_local_buffer_t *factors);
499
501void dt_opencl_write_device_config(const int devid);
502gboolean dt_opencl_read_device_config(const int devid);
514gboolean dt_opencl_detected_device_enabled(const int detected);
518int dt_opencl_set_detected_device_enabled(const int detected, const gboolean enabled);
522gboolean dt_opencl_detected_device_pinned_memory(const int detected);
526int dt_opencl_set_detected_device_pinned_memory(const int detected, const gboolean enabled);
530size_t dt_opencl_detected_device_headroom(const int detected);
534int dt_opencl_set_detected_device_headroom(const int detected, const size_t headroom);
535int dt_opencl_avoid_atomics(const int devid);
536int dt_opencl_micro_nap(const int devid);
537gboolean dt_opencl_use_pinned_memory(const int devid);
538gboolean dt_opencl_is_pinned_memory(cl_mem mem);
539
540#ifdef __cplusplus
541}
542#endif
543
544#else
545
546#include "control/conf.h"
547#include <stdlib.h>
548
549#ifdef __cplusplus
550extern "C" {
551#endif
552
553typedef struct dt_opencl_t
554{
555 int inited;
556 int enabled;
557 int stopped;
558 int error_count;
560typedef struct dt_opencl_detected_device_t
561{
562 int config_id;
563 char *name;
564 char *cname;
565 unsigned int cltype;
566 int disabled;
567 int pinned_memory;
568 size_t forced_headroom;
570static inline void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl, const gboolean print_statistics)
571{
572 cl->inited = 0;
573 cl->enabled = 0;
574 cl->stopped = 0;
575 cl->error_count = 0;
576 dt_conf_set_bool("opencl", FALSE);
577 dt_print(DT_DEBUG_OPENCL, "[opencl_init] this version of darktable was built without opencl support\n");
578}
579static inline void dt_opencl_cleanup(dt_opencl_t *cl)
580{
581}
582static inline gboolean dt_opencl_finish(const int devid)
583{
584 return -1;
585}
586static inline int dt_opencl_enqueue_barrier(const int devid)
587{
588 return -1;
589}
590static inline int dt_opencl_lock_device(const int dev)
591{
592 return -1;
593}
594static inline void dt_opencl_unlock_device(const int dev)
595{
596}
597static inline int dt_opencl_load_program(const int dev, const char *filename)
598{
599 return -1;
600}
601static inline int dt_opencl_build_program(const int dev, const int program)
602{
603 return -1;
604}
605static inline int dt_opencl_create_kernel(const int program, const char *name)
606{
607 return -1;
608}
609static inline void dt_opencl_free_kernel(const int kernel)
610{
611}
612static inline int dt_opencl_get_max_work_item_sizes(const int dev, size_t *sizes)
613{
614 return -1;
615}
616static inline int dt_opencl_get_work_group_limits(const int dev, size_t *sizes, size_t *workgroupsize,
617 unsigned long *localmemsize)
618{
619 return -1;
620}
621static inline int dt_opencl_get_kernel_work_group_size(const int dev, const int kernel,
622 size_t *kernelworkgroupsize)
623{
624 return -1;
625}
626static inline int dt_opencl_set_kernel_arg(const int dev, const int kernel, const size_t size, const void *arg)
627{
628 return -1;
629}
630static inline int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
631{
632 return -1;
633}
634static inline int dt_opencl_enqueue_kernel_2d_with_local(const int dev, const int kernel, const size_t *sizes,
635 const size_t *local)
636{
637 return -1;
638}
639static inline int dt_opencl_is_inited(void)
640{
641 return 0;
642}
643static inline int dt_opencl_is_enabled(void)
644{
645 return 0;
646}
647static inline void dt_opencl_disable(void)
648{
649}
650static inline int dt_opencl_update_settings(void)
651{
652 return 0;
653}
654static inline int dt_opencl_get_detected_device_count(void)
655{
656 return 0;
657}
658static inline const dt_opencl_detected_device_t *dt_opencl_get_detected_device(const int detected)
659{
660 return NULL;
661}
662static inline gboolean dt_opencl_detected_device_enabled(const int detected)
663{
664 return FALSE;
665}
666static inline int dt_opencl_set_detected_device_enabled(const int detected, const gboolean enabled)
667{
668 return -1;
669}
670static inline gboolean dt_opencl_detected_device_pinned_memory(const int detected)
671{
672 return FALSE;
673}
674static inline int dt_opencl_set_detected_device_pinned_memory(const int detected, const gboolean enabled)
675{
676 return -1;
677}
678static inline size_t dt_opencl_detected_device_headroom(const int detected)
679{
680 return 0;
681}
682static inline int dt_opencl_set_detected_device_headroom(const int detected, const size_t headroom)
683{
684 return -1;
685}
686static inline gboolean dt_opencl_image_fits_device(const int devid, const size_t width, const size_t height,
687 const unsigned bpp, const float factor, const size_t overhead)
688{
689 return FALSE;
690}
691static inline size_t dt_opencl_get_device_available(const int devid)
692{
693 return 0;
694}
695static inline void dt_opencl_check_tuning(const int devid)
696{
697 return;
698}
699static inline size_t dt_opencl_get_device_memalloc(const int devid)
700{
701 return 0;
702}
703static inline unsigned long dt_opencl_get_mem_flags(void *mem)
704{
705 return 0;
706}
707static inline void dt_opencl_release_mem_object(void *mem)
708{
709}
710static inline void *dt_opencl_events_get_slot(const int devid, const char *tag)
711{
712 return NULL;
713}
714static inline void dt_opencl_events_reset(const int devid)
715{
716}
717static inline void dt_opencl_events_wait_for(const int devid)
718{
719}
720static inline int dt_opencl_events_flush(const int devid, const int reset)
721{
722 return 0;
723}
724static inline void dt_opencl_events_profiling(const int devid, const int aggregated)
725{
726}
727
728#ifdef __cplusplus
729}
730#endif
731
732#endif
733
734// clang-format off
735// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
736// vim: shiftwidth=2 expandtab tabstop=2 cindent
737// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
738// 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:1266
void dt_print(dt_debug_thread_t thread, const char *msg,...)
Definition darktable.c:1542
@ DT_DEBUG_OPENCL
Definition darktable.h:722
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:2664
int dt_opencl_get_kernel_work_group_size(const int dev, const int kernel, size_t *kernelworkgroupsize)
Definition opencl.c:2115
cl_event * dt_opencl_events_get_slot(const int devid, const char *tag)
Definition opencl.c:2793
int dt_opencl_local_buffer_opt(const int devid, const int kernel, dt_opencl_local_buffer_t *factors)
Definition opencl.c:3156
void dt_opencl_unlock_device(const int dev)
Definition opencl.c:1648
int dt_opencl_enqueue_kernel_2d(const int dev, const int kernel, const size_t *sizes)
Definition opencl.c:2136
void * dt_opencl_alloc_device_buffer(const int devid, const size_t size)
Definition opencl.c:2544
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:2175
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:2493
size_t dt_opencl_get_mem_object_size(cl_mem mem)
Definition opencl.c:2550
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:1235
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:2284
void dt_opencl_init(dt_opencl_t *cl, const gboolean exclude_opencl, const gboolean print_statistics)
Definition opencl.c:995
void dt_opencl_events_reset(const int devid)
Definition opencl.c:2891
cl_int dt_opencl_events_flush(const int devid, const int reset)
Definition opencl.c:2968
int dt_opencl_finish(const int devid)
Definition opencl.c:1347
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:2163
int dt_opencl_lock_device(const int pipetype)
Definition opencl.c:1563
gboolean dt_opencl_read_device_config(const int devid)
Definition opencl.c:246
void dt_opencl_check_tuning(const int devid)
Definition opencl.c:2647
void * dt_opencl_alloc_device(const int devid, const int width, const int height, const int bpp)
Definition opencl.c:2471
int dt_opencl_is_inited(void)
Definition opencl.c:2730
void * dt_opencl_copy_host_to_device_constant(const int devid, const size_t size, void *host)
Definition opencl.c:2332
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:2723
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:2353
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:2222
int dt_opencl_dev_roundup_width(int size, const int devid)
Definition opencl.c:2718
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:2560
int dt_opencl_create_kernel(const int program, const char *name)
Definition opencl.c:2030
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:2232
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:1728
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:2396
int dt_opencl_get_image_height(cl_mem mem)
Definition opencl.c:2598
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:2192
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:2320
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:2261
int dt_opencl_set_detected_device_enabled(const int detected, const gboolean enabled)
Definition opencl.c:337
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:2309
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:1902
int dt_opencl_get_max_work_item_sizes(const int dev, size_t *sizes)
Definition opencl.c:2087
int dt_opencl_enqueue_barrier(const int devid)
Definition opencl.c:1361
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:2683
int dt_opencl_unmap_mem_object(const int devid, cl_mem mem_object, void *mapped_ptr)
Definition opencl.c:2430
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:2204
gboolean dt_opencl_detected_device_pinned_memory(const int detected)
Definition opencl.c:369
int dt_opencl_set_detected_device_headroom(const int detected, const size_t headroom)
Definition opencl.c:410
int dt_opencl_is_enabled(void)
Definition opencl.c:2737
void dt_opencl_md5sum(const char **files, char **md5sums)
Definition opencl.c:1674
void dt_opencl_free_kernel(const int kernel)
Definition opencl.c:2073
gboolean dt_opencl_use_pinned_memory(const int devid)
Definition opencl.c:183
void dt_opencl_cleanup(dt_opencl_t *cl)
Definition opencl.c:1284
int dt_opencl_get_image_width(cl_mem mem)
Definition opencl.c:2587
cl_ulong dt_opencl_get_device_memalloc(const int devid)
Definition opencl.c:2677
#define DT_OPENCL_EVENTNAMELENGTH
Definition opencl.h:48
void dt_opencl_memory_statistics(int devid, cl_mem mem, dt_opencl_memory_t action)
Definition opencl.c:2621
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:2185
int dt_opencl_get_detected_device_count(void)
Definition opencl.c:308
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:2410
#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:2514
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:2238
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:2127
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:2272
int dt_opencl_update_settings(void)
Definition opencl.c:2754
void dt_opencl_events_wait_for(const int devid)
Definition opencl.c:2924
int dt_opencl_set_detected_device_pinned_memory(const int detected, const gboolean enabled)
Definition opencl.c:382
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:2169
void dt_opencl_events_profiling(const int devid, const int aggregated)
Definition opencl.c:3057
int dt_opencl_get_work_group_limits(const int dev, size_t *sizes, size_t *workgroupsize, unsigned long *localmemsize)
Definition opencl.c:2095
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:2142
cl_mem_flags dt_opencl_get_mem_flags(cl_mem mem)
Definition opencl.c:2578
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:2296
const dt_opencl_detected_device_t * dt_opencl_get_detected_device(const int detected)
Definition opencl.c:316
void * dt_opencl_copy_host_to_device(const int devid, void *host, const int width, const int height, const int bpp)
Definition opencl.c:2347
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:2249
size_t dt_opencl_detected_device_headroom(const int detected)
Definition opencl.c:398
#define DT_OPENCL_MAX_KERNELS
Definition opencl.h:46
void dt_opencl_release_mem_object(cl_mem mem)
Definition opencl.c:2383
int dt_opencl_get_image_element_size(cl_mem mem)
Definition opencl.c:2609
gboolean dt_opencl_detected_device_enabled(const int detected)
Definition opencl.c:324
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:2216
void dt_opencl_disable(void)
Definition opencl.c:2745
const float factor
Definition pdf.h:90
size_t forced_headroom
Definition opencl.h:204
unsigned int cltype
Definition opencl.h:188
const char * name
Definition opencl.h:149
size_t used_available
Definition opencl.h:156
cl_event * eventlist
Definition opencl.h:137
cl_command_queue cmd_queue
Definition opencl.h:127
cl_context context
Definition opencl.h:126
const char * options_md5
Definition opencl.h:152
cl_ulong max_mem_alloc
Definition opencl.h:130
cl_ulong max_global_mem
Definition opencl.h:131
size_t max_image_width
Definition opencl.h:128
cl_ulong used_global_mem
Definition opencl.h:132
cl_device_id devid
Definition opencl.h:125
int program_used[256]
Definition opencl.h:135
dt_pthread_mutex_t lock
Definition opencl.h:124
size_t peak_memory
Definition opencl.h:155
cl_kernel kernel[512]
Definition opencl.h:134
int kernel_used[512]
Definition opencl.h:136
size_t max_image_height
Definition opencl.h:129
cl_program program[256]
Definition opencl.h:133
size_t memory_in_use
Definition opencl.h:154
const char * vendor
Definition opencl.h:148
dt_opencl_eventtag_t * eventtags
Definition opencl.h:138
const char * options
Definition opencl.h:151
const char * cname
Definition opencl.h:150
cl_ulong timelapsed
Definition opencl.h:107
const size_t cellsize
Definition opencl.h:287
const size_t overhead
Definition opencl.h:288
int num_devs
Definition opencl.h:236
int print_statistics
Definition opencl.h:233
struct dt_gaussian_cl_global_t * gaussian
Definition opencl.h:257
int * dev_priority_image
Definition opencl.h:242
int error_count
Definition opencl.h:238
int opencl_synchronization_timeout
Definition opencl.h:239
int * dev_priority_preview
Definition opencl.h:243
dt_opencl_device_t * dev
Definition opencl.h:246
struct dt_bilateral_cl_global_t * bilateral
Definition opencl.h:254
int stopped
Definition opencl.h:235
struct dt_colorspaces_cl_global_t * colorspaces
Definition opencl.h:272
struct dt_guided_filter_cl_global_t * guided_filter
Definition opencl.h:275
int enabled
Definition opencl.h:234
struct dt_interpolation_cl_global_t * interpolation
Definition opencl.h:260
struct dt_local_laplacian_cl_global_t * local_laplacian
Definition opencl.h:263
int mandatory[5]
Definition opencl.h:241
dt_pthread_mutex_t lock
Definition opencl.h:231
struct dt_blendop_cl_global_t * blendop
Definition opencl.h:251
struct dt_dwt_cl_global_t * dwt
Definition opencl.h:266
int * dev_priority_export
Definition opencl.h:244
int inited
Definition opencl.h:232
dt_opencl_detected_device_t * detected_devs
Definition opencl.h:247
dt_dlopencl_t * dlocl
Definition opencl.h:248
int num_detected_devs
Definition opencl.h:237
int * dev_priority_thumbnail
Definition opencl.h:245
uint32_t crc
Definition opencl.h:240
struct dt_heal_cl_global_t * heal
Definition opencl.h:269