From: cristy Date: Thu, 21 Oct 2010 16:15:05 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~8657 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09d81172fd193d98a4d6d433da0ccf1406a4f93e;p=imagemagick --- diff --git a/magick/composite.c b/magick/composite.c index abba2e408..21bee15d2 100644 --- a/magick/composite.c +++ b/magick/composite.c @@ -69,6 +69,7 @@ #include "magick/resample.h" #include "magick/resource_.h" #include "magick/string_.h" +#include "magick/thread-private.h" #include "magick/utility.h" #include "magick/version.h" @@ -2753,7 +2754,7 @@ MagickExport MagickBooleanType TextureImage(Image *image,const Image *texture) Tile texture onto the image background. */ #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(status) + #pragma omp parallel for schedule(dynamic,4) shared(status) omp_throttle(1) #endif for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) texture->rows) { @@ -2801,7 +2802,7 @@ MagickExport MagickBooleanType TextureImage(Image *image,const Image *texture) image_view=AcquireCacheView(image); texture_view=AcquireCacheView(texture); #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(status) + #pragma omp parallel for schedule(dynamic,4) shared(status) omp_throttle(1) #endif for (y=0; y < (ssize_t) image->rows; y++) { diff --git a/magick/decorate.c b/magick/decorate.c index 7158947c5..3353d512a 100644 --- a/magick/decorate.c +++ b/magick/decorate.c @@ -54,6 +54,7 @@ #include "magick/monitor-private.h" #include "magick/pixel-private.h" #include "magick/quantum.h" +#include "magick/thread-private.h" #include "magick/transform.h" /* @@ -402,7 +403,7 @@ MagickExport Image *FrameImage(const Image *image,const FrameInfo *frame_info, Draw sides of ornamental border. */ #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(progress,status) + #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1) #endif for (y=0; y < (ssize_t) image->rows; y++) { @@ -726,7 +727,7 @@ MagickExport MagickBooleanType RaiseImage(Image *image, exception=(&image->exception); image_view=AcquireCacheView(image); #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(progress,status) + #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1) #endif for (y=0; y < (ssize_t) raise_info->height; y++) { @@ -793,7 +794,7 @@ MagickExport MagickBooleanType RaiseImage(Image *image, } } #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(progress,status) + #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1) #endif for (y=(ssize_t) raise_info->height; y < (ssize_t) (image->rows-raise_info->height); y++) { @@ -849,7 +850,7 @@ MagickExport MagickBooleanType RaiseImage(Image *image, } } #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(progress,status) + #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1) #endif for (y=(ssize_t) (image->rows-raise_info->height); y < (ssize_t) image->rows; y++) { diff --git a/magick/effect.c b/magick/effect.c index 83ee63c61..083a64471 100644 --- a/magick/effect.c +++ b/magick/effect.c @@ -3197,7 +3197,7 @@ MagickExport Image *MotionBlurImageChannel(const Image *image, image_view=AcquireCacheView(image); blur_view=AcquireCacheView(blur_image); #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(progress,status) + #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1) #endif for (y=0; y < (ssize_t) image->rows; y++) { @@ -5196,7 +5196,7 @@ MagickExport Image *SpreadImage(const Image *image,const double radius, random_info=AcquireRandomInfoThreadSet(); image_view=AcquireCacheView(spread_image); #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(progress,status) + #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1) #endif for (y=0; y < (ssize_t) spread_image->rows; y++) { diff --git a/magick/image-view.c b/magick/image-view.c index 7553ad8fd..45394334d 100644 --- a/magick/image-view.c +++ b/magick/image-view.c @@ -245,7 +245,7 @@ MagickExport MagickBooleanType DuplexTransferImageViewIterator( progress=0; exception=destination->exception; #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) #endif for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) { @@ -561,7 +561,7 @@ MagickExport MagickBooleanType GetImageViewIterator(ImageView *source, status=MagickTrue; progress=0; #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) #endif for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) { @@ -903,7 +903,7 @@ MagickExport MagickBooleanType SetImageViewIterator(ImageView *destination, progress=0; exception=destination->exception; #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(destination->number_threads) #endif for (y=destination->extent.y; y < (ssize_t) destination->extent.height; y++) { @@ -962,6 +962,41 @@ MagickExport MagickBooleanType SetImageViewIterator(ImageView *destination, % % % % % % +% S e t I m a g e V i e w T h r e a d s % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% SetImageViewThreads() sets the number of threads in a thread team. +% +% The format of the SetImageViewDescription method is: +% +% void SetImageViewThreads(ImageView *image_view, +% const size_t number_threads) +% +% A description of each parameter follows: +% +% o image_view: the image view. +% +% o number_threads: the number of threads in a thread team. +% +*/ +MagickExport void SetImageViewThreads(ImageView *image_view, + const size_t number_threads) +{ + assert(image_view != (ImageView *) NULL); + assert(image_view->signature == MagickSignature); + image_view->number_threads=number_threads; + if (number_threads > GetOpenMPMaximumThreads()) + image_view->number_threads=GetOpenMPMaximumThreads(); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % T r a n s f e r I m a g e V i e w I t e r a t o r % % % % % @@ -1036,7 +1071,7 @@ MagickExport MagickBooleanType TransferImageViewIterator(ImageView *source, progress=0; exception=destination->exception; #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) #endif for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) { @@ -1174,7 +1209,7 @@ MagickExport MagickBooleanType UpdateImageViewIterator(ImageView *source, progress=0; exception=source->exception; #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) #endif for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) { diff --git a/magick/image-view.h b/magick/image-view.h index a18641944..53e2975d5 100644 --- a/magick/image-view.h +++ b/magick/image-view.h @@ -73,7 +73,8 @@ extern MagickExport RectangleInfo GetImageViewExtent(const ImageView *); extern MagickExport void - SetImageViewDescription(ImageView *,const char *); + SetImageViewDescription(ImageView *,const char *), + SetImageViewThreads(ImageView *,const size_t); #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/magick/shear.c b/magick/shear.c index c3278dff2..959132dd6 100644 --- a/magick/shear.c +++ b/magick/shear.c @@ -74,6 +74,7 @@ #include "magick/statistic.h" #include "magick/string_.h" #include "magick/string-private.h" +#include "magick/thread-private.h" #include "magick/threshold.h" #include "magick/transform.h" @@ -1083,7 +1084,7 @@ static Image *IntegralRotateImage(const Image *image,size_t rotations, */ GetPixelCacheTileSize(image,&tile_width,&tile_height); #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress, status) + #pragma omp parallel for schedule(static,1) shared(progress, status) om_throttle(1) #endif for (tile_y=0; tile_y < (ssize_t) image->rows; tile_y+=(ssize_t) tile_height) { @@ -1198,7 +1199,7 @@ static Image *IntegralRotateImage(const Image *image,size_t rotations, Rotate 180 degrees. */ #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,8) shared(progress,status) + #pragma omp parallel for schedule(static,8) shared(progress,status) omp_throttle(1) #endif for (y=0; y < (ssize_t) image->rows; y++) { @@ -1274,7 +1275,7 @@ static Image *IntegralRotateImage(const Image *image,size_t rotations, */ GetPixelCacheTileSize(image,&tile_width,&tile_height); #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) omp_throttle(1) #endif for (tile_y=0; tile_y < (ssize_t) image->rows; tile_y+=(ssize_t) tile_height) { diff --git a/magick/thread-private.h b/magick/thread-private.h index a86ebe2de..f02113df8 100644 --- a/magick/thread-private.h +++ b/magick/thread-private.h @@ -24,6 +24,8 @@ extern "C" { #include +#define omp_throttle(factor) num_threads(omp_get_max_threads() >> (factor)) + #if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR > 10)) #define MagickCachePrefetch(address,mode,locality) \ __builtin_prefetch(address,mode,locality) diff --git a/magick/threshold.c b/magick/threshold.c index f73f6b868..32a85e3ee 100644 --- a/magick/threshold.c +++ b/magick/threshold.c @@ -79,8 +79,9 @@ #include "magick/signature-private.h" #include "magick/string_.h" #include "magick/string-private.h" -#include "magick/transform.h" +#include "magick/thread-private.h" #include "magick/threshold.h" +#include "magick/transform.h" #include "magick/xml-tree.h" /* diff --git a/magick/transform.c b/magick/transform.c index 16a67134a..1582ee54b 100644 --- a/magick/transform.c +++ b/magick/transform.c @@ -63,6 +63,7 @@ #include "magick/resize.h" #include "magick/statistic.h" #include "magick/string_.h" +#include "magick/thread-private.h" #include "magick/transform.h" /* @@ -161,6 +162,9 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info, j=0; image_view=AcquireCacheView(image); chop_view=AcquireCacheView(chop_image); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(dynamic,4) shared(status) omp_throttle(1) +#endif for (y=0; y < (ssize_t) extent.y; y++) { register const PixelPacket @@ -213,6 +217,9 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info, Extract chop image. */ i+=(ssize_t) extent.height; +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(dynamic,4) shared(status) omp_throttle(1) +#endif for (y=0; y < (ssize_t) (image->rows-(extent.y+extent.height)); y++) { register const PixelPacket @@ -625,7 +632,7 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry, image_view=AcquireCacheView(image); crop_view=AcquireCacheView(crop_image); #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(progress,status) + #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1) #endif for (y=0; y < (ssize_t) crop_image->rows; y++) { @@ -936,7 +943,7 @@ MagickExport Image *FlipImage(const Image *image,ExceptionInfo *exception) image_view=AcquireCacheView(image); flip_view=AcquireCacheView(flip_image); #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(progress,status) + #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1) #endif for (y=0; y < (ssize_t) flip_image->rows; y++) { @@ -1056,7 +1063,7 @@ MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception) image_view=AcquireCacheView(image); flop_view=AcquireCacheView(flop_image); #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(dynamic,4) shared(progress,status) + #pragma omp parallel for schedule(dynamic,4) shared(progress,status) omp_throttle(1) #endif for (y=0; y < (ssize_t) flop_image->rows; y++) { diff --git a/wand/wand-view.c b/wand/wand-view.c index eaee62bab..3e268aba8 100644 --- a/wand/wand-view.c +++ b/wand/wand-view.c @@ -287,7 +287,7 @@ WandExport MagickBooleanType DuplexTransferWandViewIterator(WandView *source, progress=0; exception=destination->exception; #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) #endif for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) { @@ -553,7 +553,7 @@ WandExport MagickBooleanType GetWandViewIterator(WandView *source, status=MagickTrue; progress=0; #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) #endif for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) { @@ -951,7 +951,7 @@ WandExport MagickBooleanType SetWandViewIterator(WandView *destination, progress=0; exception=destination->exception; #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(destination->number_threads) #endif for (y=destination->extent.y; y < (ssize_t) destination->extent.height; y++) { @@ -1018,6 +1018,41 @@ WandExport MagickBooleanType SetWandViewIterator(WandView *destination, % % % % % % +% S e t W a n d V i e w T h r e a d s % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% SetWandViewThreads() sets the number of threads in a thread team. +% +% The format of the SetWandViewDescription method is: +% +% void SetWandViewThreads(WandView *image_view, +% const size_t number_threads) +% +% A description of each parameter follows: +% +% o image_view: the image view. +% +% o number_threads: the number of threads in a thread team. +% +*/ +MagickExport void SetWandViewThreads(WandView *image_view, + const size_t number_threads) +{ + assert(image_view != (WandView *) NULL); + assert(image_view->signature == MagickSignature); + image_view->number_threads=number_threads; + if (number_threads > GetOpenMPMaximumThreads()) + image_view->number_threads=GetOpenMPMaximumThreads(); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % T r a n s f e r W a n d V i e w I t e r a t o r % % % % % @@ -1092,7 +1127,7 @@ WandExport MagickBooleanType TransferWandViewIterator(WandView *source, progress=0; exception=destination->exception; #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) #endif for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) { @@ -1256,7 +1291,7 @@ WandExport MagickBooleanType UpdateWandViewIterator(WandView *source, progress=0; exception=source->exception; #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,1) shared(progress,status) + #pragma omp parallel for schedule(static,1) shared(progress,status) num_threads(source->number_threads) #endif for (y=source->extent.y; y < (ssize_t) source->extent.height; y++) { diff --git a/wand/wand-view.h b/wand/wand-view.h index aff7bcfaf..6fc85d837 100644 --- a/wand/wand-view.h +++ b/wand/wand-view.h @@ -56,7 +56,8 @@ extern WandExport RectangleInfo GetWandViewExtent(const WandView *); extern WandExport void - SetWandViewDescription(WandView *,const char *); + SetWandViewDescription(WandView *,const char *), + SetWandViewThreads(WandView *,const size_t); extern WandExport WandView *CloneWandView(const WandView *),