[Bf-blender-cvs] [f8f25c3] master: Fix T40510, revert openmp thread count to how it was in 2.70 for non Apple systems.

Antony Riakiotakis noreply at git.blender.org
Sun Jun 8 00:39:19 CEST 2014


Commit: f8f25c38d3352c7f480bbf1eba6415f76f62c76e
Author: Antony Riakiotakis
Date:   Sun Jun 8 01:13:28 2014 +0300
https://developer.blender.org/rBf8f25c38d3352c7f480bbf1eba6415f76f62c76e

Fix T40510, revert openmp thread count to how it was in
2.70 for non Apple systems.

Also refactored the code that restores the previous openmp thread count.
The logic here was weird, mostly due to all the commit madness with
Apple openmp support. The restored thread count though should not depend
on the on/off state of threaded sculpting (since it has to do with
systems other than sculpting only). For OSX threads are restored to the
system thread count but Jens should recheck here.

===================================================================

M	source/blender/blenlib/BLI_threads.h
M	source/blender/editors/sculpt_paint/sculpt.c

===================================================================

diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h
index 1c9e75d..74291ca 100644
--- a/source/blender/blenlib/BLI_threads.h
+++ b/source/blender/blenlib/BLI_threads.h
@@ -74,8 +74,6 @@ void BLI_end_threaded_malloc(void);
 int     BLI_system_thread_count(void); /* gets the number of threads the system can make use of */
 void    BLI_system_num_threads_override_set(int num);
 int     BLI_system_num_threads_override_get(void);
-
-int     BLI_system_thread_count_omp(void);
 	
 /* Global Mutex Locks
  * 
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index abbb8dd..9324656 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -178,7 +178,7 @@ typedef struct StrokeCache {
 	float initial_mouse[2];
 
 	/* Pre-allocated temporary storage used during smoothing */
-	int num_threads, max_threads;
+	int num_threads, init_num_threads;
 	float (**tmpgrid_co)[3], (**tmprow_co)[3];
 	float **tmpgrid_mask, **tmprow_mask;
 
@@ -3624,6 +3624,12 @@ static void sculpt_omp_start(Sculpt *sd, SculptSession *ss)
 	StrokeCache *cache = ss->cache;
 
 #ifdef _OPENMP
+
+#if defined(__APPLE__)
+	cache->init_num_threads = BLI_system_thread_count();
+#else
+	cache->init_num_threads = omp_get_max_threads();
+#endif
 	/* If using OpenMP then create a number of threads two times the
 	 * number of processor cores.
 	 * Justification: Empirically I've found that two threads per
@@ -3632,13 +3638,12 @@ static void sculpt_omp_start(Sculpt *sd, SculptSession *ss)
 #if defined(__APPLE__)
 		cache->num_threads = system_physical_thread_count();
 #else
-		cache->num_threads = omp_get_num_procs();
+		cache->num_threads = 2 * omp_get_num_procs();
 #endif
 	}
 	else {
 		cache->num_threads = 1;
 	}
-	cache->max_threads = omp_get_max_threads();
 	omp_set_num_threads(cache->num_threads);
 #else
 	(void)sd;
@@ -3671,8 +3676,9 @@ static void sculpt_omp_start(Sculpt *sd, SculptSession *ss)
 static void sculpt_omp_done(SculptSession *ss)
 {
 #ifdef _OPENMP
-	omp_set_num_threads(ss->cache->max_threads);
+	omp_set_num_threads(ss->cache->init_num_threads);
 #endif
+
 	if (ss->multires) {
 		int i;
 
@@ -4500,11 +4506,6 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
 		WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
 	}
 
-#ifdef _OPENMP
-	if (!(sd->flags & SCULPT_USE_OPENMP))
-		omp_set_num_threads(BLI_system_thread_count()); /* set back to original logical corecount */
-#endif
-
 	sculpt_brush_exit_tex(sd);
 }




More information about the Bf-blender-cvs mailing list