diff --git a/src/libslic3r/Thread.cpp b/src/libslic3r/Thread.cpp index 51dec618e..25c29d273 100644 --- a/src/libslic3r/Thread.cpp +++ b/src/libslic3r/Thread.cpp @@ -10,11 +10,11 @@ #include #include #include -#include #include #include #include "Thread.hpp" +#include "Utils.hpp" namespace Slic3r { @@ -199,16 +199,14 @@ void name_tbb_thread_pool_threads() // TBB will respect the task affinity mask on Linux and spawn less threads than std::thread::hardware_concurrency(). // const size_t nthreads_hw = std::thread::hardware_concurrency(); const size_t nthreads_hw = tbb::this_task_arena::max_concurrency(); - size_t nthreads = nthreads_hw; + size_t nthreads = nthreads_hw; #ifdef SLIC3R_PROFILE // Shiny profiler is not thread safe, thus disable parallelization. + disable_multi_threading(); nthreads = 1; #endif - if (nthreads != nthreads_hw) - tbb::global_control(tbb::global_control::max_allowed_parallelism, nthreads); - std::atomic nthreads_running(0); std::condition_variable cv; std::mutex cv_m; diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 763be8af7..62ce67ae4 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -43,7 +43,13 @@ #include #include -#include +// We are using quite an old TBB 2017 U7, which does not support global control API officially. +// Before we update our build servers, let's use the old API, which is deprecated in up to date TBB. +#ifdef TBB_HAS_GLOBAL_CONTROL + #include +#else + #include +#endif #if defined(__linux__) || defined(__GNUC__ ) #include @@ -118,7 +124,11 @@ void trace(unsigned int level, const char *message) void disable_multi_threading() { // Disable parallelization so the Shiny profiler works +#ifdef TBB_HAS_GLOBAL_CONTROL tbb::global_control(tbb::global_control::max_allowed_parallelism, 1); +#else // TBB_HAS_GLOBAL_CONTROL + static tbb::task_scheduler_init *tbb_init = new tbb::task_scheduler_init(1); +#endif // TBB_HAS_GLOBAL_CONTROL } static std::string g_var_dir; diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.hpp b/src/slic3r/GUI/BackgroundSlicingProcess.hpp index 6f5cd8852..cf9b07249 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.hpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.hpp @@ -255,7 +255,6 @@ private: std::shared_ptr m_ui_task; PrintState m_step_state; - mutable tbb::mutex m_step_state_mutex; bool set_step_started(BackgroundSlicingProcessStep step); void set_step_done(BackgroundSlicingProcessStep step); bool is_step_done(BackgroundSlicingProcessStep step) const;