18#ifndef DT_CACHES_PIXELPIPE_CACHE_ALLOC_H
19#define DT_CACHES_PIXELPIPE_CACHE_ALLOC_H
63#define dt_pixelpipe_cache_alloc_align_cache(size, id) \
64 dt_pixelpipe_cache_alloc_align_cache_impl((size), (id), __FILE__ ":" DT_STRINGIFY(__LINE__))
66#ifndef dt_pixelpipe_cache_alloc_align
67#define dt_pixelpipe_cache_alloc_align(size, pipe) \
68 dt_pixelpipe_cache_alloc_align_cache((size), (pipe)->type)
71#ifndef dt_pixelpipe_cache_alloc_align_float
72#define dt_pixelpipe_cache_alloc_align_float(pixels, pipe) \
73 ((float *)dt_pixelpipe_cache_alloc_align((size_t)(pixels) * sizeof(float), (pipe)))
76#ifndef dt_pixelpipe_cache_alloc_align_float_cache
77#define dt_pixelpipe_cache_alloc_align_float_cache(pixels, id) \
78 ((float *)dt_pixelpipe_cache_alloc_align_cache((size_t)(pixels) * sizeof(float), (id)))
81#ifndef dt_pixelpipe_cache_alloc_align_int
82#define dt_pixelpipe_cache_alloc_align_int(count, pipe) \
83 ((int *)dt_pixelpipe_cache_alloc_align((size_t)(count) * sizeof(int), (pipe)))
89#ifndef dt_pixelpipe_cache_alloc_align_int_cache
90#define dt_pixelpipe_cache_alloc_align_int_cache(count, id) \
91 ((int *)dt_pixelpipe_cache_alloc_align_cache((size_t)(count) * sizeof(int), (id)))
94#ifndef dt_pixelpipe_cache_alloc_align_double_cache
95#define dt_pixelpipe_cache_alloc_align_double_cache(count, id) \
96 ((double *)dt_pixelpipe_cache_alloc_align_cache((size_t)(count) * sizeof(double), (id)))
99#ifndef dt_pixelpipe_cache_alloc_align_double
100#define dt_pixelpipe_cache_alloc_align_double(count, pipe) \
101 ((double *)dt_pixelpipe_cache_alloc_align((size_t)(count) * sizeof(double), (pipe)))
104#define dt_pixelpipe_cache_free_align(mem) \
105 dt_pixelpipe_cache_free_align_cache((void **)&(mem), __FILE__ ":" DT_STRINGIFY(__LINE__));
123#ifndef dt_pixelpipe_cache_alloc_perthread
124#define dt_pixelpipe_cache_alloc_perthread(n, objsize, padded_size) \
125 ((void *)dt_pixelpipe_cache_alloc_perthread_impl((n), (objsize), (padded_size), __FILE__ ":" DT_STRINGIFY(__LINE__)))
136#ifndef dt_pixelpipe_cache_calloc_perthread
137#define dt_pixelpipe_cache_calloc_perthread(n, objsize, padded_size) \
138 ((void *)dt_pixelpipe_cache_calloc_perthread_impl((n), (objsize), (padded_size), __FILE__ ":" DT_STRINGIFY(__LINE__)))
147#ifndef dt_pixelpipe_cache_alloc_perthread_float
148#define dt_pixelpipe_cache_alloc_perthread_float(n, padded_size) \
149 ((float *)dt_pixelpipe_cache_alloc_perthread_float_impl((n), (padded_size), __FILE__ ":" DT_STRINGIFY(__LINE__)))
153#define dt_get_perthread(buf, padsize) DT_IS_ALIGNED((buf) + ((padsize) * dt_get_thread_num()))
156#define dt_get_bythread(buf, padsize, tnum) DT_IS_ALIGNED((buf) + ((padsize) * (tnum)))
int dt_get_num_openmp_threads(void)
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define DT_CACHELINE_BYTES
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 i...
static void * dt_pixelpipe_cache_alloc_perthread_impl(const size_t n, const size_t objsize, size_t *padded_size, const char *message)
static float * dt_pixelpipe_cache_alloc_perthread_float_impl(const size_t n, size_t *padded_size, const char *message)
void dt_pixelpipe_cache_free_align_cache(void **mem, const char *message)
Free aligned memory allocated with dt_pixelpipe_cache_alloc_align_cache.
static void * dt_pixelpipe_cache_calloc_perthread_impl(const size_t n, const size_t objsize, size_t *padded_size, const char *message)