# HG changeset patch # User Markus Mützel # Date 1660240631 -7200 # Node ID 68ec7f275f0e82f61443d5f32483a9cfe279d8d1 # Parent 932e43d948a692fa7ba30eccdd39f48a01f34e22 fftw: Limit the default number of threads used by FFTW to 3. * liboctave/numeric/oct-fftw.cc (fftw_planner::fftw_planner): Limit the default number of threads used by FFTW to 3. * libinterp/dldfcn/fftw.cc (Ffftw): Document new default number of threads used by FFTW. See: https://octave.discourse.group/t/3121 diff -r 932e43d948a6 -r 68ec7f275f0e libinterp/dldfcn/fftw.cc --- a/libinterp/dldfcn/fftw.cc Thu Aug 11 09:38:09 2022 +0200 +++ b/libinterp/dldfcn/fftw.cc Thu Aug 11 19:57:11 2022 +0200 @@ -134,9 +134,9 @@ fftw ("threads", @var{NTHREADS}) @end example -Note that octave must be compiled with multi-threaded @sc{fftw} support for -this feature. The number of processors available to the current process is -used per default. +Note that Octave must be compiled with multi-threaded @sc{fftw} support for +this feature. By default, the number of (logical) processors available to the +current process or @var{3} is used (whichever is smaller). @seealso{fft, ifft, fft2, ifft2, fftn, ifftn} @end deftypefn */) diff -r 932e43d948a6 -r 68ec7f275f0e liboctave/numeric/oct-fftw.cc --- a/liboctave/numeric/oct-fftw.cc Thu Aug 11 09:38:09 2022 +0200 +++ b/liboctave/numeric/oct-fftw.cc Thu Aug 11 19:57:11 2022 +0200 @@ -80,11 +80,16 @@ if (! init_ret) (*current_liboctave_error_handler) ("Error initializing FFTW threads"); - // Use number of processors available to the current process - // This can be later changed with fftw ("threads", nthreads). + // Check number of processors available to the current process m_nthreads = octave_num_processors_wrapper (OCTAVE_NPROC_CURRENT_OVERRIDABLE); + // Limit number of threads to 3 by default + // See: https://octave.discourse.group/t/3121 + // This can be later changed with fftw ("threads", nthreads). + if (m_nthreads > 3) + m_nthreads = 3; + fftw_plan_with_nthreads (m_nthreads); #endif