blob: 9cbe03f9766383b446c784cbb33284e82d522abb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
.. _global_state:
************
Global State
************
NumPy has a few import-time, compile-time, or runtime options
which change the global behaviour.
Most of these are related to performance or for debugging
purposes and will not be interesting to the vast majority
of users.
Performance-Related Options
===========================
Number of Threads used for Linear Algebra
-----------------------------------------
NumPy itself is normally intentionally limited to a single thread
during function calls, however it does support multiple Python
threads running at the same time.
Note that for performant linear algebra NumPy uses a BLAS backend
such as OpenBLAS or MKL, which may use multiple threads that may
be controlled by environment variables such as ``OMP_NUM_THREADS``
depending on what is used.
One way to control the number of threads is the package
`threadpoolctl <https://pypi.org/project/threadpoolctl/>`_
Madvise Hugepage on Linux
-------------------------
When working with very large arrays on modern Linux kernels,
you can experience a significant speedup when transparent
hugepage is enabled.
The current system policy for transparent hugepages can be
seen by::
cat /sys/kernel/mm/transparent_hugepage/enabled
on most kernels. When set to ``madvise`` NumPy will typically
use hugepages for a performance boost. This behaviour can
be set through the environment variable::
NUMPY_MADVISE_HUGEPAGE=0
or ``1`` for enabling it. When not set, the default is to use
madvise on Kernels 4.6 and newer. These kernels presumably
experience a large speedup when set.
This flag is checked at import time.
Interoperability
===============
The array function protocol which allows array-like objects to
hook into the NumPy API is currently enabled by default.
It can be disabled using::
NUMPY_EXPERIMENTAL_ARRAY_FUNCTION=0
See also :py:meth:`numpy.class.__array_function__` for more information.
This flag is checked at import time.
Debugging
=========
Relaxed Strides Checking
------------------------
The *compile-time* environment variables::
NPY_RELAXED_STRIDES_DEBUG=0
NPY_RELAXED_STRIDES_CHECKING=1
control how NumPy reports contiguity for arrays.
The default that it is enabled and the debug mode is disabled.
This setting should always be enabled. Setting the
debug option can be interesting for testing code written
in C which iterates through arrays that may or may not be
contiguous in memory.
Most users will have no reason to change these, for details
please see the :ref:`memory layout <memory-layout>`_ documentation.
|