[Bf-blender-cvs] [f3798fa] master: Revert the testing sculpt openmp thread control and limit for OSX to physical threads as in 2.70a tag

Jens Verwiebe noreply at git.blender.org
Sun Apr 27 18:39:11 CEST 2014


Commit: f3798fa45e3b4936679948f9c9f51103dfe7a9d4
Author: Jens Verwiebe
Date:   Sun Apr 27 18:38:53 2014 +0200
https://developer.blender.org/rBf3798fa45e3b4936679948f9c9f51103dfe7a9d4

Revert the testing sculpt openmp thread control and limit for OSX to physical threads as in 2.70a tag

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/BKE_scene.h
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenlib/intern/threads.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index eec99a7..0797592 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1315,14 +1315,6 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
         col.prop(sculpt, "gravity_object")
         col.separator()
 
-        col = layout.column(align=True)
-        col.label(text="Threads:")
-        col.row(align=True).prop(scene, "omp_threads_mode", expand=True)
-        sub = col.column(align=True)
-        sub.enabled = (scene.omp_threads_mode != 'AUTO')
-        sub.prop(scene, "omp_threads")
-        col.separator()
-
         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
         layout.prop(sculpt, "show_low_resolution")
         layout.prop(sculpt, "use_deform_only")
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 5fe8904..a10a3f3 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -137,7 +137,6 @@ bool BKE_scene_check_rigidbody_active(const struct Scene *scene);
 int BKE_scene_num_threads(const struct Scene *scene);
 int BKE_render_num_threads(const struct RenderData *r);
 
-int BKE_scene_num_omp_threads(const struct Scene *scene);
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 608b049..a758735 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -638,9 +638,6 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
 
 	sce->gm.exitkey = 218; // Blender key code for ESC
 
-	sce->omp_threads_mode = SCE_OMP_AUTO;
-	sce->omp_threads = 1;
-
 	sound_create_scene(sce);
 
 	/* color management */
@@ -1883,11 +1880,3 @@ int BKE_scene_num_threads(const Scene *scene)
 {
 	return BKE_render_num_threads(&scene->r);
 }
-
-int BKE_scene_num_omp_threads(const struct Scene *scene)
-{
-	if (scene->omp_threads_mode == SCE_OMP_AUTO)
-		return BLI_system_thread_count_omp();
-	else
-		return scene->omp_threads;
-}
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 0cdefac..74e513b 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -62,15 +62,6 @@
 #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) && !defined(__clang__)
 #  define USE_APPLE_OMP_FIX
 #endif
-
-/* how many cores not counting HT aka physical 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
@@ -350,24 +341,6 @@ void BLI_end_threads(ListBase *threadbase)
 
 /* System Information */
 
