extern "C" {
#endif
+#include <MagickCore/cache.h>
+#include <MagickCore/resource_.h>
#include <MagickCore/thread_.h>
-#if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR > 10))
+/*
+ Single threaded unless workload justifies the threading overhead.
+*/
+#define WorkloadThreshold() (16*GetMagickResourceLimit(ThreadResource))
+#define dynamic_number_threads(image,columns,rows,expression) \
+ if (((((columns) > WorkloadThreshold()) || \
+ ((rows) > WorkloadThreshold()))) && ((MagickSizeType) \
+ ((columns)*(rows)) > (WorkloadThreshold()*WorkloadThreshold())) && \
+ (GetImagePixelCacheType(image) != DiskCache) && (expression)) \
+ num_threads(GetMagickResourceLimit(ThreadResource))
+
+#if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 10))
#define MagickCachePrefetch(address,mode,locality) \
__builtin_prefetch(address,mode,locality)
#else
#define MagickCachePrefetch(address,mode,locality)
#endif
-#define omp_concurrent(concurrent) \
- num_threads((concurrent) != MagickFalse ? omp_get_max_threads() : 1)
-#define omp_throttle(factor) num_threads(omp_get_max_threads() >> \
- (factor) == 0 ? 1 : omp_get_max_threads() >> (factor))
-
#if defined(MAGICKCORE_THREAD_SUPPORT)
typedef pthread_mutex_t MagickMutexType;
#elif defined(MAGICKCORE_WINDOWS_SUPPORT)
*/
static inline size_t GetOpenMPMaximumThreads(void)
{
- static size_t
- maximum_threads = 1;
-
#if defined(MAGICKCORE_OPENMP_SUPPORT)
- {
- ssize_t
- threads;
-
- threads=omp_get_max_threads();
- if (threads > (ssize_t) maximum_threads)
- maximum_threads=threads;
- }
+ return(omp_get_max_threads());
+#else
+ return(1);
#endif
- return(maximum_threads);
}
static inline int GetOpenMPThreadId(void)