30static size_t parallel_imgop_minimum = 500000;
42 va_start(args,roi_out);
45 const int size = va_arg(args,
int);
46 float **bufptr = va_arg(args,
float**);
48 (
void)va_arg(args,
size_t*);
56 va_start(args,roi_out);
59 const int size = va_arg(args,
int);
60 float **bufptr = va_arg(args,
float**);
69 nfloats = channels * roi_out->
width * roi_out->
height;
72 nfloats = channels * roi_out->
height;
75 nfloats = channels * roi_out->
width;
81 nfloats = channels * roi_in->
width * roi_in->
height;
84 nfloats = channels * roi_in->
height;
87 nfloats = channels * roi_in->
width;
106 memset(*bufptr, 0, nfloats *
sizeof(
float));
119 va_start(args,roi_out);
122 const int size = va_arg(args,
int);
123 float **bufptr = va_arg(args,
float**);
125 (
void)va_arg(args,
size_t*);
145 if (nfloats > parallel_imgop_minimum)
150#pragma omp parallel for simd aligned(in, out : 16) default(firstprivate)
151 for(
size_t k = 0;
k < nfloats;
k++)
157 memcpy(
out, in, nfloats *
sizeof(
float));
165 const dt_iop_roi_t *
const __restrict__ roi_out,
const int zero_pad)
167 if (roi_in->width == roi_out->width && roi_in->height == roi_out->height)
172 else if (roi_in->width <= roi_out->width && roi_in->height <= roi_out->height)
175 fprintf(stderr,
"copy_image_roi with larger output not yet implemented\n");
178 else if (roi_in->width >= roi_out->width && roi_in->height >= roi_out->height)
181 fprintf(stderr,
"copy_image_roi with smaller output not yet implemented\n");
187 fprintf(stderr,
"copy_image_roi called with inconsistent RoI!\n");
198 if (nfloats > parallel_imgop_minimum)
203#pragma omp parallel for simd aligned(buf, src : 16) default(firstprivate)
204 for(
size_t k = 0;
k < nfloats;
k++)
205 buf[
k] = scale * src[
k];
211#pragma omp simd aligned(buf, src : 16)
213 for (
size_t k = 0;
k < nfloats;
k++)
214 buf[
k] = scale * src[
k];
223 if (nfloats > parallel_imgop_minimum)
227 const size_t chunksize = (((nfloats + nthreads - 1) / nthreads) + 3) / 4;
228#pragma omp parallel for default(firstprivate) num_threads(nthreads)
229 for(
size_t chunk = 0; chunk < nthreads; chunk++)
231#pragma omp simd aligned(buf:16)
232 for(
size_t k = 4 * chunk * chunksize;
k <
MIN(4*(chunk+1)*chunksize, nfloats);
k++)
239 if (fill_value == 0.0f)
242 memset(buf, 0,
sizeof(
float) * nfloats);
247#pragma omp simd aligned(buf:16)
249 for (
size_t k = 0;
k < nfloats;
k++)
260 if (nfloats > parallel_imgop_minimum)
265#pragma omp parallel for simd aligned(buf:16) default(firstprivate)
266 for(
size_t k = 0;
k < nfloats;
k++)
273#pragma omp simd aligned(buf:16)
275 for (
size_t k = 0;
k < nfloats;
k++)
285 if (nfloats > parallel_imgop_minimum)
290#pragma omp parallel for simd aligned(buf, other_image : 16) default(firstprivate)
291 for(
size_t k = 0;
k < nfloats;
k++)
292 buf[
k] += other_image[
k];
298#pragma omp simd aligned(buf, other_image : 16)
300 for (
size_t k = 0;
k < nfloats;
k++)
301 buf[
k] += other_image[
k];
310 if (nfloats > parallel_imgop_minimum)
315#pragma omp parallel for simd aligned(buf, other_image : 16) default(firstprivate)
316 for(
size_t k = 0;
k < nfloats;
k++)
317 buf[
k] -= other_image[
k];
323#pragma omp simd aligned(buf, other_image : 16)
325 for (
size_t k = 0;
k < nfloats;
k++)
326 buf[
k] -= other_image[
k];
335 if (nfloats > parallel_imgop_minimum)
340#pragma omp parallel for simd aligned(buf:16) default(firstprivate)
341 for(
size_t k = 0;
k < nfloats;
k++)
342 buf[
k] = max_value - buf[
k];
348#pragma omp simd aligned(buf:16)
350 for (
size_t k = 0;
k < nfloats;
k++)
351 buf[
k] = max_value - buf[
k];
360 if (nfloats > parallel_imgop_minimum)
365#pragma omp parallel for simd aligned(buf:16) default(firstprivate)
366 for(
size_t k = 0;
k < nfloats;
k++)
373#pragma omp simd aligned(buf:16)
375 for (
size_t k = 0;
k < nfloats;
k++)
385 if (nfloats > parallel_imgop_minimum)
390#pragma omp parallel for simd aligned(buf:16) default(firstprivate)
391 for(
size_t k = 0;
k < nfloats;
k++)
398#pragma omp simd aligned(buf:16)
400 for (
size_t k = 0;
k < nfloats;
k++)
410 const float lambda_1 = 1.0f - lambda;
412 if (nfloats > parallel_imgop_minimum/2)
417#pragma omp parallel for simd aligned(buf:16) default(firstprivate)
418 for(
size_t k = 0;
k < nfloats;
k++)
419 buf[
k] = lambda*buf[
k] + lambda_1*other[
k];
425#pragma omp simd aligned(buf:16)
427 for (
size_t k = 0;
k < nfloats;
k++)
428 buf[
k] = lambda*buf[
k] + lambda_1*other[
k];
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
const dt_colormatrix_t dt_aligned_pixel_t out
int dt_get_num_openmp_threads(void)
__DT_CLONE_TARGETS__ void dt_iop_image_add_image(float *const buf, const float *const other_image, const size_t width, const size_t height, const size_t ch)
__DT_CLONE_TARGETS__ void dt_iop_image_mul_const(float *const buf, const float mul_value, const size_t width, const size_t height, const size_t ch)
__DT_CLONE_TARGETS__ void dt_iop_image_copy(float *const __restrict__ out, const float *const __restrict__ in, const size_t nfloats)
__DT_CLONE_TARGETS__ void dt_iop_image_sub_image(float *const buf, const float *const other_image, const size_t width, const size_t height, const size_t ch)
int dt_iop_alloc_image_buffers(struct dt_iop_module_t *const module, const struct dt_iop_roi_t *const roi_in, const struct dt_iop_roi_t *const roi_out,...)
__DT_CLONE_TARGETS__ void dt_iop_image_add_const(float *const buf, const float add_value, const size_t width, const size_t height, const size_t ch)
void dt_iop_copy_image_roi(float *const __restrict__ out, const float *const __restrict__ in, const size_t ch, const dt_iop_roi_t *const __restrict__ roi_in, const dt_iop_roi_t *const __restrict__ roi_out, const int zero_pad)
__DT_CLONE_TARGETS__ void dt_iop_image_invert(float *const buf, const float max_value, const size_t width, const size_t height, const size_t ch)
__DT_CLONE_TARGETS__ void dt_iop_image_fill(float *const buf, const float fill_value, const size_t width, const size_t height, const size_t ch)
__DT_CLONE_TARGETS__ void dt_iop_image_linear_blend(float *const restrict buf, const float lambda, const float *const restrict other, const size_t width, const size_t height, const size_t ch)
__DT_CLONE_TARGETS__ void dt_iop_image_scaled_copy(float *const restrict buf, const float *const restrict src, const float scale, const size_t width, const size_t height, const size_t ch)
__DT_CLONE_TARGETS__ void dt_iop_image_div_const(float *const buf, const float div_value, const size_t width, const size_t height, const size_t ch)
#define DT_IMGSZ_ROI_MASK
#define DT_IMGSZ_CLEARBUF
static void dt_iop_image_copy_by_size(float *const __restrict__ out, const float *const __restrict__ in, const size_t width, const size_t height, const size_t ch)
#define DT_IMGSZ_PERTHREAD
#define DT_IMGSZ_DIM_MASK
float *const restrict const size_t k
float *const restrict const size_t const size_t ch
#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_pixelpipe_cache_alloc_align_float_cache(pixels, id)
#define dt_pixelpipe_cache_free_align(mem)
#define dt_pixelpipe_cache_alloc_perthread_float(n, padded_size)
Region of interest passed through the pixelpipe.
#define __DT_CLONE_TARGETS__