Skip to content

Commit

Permalink
Update docs to discuss NUMEXPR_MAX_THREADS
Browse files Browse the repository at this point in the history
  • Loading branch information
robbmcleod committed Apr 30, 2018
1 parent 09959bb commit 5cbc1b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
6 changes: 5 additions & 1 deletion doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ NumExpr API

.. py:attribute:: nthreads
The number of available threads detected.
The number of threads currently in-use.

.. py:attribute:: MAX_THREADS
The maximum number of threads, as set by the environment variable ``NUMEXPR_MAX_THREADS``

.. py:attribute:: version
Expand Down
24 changes: 15 additions & 9 deletions doc/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ General routines
* :code:`print_versions()`: Print the versions of software that numexpr relies on.
* :code:`set_num_threads(nthreads)`: Sets a number of threads to be used in operations.
Returns the previous setting for the number of threads. See note below to see
how the number of threads is set initially in NumExpr.
how the number of threads is set via environment variables.

If you are using VML, you may want to use *set_vml_num_threads(nthreads)* to
perform the parallel job with VML instead. However, you should get very
Expand All @@ -239,14 +239,20 @@ General routines

* :code:`detect_number_of_cores()`: Detects the number of cores on a system.

*Note on the initial number of threads:* The initial number of threads will be
set to the number of cores detected in the system or 8, whichever is *lower*.
The :code:`NUMEXPR_MUM_THREADS` environment variable is also honored at
initialization time and, if defined, the initial number of threads will be set
to this value instead. Alternatively, the `OMP_NUM_THREADS` environment
variable is also honored, but beware because that might affect to other OpenMP
applications too. Finally, and because of internal limitations, the number of
threads cannot be larger than 4096 (there is an internal protection for this).
**Note on the maximum number of threads:** Threads are spawned at import-time,
with the number being set by the environment variable ``NUMEXPR_MAX_THREADS``.
Example:

:code:`import os; os.environ['NUMEXPR_MAX_THREADS'] = '16'`

The default maximum thread count is 64. The initial number of threads _that are
used_ will be set to the number of cores detected in the system or 8, whichever
is **lower**. For historical reasons, the :code:`NUMEXPR_NUM_THREADS` environment
variable is also honored at initialization time and, if defined, the initial
number of threads will be set to this value instead. Alternatively, the
`OMP_NUM_THREADS` environment variable is also honored, but beware because that
might affect to other OpenMP applications too.



Intel's VML specific support routines
Expand Down

0 comments on commit 5cbc1b3

Please sign in to comment.