Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Verwiebe <info@jensverwiebe.de>2014-03-31 15:51:40 +0400
committerJens Verwiebe <info@jensverwiebe.de>2014-03-31 15:51:49 +0400
commit277fb1a31fc4b0c9691b3bbab43fd1a970d3e575 (patch)
tree14fdf30a1783d0d4b17ca83f4de8b4e0c4276c66 /source/blender/blenlib/intern/threads.c
parente05d35bfaffec69ed4d990f6a90a1b9244970aa4 (diff)
Sculpt/dyntopo: Make the omp threads configurable to overcome performance issues
- autodetect optimal default, which typically avoids HT threads - can store setting in .blend per scene - this does not touch general omp max threads, due i found other areas where the calculations are fitting for huge corecount - Intel notes, some of the older generation processors with HyperThreading would not provide significant performance boost for FPU intensive applications. On those systems you might want to set OMP_NUM_THREADS = total number of cores (not total number of hardware theads).
Diffstat (limited to 'source/blender/blenlib/intern/threads.c')
-rw-r--r--source/blender/blenlib/intern/threads.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index ded2fd7e06d..78752fde608 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -54,10 +54,25 @@
# include <sys/time.h>
#endif
-#if defined(__APPLE__) && defined(_OPENMP) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) && !defined(__clang__)
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
+#if defined(__APPLE__)
+#if defined(_OPENMP) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) && !defined(__clang__)
# define USE_APPLE_OMP_FIX
#endif
+/* how many cores not counting HT aka pysical cores */
+static int system_physical_thread_count(void)
+{
+ int ptcount;
+ size_t ptcount_len = sizeof(ptcount);
+ sysctlbyname("hw.physicalcpu", &ptcount, &ptcount_len, NULL, 0);
+ return ptcount;
+}
+#endif // __APPLE__
+
#ifdef USE_APPLE_OMP_FIX
/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */
extern pthread_key_t gomp_tls_key;
@@ -335,6 +350,22 @@ void BLI_end_threads(ListBase *threadbase)
/* System Information */
+/* gets the number of openmp threads the system can make use of */
+int BLI_omp_thread_count(void)
+{
+ int t;
+#ifdef _OPENMP
+#ifdef __APPLE__
+ t = system_physical_thread_count();
+#else
+ t = omp_get_num_procs();
+#endif
+#else
+ t = 1;
+#endif
+ return t;
+}
+
/* how many threads are native on this system? */
int BLI_system_thread_count(void)
{