-/**
- * Returns the number of openmp threads the system can make use of
- */
-int BLI_system_thread_count_omp(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)
 {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 25f02cd..291eda9 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -105,6 +105,19 @@
 #include <omp.h>
 #endif
 
+#if defined(__APPLE__) && defined _OPENMP
+#include <sys/sysctl.h>
+
+/* Query how many cores not counting HT aka physical cores we've got. */
+static int system_physical_thread_count(void)
+{
+	int pcount;
+	size_t pcount_len = sizeof(pcount);
+	sysctlbyname("hw.physicalcpu", &pcount, &pcount_len, NULL, 0);
+	return pcount;
+}
+#endif  /* __APPLE__ */
+
 void ED_sculpt_get_average_stroke(Object *ob, float stroke[3])
 {
 	if (ob->sculpt->last_stroke_valid && ob->sculpt->average_stroke_counter > 0) {
@@ -231,7 +244,7 @@ typedef struct StrokeCache {
 	float initial_mouse[2];
 
 	/* Pre-allocated temporary storage used during smoothing */
-	int num_threads;
+	int num_threads, max_threads;
 	float (**tmpgrid_co)[3], (**tmprow_co)[3];
 	float **tmpgrid_mask, **tmprow_mask;
 
@@ -3780,12 +3793,17 @@ static void sculpt_omp_start(Scene *scene, Sculpt *sd, SculptSession *ss)
 	 * Justification: Empirically I've found that two threads per
 	 * processor gives higher throughput. */
 	if (sd->flags & SCULPT_USE_OPENMP) {
-		cache->num_threads = BKE_scene_num_omp_threads(scene);
+#if defined(__APPLE__)
+		cache->num_threads = system_physical_thread_count();
+#else
+		cache->num_threads = omp_get_num_procs();
+#endif
 	}
 	else {
 		cache->num_threads = 1;
 	}
-	omp_set_num_threads(cache->num_threads);  /* set user-defined corecount, "AUTO" = physical cores on OSX, logical cores for other OS atm.*/
+	cache->max_threads = omp_get_max_threads();
+	omp_set_num_threads(cache->num_threads);
 #else
 	(void)scene;
 	(void)sd;
@@ -3817,6 +3835,9 @@ static void sculpt_omp_start(Scene *scene, Sculpt *sd, SculptSession *ss)
 
 static void sculpt_omp_done(SculptSession *ss)
 {
+#ifdef _OPENMP
+	omp_set_num_threads(ss->cache->max_threads);
+#endif
 	if (ss->multires) {
 		int i;
 
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 2e6ef7a..5a47e76 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1174,12 +1174,8 @@ typedef struct Scene {
 	short flag;								/* various settings */
 	
 	char use_nodes;
-
-	/* Openmp Global Settings */
-	char  omp_threads_mode;
-	short omp_threads;
-	char pad[6];
-
+	char pad[1];
+	
 	struct bNodeTree *nodetree;
 	
 	struct Editing *ed;								/* sequence editor data is allocated here */
@@ -1783,10 +1779,6 @@ typedef enum SculptFlags {
 #define	USER_UNIT_OPT_SPLIT		1
 #define USER_UNIT_ROT_RADIANS	2
 
-/* OpenMP settings */
-#define SCE_OMP_AUTO 0
-#define SCE_OMP_FIXED 1
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 7ea719c..37e279f 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -681,12 +681,6 @@ static char *rna_RenderSettings_path(PointerRNA *UNUSED(ptr))
 	return BLI_sprintfN("render");
 }
 
-static int rna_omp_threads_get(PointerRNA *ptr)
-{
-	Scene *scene = (Scene *)ptr->data;
-	return BKE_scene_num_omp_threads(scene);
-}
-
 static int rna_RenderSettings_threads_get(PointerRNA *ptr)
 {
 	RenderData *rd = (RenderData *)ptr->data;
@@ -5096,12 +5090,6 @@ void RNA_def_scene(BlenderRNA *brna)
 		{0, NULL, 0, NULL, NULL}
 	};
 
-	static EnumPropertyItem omp_threads_mode_items[] = {
-		{SCE_OMP_AUTO, "AUTO", 0, "Auto-detect", "Automatically determine the number of threads"},
-		{SCE_OMP_FIXED, "FIXED", 0, "Fixed", "Manually determine the number of threads"},
-		{0, NULL, 0, NULL, NULL}
-	};
-
 	/* Struct definition */
 	srna = RNA_def_struct(brna, "Scene", "ID");
 	RNA_def_struct_ui_text(srna, "Scene",
@@ -5472,16 +5460,6 @@ void RNA_def_scene(BlenderRNA *brna)
 	RNA_def_property_struct_type(prop, "ColorManagedSequencerColorspaceSettings");
 	RNA_def_property_ui_text(prop, "Sequencer Color Space Settings", "Settings of color space sequencer is working in");
 
-	prop = RNA_def_property(srna, "omp_threads", PROP_INT, PROP_NONE);
-	RNA_def_property_range(prop, 1, BLENDER_MAX_THREADS);
-	RNA_def_property_int_funcs(prop, "rna_omp_threads_get", NULL, NULL);
-	RNA_def_property_ui_text(prop, "OpenMP Threads",
-	                         "Number of CPU threads to use for openmp");
-
-	prop = RNA_def_property(srna, "omp_threads_mode", PROP_ENUM, PROP_NONE);
-	RNA_def_property_enum_items(prop, omp_threads_mode_items);
-	RNA_def_property_ui_text(prop, "OpenMP Mode", "Determine the amount of openmp threads used");
-
 	/* Nestled Data  */
 	/* *** Non-Animated *** */
 	RNA_define_animate_sdna(false);




More information about the Bf-blender-cvs mailing list