changeset 31184:68ec7f275f0e

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
author Markus Mützel <markus.muetzel@gmx.de>
date Thu, 11 Aug 2022 19:57:11 +0200
parents 932e43d948a6
children 07e3911e24c2
files libinterp/dldfcn/fftw.cc liboctave/numeric/oct-fftw.cc
diffstat 2 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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 */)
--- 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