![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include <inttypes.h>#include <stdarg.h>#include <glib.h>#include <stdlib.h>#include <signal.h>#include <string.h>#include "system/sys_resources.h"#include "caches/pixelpipe_cache_pressure.h"#include "develop/pixelpipe_hb.h"#include "caches/pixelpipe_cache.h"#include "common/opencl.h"#include "pixel/format.h"#include "develop/imageop.h"
Include dependency graph for pixelpipe_cache.c:Go to the source code of this file.
Data Structures | |
| struct | dt_dev_pixelpipe_cache_t |
| struct | dt_cache_clmem_t |
| struct | _cache_lru_t |
| struct | _cache_invalidate_t |
Macros | |
| #define | _cache_print(channel, ...) |
| #define | DT_PIXELPIPE_CACHE_PRESSURE_EXEMPT_SIZE ((size_t)1024 * 1024) |
Typedefs | |
| typedef struct dt_dev_pixelpipe_cache_t | dt_dev_pixelpipe_cache_t |
| typedef struct dt_cache_clmem_t | dt_cache_clmem_t |
| typedef enum dt_pixel_cache_materialize_source_rank_t | dt_pixel_cache_materialize_source_rank_t |
| typedef struct _cache_lru_t | _cache_lru_t |
| typedef struct _cache_invalidate_t | _cache_invalidate_t |
Functions | |
| gboolean | dt_dev_pixelpipe_cache_is_ready (void) |
| Has the pixelpipe cache been initialised? Callers that run before dt_dev_pixelpipe_cache_init() succeeds, or after its cleanup, ask this rather than testing a handle they should not hold. | |
| void | dt_dev_pixelpipe_cache_set_handlers (dt_pixelpipe_cache_warn_handler_t warn, dt_pixelpipe_cache_ready_handler_t ready, const dt_pixelpipe_cache_observer_t *observer) |
| Install the handlers. Call once, from the orchestrator, before any pipe runs. | |
| static void | _warn_user (const char *format,...) __attribute__((format(printf |
| static gboolean | _observed (void) |
| static void | _observe_read (uint64_t hash, size_t size) |
| static void | _observe_delete (uint64_t hash, size_t size, int owner_pipe_id, const char *name) |
| static void | _observe_rekey (uint64_t old_hash, uint64_t new_hash) |
| static dt_pixel_cache_entry_t * | _non_threadsafe_cache_get_entry (dt_dev_pixelpipe_cache_t *cache, GHashTable *table, const uint64_t key) |
| static const char * | _cache_debug_module_name (void) |
| static void | _trace_exact_hit (const char *phase, const uint64_t hash, dt_pixel_cache_entry_t *cache_entry, void *data, void *cl_mem_output, const int preferred_devid, const gboolean verbose) |
| const char * | dt_pixelpipe_cache_set_current_module (const char *module) |
| Set the current module name for cache diagnostics (thread-local). | |
| void | _non_thread_safe_cache_ref_count_entry (dt_dev_pixelpipe_cache_t *cache, gboolean lock, dt_pixel_cache_entry_t *cache_entry) |
| static void | _free_cache_entry (dt_pixel_cache_entry_t *cache_entry) |
| static void | _pixelpipe_cache_finalize_entry (dt_pixel_cache_entry_t *cache_entry, void **data, const char *message) |
| int | _non_thread_safe_cache_remove (dt_dev_pixelpipe_cache_t *cache, const gboolean force, dt_pixel_cache_entry_t *cache_entry, GHashTable *table) |
| static dt_pixel_cache_entry_t * | _pixelpipe_cache_create_entry_locked (dt_dev_pixelpipe_cache_t *cache, const uint64_t hash, const size_t size, const char *name, const int id) |
| static dt_pixel_cache_entry_t * | dt_pixel_cache_new_entry (const uint64_t hash, const size_t size, const char *name, const int id, dt_dev_pixelpipe_cache_t *cache, gboolean alloc, GHashTable *table) |
| static gboolean | _cache_entry_clmem_flush_device (dt_pixel_cache_entry_t *entry, const int devid) |
| static gboolean | _cache_entry_materialize_host_data_locked (dt_pixel_cache_entry_t *entry, int preferred_devid, gboolean prefer_device_payload) |
| static int | dt_dev_pixelpipe_cache_flush_old (dt_dev_pixelpipe_cache_t *cache) |
| static int | _memory_pressure_shedder (dt_dev_pixelpipe_cache_t *cache) |
| static gboolean | _cache_entry_clmem_flush_host_pinned_locked (dt_pixel_cache_entry_t *entry, void *host_ptr, int devid) |
| static void | _pixel_cache_touch (dt_pixel_cache_entry_t *cache_entry) |
| static int64_t | _pixel_cache_get_age (dt_pixel_cache_entry_t *cache_entry) |
| static dt_pixel_cache_entry_t * | _cache_entry_for_host_ptr_locked (dt_dev_pixelpipe_cache_t *cache, void *host_ptr) |
| dt_pixel_cache_entry_t * | dt_dev_pixelpipe_cache_get_entry (const uint64_t hash) |
| Get an internal reference to the cache entry matching hash. If you are going to access this entry more than once, keeping the reference and using it instead of hashes will prevent redundant lookups. | |
| dt_pixel_cache_entry_t * | dt_dev_pixelpipe_cache_get_entry_by_data (void *data) |
| static size_t | _pixel_cache_get_size (dt_pixel_cache_entry_t *cache_entry) |
| static void | _pixel_cache_message (dt_pixel_cache_entry_t *cache_entry, const char *message, gboolean verbose) |
| gboolean | dt_dev_pixelpipe_cache_ref_entry_by_hash (const uint64_t hash, void **data, dt_pixel_cache_entry_t **entry) |
| Resolve and retain an existing cache entry by hash. | |
| gboolean | dt_dev_pixelpipe_cache_ref_host_entry_by_hash (const uint64_t hash, void **data, dt_pixel_cache_entry_t **entry) |
| Resolve and retain an existing cacheline that already holds HOST pixels. | |
| int | dt_dev_pixelpipe_cache_remove (const gboolean force, dt_pixel_cache_entry_t *cache_entry) |
| Arbitrarily remove the cache entry matching hash. Entries having a reference count > 0 (inter-thread locked) or being having their read/write lock locked will be ignored. If force is TRUE, we ignore reference count, but not locks. | |
| static gboolean | _cache_entry_materialize_host_data (dt_dev_pixelpipe_cache_t *cache, int preferred_devid, dt_pixel_cache_entry_t *entry) |
| static gboolean | _cache_entry_clmem_has_host_pinned_locked (dt_pixel_cache_entry_t *entry, void *host_ptr, int devid) |
| void | dt_dev_pixelpipe_cache_flush_clmem (const int devid) |
| Release cached OpenCL buffers for a single device. | |
| void | dt_dev_pixelpipe_cache_flush_clmem_for_pipe (const int devid) |
Like dt_dev_pixelpipe_cache_flush_clmem(), for callers that do not hold the device lock (dt_opencl_reserve_device_by_id()) (e.g. a pipe's own cleanup after dt_dev_pixelpipe_process() already released it). Takes the lock itself, then delegates. No-op if devid < 0 or OpenCL isn't available. | |
| static void | _cache_get_oldest (gpointer key, gpointer value, gpointer user_data) |
| static void | _print_cache_lines (gpointer key, gpointer value, gpointer user_data) |
| static int | _non_thread_safe_pixel_pipe_cache_remove_lru (dt_dev_pixelpipe_cache_t *cache) |
| int | dt_dev_pixel_pipe_cache_remove_lru (void) |
| static void * | _pixel_cache_clmem_get (dt_pixel_cache_entry_t *entry, void *host_ptr, int devid, int width, int height, int bpp, int flags) |
| void * | dt_dev_pixelpipe_cache_borrow_cl_payload (dt_pixel_cache_entry_t *entry, int devid, int width, int height, int bpp) |
| Borrow a cached OpenCL payload attached to a cache entry. | |
| void | dt_dev_pixelpipe_cache_return_cl_payload (dt_pixel_cache_entry_t *entry, void *mem) |
| Return a borrowed cached OpenCL payload to its cache entry. | |
| static int | _pixel_cache_clmem_put (dt_pixel_cache_entry_t *entry, void *host_ptr, void *mem) |
| static void | _pixel_cache_clmem_remove (dt_pixel_cache_entry_t *entry, void *mem) |
| void | dt_dev_pixelpipe_cache_flush_entry_clmem (dt_pixel_cache_entry_t *entry) |
| Flush all reusable OpenCL payloads cached on one cache entry. | |
| void * | dt_dev_pixelpipe_cache_get_pinned_image (void *host_ptr, dt_pixel_cache_entry_t *entry_hint, int devid, int width, int height, int bpp, int flags, gboolean *out_reused) |
| Acquire a pinned OpenCL image for a host buffer tracked by the pixelpipe cache. | |
| void | dt_dev_pixelpipe_cache_put_pinned_image (void *host_ptr, dt_pixel_cache_entry_t *entry_hint, void **mem) |
Release or cache a pinned OpenCL image acquired with dt_dev_pixelpipe_cache_get_pinned_image(). | |
| gboolean | dt_dev_pixelpipe_cache_flush_host_pinned_image (void *host_ptr, dt_pixel_cache_entry_t *entry_hint, int devid) |
| Drop cached pinned OpenCL images associated with a given host buffer. | |
| static gboolean | _is_gamma_rgba8_output (const dt_iop_module_t *module, const size_t bpp, const char *message) |
| void * | dt_dev_pixelpipe_cache_alloc_cl_device_buffer (int devid, const dt_iop_roi_t *roi, const size_t bpp, const dt_iop_module_t *module, const char *message, void *keep) |
| void * | dt_dev_pixelpipe_cache_get_cl_buffer (int devid, void *const host_ptr, const dt_iop_roi_t *roi, const size_t bpp, dt_iop_module_t *module, const char *message, dt_pixel_cache_entry_t *cache_entry, gboolean *out_reused, void *keep) |
| void | dt_dev_pixelpipe_cache_release_cl_buffer (void **cl_mem_buffer, dt_pixel_cache_entry_t *cache_entry, void *host_ptr, const gboolean cache_device) |
| Release or cache an OpenCL image associated with a host cache line. | |
| int | dt_dev_pixelpipe_cache_sync_cl_buffer (const int devid, void *host_ptr, void *cl_mem_buffer, const dt_iop_roi_t *roi, int cl_mode, size_t bpp, dt_iop_module_t *module, const char *message) |
| Synchronize between host memory and a pinned OpenCL image. | |
| float * | dt_dev_pixelpipe_cache_restore_cl_buffer (dt_dev_pixelpipe_t *pipe, float *input, void *cl_mem_input, const dt_iop_roi_t *roi_in, dt_iop_module_t *module, const size_t in_bpp, dt_pixel_cache_entry_t *input_entry, const char *message) |
| Force device → host resynchronization of the pixelpipe input cache line. | |
| int | dt_dev_pixelpipe_cache_prepare_cl_input (dt_dev_pixelpipe_t *pipe, dt_iop_module_t *module, float *input, void **cl_mem_input, const dt_iop_roi_t *roi_in, const size_t in_bpp, dt_pixel_cache_entry_t *input_entry, dt_pixel_cache_entry_t **locked_input_entry, void *keep) |
| Prepare/obtain the OpenCL input image for a module. | |
| dt_pixel_cache_entry_t * | dt_dev_pixelpipe_cache_ref_entry_for_host_ptr (void *host_ptr) |
| Resolve and retain the cache entry owning a host pointer. | |
| static gboolean | _system_memory_pressure_valve (dt_dev_pixelpipe_cache_t *cache, size_t request_size) |
| static void * | _arena_alloc_with_defrag (dt_dev_pixelpipe_cache_t *cache, size_t request_size, size_t *actual_size) |
| static void | _arena_stats_bytes (dt_dev_pixelpipe_cache_t *cache, uint32_t *total_pages, uint32_t *largest_pages, size_t *total_bytes, size_t *largest_bytes) |
| size_t | dt_pixelpipe_cache_get_largest_free_run (void) |
| static void | _log_arena_allocation_failure (dt_dev_pixelpipe_cache_t *cache, size_t request_size, const char *entry_name, const char *module, uint64_t hash, gboolean name_is_file) |
| void * | dt_pixel_cache_alloc (dt_pixel_cache_entry_t *cache_entry) |
Actually allocate the memory buffer attached to the cache entry once you create it with dt_dev_pixelpipe_cache_get(). Sizes and everything are already saved in the entry, and the cache will have the needed space reserved. | |
| void * | dt_pixel_cache_entry_get_data (dt_pixel_cache_entry_t *entry) |
| size_t | dt_pixel_cache_entry_get_size (dt_pixel_cache_entry_t *entry) |
| Peek the size (in bytes) reserved for the host buffer of a cache entry. | |
| static size_t | _pressure_held (void *user) |
| static size_t | _pressure_shed (void *user, const size_t target, size_t *given_back) |
| static dt_pixelpipe_cache_pressure_sink_t | _pressure_sink (dt_dev_pixelpipe_cache_t *cache) |
| static void | _pressure_wake (void *user) |
| static size_t | _cache_budget_locked (const dt_dev_pixelpipe_cache_t *cache) |
| static void | _pressure_react_locked (dt_dev_pixelpipe_cache_t *cache) |
| static int | _free_space_to_alloc (dt_dev_pixelpipe_cache_t *cache, const size_t size, const uint64_t hash, const char *name) |
| void * | dt_pixelpipe_cache_alloc_align_cache_impl (size_t size, int id, const char *name) |
| Allocate aligned memory tracked by the pixelpipe cache. This allows LRU cache entries to be evicted if needed to make room. | |
| void | dt_pixelpipe_cache_free_align_cache (void **mem, const char *message) |
| Free aligned memory allocated with dt_pixelpipe_cache_alloc_align_cache. | |
| gboolean | dt_dev_pixelpipe_cache_init (size_t max_memory, const gboolean verbose, const gboolean verbose_detail) |
| Reserve the cache's arena and start it. | |
| void | dt_dev_pixelpipe_cache_cleanup (void) |
| static dt_pixel_cache_entry_t * | _cache_try_rekey_reuse_locked (dt_dev_pixelpipe_cache_t *cache, const uint64_t new_hash, const size_t size, const dt_pixel_cache_entry_t *reuse_hint) |
| int | dt_dev_pixelpipe_cache_get (const uint64_t hash, const size_t size, const char *name, const int id, const gboolean alloc, void **data, dt_pixel_cache_entry_t **entry) |
| Get a cache line from the cache. | |
| dt_dev_pixelpipe_cache_writable_status_t | dt_dev_pixelpipe_cache_get_writable (const uint64_t hash, const size_t size, const char *name, const int id, const gboolean alloc, const gboolean allow_rekey_reuse, const dt_pixel_cache_entry_t *reuse_hint, void **data, dt_pixel_cache_entry_t **entry) |
| static dt_pixel_cache_entry_t * | _cache_lookup_existing (dt_dev_pixelpipe_cache_t *cache, const uint64_t hash, void **data) |
| static gboolean | _cache_try_restore_device_payload (dt_pixel_cache_entry_t *cache_entry, const int preferred_devid, void **cl_mem_output) |
| gboolean | dt_dev_pixelpipe_cache_restore_host_payload (dt_pixel_cache_entry_t *cache_entry, const int preferred_devid, void **data) |
| Materialize a host payload for a live cache entry from its cached device payload. | |
| gboolean | dt_dev_pixelpipe_cache_peek (const uint64_t hash, void **data, dt_pixel_cache_entry_t **entry, const int preferred_devid, void **cl_mem_output) |
| Non-owning lookup of an existing cache line. | |
| static gboolean | _for_each_remove (gpointer key, gpointer value, gpointer user_data) |
| void | dt_dev_pixelpipe_cache_flush (const int id) |
| Remove cache lines matching id. Entries locked in read/write or having reference count greater than 0 are not removed. | |
| int | dt_dev_pixelpipe_cache_invalidate_hashes (const uint64_t *hashes, const size_t count) |
| Invalidate cache lines matching an explicit list of hashes. | |
| static void | _cache_get_newest (gpointer key, gpointer value, gpointer user_data) |
| static gboolean | _for_each_remove_old (gpointer key, gpointer value, gpointer user_data) |
| void | dt_dev_pixelpipe_cache_ref_count_entry (gboolean lock, dt_pixel_cache_entry_t *cache_entry) |
| Increase/Decrease the reference count on the cache line as to prevent LRU item removal. This function should be called within a read/write lock-protected section to avoid changing an entry while or after it is deleted in parallel. | |
| void | dt_dev_pixelpipe_cache_wrlock_entry (gboolean lock, dt_pixel_cache_entry_t *cache_entry) |
| Lock or release the write lock on the entry. | |
| void | dt_dev_pixelpipe_cache_rdlock_entry (gboolean lock, dt_pixel_cache_entry_t *cache_entry) |
| Lock or release the read lock on the entry. | |
| void | dt_dev_pixelpipe_cache_flag_auto_destroy (dt_pixel_cache_entry_t *cache_entry) |
Flag the cache entry as "auto_destroy". This is useful for short-lived/disposable cache entries, that won't be needed in the future. These will be freed out of the typical LRU, aged-based garbage collection. The thread that tagged this entry as "auto_destroy" is responsible for freeing it as soon as it is done with it, using dt_dev_pixelpipe_cache_auto_destroy_apply(). If not manually freed this way, the entry will be caught using the generic LRU garbage collection. | |
| void | dt_dev_pixelpipe_cache_auto_destroy_apply (dt_pixel_cache_entry_t *cache_entry) |
Free the entry if it has the flag "auto_destroy". See dt_dev_pixelpipe_cache_flag_auto_destroy(). This only removes entries whose reference count already dropped to 0 and whose lock is currently free. Call it right after the final consumer releases its refcount, from the same control flow that flagged the entry for auto-destruction. If another consumer still owns the entry, this becomes a no-op and generic cache eviction or a later explicit retry will reap it once ownership reaches 0. | |
| void | dt_dev_pixelpipe_cache_unref_hash (const uint64_t hash) |
| Find the entry matching hash, and decrease its ref_count if found. | |
| int | dt_dev_pixelpipe_cache_rekey (const uint64_t old_hash, const uint64_t new_hash, dt_pixel_cache_entry_t *entry) |
| Change the hash/key of an existing cache line in place, without freeing, reallocating or invalidating the underlying entry. | |
| void | dt_dev_pixelpipe_cache_print (void) |
| void | dt_dev_pixelpipe_cache_get_usage (size_t *current, size_t *max) |
| GArray * | dt_dev_pixelpipe_cache_get_entries_stats (void) |
| size_t | dt_dev_pixelpipe_cache_get_vram_total (void) |
Variables | |
| static gboolean | _verbose = FALSE |
| static gboolean | _verbose_detail = FALSE |
| static dt_dev_pixelpipe_cache_t * | _pixelpipe_cache = NULL |
| static dt_pixelpipe_cache_warn_handler_t | _warn_handler = NULL |
| static dt_pixelpipe_cache_ready_handler_t | _ready_handler = NULL |
| static const dt_pixelpipe_cache_observer_t * | _observer = NULL |
| static __thread const char * | dt_pixelpipe_cache_current_module = NULL |
| static int | garbage_collection = 0 |
| static int | pressure_shedding = 0 |
| #define _cache_print | ( | channel, | |
| ... | |||
| ) |
Definition at line 60 of file pixelpipe_cache.c.
| #define DT_PIXELPIPE_CACHE_PRESSURE_EXEMPT_SIZE ((size_t)1024 * 1024) |
Definition at line 1641 of file pixelpipe_cache.c.
| typedef struct _cache_invalidate_t _cache_invalidate_t |
| typedef struct _cache_lru_t _cache_lru_t |
| typedef struct dt_cache_clmem_t dt_cache_clmem_t |
| typedef struct dt_dev_pixelpipe_cache_t dt_dev_pixelpipe_cache_t |
Definition at line 196 of file pixelpipe_cache.c.
|
inlinestatic |
Definition at line 1784 of file pixelpipe_cache.c.
References _non_thread_safe_pixel_pipe_cache_remove_lru(), _system_memory_pressure_valve(), dt_dev_pixelpipe_cache_t::arena, dt_cache_arena_alloc(), dt_cache_arena_calc(), dt_cache_arena_stats(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, IS_NULL_PTR, and dt_dev_pixelpipe_cache_t::lock.
Referenced by dt_pixel_cache_alloc(), and dt_pixelpipe_cache_alloc_align_cache_impl().
|
inlinestatic |
Definition at line 1812 of file pixelpipe_cache.c.
References dt_dev_pixelpipe_cache_t::arena, dt_cache_arena_stats(), and dt_cache_arena_t::page_size.
Referenced by _log_arena_allocation_failure(), and dt_pixelpipe_cache_get_largest_free_run().
|
inlinestatic |
Definition at line 2012 of file pixelpipe_cache.c.
References dt_pixelpipe_cache_pressure_monitor_t::budget, dt_pixelpipe_cache_pressure_budget(), and dt_dev_pixelpipe_cache_t::psi.
Referenced by _free_space_to_alloc().
|
inlinestatic |
Definition at line 161 of file pixelpipe_cache.c.
References dt_pixelpipe_cache_current_module.
Referenced by _cache_try_rekey_reuse_locked(), _pixel_cache_message(), _trace_exact_hit(), and dt_dev_pixelpipe_cache_rekey().
|
static |
Definition at line 1883 of file pixelpipe_cache.c.
References _cache_print, _verbose, _verbose_detail, dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_pixel_cache_entry_t::data, DT_DEBUG_OPENCL, dt_free, dt_opencl_get_mem_context_id(), dt_opencl_release_mem_object(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_pixel_cache_entry_t::hash, and IS_NULL_PTR.
Referenced by dt_dev_pixelpipe_cache_flush_clmem().
|
static |
Definition at line 618 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_free, dt_opencl_get_mem_context_id(), dt_opencl_release_mem_object(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, IS_NULL_PTR, and TRUE.
Referenced by dt_dev_pixelpipe_cache_flush_host_pinned_image().
|
static |
Definition at line 596 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_opencl_get_mem_context_id(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, IS_NULL_PTR, and TRUE.
Referenced by dt_dev_pixelpipe_cache_flush_host_pinned_image().
|
static |
Definition at line 254 of file pixelpipe_cache.c.
References _non_threadsafe_cache_get_entry(), dt_pixel_cache_entry_t::data, dt_pixel_cache_entry_t::external_alloc, dt_dev_pixelpipe_cache_t::external_entries, and IS_NULL_PTR.
Referenced by dt_dev_pixelpipe_cache_flush_host_pinned_image(), dt_dev_pixelpipe_cache_get_pinned_image(), and dt_dev_pixelpipe_cache_ref_entry_for_host_ptr().
|
static |
Definition at line 576 of file pixelpipe_cache.c.
References _cache_entry_materialize_host_data_locked(), dt_dev_pixelpipe_cache_wrlock_entry(), dt_pixel_cache_alloc(), dt_pixel_cache_entry_get_data(), FALSE, IS_NULL_PTR, and TRUE.
Referenced by dt_dev_pixelpipe_cache_restore_host_payload().
|
static |
Definition at line 480 of file pixelpipe_cache.c.
References bpp, dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_pixel_cache_entry_t::data, dt_opencl_get_image_element_size(), dt_opencl_get_image_height(), dt_opencl_get_image_width(), dt_opencl_get_mem_context_id(), dt_opencl_is_pinned_memory(), dt_opencl_map_image(), dt_opencl_read_host_from_device(), dt_opencl_unmap_mem_object(), DT_PIXEL_CACHE_MATERIALIZE_SOURCE_NONE, DT_PIXEL_CACHE_MATERIALIZE_SOURCE_PRIMARY_ANY, DT_PIXEL_CACHE_MATERIALIZE_SOURCE_PRIMARY_PREFERRED, DT_PIXEL_CACHE_MATERIALIZE_SOURCE_SECONDARY_ANY, DT_PIXEL_CACHE_MATERIALIZE_SOURCE_SECONDARY_PREFERRED, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, height, dt_cache_clmem_t::host_ptr, IS_NULL_PTR, dt_cache_clmem_t::mem, TRUE, and width.
Referenced by _cache_entry_materialize_host_data().
|
static |
Definition at line 2829 of file pixelpipe_cache.c.
References _pixel_cache_get_age(), and value.
Referenced by dt_dev_pixelpipe_cache_flush_old().
|
static |
Definition at line 758 of file pixelpipe_cache.c.
References _pixel_cache_get_age(), _pixel_cache_message(), _cache_lru_t::cache_entry, dt_atomic_get_int(), dt_pthread_rwlock_trywrlock(), dt_pthread_rwlock_unlock(), _cache_lru_t::hash, dt_pixel_cache_entry_t::hash, dt_pixel_cache_entry_t::lock, _cache_lru_t::max_age, dt_pixel_cache_entry_t::refcount, TRUE, and value.
Referenced by _non_thread_safe_pixel_pipe_cache_remove_lru().
|
static |
Definition at line 2598 of file pixelpipe_cache.c.
References _non_threadsafe_cache_get_entry(), _observe_read(), _pixelpipe_cache_finalize_entry(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, dt_dev_pixelpipe_cache_t::hits, dt_pixel_cache_entry_t::hits, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, dt_dev_pixelpipe_cache_t::queries, and dt_pixel_cache_entry_t::size.
Referenced by dt_dev_pixelpipe_cache_peek().
|
static |
Definition at line 2385 of file pixelpipe_cache.c.
References _cache_debug_module_name(), _cache_print, _non_thread_safe_cache_ref_count_entry(), _non_threadsafe_cache_get_entry(), _observe_rekey(), dt_pixel_cache_entry_t::auto_destroy, dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_pixel_cache_entry_t::data, dt_atomic_get_int(), DT_DEBUG_PIPECACHE, dt_dev_pixelpipe_cache_wrlock_entry(), DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, FALSE, dt_pixel_cache_entry_t::hash, IS_NULL_PTR, dt_pixel_cache_entry_t::refcount, dt_pixel_cache_entry_t::serial, size, dt_pixel_cache_entry_t::size, and TRUE.
Referenced by dt_dev_pixelpipe_cache_get_writable().
|
static |
Definition at line 2622 of file pixelpipe_cache.c.
References _pixel_cache_touch(), dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_free, dt_opencl_get_mem_context_id(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, and IS_NULL_PTR.
Referenced by dt_dev_pixelpipe_cache_peek().
|
static |
Definition at line 2776 of file pixelpipe_cache.c.
References dt_pthread_rwlock_trywrlock(), dt_pthread_rwlock_unlock(), dt_pixel_cache_entry_t::id, dt_pixel_cache_entry_t::lock, and value.
Referenced by dt_dev_pixelpipe_cache_flush().
|
static |
Definition at line 2839 of file pixelpipe_cache.c.
References _pixel_cache_get_age(), dt_atomic_get_int(), dt_pthread_rwlock_trywrlock(), dt_pthread_rwlock_unlock(), dt_pixel_cache_entry_t::hits, dt_pixel_cache_entry_t::lock, dt_pixel_cache_entry_t::refcount, and value.
Referenced by dt_dev_pixelpipe_cache_flush_old().
|
static |
Definition at line 2210 of file pixelpipe_cache.c.
References _observe_delete(), _pixel_cache_message(), _pixelpipe_cache, dt_dev_pixelpipe_cache_t::arena, dt_pixel_cache_entry_t::cache, dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_dev_pixelpipe_cache_t::current_memory, dt_pixel_cache_entry_t::data, dt_cache_arena_free(), dt_dev_pixelpipe_cache_flush_entry_clmem(), dt_free, dt_opencl_finish(), dt_opencl_get_mem_context_id(), dt_opencl_is_inited(), dt_opencl_release_device(), dt_opencl_try_reserve_device_by_id(), dt_pthread_mutex_destroy(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_pthread_rwlock_destroy(), FALSE, dt_pixel_cache_entry_t::hash, dt_pixel_cache_entry_t::id, IS_NULL_PTR, dt_pixel_cache_entry_t::lock, dt_pixel_cache_entry_t::name, and dt_pixel_cache_entry_t::size.
Referenced by dt_dev_pixelpipe_cache_init().
|
static |
Definition at line 2025 of file pixelpipe_cache.c.
References _cache_budget_locked(), _non_thread_safe_pixel_pipe_cache_remove_lru(), _pressure_react_locked(), _warn_user(), dt_dev_pixelpipe_cache_t::current_memory, dt_dev_pixelpipe_cache_t::entries, error(), IS_NULL_PTR, dt_dev_pixelpipe_cache_t::max_memory, name, and size.
Referenced by dt_pixel_cache_new_entry(), and dt_pixelpipe_cache_alloc_align_cache_impl().
|
inlinestatic |
Definition at line 1185 of file pixelpipe_cache.c.
Referenced by dt_dev_pixelpipe_cache_alloc_cl_device_buffer(), and dt_dev_pixelpipe_cache_get_cl_buffer().
|
inlinestatic |
Definition at line 1838 of file pixelpipe_cache.c.
References _arena_stats_bytes(), _warn_user(), dt_dev_pixelpipe_cache_t::current_memory, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::max_memory, and void().
Referenced by dt_pixel_cache_alloc(), and dt_pixelpipe_cache_alloc_align_cache_impl().
|
static |
Definition at line 2908 of file pixelpipe_cache.c.
References _non_thread_safe_pixel_pipe_cache_remove_lru(), _pressure_react_locked(), dt_dev_pixelpipe_cache_t::arena, dt_dev_pixelpipe_cache_t::current_memory, dt_cache_arena_trim(), DT_DEBUG_MEMORY, DT_DEBUG_PIPECACHE, dt_get_memory_pressure_floor(), dt_get_system_available_mem(), dt_invalidate_system_available_mem(), dt_print(), dt_pthread_mutex_trylock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, dt_dev_pixelpipe_cache_t::lock, dt_dev_pixelpipe_cache_t::sys_available_est, dt_dev_pixelpipe_cache_t::sys_probe_time_us, and dt_dev_pixelpipe_cache_t::sys_probe_valid.
Referenced by dt_dev_pixelpipe_cache_init().
| void _non_thread_safe_cache_ref_count_entry | ( | dt_dev_pixelpipe_cache_t * | cache, |
| gboolean | lock, | ||
| dt_pixel_cache_entry_t * | cache_entry | ||
| ) |
Definition at line 2964 of file pixelpipe_cache.c.
References _pixel_cache_message(), _pixel_cache_touch(), dt_atomic_add_int(), dt_atomic_sub_int(), IS_NULL_PTR, lock, dt_pixel_cache_entry_t::refcount, and TRUE.
Referenced by _cache_try_rekey_reuse_locked(), _pixelpipe_cache_create_entry_locked(), dt_dev_pixelpipe_cache_get(), dt_dev_pixelpipe_cache_ref_count_entry(), dt_dev_pixelpipe_cache_ref_entry_by_hash(), dt_dev_pixelpipe_cache_ref_entry_for_host_ptr(), dt_dev_pixelpipe_cache_ref_host_entry_by_hash(), dt_pixelpipe_cache_alloc_align_cache_impl(), and dt_pixelpipe_cache_free_align_cache().
| int _non_thread_safe_cache_remove | ( | dt_dev_pixelpipe_cache_t * | cache, |
| const gboolean | force, | ||
| dt_pixel_cache_entry_t * | cache_entry, | ||
| GHashTable * | table | ||
| ) |
Definition at line 435 of file pixelpipe_cache.c.
References _cache_print, _pixel_cache_message(), dt_atomic_get_int(), DT_DEBUG_PIPECACHE, dt_pthread_rwlock_trywrlock(), dt_pthread_rwlock_unlock(), dt_pixel_cache_entry_t::hash, IS_NULL_PTR, dt_pixel_cache_entry_t::lock, dt_pixel_cache_entry_t::refcount, and TRUE.
Referenced by _non_thread_safe_pixel_pipe_cache_remove_lru(), dt_dev_pixelpipe_cache_get(), dt_dev_pixelpipe_cache_get_writable(), dt_dev_pixelpipe_cache_invalidate_hashes(), and dt_dev_pixelpipe_cache_remove().
|
static |
Definition at line 802 of file pixelpipe_cache.c.
References _cache_get_oldest(), _cache_print, _non_thread_safe_cache_remove(), _print_cache_lines(), _cache_lru_t::cache_entry, dt_dev_pixelpipe_cache_t::current_memory, DT_DEBUG_PIPECACHE, dt_free, dt_dev_pixelpipe_cache_t::entries, error(), FALSE, _cache_lru_t::hash, and _cache_lru_t::max_age.
Referenced by _arena_alloc_with_defrag(), _free_space_to_alloc(), _memory_pressure_shedder(), _pressure_shed(), _system_memory_pressure_valve(), and dt_dev_pixel_pipe_cache_remove_lru().
|
static |
Definition at line 264 of file pixelpipe_cache.c.
References key.
Referenced by _cache_entry_for_host_ptr_locked(), _cache_lookup_existing(), _cache_try_rekey_reuse_locked(), dt_dev_pixelpipe_cache_get(), dt_dev_pixelpipe_cache_get_entry(), dt_dev_pixelpipe_cache_get_writable(), dt_dev_pixelpipe_cache_invalidate_hashes(), dt_dev_pixelpipe_cache_ref_entry_by_hash(), dt_dev_pixelpipe_cache_ref_host_entry_by_hash(), dt_dev_pixelpipe_cache_rekey(), dt_dev_pixelpipe_cache_unref_hash(), and dt_pixelpipe_cache_free_align_cache().
|
inlinestatic |
Definition at line 146 of file pixelpipe_cache.c.
References _observed(), _observer, dt_pixelpipe_cache_observer_t::cacheline_delete, name, and size.
Referenced by _free_cache_entry().
Definition at line 142 of file pixelpipe_cache.c.
References _observed(), _observer, dt_pixelpipe_cache_observer_t::cacheline_read, and size.
Referenced by _cache_lookup_existing(), dt_dev_pixelpipe_cache_get(), dt_dev_pixelpipe_cache_ref_entry_by_hash(), and dt_dev_pixelpipe_cache_ref_host_entry_by_hash().
Definition at line 150 of file pixelpipe_cache.c.
References _observed(), _observer, and dt_pixelpipe_cache_observer_t::rekey.
Referenced by _cache_try_rekey_reuse_locked(), and dt_dev_pixelpipe_cache_rekey().
|
inlinestatic |
Definition at line 135 of file pixelpipe_cache.c.
References _observer, and dt_pixelpipe_cache_observer_t::active.
Referenced by _observe_delete(), _observe_read(), and _observe_rekey().
|
static |
Definition at line 841 of file pixelpipe_cache.c.
References _cache_print, _pixel_cache_touch(), _verbose, _verbose_detail, bpp, dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, DT_DEBUG_OPENCL, dt_free, dt_opencl_get_image_element_size(), dt_opencl_get_image_height(), dt_opencl_get_image_width(), dt_opencl_get_mem_context_id(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_pixel_cache_entry_t::hash, height, IS_NULL_PTR, and width.
Referenced by dt_dev_pixelpipe_cache_get_cl_buffer(), and dt_dev_pixelpipe_cache_get_pinned_image().
|
static |
| entry | |
| host_ptr | |
| mem |
Definition at line 953 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_opencl_get_mem_context_id(), dt_opencl_release_mem_object(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), and IS_NULL_PTR.
Referenced by dt_dev_pixelpipe_cache_put_pinned_image(), and dt_dev_pixelpipe_cache_release_cl_buffer().
|
static |
Definition at line 997 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_free, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), and IS_NULL_PTR.
Referenced by dt_dev_pixelpipe_cache_get_pinned_image(), and dt_dev_pixelpipe_cache_release_cl_buffer().
|
inlinestatic |
Definition at line 248 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::age, and dt_atomic_get_uint64().
Referenced by _cache_get_newest(), _cache_get_oldest(), _for_each_remove_old(), and _pixel_cache_message().
|
static |
Definition at line 328 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::size.
Referenced by _pixel_cache_message().
|
static |
Definition at line 334 of file pixelpipe_cache.c.
References _cache_debug_module_name(), _cache_print, _pixel_cache_get_age(), _pixel_cache_get_size(), _verbose, _verbose_detail, dt_pixel_cache_entry_t::auto_destroy, dt_pixel_cache_entry_t::data, dt_atomic_get_int(), DT_DEBUG_PIPECACHE, dt_pixel_cache_entry_t::external_alloc, dt_pixel_cache_entry_t::hash, dt_pixel_cache_entry_t::hits, dt_pixel_cache_entry_t::id, dt_pixel_cache_entry_t::name, dt_pixel_cache_entry_t::refcount, and dt_pixel_cache_entry_t::serial.
Referenced by _cache_get_oldest(), _free_cache_entry(), _non_thread_safe_cache_ref_count_entry(), _non_thread_safe_cache_remove(), _pixelpipe_cache_finalize_entry(), _print_cache_lines(), dt_dev_pixelpipe_cache_auto_destroy_apply(), dt_dev_pixelpipe_cache_flag_auto_destroy(), dt_dev_pixelpipe_cache_get(), dt_dev_pixelpipe_cache_get_writable(), dt_dev_pixelpipe_cache_rdlock_entry(), and dt_dev_pixelpipe_cache_wrlock_entry().
|
inlinestatic |
Definition at line 242 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::age, dt_atomic_set_uint64(), and IS_NULL_PTR.
Referenced by _cache_try_restore_device_payload(), _non_thread_safe_cache_ref_count_entry(), _pixel_cache_clmem_get(), _pixelpipe_cache_finalize_entry(), dt_dev_pixelpipe_cache_borrow_cl_payload(), dt_dev_pixelpipe_cache_get_entry(), dt_dev_pixelpipe_cache_get_entry_by_data(), dt_dev_pixelpipe_cache_get_writable(), dt_dev_pixelpipe_cache_restore_host_payload(), and dt_pixelpipe_cache_alloc_align_cache_impl().
|
static |
Definition at line 2369 of file pixelpipe_cache.c.
References _non_thread_safe_cache_ref_count_entry(), dt_dev_pixelpipe_cache_wrlock_entry(), dt_pixel_cache_new_entry(), dt_dev_pixelpipe_cache_t::entries, FALSE, IS_NULL_PTR, name, size, and TRUE.
Referenced by dt_dev_pixelpipe_cache_get(), and dt_dev_pixelpipe_cache_get_writable().
|
static |
Definition at line 348 of file pixelpipe_cache.c.
References _pixel_cache_message(), _pixel_cache_touch(), dt_pixel_cache_entry_t::data, DT_CACHELINE_BYTES, and FALSE.
Referenced by _cache_lookup_existing(), dt_dev_pixelpipe_cache_get(), dt_dev_pixelpipe_cache_get_writable(), dt_dev_pixelpipe_cache_ref_entry_by_hash(), and dt_dev_pixelpipe_cache_ref_host_entry_by_hash().
|
static |
Definition at line 1973 of file pixelpipe_cache.c.
Referenced by _pressure_sink().
|
static |
Definition at line 2018 of file pixelpipe_cache.c.
References _pressure_sink(), dt_pixelpipe_cache_pressure_react(), and dt_dev_pixelpipe_cache_t::psi.
Referenced by _free_space_to_alloc(), and _memory_pressure_shedder().
|
static |
Definition at line 1978 of file pixelpipe_cache.c.
References _non_thread_safe_pixel_pipe_cache_remove_lru(), dt_dev_pixelpipe_cache_t::arena, dt_dev_pixelpipe_cache_t::current_memory, dt_cache_arena_trim(), dt_invalidate_system_available_mem(), dt_dev_pixelpipe_cache_t::entries, and dt_dev_pixelpipe_cache_t::sys_probe_time_us.
Referenced by _pressure_sink().
|
static |
Definition at line 1993 of file pixelpipe_cache.c.
References _pressure_held(), _pressure_shed(), and dt_pixelpipe_cache_pressure_sink_t::held.
Referenced by _pressure_react_locked(), and _pressure_wake().
Definition at line 2001 of file pixelpipe_cache.c.
References _pressure_sink(), dt_pixelpipe_cache_pressure_triggered(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::lock, and dt_dev_pixelpipe_cache_t::psi.
Referenced by dt_dev_pixelpipe_cache_init().
|
static |
Definition at line 791 of file pixelpipe_cache.c.
References _pixel_cache_message(), FALSE, and value.
Referenced by _non_thread_safe_pixel_pipe_cache_remove_lru().
|
static |
Definition at line 1665 of file pixelpipe_cache.c.
References _non_thread_safe_pixel_pipe_cache_remove_lru(), _warn_user(), dt_dev_pixelpipe_cache_t::arena, dt_dev_pixelpipe_cache_t::current_memory, dt_cache_arena_trim(), DT_DEBUG_MEMORY, DT_DEBUG_PIPECACHE, dt_get_memory_pressure_floor(), dt_get_system_available_mem(), dt_invalidate_system_available_mem(), DT_PIXELPIPE_CACHE_PRESSURE_EXEMPT_SIZE, dt_print(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, dt_dev_pixelpipe_cache_t::lock, dt_dev_pixelpipe_cache_t::sys_available_est, dt_dev_pixelpipe_cache_t::sys_probe_time_us, dt_dev_pixelpipe_cache_t::sys_probe_valid, and TRUE.
Referenced by _arena_alloc_with_defrag().
|
static |
Definition at line 166 of file pixelpipe_cache.c.
References _cache_debug_module_name(), _cache_print, _verbose, _verbose_detail, dt_pixel_cache_entry_t::auto_destroy, dt_atomic_get_int(), DT_DEBUG_PIPECACHE, DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pixel_cache_entry_t::hash, dt_pixel_cache_entry_t::name, dt_pixel_cache_entry_t::refcount, and dt_pixel_cache_entry_t::serial.
Referenced by dt_dev_pixelpipe_cache_peek().
Definition at line 124 of file pixelpipe_cache.c.
References _warn_handler.
Referenced by _free_space_to_alloc(), _log_arena_allocation_failure(), and _system_memory_pressure_valve().
| int dt_dev_pixel_pipe_cache_remove_lru | ( | void | ) |
remove the least used cache entry
Definition at line 831 of file pixelpipe_cache.c.
References _non_thread_safe_pixel_pipe_cache_remove_lru(), _pixelpipe_cache, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), error(), and dt_dev_pixelpipe_cache_t::lock.
Referenced by dt_tiling_piece_fits_host_memory().
| void * dt_dev_pixelpipe_cache_alloc_cl_device_buffer | ( | int | devid, |
| const dt_iop_roi_t * | roi, | ||
| const size_t | bpp, | ||
| const dt_iop_module_t * | module, | ||
| const char * | message, | ||
| void * | keep | ||
| ) |
Definition at line 1192 of file pixelpipe_cache.c.
References _is_gamma_rgba8_output(), bpp, dt_opencl_alloc_device(), DT_OPENCL_BPP_ENCODE_RGBA8, dt_iop_roi_t::height, and dt_iop_roi_t::width.
Referenced by dt_dev_pixelpipe_cache_get_cl_buffer(), and pixelpipe_process_on_GPU().
| void dt_dev_pixelpipe_cache_auto_destroy_apply | ( | struct dt_pixel_cache_entry_t * | entry | ) |
Free the entry if it has the flag "auto_destroy". See dt_dev_pixelpipe_cache_flag_auto_destroy(). This only removes entries whose reference count already dropped to 0 and whose lock is currently free. Call it right after the final consumer releases its refcount, from the same control flow that flagged the entry for auto-destruction. If another consumer still owns the entry, this becomes a no-op and generic cache eviction or a later explicit retry will reap it once ownership reaches 0.
| cache |
Definition at line 3049 of file pixelpipe_cache.c.
References _pixel_cache_message(), _pixelpipe_cache, dt_pixel_cache_entry_t::auto_destroy, dt_atomic_get_int(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_pthread_rwlock_trywrlock(), dt_pthread_rwlock_unlock(), dt_dev_pixelpipe_cache_t::entries, FALSE, dt_pixel_cache_entry_t::hash, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, dt_pixel_cache_entry_t::lock, dt_pixel_cache_entry_t::refcount, and TRUE.
Referenced by _abort_module_shutdown_cleanup(), dt_dev_pixelpipe_cleanup(), and dt_dev_pixelpipe_process_rec().
| void * dt_dev_pixelpipe_cache_borrow_cl_payload | ( | struct dt_pixel_cache_entry_t * | entry, |
| int | devid, | ||
| int | width, | ||
| int | height, | ||
| int | bpp | ||
| ) |
Borrow a cached OpenCL payload attached to a cache entry.
This reopens a cached cl_mem image already tracked by the cache entry and increments its internal borrow counter so cache flush/eviction paths will keep it alive until the caller returns it with dt_dev_pixelpipe_cache_return_cl_payload().
| entry | Cache entry owning the payload. |
| host_ptr | Host pointer key for pinned payloads, or NULL for device-only payloads. |
| devid | OpenCL device id. |
| width | Image width. |
| height | Image height. |
| bpp | Bytes per pixel. |
| flags | Tracked OpenCL flags used when the payload was cached. |
cl_mem, or NULL if no matching cached payload exists. Definition at line 890 of file pixelpipe_cache.c.
References _pixel_cache_touch(), bpp, dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_opencl_get_image_element_size(), dt_opencl_get_image_height(), dt_opencl_get_image_width(), dt_opencl_get_mem_context_id(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), height, and width.
Referenced by pixelpipe_process_on_GPU().
Definition at line 2340 of file pixelpipe_cache.c.
References _pixelpipe_cache, dt_dev_pixelpipe_cache_t::arena, dt_cache_arena_cleanup(), dt_pixelpipe_cache_pressure_watch_stop(), dt_pthread_mutex_destroy(), dt_dev_pixelpipe_cache_t::entries, dt_dev_pixelpipe_cache_t::external_entries, garbage_collection, dt_dev_pixelpipe_cache_t::lock, pressure_shedding, and dt_dev_pixelpipe_cache_t::psi.
Referenced by dt_cleanup().
| void dt_dev_pixelpipe_cache_flag_auto_destroy | ( | struct dt_pixel_cache_entry_t * | entry | ) |
Flag the cache entry as "auto_destroy". This is useful for short-lived/disposable cache entries, that won't be needed in the future. These will be freed out of the typical LRU, aged-based garbage collection. The thread that tagged this entry as "auto_destroy" is responsible for freeing it as soon as it is done with it, using dt_dev_pixelpipe_cache_auto_destroy_apply(). If not manually freed this way, the entry will be caught using the generic LRU garbage collection.
| cache |
Definition at line 3033 of file pixelpipe_cache.c.
References _pixel_cache_message(), _pixelpipe_cache, dt_pixel_cache_entry_t::auto_destroy, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, and TRUE.
Referenced by _abort_module_shutdown_cleanup(), dt_dev_pixelpipe_cache_peek(), dt_dev_pixelpipe_cleanup(), and dt_dev_pixelpipe_process_rec().
| void dt_dev_pixelpipe_cache_flush | ( | const int | id | ) |
Remove cache lines matching id. Entries locked in read/write or having reference count greater than 0 are not removed.
| cache | |
| id | ID of the pipeline owning the cache line, or -1 to remove all lines. |
Definition at line 2790 of file pixelpipe_cache.c.
References _for_each_remove(), _pixelpipe_cache, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, and dt_dev_pixelpipe_cache_t::lock.
Referenced by dt_dev_pixelpipe_reset_all().
| void dt_dev_pixelpipe_cache_flush_clmem | ( | const int | devid | ) |
Release cached OpenCL buffers for a single device.
This is intentionally a lightweight VRAM-pressure/retry helper: it drops cached cl_mem objects without taking per-entry write locks. Realtime paths rely on it to free scratch OpenCL buffers without stalling in-flight renders.
| devid | Device to flush, or a negative value for a no-op (e.g. a pipe that never used OpenCL). The caller must already hold the device lock (dt_opencl_reserve_device_by_id()) – this is the case for the pixelpipe currently running on that device. Callers that don't hold it (e.g. cleaning up a pipe after it finished) must use dt_dev_pixelpipe_cache_flush_clmem_for_pipe() instead. |
Definition at line 659 of file pixelpipe_cache.c.
References _cache_entry_clmem_flush_device(), _cache_print, _pixelpipe_cache, _verbose, _verbose_detail, dt_atomic_get_int(), DT_DEBUG_OPENCL, dt_opencl_events_wait_for(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_pthread_rwlock_trywrlock(), dt_pthread_rwlock_unlock(), dt_dev_pixelpipe_cache_t::entries, dt_pixel_cache_entry_t::hash, key, dt_dev_pixelpipe_cache_t::lock, dt_pixel_cache_entry_t::lock, dt_pixel_cache_entry_t::refcount, and value.
Referenced by _dt_opencl_alloc_image2d(), dt_dev_pixelpipe_cache_flush_clmem_for_pipe(), dt_opencl_alloc_device_buffer_with_flags(), guided_filter_cl(), and pixelpipe_process_on_GPU().
| void dt_dev_pixelpipe_cache_flush_clmem_for_pipe | ( | const int | devid | ) |
Like dt_dev_pixelpipe_cache_flush_clmem(), for callers that do not hold the device lock (dt_opencl_reserve_device_by_id()) (e.g. a pipe's own cleanup after dt_dev_pixelpipe_process() already released it). Takes the lock itself, then delegates. No-op if devid < 0 or OpenCL isn't available.
Definition at line 729 of file pixelpipe_cache.c.
References dt_dev_pixelpipe_cache_flush_clmem(), dt_opencl_is_inited(), dt_opencl_release_device(), and dt_opencl_reserve_device_by_id().
Referenced by _studio_dev_teardown(), dt_dev_pixelpipe_cleanup(), and leave().
| void dt_dev_pixelpipe_cache_flush_entry_clmem | ( | struct dt_pixel_cache_entry_t * | entry | ) |
Flush all reusable OpenCL payloads cached on one cache entry.
Borrowed payloads are preserved until all borrowers returned them.
| entry | Cache entry whose cached cl_mem payloads should be flushed. |
Definition at line 1017 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_free, dt_opencl_release_mem_object(), dt_pthread_mutex_lock(), and dt_pthread_mutex_unlock().
Referenced by _free_cache_entry(), dt_dev_pixelpipe_cache_rekey(), and dt_dev_pixelpipe_process_rec().
| gboolean dt_dev_pixelpipe_cache_flush_host_pinned_image | ( | void * | host_ptr, |
| struct dt_pixel_cache_entry_t * | entry_hint, | ||
| int | devid | ||
| ) |
Drop cached pinned OpenCL images associated with a given host buffer.
This is meant for host buffers that remain alive and continue to be mutated by the CPU (for example, privately owned working patches). Reusing a stale CL_MEM_USE_HOST_PTR image for such buffers can hide later host-side edits on some drivers. Flushing the cached pinned images forces the next use to rebind the host storage.
| cache | Pixelpipe cache. |
| host_ptr | Host-backed image data. |
| entry_hint | Optional owning cache entry for regular cache lines, or NULL. |
| devid | Device id to flush, or -1 for all cached devices for that host buffer. |
Definition at line 1132 of file pixelpipe_cache.c.
References _cache_entry_clmem_flush_host_pinned_locked(), _cache_entry_clmem_has_host_pinned_locked(), _cache_entry_for_host_ptr_locked(), _pixelpipe_cache, dt_dev_pixelpipe_cache_ref_count_entry(), dt_opencl_events_wait_for(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, and TRUE.
Referenced by _rasterize_pending_dab_batch(), _rekey_shared_base_patch(), dt_dev_pixelpipe_gpu_flush_host_pinned_images(), dt_drawlayer_cache_flush_process_patch_to_base(), and dt_drawlayer_cache_populate_process_patch_from_base().
|
static |
Definition at line 2859 of file pixelpipe_cache.c.
References _cache_get_newest(), _for_each_remove_old(), dt_dev_pixelpipe_cache_t::arena, dt_cache_arena_trim(), dt_get_memory_pressure_floor(), dt_get_system_available_mem(), dt_pthread_mutex_trylock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, and dt_dev_pixelpipe_cache_t::lock.
Referenced by dt_dev_pixelpipe_cache_init().
| int dt_dev_pixelpipe_cache_get | ( | const uint64_t | hash, |
| const size_t | size, | ||
| const char * | name, | ||
| const int | id, | ||
| const gboolean | alloc, | ||
| void ** | data, | ||
| struct dt_pixel_cache_entry_t ** | entry | ||
| ) |
Get a cache line from the cache.
WARNING: This internally increases the reference count, so you have to manually decrease it using dt_dev_pixelpipe_ref_count_entry() once the cache line content has been consumed or it will never be freed.
WARNING: if the cache line was newly allocated, a write lock is put on straight away. You will have to release it from the same calling thread next, to avoid dead locks.
| cache | |
| hash | State checksum of the cache line. |
| size | Buffer size in bytes. |
| name | Name of the cache line (for debugging). |
| id | ID of the pipeline owning the cache line. |
| data | Pointer to the buffer pointer (returned). |
| alloc | Whether or not we should actually alloc the buffer, or simply reserve it. If FALSE use dt_pixel_cache_alloc() when you actually need the buffer. |
| cache_entry | a reference to the cache entry, to be reused later. Can be NULL. The caller doesn't own the data and shouldn't free it. |
Definition at line 2453 of file pixelpipe_cache.c.
References _cache_print, _non_thread_safe_cache_ref_count_entry(), _non_thread_safe_cache_remove(), _non_threadsafe_cache_get_entry(), _observe_read(), _pixel_cache_message(), _pixelpipe_cache, _pixelpipe_cache_create_entry_locked(), _pixelpipe_cache_finalize_entry(), dt_pixel_cache_entry_t::auto_destroy, dt_pixel_cache_entry_t::data, DT_DEBUG_PIPECACHE, dt_dev_pixelpipe_cache_wrlock_entry(), dt_pixel_cache_alloc(), DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, FALSE, dt_dev_pixelpipe_cache_t::hits, dt_pixel_cache_entry_t::hits, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, name, dt_dev_pixelpipe_cache_t::queries, size, dt_pixel_cache_entry_t::size, and TRUE.
Referenced by _group_get_mask_roi(), dt_develop_blend_process(), dt_develop_blend_process_cl(), dt_drawlayer_cache_patch_alloc_shared(), process(), and process_cl().
| void * dt_dev_pixelpipe_cache_get_cl_buffer | ( | int | devid, |
| void *const | host_ptr, | ||
| const dt_iop_roi_t * | roi, | ||
| const size_t | bpp, | ||
| dt_iop_module_t * | module, | ||
| const char * | message, | ||
| dt_pixel_cache_entry_t * | cache_entry, | ||
| gboolean * | out_reused, | ||
| void * | keep | ||
| ) |
Definition at line 1201 of file pixelpipe_cache.c.
References _cache_print, _is_gamma_rgba8_output(), _pixel_cache_clmem_get(), _verbose, _verbose_detail, bpp, dt_atomic_add_int(), dt_atomic_get_int(), DT_DEBUG_OPENCL, dt_dev_pixelpipe_cache_alloc_cl_device_buffer(), dt_opencl_alloc_device_use_host_pointer(), DT_OPENCL_BPP_ENCODE_RGBA8, dt_opencl_use_pinned_memory(), FALSE, flags, dt_iop_roi_t::height, IS_NULL_PTR, and dt_iop_roi_t::width.
Referenced by _drawlayer_acquire_layer_image(), _drawlayer_acquire_source_image(), dt_dev_pixelpipe_cache_prepare_cl_input(), and pixelpipe_process_on_GPU().
| GArray * dt_dev_pixelpipe_cache_get_entries_stats | ( | void | ) |
Definition at line 3220 of file pixelpipe_cache.c.
References _pixelpipe_cache, dt_pixel_cache_stats_entry_t::cl_bytes, dt_pixel_cache_stats_entry_t::cl_count, dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_atomic_get_int(), dt_opencl_get_mem_object_size(), dt_pthread_mutex_lock(), dt_pthread_mutex_trylock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, FALSE, dt_pixel_cache_stats_entry_t::hash, dt_pixel_cache_entry_t::hash, dt_pixel_cache_stats_entry_t::hits, dt_pixel_cache_entry_t::hits, IS_NULL_PTR, key, dt_dev_pixelpipe_cache_t::lock, dt_pixel_cache_stats_entry_t::name, dt_pixel_cache_entry_t::name, out, dt_pixel_cache_stats_entry_t::refcount, dt_pixel_cache_entry_t::refcount, dt_pixel_cache_stats_entry_t::size, dt_pixel_cache_entry_t::size, and value.
Referenced by _rebuild_memory().
| dt_pixel_cache_entry_t * dt_dev_pixelpipe_cache_get_entry | ( | const uint64_t | hash | ) |
Get an internal reference to the cache entry matching hash. If you are going to access this entry more than once, keeping the reference and using it instead of hashes will prevent redundant lookups.
| cache | |
| hash |
Definition at line 272 of file pixelpipe_cache.c.
References _non_threadsafe_cache_get_entry(), _pixel_cache_touch(), _pixelpipe_cache, DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, and dt_dev_pixelpipe_cache_t::lock.
Referenced by dt_dev_pixelpipe_cleanup(), dt_dev_pixelpipe_process_rec(), and dt_dev_retrieve_rawdetail_mask().
| dt_pixel_cache_entry_t * dt_dev_pixelpipe_cache_get_entry_by_data | ( | void * | data | ) |
Definition at line 287 of file pixelpipe_cache.c.
References _pixel_cache_touch(), _pixelpipe_cache, dt_pixel_cache_entry_t::data, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, dt_dev_pixelpipe_cache_t::external_entries, key, dt_dev_pixelpipe_cache_t::lock, and value.
| void * dt_dev_pixelpipe_cache_get_pinned_image | ( | void * | host_ptr, |
| struct dt_pixel_cache_entry_t * | entry_hint, | ||
| int | devid, | ||
| int | width, | ||
| int | height, | ||
| int | bpp, | ||
| int | flags, | ||
| gboolean * | out_reused | ||
| ) |
Acquire a pinned OpenCL image for a host buffer tracked by the pixelpipe cache.
This is the public helper for modules that manage their own host buffers but still want the pixelpipe cache to own the reusable pinned cl_mem images. The helper accepts an optional cache-entry hint for normal cache lines. If that hint is NULL, it will try to resolve the host pointer against the cache's privately-owned external allocations.
On reuse, the helper synchronizes host memory to the OpenCL image before returning.
| cache | Pixelpipe cache. | |
| host_ptr | Host-backed image data. | |
| entry_hint | Optional owning cache entry for regular cache lines, or NULL. | |
| devid | OpenCL device id. | |
| width | Image width. | |
| height | Image height. | |
| bpp | Bytes per pixel. | |
| flags | OpenCL allocation flags (must include CL_MEM_USE_HOST_PTR). | |
| [out] | out_reused | Optional flag set TRUE when an existing pinned image was reused. |
cl_mem) or NULL on failure. Definition at line 1039 of file pixelpipe_cache.c.
References _cache_entry_for_host_ptr_locked(), _cache_print, _pixel_cache_clmem_get(), _pixel_cache_clmem_remove(), _pixelpipe_cache, bpp, DT_DEBUG_OPENCL, dt_opencl_alloc_device_use_host_pointer(), dt_opencl_is_pinned_memory(), dt_opencl_map_image(), dt_opencl_release_mem_object(), dt_opencl_unmap_mem_object(), dt_opencl_use_pinned_memory(), dt_opencl_write_host_to_device(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), FALSE, flags, height, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, TRUE, and width.
Referenced by _blend_layer_over_input_cl(), and _drawlayer_acquire_source_image().
| void dt_dev_pixelpipe_cache_get_usage | ( | size_t * | current, |
| size_t * | max | ||
| ) |
Definition at line 3206 of file pixelpipe_cache.c.
References _pixelpipe_cache, dt_pixelpipe_cache_pressure_monitor_t::budget, dt_dev_pixelpipe_cache_t::current_memory, dt_pixelpipe_cache_pressure_reported(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, max, and dt_dev_pixelpipe_cache_t::psi.
Referenced by _rebuild_memory(), dt_get_available_mem(), and dt_tiling_piece_fits_host_memory().
| size_t dt_dev_pixelpipe_cache_get_vram_total | ( | void | ) |
Definition at line 3263 of file pixelpipe_cache.c.
References dt_opencl_get_device_max_global_mem(), dt_opencl_get_num_devices(), dt_opencl_is_enabled(), and i.
Referenced by _rebuild_memory().
| dt_dev_pixelpipe_cache_writable_status_t dt_dev_pixelpipe_cache_get_writable | ( | const uint64_t | hash, |
| const size_t | size, | ||
| const char * | name, | ||
| const int | id, | ||
| const gboolean | alloc, | ||
| const gboolean | allow_rekey_reuse, | ||
| const dt_pixel_cache_entry_t * | reuse_hint, | ||
| void ** | data, | ||
| dt_pixel_cache_entry_t ** | entry | ||
| ) |
Definition at line 2527 of file pixelpipe_cache.c.
References _cache_try_rekey_reuse_locked(), _non_thread_safe_cache_remove(), _non_threadsafe_cache_get_entry(), _pixel_cache_message(), _pixel_cache_touch(), _pixelpipe_cache, _pixelpipe_cache_create_entry_locked(), _pixelpipe_cache_finalize_entry(), dt_pixel_cache_entry_t::auto_destroy, dt_pixel_cache_entry_t::data, DT_DEV_PIXELPIPE_CACHE_WRITABLE_CREATED, DT_DEV_PIXELPIPE_CACHE_WRITABLE_ERROR, DT_DEV_PIXELPIPE_CACHE_WRITABLE_EXACT_HIT, DT_DEV_PIXELPIPE_CACHE_WRITABLE_REKEYED, dt_pixel_cache_alloc(), DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, FALSE, dt_dev_pixelpipe_cache_t::hits, dt_pixel_cache_entry_t::hits, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, name, dt_dev_pixelpipe_cache_t::queries, and size.
Referenced by dt_dev_pixelpipe_process_rec().
| gboolean dt_dev_pixelpipe_cache_init | ( | size_t | max_memory, |
| const gboolean | verbose, | ||
| const gboolean | verbose_detail | ||
| ) |
Reserve the cache's arena and start it.
constructs a new cache with given cache line count (entries) and float buffer entry size in bytes.
| [out] | returns | 0 if fail to allocate mem cache. |
| max_memory | arena size in bytes. A session constant: the orchestrator decides it from the resource plan and retries smaller on failure, which is resource policy. | |
| verbose | whether the cache traces at all (was -d pipecache). | |
| verbose_detail | whether it traces in detail (was -d verbose). Ignored when verbose is FALSE, matching the old two-level gate. |
Both flags are read ONCE, here, from the session's debug flags by the orchestrator. The cache does not consult them at runtime: a cache that changes what it does halfway through a session because a global moved is harder to reason about than one told at startup, and it keeps the debug machinery out of a storage module.
Definition at line 2287 of file pixelpipe_cache.c.
References _free_cache_entry(), _memory_pressure_shedder(), _pixelpipe_cache, _pressure_wake(), _verbose, _verbose_detail, dt_dev_pixelpipe_cache_t::arena, dt_dev_pixelpipe_cache_t::current_memory, dt_cache_arena_init(), dt_dev_pixelpipe_cache_flush_old(), dt_free, dt_free_gpointer(), dt_pixelpipe_cache_pressure_monitor_init(), dt_pixelpipe_cache_pressure_watch_start(), dt_pthread_mutex_destroy(), dt_pthread_mutex_init(), dt_dev_pixelpipe_cache_t::entries, dt_dev_pixelpipe_cache_t::external_entries, FALSE, garbage_collection, dt_dev_pixelpipe_cache_t::hits, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, dt_dev_pixelpipe_cache_t::max_memory, dt_dev_pixelpipe_cache_t::next_serial, pressure_shedding, dt_dev_pixelpipe_cache_t::psi, dt_dev_pixelpipe_cache_t::queries, dt_dev_pixelpipe_cache_t::sys_available_est, dt_dev_pixelpipe_cache_t::sys_probe_time_us, dt_dev_pixelpipe_cache_t::sys_probe_valid, and TRUE.
Referenced by dt_init().
| int dt_dev_pixelpipe_cache_invalidate_hashes | ( | const uint64_t * | hashes, |
| const size_t | count | ||
| ) |
Invalidate cache lines matching an explicit list of hashes.
Entries which are not in use are removed immediately. Entries still referenced or locked are left untouched because they may be published backbuffers owned by another pipeline.
This targets shared cache states independently of the pipeline which created them, while preserving every cache line not named by hashes.
| cache | Pixelpipe cache to update. |
| hashes | Cache keys to invalidate. |
| count | Number of keys in hashes. |
Definition at line 2798 of file pixelpipe_cache.c.
References _non_thread_safe_cache_remove(), _non_threadsafe_cache_get_entry(), _pixelpipe_cache, DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, FALSE, IS_NULL_PTR, k, and dt_dev_pixelpipe_cache_t::lock.
Referenced by dt_dev_pixelpipe_process().
| gboolean dt_dev_pixelpipe_cache_is_ready | ( | void | ) |
Has the pixelpipe cache been initialised? Callers that run before dt_dev_pixelpipe_cache_init() succeeds, or after its cleanup, ask this rather than testing a handle they should not hold.
The application-wide pixelpipe cache singleton. DECLARED here because it is this module's object; BOUND by the orchestrator (darktable.c), so this header never needs to see the application struct.
Definition at line 101 of file pixelpipe_cache.c.
References _pixelpipe_cache, and IS_NULL_PTR.
Referenced by dt_cleanup(), and dt_init().
| gboolean dt_dev_pixelpipe_cache_peek | ( | const uint64_t | hash, |
| void ** | data, | ||
| struct dt_pixel_cache_entry_t ** | entry, | ||
| const int | preferred_devid, | ||
| void ** | cl_mem_output | ||
| ) |
Non-owning lookup of an existing cache line.
This does not create a new cache line and does not change reference counts or entry locks. Callers that need lifetime guarantees must retain the entry explicitly with dt_dev_pixelpipe_cache_ref_count_entry() and/or dt_dev_pixelpipe_cache_rdlock_entry().
If !IS_NULL_PTR(cl_mem_output), the lookup becomes authoritative for exact-hit consumers:
cl_mem_output when requested,Definition at line 2678 of file pixelpipe_cache.c.
References _cache_lookup_existing(), _cache_print, _cache_try_restore_device_payload(), _pixelpipe_cache, _trace_exact_hit(), dt_pixel_cache_entry_t::auto_destroy, DT_DEBUG_PIPECACHE, dt_dev_pixelpipe_cache_flag_auto_destroy(), dt_dev_pixelpipe_cache_remove(), dt_dev_pixelpipe_cache_restore_host_payload(), dt_pixel_cache_entry_get_data(), DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_rwlock_tryrdlock(), dt_pthread_rwlock_unlock(), FALSE, IS_NULL_PTR, dt_pixel_cache_entry_t::lock, and TRUE.
Referenced by _group_get_mask_roi(), _peek_gui(), dt_dev_pixelpipe_process(), and dt_dev_retrieve_rawdetail_mask().
| int dt_dev_pixelpipe_cache_prepare_cl_input | ( | dt_dev_pixelpipe_t * | pipe, |
| dt_iop_module_t * | module, | ||
| float * | input, | ||
| void ** | cl_mem_input, | ||
| const dt_iop_roi_t * | roi_in, | ||
| const size_t | in_bpp, | ||
| dt_pixel_cache_entry_t * | input_entry, | ||
| dt_pixel_cache_entry_t ** | locked_input_entry, | ||
| void * | keep | ||
| ) |
Prepare/obtain the OpenCL input image for a module.
| pipe | Current pixelpipe (provides device id + global settings). | |
| module | Module being processed (for debug logs). | |
| input | Host input pointer (may be NULL on GPU-only paths). | |
| [in,out] | cl_mem_input | OpenCL input image; may already be set by the previous module. |
| roi_in | ROI for the input buffer. | |
| in_bpp | Input bytes-per-pixel. | |
| input_entry | Pixelpipe cache entry corresponding to the input hash. | |
| [out] | locked_input_entry | If non-NULL on return, the caller must unlock it after GPU work completed. |
| keep | OpenCL buffer to keep alive while flushing device scratch allocations. |
There are two major cases:
1) !IS_NULL_PTR(*cl_mem_input): The previous module already produced an OpenCL buffer and we are continuing on GPU. We may still need to keep the cache entry write-locked if it is a true zero-copy pinned image, because in-place OpenCL colorspace transforms can mutate the host-backed buffer before the current module runs.
2) IS_NULL_PTR(*cl_mem_input): We start from a host cache buffer (input). We allocate (or reuse) a pinned image backed by that host buffer, and if it is not true zero-copy we push host→device once before running kernels.
Definition at line 1450 of file pixelpipe_cache.c.
References _cache_print, dt_dev_pixelpipe_t::devid, DT_DEBUG_OPENCL, dt_dev_pixelpipe_cache_get_cl_buffer(), dt_dev_pixelpipe_cache_rdlock_entry(), dt_opencl_events_wait_for(), dt_opencl_is_pinned_memory(), dt_opencl_write_host_to_device(), FALSE, dt_iop_roi_t::height, IS_NULL_PTR, dt_iop_module_t::op, TRUE, and dt_iop_roi_t::width.
Referenced by pixelpipe_process_on_GPU().
print out cache lines/hashes (debug).
Definition at line 3195 of file pixelpipe_cache.c.
References _cache_print, _pixelpipe_cache, _verbose, dt_dev_pixelpipe_cache_t::current_memory, DT_DEBUG_PIPECACHE, dt_dev_pixelpipe_cache_t::entries, dt_dev_pixelpipe_cache_t::hits, dt_dev_pixelpipe_cache_t::max_memory, and dt_dev_pixelpipe_cache_t::queries.
Referenced by dt_dev_pixelpipe_process().
| void dt_dev_pixelpipe_cache_put_pinned_image | ( | void * | host_ptr, |
| struct dt_pixel_cache_entry_t * | entry_hint, | ||
| void ** | mem | ||
| ) |
Release or cache a pinned OpenCL image acquired with dt_dev_pixelpipe_cache_get_pinned_image().
If the image is still a host-backed pinned allocation and an owning cache entry can be resolved, it is returned to that cache entry for reuse. Otherwise it is released.
| cache | Pixelpipe cache. | |
| host_ptr | Host-backed image data. | |
| entry_hint | Optional owning cache entry for regular cache lines, or NULL. | |
| [in,out] | mem | Pointer to the cl_mem handle (cleared on return). |
Definition at line 1113 of file pixelpipe_cache.c.
References _cache_print, _pixel_cache_clmem_put(), _verbose, _verbose_detail, DT_DEBUG_OPENCL, IS_NULL_PTR, and state.
Referenced by _blend_layer_over_input_cl().
| void dt_dev_pixelpipe_cache_rdlock_entry | ( | gboolean | lock, |
| struct dt_pixel_cache_entry_t * | entry | ||
| ) |
Lock or release the read lock on the entry.
| cache | |
| lock | TRUE to lock, FALSE to release |
| entry | The cache entry object to lock. |
Definition at line 3017 of file pixelpipe_cache.c.
References _pixel_cache_message(), dt_pthread_rwlock_rdlock(), dt_pthread_rwlock_unlock(), dt_pixel_cache_entry_t::lock, lock, and TRUE.
Referenced by _build_preview_fallback_surface(), _draw_preview_fallback(), _group_get_mask_roi(), _lib_navigation_draw_callback(), _pixelpipe_pick_from_image(), _process_histogram(), _process_vectorscope(), _refresh_preview_cursor_sample(), _refresh_preview_module_histogram_for_hash(), _sample_picker_from_cache(), color_picker_apply(), dt_dev_get_raster_mask(), dt_dev_pixelpipe_cache_prepare_cl_input(), dt_dev_pixelpipe_process_rec(), dt_dev_render_locked_surface(), dt_dev_resync_mipmap_cache(), dt_drawlayer_cache_patch_rdlock(), dt_drawlayer_cache_patch_rdunlock(), dt_imageio_export_with_flags(), dt_iop_autoset_advance(), gui_post_expose(), mouse_moved(), pixelpipe_process_on_CPU(), pixelpipe_process_on_GPU(), scrolled(), and update_histogram().
| void dt_dev_pixelpipe_cache_ref_count_entry | ( | gboolean | lock, |
| struct dt_pixel_cache_entry_t * | entry | ||
| ) |
Increase/Decrease the reference count on the cache line as to prevent LRU item removal. This function should be called within a read/write lock-protected section to avoid changing an entry while or after it is deleted in parallel.
WARNING: cache entries whose reference count is greater than 0 will never be deleted from cache.
| cache | |
| lock | TRUE to lock, FALSE to unlock |
Definition at line 2984 of file pixelpipe_cache.c.
References _non_thread_safe_cache_ref_count_entry(), _pixelpipe_cache, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::lock, and lock.
Referenced by _abort_module_shutdown_cleanup(), _blend_layer_over_input_cl(), _develop_cacheline_ready_callback(), _develop_history_resync_callback(), _group_get_mask_roi(), _peek_gui(), _refresh_global_histogram_backbuf_for_hash(), _refresh_preview_cursor_sample(), _refresh_preview_module_histogram_for_hash(), _retain_base_patch_loaded_ref(), _retain_base_patch_stroke_ref(), _sample_picker_from_cache(), _update_backbuf_cache_reference(), color_picker_apply(), dt_dev_get_raster_mask(), dt_dev_pixelpipe_cache_flush_host_pinned_image(), dt_dev_pixelpipe_cache_unref_hash(), dt_dev_pixelpipe_process_rec(), dt_dev_resync_mipmap_cache(), dt_dev_retrieve_rawdetail_mask(), dt_develop_blend_process(), dt_develop_blend_process_cl(), dt_drawlayer_cache_patch_alloc_shared(), dt_drawlayer_cache_patch_clear(), dt_drawlayer_release_all_base_patch_extra_refs(), dt_imageio_export_with_flags(), dt_iop_autoset_advance(), gui_cleanup(), gui_focus(), gui_post_expose(), invalidate_luminance_cache(), mouse_moved(), process(), scrolled(), and update_histogram().
| gboolean dt_dev_pixelpipe_cache_ref_entry_by_hash | ( | const uint64_t | hash, |
| void ** | data, | ||
| struct dt_pixel_cache_entry_t ** | entry | ||
| ) |
Resolve and retain an existing cache entry by hash.
This is the race-free counterpart to dt_dev_pixelpipe_cache_peek() for GUI code that needs to keep a cacheline past the lookup call. The cache lock is held while the entry is found and its refcount is incremented, so normal cache eviction cannot destroy the returned entry before the caller takes its own read lock.
The function never creates or allocates a cache entry. Release a successful result with dt_dev_pixelpipe_cache_ref_count_entry(cache, FALSE, entry).
| cache | Pixelpipe cache. |
| hash | Cacheline hash to resolve. |
| data | Returned current host buffer pointer, if requested. |
| entry | Returned retained cache entry, if requested. |
Definition at line 357 of file pixelpipe_cache.c.
References _non_thread_safe_cache_ref_count_entry(), _non_threadsafe_cache_get_entry(), _observe_read(), _pixelpipe_cache, _pixelpipe_cache_finalize_entry(), dt_pixel_cache_entry_t::auto_destroy, DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, FALSE, dt_dev_pixelpipe_cache_t::hits, dt_pixel_cache_entry_t::hits, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, dt_dev_pixelpipe_cache_t::queries, dt_pixel_cache_entry_t::size, and TRUE.
Referenced by _develop_cacheline_ready_callback(), _develop_history_resync_callback(), dt_dev_get_raster_mask(), dt_dev_pixelpipe_process(), dt_dev_pixelpipe_process_rec(), dt_dev_resync_mipmap_cache(), dt_imageio_export_with_flags(), and gui_focus().
| dt_pixel_cache_entry_t * dt_dev_pixelpipe_cache_ref_entry_for_host_ptr | ( | void * | host_ptr | ) |
Resolve and retain the cache entry owning a host pointer.
This helper searches both regular and external pixelpipe cache tables for the entry whose host buffer pointer exactly matches host_ptr.
On success it increments the entry refcount before returning, so callers can safely use the entry across asynchronous OpenCL operations. Release it with: dt_dev_pixelpipe_cache_ref_count_entry(cache, FALSE, entry).
| cache | Pixelpipe cache. |
| host_ptr | Host buffer pointer to resolve. |
Definition at line 1623 of file pixelpipe_cache.c.
References _cache_entry_for_host_ptr_locked(), _non_thread_safe_cache_ref_count_entry(), _pixelpipe_cache, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, and TRUE.
Referenced by _blend_layer_over_input_cl(), dt_drawlayer_cache_ensure_mask_buffer(), and dt_drawlayer_cache_ensure_process_patch_buffer().
| gboolean dt_dev_pixelpipe_cache_ref_host_entry_by_hash | ( | const uint64_t | hash, |
| void ** | data, | ||
| struct dt_pixel_cache_entry_t ** | entry | ||
| ) |
Resolve and retain an existing cacheline that already holds HOST pixels.
The race-free lookup for GUI consumers that sample an intermediate module cacheline – color picker, module histograms, autoset, colorequal. Those cachelines sit at refcount 0 between renders, so the pipeline is free to evict them at any moment: looking one up and THEN taking a reference leaves a window in which it is freed, and the sampling pass then reads a dangling buffer. Here the lookup and the reference happen under one hold of the cache lock, so an entry handed back cannot have been evicted in between.
Unlike dt_dev_pixelpipe_cache_ref_entry_by_hash(), this one additionally requires host pixels to be present (GUI threads own no OpenCL device and must never materialize a device-only payload) and refuses an entry that is currently write-locked. It never allocates and never waits on a lock.
Release a successful result with dt_dev_pixelpipe_cache_ref_count_entry(FALSE, entry).
| hash | Cacheline hash to resolve. |
| data | Returned host buffer pointer, if requested. Never NULL on success. |
| entry | Returned retained cache entry, if requested. |
Definition at line 389 of file pixelpipe_cache.c.
References _non_thread_safe_cache_ref_count_entry(), _non_threadsafe_cache_get_entry(), _observe_read(), _pixelpipe_cache, _pixelpipe_cache_finalize_entry(), dt_pixel_cache_entry_t::auto_destroy, dt_pixel_cache_entry_t::data, DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_pthread_rwlock_tryrdlock(), dt_pthread_rwlock_unlock(), dt_dev_pixelpipe_cache_t::entries, FALSE, dt_dev_pixelpipe_cache_t::hits, dt_pixel_cache_entry_t::hits, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, dt_pixel_cache_entry_t::lock, dt_dev_pixelpipe_cache_t::queries, dt_pixel_cache_entry_t::size, and TRUE.
Referenced by _peek_gui().
| int dt_dev_pixelpipe_cache_rekey | ( | const uint64_t | old_hash, |
| const uint64_t | new_hash, | ||
| struct dt_pixel_cache_entry_t * | entry | ||
| ) |
Change the hash/key of an existing cache line in place, without freeing, reallocating or invalidating the underlying entry.
This is useful when a cache line remains the authoritative buffer but the caller needs its identity to follow a new logical snapshot (for example a new module-parameter hash). The entry contents, locks, refcount and storage are preserved; only the hash-table key and entry->hash are updated.
The operation fails if:
new_hash.| cache | |
| old_hash | Current key of the entry. |
| new_hash | Desired new key. |
| entry | Optional direct entry reference. May be NULL. |
Definition at line 3105 of file pixelpipe_cache.c.
References _cache_debug_module_name(), _cache_print, _non_threadsafe_cache_get_entry(), _observe_rekey(), _pixelpipe_cache, dt_pixel_cache_entry_t::auto_destroy, dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_pixel_cache_entry_t::data, dt_atomic_get_int(), DT_DEBUG_PIPECACHE, dt_dev_pixelpipe_cache_flush_entry_clmem(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, dt_pixel_cache_entry_t::hash, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, dt_pixel_cache_entry_t::refcount, and dt_pixel_cache_entry_t::serial.
Referenced by _rekey_shared_base_patch().
| void dt_dev_pixelpipe_cache_release_cl_buffer | ( | void ** | cl_mem_buffer, |
| dt_pixel_cache_entry_t * | cache_entry, | ||
| void * | host_ptr, | ||
| const gboolean | cache_device | ||
| ) |
Release or cache an OpenCL image associated with a host cache line.
Release or cache an OpenCL image associated with one cache entry.
| [in,out] | cl_mem_buffer | Pointer to a cl_mem stored as void*. |
| cache_entry | Pixelpipe cache entry the host pointer belongs to (may be NULL). | |
| host_ptr | Host pointer backing the OpenCL image (may be NULL). | |
| cache_device | Allow caching pure device-side buffers for scratch reuse. |
This helper is a single point of truth for OpenCL image lifetime management in the pixelpipe:
CL_MEM_USE_HOST_PTR) and we have both cache_entry and host_ptr, we put it in the cache entry's cl_mem_list for reuse.cl_mem objects are later evicted, the cache layer is responsible for materializing host RAM first if no authoritative host buffer exists yet.Additionally, when we release an image, we must ensure there is no stale pointer in cl_mem_list (for example, if some earlier path cached it and we are now deciding to free it). We call _pixel_cache_clmem_remove() before releasing to keep the cache bookkeeping coherent.
Definition at line 1302 of file pixelpipe_cache.c.
References _pixel_cache_clmem_put(), _pixel_cache_clmem_remove(), dt_opencl_release_mem_object(), and IS_NULL_PTR.
Referenced by _abort_module_shutdown_cleanup(), _blend_layer_over_input_cl(), _drawlayer_acquire_source_image(), _gpu_early_cpu_fallback_if_unsupported(), and pixelpipe_process_on_GPU().
| int dt_dev_pixelpipe_cache_remove | ( | const gboolean | force, |
| struct dt_pixel_cache_entry_t * | entry | ||
| ) |
Arbitrarily remove the cache entry matching hash. Entries having a reference count > 0 (inter-thread locked) or being having their read/write lock locked will be ignored. If force is TRUE, we ignore reference count, but not locks.
| cache | |
| force |
Definition at line 469 of file pixelpipe_cache.c.
References _non_thread_safe_cache_remove(), _pixelpipe_cache, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, error(), and dt_dev_pixelpipe_cache_t::lock.
Referenced by _abort_module_shutdown_cleanup(), dt_dev_pixelpipe_cache_peek(), dt_dev_pixelpipe_process_rec(), dt_develop_blend_process(), dt_develop_blend_process_cl(), process(), and process_cl().
| float * dt_dev_pixelpipe_cache_restore_cl_buffer | ( | dt_dev_pixelpipe_t * | pipe, |
| float * | input, | ||
| void * | cl_mem_input, | ||
| const dt_iop_roi_t * | roi_in, | ||
| dt_iop_module_t * | module, | ||
| const size_t | in_bpp, | ||
| dt_pixel_cache_entry_t * | input_entry, | ||
| const char * | message | ||
| ) |
Force device → host resynchronization of the pixelpipe input cache line.
This is used when we are about to switch from GPU processing to CPU processing for a given module. In that scenario, the most recent correct pixels may only exist in cl_mem_input (GPU-only intermediate), while input (host pointer) is either NULL or stale.
The function:
Definition at line 1409 of file pixelpipe_cache.c.
References dt_dev_pixelpipe_t::devid, dt_dev_pixelpipe_cache_sync_cl_buffer(), dt_dev_pixelpipe_cache_wrlock_entry(), FALSE, IS_NULL_PTR, and TRUE.
Referenced by _gpu_early_cpu_fallback_if_unsupported().
| gboolean dt_dev_pixelpipe_cache_restore_host_payload | ( | struct dt_pixel_cache_entry_t * | entry, |
| int | preferred_devid, | ||
| void ** | data | ||
| ) |
Materialize a host payload for a live cache entry from its cached device payload.
Recursive pixelpipe stages reopen transient upstream cache entries directly, before those entries become valid exact-hits. When such an entry only carries a GPU payload, the caller may still need a host pointer for CPU fallback or for a non-OpenCL module. This helper keeps the recovery local to the cache layer:
entry when needed,data.The function leaves the cache entry owned by the caller. It does not change refcounts.
| cache | Pixelpipe cache. | |
| entry | Live cache entry to restore. | |
| preferred_devid | Preferred OpenCL device id, or -1 for any. | |
| [out] | data | Restored host pointer, or NULL on failure. |
Definition at line 2656 of file pixelpipe_cache.c.
References _cache_entry_materialize_host_data(), _pixel_cache_touch(), _pixelpipe_cache, dt_pixel_cache_entry_get_data(), FALSE, IS_NULL_PTR, and TRUE.
Referenced by dt_dev_pixelpipe_cache_peek(), and dt_dev_pixelpipe_process_rec().
| void dt_dev_pixelpipe_cache_return_cl_payload | ( | struct dt_pixel_cache_entry_t * | entry, |
| void * | mem | ||
| ) |
Return a borrowed cached OpenCL payload to its cache entry.
| entry | Cache entry owning the payload. |
| mem | Borrowed cl_mem to release back to cache bookkeeping. |
Definition at line 919 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), IS_NULL_PTR, and void().
Referenced by _gpu_early_cpu_fallback_if_unsupported(), and pixelpipe_process_on_GPU().
| void dt_dev_pixelpipe_cache_set_handlers | ( | dt_pixelpipe_cache_warn_handler_t | warn, |
| dt_pixelpipe_cache_ready_handler_t | ready, | ||
| const dt_pixelpipe_cache_observer_t * | observer | ||
| ) |
Install the handlers. Call once, from the orchestrator, before any pipe runs.
| warn | may be NULL – the warning is then dropped, not printed somewhere else. |
| ready | may be NULL. |
| observer | BORROWED, not copied: it must outlive the cache. Pass NULL to detach. |
Definition at line 112 of file pixelpipe_cache.c.
References _observer, _ready_handler, and _warn_handler.
Referenced by dt_init().
| int dt_dev_pixelpipe_cache_sync_cl_buffer | ( | const int | devid, |
| void * | host_ptr, | ||
| void * | cl_mem_buffer, | ||
| const dt_iop_roi_t * | roi, | ||
| int | cl_mode, | ||
| size_t | bpp, | ||
| dt_iop_module_t * | module, | ||
| const char * | message | ||
| ) |
Synchronize between host memory and a pinned OpenCL image.
| devid | OpenCL device index. |
| host_ptr | Host pointer to read from / write to. |
| cl_mem_buffer | OpenCL image. |
| roi | Image dimensions. |
| cl_mode | CL_MAP_WRITE for host→device, CL_MAP_READ for device→host. |
| bpp | Bytes per pixel. |
| module | Module for debug logs (may be NULL). |
| message | Context string for debug logs. |
This function intentionally tries a hierarchy of synchronization mechanisms:
CL_MEM_USE_HOST_PTR images, we attempt a map/unmap cycle. If the mapped pointer equals host_ptr, we treat it as true zero-copy and the map/unmap acts as a synchronization barrier (fast, avoids extra copies).dt_opencl_write_host_to_device / dt_opencl_read_host_from_device), which already guarantee that the copied pixels are visible on the host/device side when the helper returns.The map/unmap approach is used as a synchronization barrier because on many drivers it will:
Definition at line 1350 of file pixelpipe_cache.c.
References _cache_print, bpp, DT_DEBUG_OPENCL, dt_opencl_is_pinned_memory(), dt_opencl_map_image(), dt_opencl_read_host_from_device(), dt_opencl_unmap_mem_object(), dt_opencl_write_host_to_device(), dt_iop_roi_t::height, IS_NULL_PTR, dt_iop_module_t::op, TRUE, and dt_iop_roi_t::width.
Referenced by _gpu_init_input(), dt_dev_pixelpipe_cache_restore_cl_buffer(), and pixelpipe_process_on_GPU().
Find the entry matching hash, and decrease its ref_count if found.
| cache | |
| hash |
Definition at line 3091 of file pixelpipe_cache.c.
References _non_threadsafe_cache_get_entry(), _pixelpipe_cache, dt_dev_pixelpipe_cache_ref_count_entry(), DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_dev_pixelpipe_cache_t::entries, FALSE, dt_dev_pixelpipe_cache_t::lock, and dt_dev_pixelpipe_cache_t::queries.
Referenced by _clear_histogram_backbuf(), _refresh_global_histogram_backbuf_for_hash(), _studio_dev_teardown(), _update_backbuf_cache_reference(), dt_dev_clear_rawdetail_mask(), dt_dev_pixelpipe_cleanup(), dt_dev_pixelpipe_process(), and leave().
| void dt_dev_pixelpipe_cache_wrlock_entry | ( | gboolean | lock, |
| struct dt_pixel_cache_entry_t * | entry | ||
| ) |
Lock or release the write lock on the entry.
| cache | |
| lock | TRUE to lock, FALSE to release |
Definition at line 2994 of file pixelpipe_cache.c.
References _pixel_cache_message(), _ready_handler, DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_rwlock_unlock(), dt_pthread_rwlock_wrlock(), dt_pixel_cache_entry_t::hash, dt_pixel_cache_entry_t::lock, lock, dt_pixel_cache_entry_t::producer_node_key, and TRUE.
Referenced by _cache_entry_materialize_host_data(), _cache_try_rekey_reuse_locked(), _gpu_early_cpu_fallback_if_unsupported(), _gpu_init_input(), _group_get_mask_roi(), _pixelpipe_cache_create_entry_locked(), dt_dev_pixelpipe_cache_get(), dt_dev_pixelpipe_cache_restore_cl_buffer(), dt_dev_pixelpipe_process_rec(), dt_develop_blend_process(), dt_develop_blend_process_cl(), dt_drawlayer_cache_patch_alloc_shared(), dt_drawlayer_cache_patch_wrlock(), dt_drawlayer_cache_patch_wrunlock(), process(), and process_cl().
| void * dt_pixel_cache_alloc | ( | struct dt_pixel_cache_entry_t * | entry | ) |
Actually allocate the memory buffer attached to the cache entry once you create it with dt_dev_pixelpipe_cache_get(). Sizes and everything are already saved in the entry, and the cache will have the needed space reserved.
| cache | |
| entry | the cache entry |
Definition at line 1938 of file pixelpipe_cache.c.
References _arena_alloc_with_defrag(), _log_arena_allocation_failure(), _pixelpipe_cache, dt_pixel_cache_entry_t::data, FALSE, dt_pixel_cache_entry_t::hash, IS_NULL_PTR, dt_pixel_cache_entry_t::name, and dt_pixel_cache_entry_t::size.
Referenced by _cache_entry_materialize_host_data(), _gpu_early_cpu_fallback_if_unsupported(), _gpu_init_input(), dt_dev_pixelpipe_cache_get(), dt_dev_pixelpipe_cache_get_writable(), dt_pixel_cache_new_entry(), pixelpipe_process_on_CPU(), and pixelpipe_process_on_GPU().
| void * dt_pixel_cache_entry_get_data | ( | struct dt_pixel_cache_entry_t * | entry | ) |
Peek the host data pointer of a cache entry without allocating.
Definition at line 1957 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::data.
Referenced by _cache_entry_materialize_host_data(), _lib_navigation_draw_callback(), color_picker_apply(), dt_dev_lock_pipe_surface(), dt_dev_pixelpipe_cache_gpu_device_buffer(), dt_dev_pixelpipe_cache_peek(), dt_dev_pixelpipe_cache_restore_host_payload(), dt_dev_pixelpipe_process_rec(), gui_post_expose(), mouse_moved(), pixelpipe_process_on_CPU(), pixelpipe_process_on_GPU(), scrolled(), and update_histogram().
| size_t dt_pixel_cache_entry_get_size | ( | struct dt_pixel_cache_entry_t * | entry | ) |
Peek the size (in bytes) reserved for the host buffer of a cache entry.
The pixelpipe cache treats dt_pixel_cache_entry_t as an internal/private structure. External users (such as the pixelpipe implementation) should not access struct fields directly.
This accessor is intentionally "peek-only": it does not allocate and it does not change ownership.
Definition at line 1962 of file pixelpipe_cache.c.
References dt_pixel_cache_entry_t::size.
Referenced by _lib_navigation_draw_callback(), _refresh_global_histogram_backbuf_for_hash(), _refresh_preview_module_histogram_for_hash(), _update_backbuf_cache_reference(), dt_dev_lock_pipe_surface(), dt_dev_pixelpipe_process_rec(), and luminance_entry_fits().
|
static |
Definition at line 2139 of file pixelpipe_cache.c.
References _free_space_to_alloc(), dt_pixel_cache_entry_t::age, dt_dev_pixelpipe_cache_t::arena, dt_pixel_cache_entry_t::auto_destroy, dt_pixel_cache_entry_t::cache, dt_pixel_cache_entry_t::cl_mem_list, dt_pixel_cache_entry_t::cl_mem_lock, dt_dev_pixelpipe_cache_t::current_memory, dt_pixel_cache_entry_t::data, dt_atomic_set_uint64(), dt_cache_arena_calc(), dt_free, dt_pixel_cache_alloc(), DT_PIXELPIPE_CACHE_HASH_INVALID, dt_pthread_mutex_destroy(), dt_pthread_mutex_init(), dt_pthread_rwlock_destroy(), dt_pthread_rwlock_init(), error(), dt_pixel_cache_entry_t::external_alloc, FALSE, dt_pixel_cache_entry_t::hash, dt_pixel_cache_entry_t::hits, dt_pixel_cache_entry_t::id, IS_NULL_PTR, key, dt_pixel_cache_entry_t::lock, dt_pixel_cache_entry_t::name, name, dt_dev_pixelpipe_cache_t::next_serial, dt_pixel_cache_entry_t::producer_node_key, dt_pixel_cache_entry_t::refcount, dt_pixel_cache_entry_t::serial, size, and dt_pixel_cache_entry_t::size.
Referenced by _pixelpipe_cache_create_entry_locked(), and dt_pixelpipe_cache_alloc_align_cache_impl().
| void * dt_pixelpipe_cache_alloc_align_cache_impl | ( | size_t | size, |
| int | id, | ||
| const char * | name | ||
| ) |
Allocate aligned memory tracked by the pixelpipe cache. This allows LRU cache entries to be evicted if needed to make room.
| cache | Pixelpipe cache to manage. |
| size | Buffer size in bytes. |
| id | Pipeline type owning the buffer. |
| name | Human-readable name. |
Definition at line 2065 of file pixelpipe_cache.c.
References _arena_alloc_with_defrag(), _free_space_to_alloc(), _log_arena_allocation_failure(), _non_thread_safe_cache_ref_count_entry(), _pixel_cache_touch(), _pixelpipe_cache, dt_dev_pixelpipe_cache_t::arena, dt_pixel_cache_entry_t::data, dt_cache_arena_free(), DT_CACHELINE_BYTES, dt_pixel_cache_new_entry(), dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), error(), dt_pixel_cache_entry_t::external_alloc, dt_dev_pixelpipe_cache_t::external_entries, FALSE, IS_NULL_PTR, dt_dev_pixelpipe_cache_t::lock, name, size, and TRUE.
Referenced by dt_drawlayer_cache_alloc_temp_buffer(), and dt_pixelpipe_cache_alloc_perthread_impl().
Free aligned memory allocated with dt_pixelpipe_cache_alloc_align_cache.
| cache | Pixelpipe cache to manage. |
| mem | Pointer to the buffer pointer. Set to NULL on successful free. |
Definition at line 2114 of file pixelpipe_cache.c.
References _non_thread_safe_cache_ref_count_entry(), _non_threadsafe_cache_get_entry(), _pixelpipe_cache, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), dt_pixel_cache_entry_t::external_alloc, dt_dev_pixelpipe_cache_t::external_entries, FALSE, dt_pixel_cache_entry_t::hash, IS_NULL_PTR, and dt_dev_pixelpipe_cache_t::lock.
Referenced by dt_drawlayer_cache_free_temp_buffer(), and dt_drawlayer_cache_patch_clear().
| size_t dt_pixelpipe_cache_get_largest_free_run | ( | void | ) |
Definition at line 1827 of file pixelpipe_cache.c.
References _arena_stats_bytes(), _pixelpipe_cache, dt_pthread_mutex_lock(), dt_pthread_mutex_unlock(), and dt_dev_pixelpipe_cache_t::lock.
Referenced by _default_process_tiling_ptp(), _default_process_tiling_roi(), and dt_tiling_piece_fits_host_memory().
| const char * dt_pixelpipe_cache_set_current_module | ( | const char * | module | ) |
Set the current module name for cache diagnostics (thread-local).
| module | Module op name or NULL to clear. |
Definition at line 182 of file pixelpipe_cache.c.
References dt_pixelpipe_cache_current_module.
Referenced by dt_dev_pixelpipe_process_rec().
|
static |
Definition at line 110 of file pixelpipe_cache.c.
Referenced by _observe_delete(), _observe_read(), _observe_rekey(), _observed(), and dt_dev_pixelpipe_cache_set_handlers().
|
static |
Definition at line 99 of file pixelpipe_cache.c.
Referenced by _free_cache_entry(), dt_dev_pixel_pipe_cache_remove_lru(), dt_dev_pixelpipe_cache_auto_destroy_apply(), dt_dev_pixelpipe_cache_cleanup(), dt_dev_pixelpipe_cache_flag_auto_destroy(), dt_dev_pixelpipe_cache_flush(), dt_dev_pixelpipe_cache_flush_clmem(), dt_dev_pixelpipe_cache_flush_host_pinned_image(), dt_dev_pixelpipe_cache_get(), dt_dev_pixelpipe_cache_get_entries_stats(), dt_dev_pixelpipe_cache_get_entry(), dt_dev_pixelpipe_cache_get_entry_by_data(), dt_dev_pixelpipe_cache_get_pinned_image(), dt_dev_pixelpipe_cache_get_usage(), dt_dev_pixelpipe_cache_get_writable(), dt_dev_pixelpipe_cache_init(), dt_dev_pixelpipe_cache_invalidate_hashes(), dt_dev_pixelpipe_cache_is_ready(), dt_dev_pixelpipe_cache_peek(), dt_dev_pixelpipe_cache_print(), dt_dev_pixelpipe_cache_ref_count_entry(), dt_dev_pixelpipe_cache_ref_entry_by_hash(), dt_dev_pixelpipe_cache_ref_entry_for_host_ptr(), dt_dev_pixelpipe_cache_ref_host_entry_by_hash(), dt_dev_pixelpipe_cache_rekey(), dt_dev_pixelpipe_cache_remove(), dt_dev_pixelpipe_cache_restore_host_payload(), dt_dev_pixelpipe_cache_unref_hash(), dt_pixel_cache_alloc(), dt_pixelpipe_cache_alloc_align_cache_impl(), dt_pixelpipe_cache_free_align_cache(), and dt_pixelpipe_cache_get_largest_free_run().
|
static |
Definition at line 109 of file pixelpipe_cache.c.
Referenced by dt_dev_pixelpipe_cache_set_handlers(), and dt_dev_pixelpipe_cache_wrlock_entry().
|
static |
Definition at line 56 of file pixelpipe_cache.c.
Referenced by _cache_entry_clmem_flush_device(), _pixel_cache_clmem_get(), _pixel_cache_message(), _trace_exact_hit(), dt_dev_pixelpipe_cache_flush_clmem(), dt_dev_pixelpipe_cache_get_cl_buffer(), dt_dev_pixelpipe_cache_init(), dt_dev_pixelpipe_cache_print(), and dt_dev_pixelpipe_cache_put_pinned_image().
|
static |
Definition at line 57 of file pixelpipe_cache.c.
Referenced by _cache_entry_clmem_flush_device(), _pixel_cache_clmem_get(), _pixel_cache_message(), _trace_exact_hit(), dt_dev_pixelpipe_cache_flush_clmem(), dt_dev_pixelpipe_cache_get_cl_buffer(), dt_dev_pixelpipe_cache_init(), and dt_dev_pixelpipe_cache_put_pinned_image().
|
static |
Definition at line 108 of file pixelpipe_cache.c.
Referenced by _warn_user(), and dt_dev_pixelpipe_cache_set_handlers().
|
static |
Definition at line 156 of file pixelpipe_cache.c.
Referenced by _cache_debug_module_name(), and dt_pixelpipe_cache_set_current_module().
|
static |
Definition at line 2284 of file pixelpipe_cache.c.
Referenced by dt_dev_pixelpipe_cache_cleanup(), and dt_dev_pixelpipe_cache_init().
|
static |
Definition at line 2285 of file pixelpipe_cache.c.
Referenced by dt_dev_pixelpipe_cache_cleanup(), and dt_dev_pixelpipe_cache_init().