diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_scene.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 11 | ||||
-rw-r--r-- | source/blender/blenlib/intern/threads.c | 27 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 27 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 22 |
6 files changed, 26 insertions, 74 deletions
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 5fe890461e0..a10a3f3f59f 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 608b0495454..a758735577e 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 0cdefac902d..74e513b5c90 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 25f02cda2cb..291eda966a9 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 2e6ef7af6ff..5a47e76b4f9 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 7ea719c7eb3..37e279f1436 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); |