...
 
Commits (4)
......@@ -721,6 +721,7 @@ namespace threading {
constexpr size_t thread_id = 0;
constexpr size_t num_threads = 1;
constexpr size_t max_threads = 1;
template <typename Func>
void thread_map(size_t /* nthreads */, Func f)
......@@ -730,6 +731,7 @@ void thread_map(size_t /* nthreads */, Func f)
thread_local size_t thread_id = 0;
thread_local size_t num_threads = 1;
static const size_t max_threads = max(1u, thread::hardware_concurrency());
class latch
{
......@@ -742,12 +744,10 @@ class latch
latch(size_t n): num_left_(n) {}
void count_down()
{
{
lock_t lock(mut_);
if (--num_left_)
return;
}
completed_.notify_all();
}
......@@ -836,7 +836,7 @@ class thread_pool
threads_(nthreads)
{ create_threads(); }
thread_pool(): thread_pool(thread::hardware_concurrency()) {}
thread_pool(): thread_pool(max_threads) {}
~thread_pool() { shutdown(); }
......@@ -883,7 +883,7 @@ template <typename Func>
void thread_map(size_t nthreads, Func f)
{
if (nthreads == 0)
nthreads = thread::hardware_concurrency();
nthreads = max_threads;
if (nthreads == 1)
{ f(); return; }
......
......@@ -19,10 +19,10 @@ define_macros = [('POCKETFFT_PTHREADS', None)]
if sys.platform == 'darwin':
import distutils.sysconfig
extra_compile_args += ['--stdlib=libc++', '-mmacosx-version-min=10.9']
extra_compile_args += ['-mmacosx-version-min=10.9']
python_module_link_args += ['-mmacosx-version-min=10.9', '-bundle']
vars = distutils.sysconfig.get_config_vars()
vars['LDSHARED'] = vars['LDSHARED'].replace('-bundle', '')
python_module_link_args += ['-bundle']
elif sys.platform == 'win32':
define_macros = []
extra_compile_args = ['/Ox', '/EHsc']
......