42#define DT_PIXELPIPE_CACHE_HASH_INVALID ((uint64_t)-1)
160 const char *
name,
const int id,
const gboolean alloc,
203 const size_t size,
const char *
name,
const int id,
204 const gboolean alloc,
const gboolean allow_rekey_reuse,
270 int preferred_devid,
void **
data);
297 gboolean *out_reused);
357 gboolean *out_reused,
void *keep);
372 const char *message,
void *keep);
387 void *host_ptr, gboolean cache_device);
423 const char *message);
449 float *input,
void **cl_mem_input,
537 void **cl_mem_output);
atomic_int dt_atomic_int
Definition atomic.h:66
int width
Definition bilateral.h:1
int height
Definition bilateral.h:1
#define dt_pthread_rwlock_t
Definition dtpthread.h:389
size_t size
Definition mipmap_cache.c:3
dt_mipmap_buffer_dsc_flags flags
Definition mipmap_cache.c:4
void * dt_dev_pixelpipe_cache_get_cl_buffer(int devid, void *host_ptr, const struct dt_iop_roi_t *roi, size_t bpp, struct dt_iop_module_t *module, const char *message, struct dt_pixel_cache_entry_t *entry, gboolean *out_reused, void *keep)
Allocate or reuse an OpenCL buffer for one cache entry payload.
void dt_dev_pixelpipe_cache_wrlock_entry(dt_dev_pixelpipe_cache_t *cache, gboolean lock, struct dt_pixel_cache_entry_t *entry)
Lock or release the write lock on the entry.
Definition pixelpipe_cache.c:2234
int dt_dev_pixelpipe_cache_sync_cl_buffer(int devid, void *host_ptr, void *cl_mem_buffer, const struct dt_iop_roi_t *roi, int cl_mode, size_t bpp, struct dt_iop_module_t *module, const char *message)
Synchronize between host memory and a pinned OpenCL image.
struct dt_pixel_cache_entry_t * dt_dev_pixelpipe_cache_get_entry(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash)
Get an internal reference to the cache entry matching hash. If you are going to access this entry mor...
Definition pixelpipe_cache.c:144
void dt_pixelpipe_cache_free_align_cache(dt_dev_pixelpipe_cache_t *cache, void **mem, const char *message)
Free aligned memory allocated with dt_pixelpipe_cache_alloc_align_cache.
Definition pixelpipe_cache.c:1586
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.
Definition pixelpipe_cache.c:605
void dt_dev_pixelpipe_cache_cleanup(dt_dev_pixelpipe_cache_t *cache)
Definition pixelpipe_cache.c:1752
struct dt_pixel_cache_entry_t * dt_dev_pixelpipe_cache_get_entry_by_data(dt_dev_pixelpipe_cache_t *cache, void *data)
Definition pixelpipe_cache.c:154
void dt_dev_pixelpipe_cache_auto_destroy_apply(dt_dev_pixelpipe_cache_t *cache, 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()....
Definition pixelpipe_cache.c:2284
dt_dev_pixelpipe_cache_t * dt_dev_pixelpipe_cache_init(size_t max_memory)
Definition pixelpipe_cache.c:1717
void dt_dev_pixelpipe_cache_print(dt_dev_pixelpipe_cache_t *cache)
Definition pixelpipe_cache.c:2426
dt_dev_pixelpipe_cache_writable_status_t dt_dev_pixelpipe_cache_get_writable(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash, const size_t size, const char *name, const int id, const gboolean alloc, const gboolean allow_rekey_reuse, const struct dt_pixel_cache_entry_t *reuse_hint, void **data, struct dt_pixel_cache_entry_t **entry)
Acquire a writable cache line for module output.
void dt_dev_pixelpipe_cache_flush(dt_dev_pixelpipe_cache_t *cache, const int id)
Remove cache lines matching id. Entries locked in read/write or having reference count greater than 0...
Definition pixelpipe_cache.c:2161
void dt_dev_pixelpipe_cache_unref_hash(dt_dev_pixelpipe_cache_t *cache, const uint64_t hash)
Find the entry matching hash, and decrease its ref_count if found.
Definition pixelpipe_cache.c:2326
int dt_dev_pixelpipe_cache_prepare_cl_input(struct dt_dev_pixelpipe_t *pipe, struct dt_iop_module_t *module, float *input, void **cl_mem_input, const struct dt_iop_roi_t *roi_in, size_t in_bpp, struct dt_pixel_cache_entry_t *input_entry, struct dt_pixel_cache_entry_t **locked_input_entry, void *keep)
Prepare the OpenCL input image corresponding to one cache-backed module input.
float * dt_dev_pixelpipe_cache_restore_cl_buffer(struct dt_dev_pixelpipe_t *pipe, float *input, void *cl_mem_input, const struct dt_iop_roi_t *roi_in, struct dt_iop_module_t *module, size_t in_bpp, struct dt_pixel_cache_entry_t *input_entry, const char *message)
Resynchronize one OpenCL input payload back into its cache-backed host buffer.
void dt_dev_pixelpipe_cache_flag_auto_destroy(dt_dev_pixelpipe_cache_t *cache, struct dt_pixel_cache_entry_t *entry)
Flag the cache entry as "auto_destroy". This is useful for short-lived/disposable cache entries,...
Definition pixelpipe_cache.c:2268
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.
Definition pixelpipe_cache.c:731
int dt_dev_pixel_pipe_cache_remove_lru(dt_dev_pixelpipe_cache_t *cache)
Definition pixelpipe_cache.c:549
void dt_dev_pixelpipe_cache_put_pinned_image(dt_dev_pixelpipe_cache_t *cache, 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().
Definition pixelpipe_cache.c:826
void * dt_pixel_cache_entry_get_data(struct dt_pixel_cache_entry_t *entry)
Definition pixelpipe_cache.c:1495
int dt_dev_pixelpipe_cache_remove(dt_dev_pixelpipe_cache_t *cache, 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 ...
Definition pixelpipe_cache.c:255
void * dt_dev_pixelpipe_cache_get_pinned_image(dt_dev_pixelpipe_cache_t *cache, 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.
Definition pixelpipe_cache.c:753
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.
Definition pixelpipe_cache.c:1500
void dt_dev_pixelpipe_cache_release_cl_buffer(void **cl_mem_buffer, struct dt_pixel_cache_entry_t *entry, void *host_ptr, gboolean cache_device)
Release or cache an OpenCL image associated with one cache entry.
Definition pixelpipe_cache.c:1017
void * dt_pixel_cache_alloc(dt_dev_pixelpipe_cache_t *cache, struct dt_pixel_cache_entry_t *entry)
Actually allocate the memory buffer attached to the cache entry once you create it with dt_dev_pixelp...
Definition pixelpipe_cache.c:1477
void dt_dev_pixelpipe_cache_rdlock_entry(dt_dev_pixelpipe_cache_t *cache, gboolean lock, struct dt_pixel_cache_entry_t *entry)
Lock or release the read lock on the entry.
Definition pixelpipe_cache.c:2252
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.
Definition pixelpipe_cache.c:633
gboolean dt_dev_pixelpipe_cache_flush_host_pinned_image(dt_dev_pixelpipe_cache_t *cache, void *host_ptr, struct dt_pixel_cache_entry_t *entry_hint, int devid)
Drop cached pinned OpenCL images associated with a given host buffer.
Definition pixelpipe_cache.c:845
void * dt_dev_pixelpipe_cache_alloc_cl_device_buffer(int devid, const struct dt_iop_roi_t *roi, size_t bpp, const struct dt_iop_module_t *module, const char *message, void *keep)
Allocate a temporary device-only OpenCL image, retrying once after cache flush.
gboolean dt_dev_pixelpipe_cache_peek(dt_dev_pixelpipe_cache_t *cache, 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.
Definition pixelpipe_cache.c:2052
void * dt_pixelpipe_cache_alloc_align_cache_impl(dt_dev_pixelpipe_cache_t *cache, size_t size, int id, const char *name)
Allocate aligned memory tracked by the pixelpipe cache. This allows LRU cache entries to be evicted i...
Definition pixelpipe_cache.c:1538
void dt_dev_pixelpipe_cache_ref_count_entry(dt_dev_pixelpipe_cache_t *cache, gboolean lock, struct dt_pixel_cache_entry_t *entry)
Increase/Decrease the reference count on the cache line as to prevent LRU item removal....
Definition pixelpipe_cache.c:2225
struct dt_pixel_cache_entry_t * dt_dev_pixelpipe_cache_ref_entry_for_host_ptr(dt_dev_pixelpipe_cache_t *cache, void *host_ptr)
Resolve and retain the cache entry owning a host pointer.
Definition pixelpipe_cache.c:1339
void dt_dev_pixelpipe_cache_flush_clmem(dt_dev_pixelpipe_cache_t *cache, const int devid)
Release cached OpenCL buffers for a device (-1 for all).
Definition pixelpipe_cache.c:444
gboolean dt_dev_pixelpipe_cache_restore_host_payload(dt_dev_pixelpipe_cache_t *cache, 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.
Definition pixelpipe_cache.c:2032
int dt_dev_pixelpipe_cache_rekey(dt_dev_pixelpipe_cache_t *cache, 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...
Definition pixelpipe_cache.c:2339
dt_dev_pixelpipe_cache_writable_status_t
Definition pixelpipe_cache.h:70
@ DT_DEV_PIXELPIPE_CACHE_WRITABLE_REKEYED
Definition pixelpipe_cache.h:74
@ DT_DEV_PIXELPIPE_CACHE_WRITABLE_ERROR
Definition pixelpipe_cache.h:71
@ DT_DEV_PIXELPIPE_CACHE_WRITABLE_CREATED
Definition pixelpipe_cache.h:73
@ DT_DEV_PIXELPIPE_CACHE_WRITABLE_EXACT_HIT
Definition pixelpipe_cache.h:72
int dt_dev_pixelpipe_cache_get(dt_dev_pixelpipe_cache_t *cache, 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.
Definition pixelpipe_cache.c:1847
const char * dt_pixelpipe_cache_set_current_module(const char *module)
Set the current module name for cache diagnostics (thread-local).
Definition pixelpipe_cache.c:78
unsigned __int64 uint64_t
Definition strptime.c:75
Definition memory_arena.h:35
Definition pixelpipe_cache.h:56
uint64_t next_serial
Definition pixelpipe_cache.h:60
size_t current_memory
Definition pixelpipe_cache.h:64
dt_cache_arena_t arena
Definition pixelpipe_cache.h:66
GHashTable * entries
Definition pixelpipe_cache.h:57
dt_pthread_mutex_t lock
Definition pixelpipe_cache.h:65
size_t max_memory
Definition pixelpipe_cache.h:63
uint64_t queries
Definition pixelpipe_cache.h:61
GHashTable * external_entries
Definition pixelpipe_cache.h:59
uint64_t hits
Definition pixelpipe_cache.h:62
Definition pixelpipe_hb.h:218
Region of interest passed through the pixelpipe.
Definition imageop.h:72
Definition pixelpipe_cache.h:87
uint64_t hash
Definition pixelpipe_cache.h:88
gboolean auto_destroy
Definition pixelpipe_cache.h:97
dt_atomic_int refcount
Definition pixelpipe_cache.h:95
gboolean external_alloc
Definition pixelpipe_cache.h:98
void * data
Definition pixelpipe_cache.h:90
size_t size
Definition pixelpipe_cache.h:91
int64_t age
Definition pixelpipe_cache.h:92
uint64_t serial
Definition pixelpipe_cache.h:89
dt_dev_pixelpipe_cache_t * cache
Definition pixelpipe_cache.h:100
dt_pthread_rwlock_t lock
Definition pixelpipe_cache.h:96
dt_pthread_mutex_t cl_mem_lock
Definition pixelpipe_cache.h:102
GList * cl_mem_list
Definition pixelpipe_cache.h:101
char * name
Definition pixelpipe_cache.h:93
int hits
Definition pixelpipe_cache.h:99
int id
Definition pixelpipe_cache.h:94