Skip to content

Commit c1c6a70

Browse files
committed
Remove OpenMP thread support from convolution.convolve()
See #7971 Signed-off-by: James Noss <[email protected]>
1 parent 47072a2 commit c1c6a70

7 files changed

Lines changed: 8 additions & 72 deletions

File tree

‎.travis.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ matrix:
7373
- os: osx
7474
stage: Cron tests
7575
env: SETUP_CMD='test --remote-data=astropy'
76-
CONDA_DEPENDENCIES="$CONDA_ALL_DEPENDENCIES clang llvm-openmp"
76+
CONDA_DEPENDENCIES="$CONDA_ALL_DEPENDENCIES clang"
7777
PIP_DEPENDENCIES='jplephem'
7878
CCOMPILER=clang
7979
EVENT_TYPE='cron'

‎CHANGES.rst‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ astropy.convolution
1515

1616
- ``convolve`` now accepts any array-like input, not just ``numpy.ndarray`` or
1717
lists. [#7303]
18-
- Thread with OpenMP support [#7293]
1918

2019
astropy.coordinates
2120
^^^^^^^^^^^^^^^^^^^
@@ -270,11 +269,6 @@ astropy.convolution
270269

271270
- ``kernel`` can now be a tuple. [#7561]
272271

273-
- Add ``n_threads`` parameter to control number of threads used in C computation.
274-
An exception is raised for negative values.
275-
A warning is issued if ``n_threads`` > total number of CPUs reported by the OS.
276-
A warning is raised if ``n_threads`` > 1 and Astropy was NOT built with OpenMP support. [#7293]
277-
278272
- Not technically an API changes, however, the doc string indicated that ``boundary=None``
279273
was the default when actually it is ``boundary='fill'``. The doc string has been corrected,
280274
however, someone may interpret this as an API change not realising that nothing has actually
@@ -455,12 +449,6 @@ astropy.convolution
455449
hoisting, and vectorization, etc. Compiler optimization level ``-O2`` required for
456450
hoisting and ``-O3`` for vectorization. [#7293]
457451

458-
- ``convolve()``: Core computation now threaded using OpenMP. However, the root
459-
setup disables this by default. To build the package with OpenMP support
460-
instantiate the environment variable ``ASTROPY_SETUP_WITH_OPENMP=1``.
461-
E.g. ``ASTROPY_SETUP_WITH_OPENMP=1 pip install astropy --no-cache-dir`` or
462-
``ASTROPY_SETUP_WITH_OPENMP=1 ./setup.py build``. [#7293]
463-
464452
- ``convolve()``: ``nan_treatment=‘interpolate’`` was slow to compute irrespective of
465453
whether any NaN values exist within the array. The input array is now
466454
checked for NaN values and interpolation is disabled if non are found. This is a
@@ -623,12 +611,6 @@ Other Changes and Additions
623611
leading to some speed improvements, and setting the stage for allowing
624612
overrides with ``__array_ufunc__``. [#7502]
625613

626-
- Building with OpenMP support is disabled by default. To build the package with
627-
OpenMP support (currently only used in ``convolution.convolve``) create and
628-
set the environment variable ``ASTROPY_SETUP_WITH_OPENMP=1``.
629-
E.g. ``ASTROPY_SETUP_WITH_OPENMP=1 pip install astropy --no-cache-dir`` or
630-
``ASTROPY_SETUP_WITH_OPENMP=1 ./setup.py build``. [#7293]
631-
632614

633615

634616
3.0.6 (unreleased)

‎astropy/convolution/convolve.py‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from ..modeling.core import _make_arithmetic_operator, BINARY_OPERATORS
2020
from ..modeling.core import _CompoundModelMeta
2121
from .utils import KernelSizeError, has_even_axis, raise_even_kernel_exception
22-
from ..utils.openmp import handle_n_threads_usage
2322

2423
# Turn the faulthandler ON to help catch any signals, e.g. segfaults
2524
# or asserts. This doesn't, currently, work with Jupyter Notebook.
@@ -71,7 +70,7 @@
7170
@support_nddata(data='array')
7271
def convolve(array, kernel, boundary='fill', fill_value=0.,
7372
nan_treatment='interpolate', normalize_kernel=True, mask=None,
74-
preserve_nan=False, normalization_zero_tol=1e-8, n_threads=0):
73+
preserve_nan=False, normalization_zero_tol=1e-8):
7574
'''
7675
Convolve an array with a kernel.
7776
@@ -130,12 +129,6 @@ def convolve(array, kernel, boundary='fill', fill_value=0.,
130129
The absolute tolerance on whether the kernel is different than zero.
131130
If the kernel sums to zero to within this precision, it cannot be
132131
normalized. Default is "1e-8".
133-
n_threads : int
134-
The number of threads to use (default 0). 0 => use all. There is no
135-
limit, be cautious if over commmiting resources.
136-
Note that an exception is raised for negative values. A warning is issued
137-
if n_threads>1 and astropy was NOT built with OpenMP support.
138-
With DASK, it is more performant to set ``n_threads=1``.
139132
140133
Returns
141134
-------
@@ -159,7 +152,9 @@ def convolve(array, kernel, boundary='fill', fill_value=0.,
159152
if nan_treatment not in ('interpolate', 'fill'):
160153
raise ValueError("nan_treatment must be one of 'interpolate','fill'")
161154

162-
n_threads = handle_n_threads_usage(n_threads)
155+
# OpenMP support is disabled at the C src code level, changing this will have
156+
# no effect.
157+
n_threads = 1
163158

164159
# Keep refs to originals
165160
passed_kernel = kernel

‎astropy/convolution/setup_package.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import sys
55
from distutils.extension import Extension
6-
from astropy_helpers.openmp_helpers import add_openmp_flags_if_available
76

87
C_CONVOLVE_PKGDIR = os.path.relpath(os.path.dirname(__file__))
98

@@ -23,6 +22,4 @@ def get_extensions():
2322
include_dirs=["numpy"],
2423
language='c')
2524

26-
add_openmp_flags_if_available(lib_convolve_ext)
27-
2825
return [lib_convolve_ext]

‎astropy/convolution/src/convolve.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#include <stddef.h>
55

6+
// Forcibly disable OpenMP support at the src level
7+
#undef _OPENMP
8+
69
#if defined(_MSC_VER)
710

811
#define FORCE_INLINE __forceinline

‎astropy/utils/openmp.py‎

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎setup.py‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from astropy_helpers.distutils_helpers import is_distutils_display_option
2323
from astropy_helpers.git_helpers import get_git_devstr
2424
from astropy_helpers.version_helpers import generate_version_py
25-
from astropy_helpers.openmp_helpers import generate_openmp_enabled_py
2625

2726
import astropy
2827

@@ -46,11 +45,6 @@
4645
generate_version_py(NAME, VERSION, RELEASE, get_debug_option(NAME),
4746
uses_git=not RELEASE)
4847

49-
# Generate function to check OpenMP support at runtime
50-
# The current default is to NOT build with OpenMP support, i.e. ``disable_openmp = True``
51-
disable_openmp = os.environ.get('ASTROPY_SETUP_WITH_OPENMP', '0') == '0'
52-
generate_openmp_enabled_py(NAME, disable_openmp=disable_openmp)
53-
5448
# Get configuration information from all of the various subpackages.
5549
# See the docstring for setup_helpers.update_package_files for more
5650
# details.

0 commit comments

Comments
 (0)