diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2010-07-27 03:34:39 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2010-07-27 03:34:39 +0000 |
| commit | 1a80d1aa528ac4afdf2663d4b640519e2ed85a37 (patch) | |
| tree | 47f4fc384625c6a95aebed2e2d631582e5120780 /src | |
| parent | Separate morphology filter into X and Y processing phases. (diff) | |
| download | inkscape-1a80d1aa528ac4afdf2663d4b640519e2ed85a37.tar.gz inkscape-1a80d1aa528ac4afdf2663d4b640519e2ed85a37.zip | |
Add OpenMP IF clauses to filter templates, instead of modifying num_threads
(bzr r9508.1.37)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/cairo-templates.h | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/display/cairo-templates.h b/src/display/cairo-templates.h index 900ca2d54..78fdff664 100644 --- a/src/display/cairo-templates.h +++ b/src/display/cairo-templates.h @@ -16,7 +16,7 @@ #include <omp.h> #include "preferences.h" // single-threaded operation if the number of pixels is below this threshold -#define OPENMP_THRESHOLD 2048 +static const int OPENMP_THRESHOLD = 2048; #endif #include <algorithm> @@ -70,7 +70,6 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s #if HAVE_OPENMP Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); - if (limit < OPENMP_THRESHOLD) num_threads = 1; // do not spawn threads for very small surfaces #endif // The number of code paths here is evil. @@ -78,14 +77,14 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s if (bpp2 == 4) { if (fast_path) { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < limit; ++i) { *(out_data + i) = blend(*(in1_data + i), *(in2_data + i)); } } else { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint32 *in1_p = in1_data + i * stride1/4; @@ -100,7 +99,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s } else { // bpp2 == 1 #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint32 *in1_p = in1_data + i * stride1/4; @@ -118,7 +117,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s if (bpp2 == 4) { // bpp1 == 1 #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint8 *in1_p = reinterpret_cast<guint8*>(in1_data) + i * stride1; @@ -135,7 +134,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s // bpp1 == 1 && bpp2 == 1 if (fast_path) { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < limit; ++i) { guint8 *in1_p = reinterpret_cast<guint8*>(in1_data) + i; @@ -148,7 +147,7 @@ void ink_cairo_surface_blend(cairo_surface_t *in1, cairo_surface_t *in2, cairo_s } } else { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint8 *in1_p = reinterpret_cast<guint8*>(in1_data) + i * stride1; @@ -199,7 +198,6 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter #if HAVE_OPENMP Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); - if (limit < OPENMP_THRESHOLD) num_threads = 1; // do not spawn threads for very small surfaces #endif if (bppin == 4) { @@ -207,14 +205,14 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter // bppin == 4, bppout == 4 if (fast_path) { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < limit; ++i) { *(out_data + i) = filter(*(in_data + i)); } } else { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint32 *in_p = in_data + i * stridein/4; @@ -229,7 +227,7 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter // bppin == 4, bppout == 1 // we use this path with COLORMATRIX_LUMINANCETOALPHA #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint32 *in_p = in_data + i * stridein/4; @@ -246,7 +244,7 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter // Note: there is no path for bppin == 1, bppout == 4 because it is useless if (fast_path) { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < limit; ++i) { guint8 *in_p = reinterpret_cast<guint8*>(in_data) + i; @@ -257,7 +255,7 @@ void ink_cairo_surface_filter(cairo_surface_t *in, cairo_surface_t *out, Filter } } else { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = 0; i < h; ++i) { guint8 *in_p = reinterpret_cast<guint8*>(in_data) + i * stridein; @@ -301,12 +299,11 @@ void ink_cairo_surface_synthesize(cairo_surface_t *out, cairo_rectangle_t const int limit = w * h; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int num_threads = prefs->getIntLimited("/options/threading/numthreads", omp_get_num_procs(), 1, 256); - if (limit < OPENMP_THRESHOLD) num_threads = 1; // do not spawn threads for very small surfaces #endif if (bppout == 4) { #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = out_area.y; i < h; ++i) { guint32 *out_p = reinterpret_cast<guint32*>(out_data + i * strideout); @@ -318,7 +315,7 @@ void ink_cairo_surface_synthesize(cairo_surface_t *out, cairo_rectangle_t const } else { // bppout == 1 #if HAVE_OPENMP - #pragma omp parallel for num_threads(num_threads) + #pragma omp parallel for if(limit > OPENMP_THRESHOLD) num_threads(num_threads) #endif for (int i = out_area.y; i < h; ++i) { guint8 *out_p = out_data + i * strideout; |
