Repository: numba/numba

Issue:
Some parallel backend tests failing with NumPy 1.22
For various tests in `numba.tests.test_parallel_backend`, errors are of the form:

```
======================================================================
FAIL: test_threading_concurrent_mix_use_masks_omp (numba.tests.test_parallel_backend.TestSpecificBackend)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/esc/miniconda3/envs/numba-dev/lib/python3.9/site-packages/numba/tests/test_parallel_backend.py", line 396, in test_template
    o, e = self.run_test_in_separate_process(injected_method, backend)
  File "/Users/esc/miniconda3/envs/numba-dev/lib/python3.9/site-packages/numba/tests/test_parallel_backend.py", line 374, in run_test_in_separate_process
    return self.run_cmd(cmdline, env_copy)
  File "/Users/esc/miniconda3/envs/numba-dev/lib/python3.9/site-packages/numba/tests/test_parallel_backend.py", line 362, in run_cmd
    raise AssertionError(
AssertionError: process failed with code 1: stderr follows
OMP: Info #271: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
E
======================================================================
ERROR: test_threading_concurrent_mix_use_masks (numba.tests.test_parallel_backend.TestParallelBackend)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/esc/miniconda3/envs/numba-dev/lib/python3.9/site-packages/numba/tests/test_parallel_backend.py", line 336, in test_method
    self.run_compile(impl, parallelism=p)
  File "/Users/esc/miniconda3/envs/numba-dev/lib/python3.9/site-packages/numba/tests/test_parallel_backend.py", line 283, in run_compile
    thread_impl(fnlist)
  File "/Users/esc/miniconda3/envs/numba-dev/lib/python3.9/site-packages/numba/tests/test_parallel_backend.py", line 180, in run_compile
    raise RuntimeError(_msg % '\n'.join([repr(x) for x in errors]))
RuntimeError: Error(s) occurred in delegated runner:
UFuncTypeError(<ufunc 'ufunc_foo'>, (<class 'numpy.dtype[float32]'>, <class 'numpy.dtype[float32]'>, None))
UFuncTypeError(<ufunc 'ufunc_foo'>, (<class 'numpy.dtype[float32]'>, <class 'numpy.dtype[float32]'>, None))
UFuncTypeError(<ufunc 'ufunc_foo'>, (<class 'numpy.dtype[float32]'>, <class 'numpy.dtype[float32]'>, None))
UFuncTypeError(<ufunc 'ufunc_foo'>, (<class 'numpy.dtype[float32]'>, <class 'numpy.dtype[float32]'>, None))

----------------------------------------------------------------------
Ran 1 test in 20.943s
```
NumPy 1.22 support
For tracking issues related to NumPy 1.22 support.

Known issues so far:

- [ ] #7756
- [ ] #7757
- [ ] #7758
- [ ] #7759
- [ ] #7760 


Discussion:

I ran a quick check on OSX using the current Numba 0.56.0dev0 and Numpy 1.22.1 (via pip).

```
 $ conda list
# packages in environment at /Users/esc/miniconda3/envs/numba-dev:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl    defaults
ca-certificates           2021.10.26           hecd8cb5_2    defaults
certifi                   2021.10.8        py39hecd8cb5_2    defaults
intel-openmp              2021.4.0          hecd8cb5_3538    defaults
libcxx                    12.0.0               h2f01273_0    defaults
libffi                    3.3                  hb1e8313_2    defaults
llvm-openmp               12.0.0               h0dcd299_1    defaults
llvmlite                  0.39.0dev0              py39_21    numba/label/dev
mkl                       2021.4.0           hecd8cb5_637    defaults
mkl-service               2.4.0            py39h9ed2024_0    defaults
mkl_fft                   1.3.1            py39h4ab4a9b_0    defaults
mkl_random                1.2.2            py39hb2f4e1b_0    defaults
ncurses                   6.3                  hca72f7f_2    defaults
numba                     0.56.0dev0      np1.16py3.9h2fabc88_gf427bd6_22    numba/label/dev
numpy                     1.22.1                   pypi_0    pypi
openssl                   1.1.1m               hca72f7f_0    defaults
pip                       21.2.4           py39hecd8cb5_0    defaults
python                    3.9.7                h88f2d9e_1    defaults
readline                  8.1.2                hca72f7f_1    defaults
setuptools                58.0.4           py39hecd8cb5_0    defaults
six                       1.16.0             pyhd3eb1b0_0    defaults
sqlite                    3.37.0               h707629a_0    defaults
tk                        8.6.11               h7bc2e8c_0    defaults
tzdata                    2021e                hda174b7_0    defaults
wheel                     0.37.1             pyhd3eb1b0_0    defaults
xz                        5.2.5                h1de35cc_0    defaults
zlib                      1.2.11               h4dc903c_4    defaults
```

```
$ cat NUMPY_LOG.txt | grep ERROR | wc -l
70
```

```
cat NUMPY_LOG.txt | grep FAIL  | wc -l
10
```


```
 💣 zsh» cat NUMPY_LOG.txt | grep ERROR
ERROR: test_floordiv_float (numba.tests.npyufunc.test_errors.TestFloatingPointExceptions)
ERROR: test_floordiv_int (numba.tests.npyufunc.test_errors.TestFloatingPointExceptions)
ERROR: test_implicit_broadcasting (numba.tests.npyufunc.test_ufunc.TestUFuncs)
ERROR: test_nested_call (numba.tests.npyufunc.test_ufuncbuilding.TestUfuncBuilding)
ERROR: test_nested_call_explicit (numba.tests.npyufunc.test_ufuncbuilding.TestUfuncBuilding)
ERROR: test_nested_call_explicit (numba.tests.npyufunc.test_ufuncbuilding.TestUfuncBuildingJitDisabled)
ERROR: test_nested_call (numba.tests.npyufunc.test_ufuncbuilding.TestUfuncBuildingJitDisabled)
ERROR: test_broadcasting (numba.tests.npyufunc.test_ufunc.TestUFuncs)
ERROR: test_basic_ufunc (numba.tests.npyufunc.test_ufuncbuilding.TestUfuncBuildingJitDisabled)
ERROR: test_basic_ufunc (numba.tests.npyufunc.test_ufuncbuilding.TestUfuncBuilding)
ERROR: test_power_float (numba.tests.npyufunc.test_errors.TestFloatingPointExceptions)
ERROR: test_remainder_float (numba.tests.npyufunc.test_errors.TestFloatingPointExceptions)
ERROR: test_remainder_int (numba.tests.npyufunc.test_errors.TestFloatingPointExceptions)
ERROR: test_truediv_float (numba.tests.npyufunc.test_errors.TestFloatingPointExceptions)
ERROR: test_scalar (numba.tests.npyufunc.test_dufunc.TestDUFunc)
ERROR: test_restricted (numba.tests.npyufunc.test_dufunc.TestDUFuncPickling)
ERROR: test_power_integer (numba.tests.npyufunc.test_errors.TestFloatingPointExceptions)
ERROR: test_truediv_integer (numba.tests.npyufunc.test_errors.TestFloatingPointExceptions)
ERROR: test_ufunc_forceobj (numba.tests.npyufunc.test_ufuncbuilding.TestUfuncBuilding)
ERROR: test_ufunc_attributes (numba.tests.npyufunc.test_ufunc.TestUFuncs)
ERROR: test_ufunc_raise (numba.tests.npyufunc.test_errors.TestExceptions)
ERROR: test_ufunc_forceobj (numba.tests.npyufunc.test_ufuncbuilding.TestUfuncBuildingJitDisabled)
ERROR: test_ufunc_props (numba.tests.npyufunc.test_dufunc.TestDUFunc)
ERROR: test_ufunc_raise_objmode (numba.tests.npyufunc.test_errors.TestExceptions)
ERROR: test_ufunc_struct (numba.tests.npyufunc.test_ufuncbuilding.TestUfuncBuilding)
ERROR: test_ufunc_struct (numba.tests.npyufunc.test_ufuncbuilding.TestUfuncBuildingJitDisabled)
ERROR: test_vectorize_objmode (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecor)
ERROR: test_vectorize_no_args (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecor)
ERROR: test_unrestricted (numba.tests.npyufunc.test_dufunc.TestDUFuncPickling)
ERROR: test_vectorize_bool_return (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecor)
ERROR: test_vectorize (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecor)
ERROR: test_3 (numba.tests.npyufunc.test_vectorize_decor.TestCPUVectorizeJitted)
ERROR: test_3 (numba.tests.npyufunc.test_vectorize_decor.TestCPUVectorizeDecor)
ERROR: test_1 (numba.tests.npyufunc.test_vectorize_decor.TestCPUVectorizeDecor)
ERROR: test_2 (numba.tests.npyufunc.test_vectorize_decor.TestCPUVectorizeDecor)
ERROR: test_1 (numba.tests.npyufunc.test_vectorize_decor.TestCPUVectorizeJitted)
ERROR: test_2 (numba.tests.npyufunc.test_vectorize_decor.TestCPUVectorizeJitted)
ERROR: test_4 (numba.tests.npyufunc.test_vectorize_decor.TestCPUVectorizeJitted)
ERROR: test_4 (numba.tests.npyufunc.test_vectorize_decor.TestCPUVectorizeDecor)
ERROR: test_target_cpu_nopython (numba.tests.npyufunc.test_vectorize_decor.TestVectorizeNopythonArg)
ERROR: test_target_cpu_nopython_no_sig (numba.tests.npyufunc.test_vectorize_decor.TestVectorizeNopythonArg)
ERROR: test_vectorize (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecorJitDisabled)
ERROR: test_vectorize_bool_return (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecorJitDisabled)
ERROR: test_vectorize_no_args (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecorJitDisabled)
ERROR: test_vectorize_output_kwarg (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecor)
ERROR: test_vectorize_objmode (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecorJitDisabled)
ERROR: test_vectorize_only_kws (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecor)
ERROR: test_vectorize_only_kws (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecorJitDisabled)
ERROR: test_vectorize_output_kwarg (numba.tests.npyufunc.test_ufuncbuilding.TestVectorizeDecorJitDisabled)
ERROR: test_ufunc_and_dufunc_calls (numba.tests.test_array_exprs.TestArrayExpressions)
ERROR: test_assignments (numba.tests.test_dataflow.TestDataFlow)
ERROR: test_assignments2 (numba.tests.test_dataflow.TestDataFlow)
ERROR: test_chained_compare_npm (numba.tests.test_dataflow.TestDataFlow)
ERROR: test_chained_compare (numba.tests.test_dataflow.TestDataFlow)
ERROR: test_vectorize (numba.tests.test_enums.TestIntEnum)
ERROR: test_vectorize (numba.tests.test_fastmath.TestFastMath)
ERROR: test_vectorize_explicit_signature (numba.tests.test_npdatetime.TestMiscCompiling)
ERROR: test_gitdiff (numba.tests.test_runtests.TestCase)
ERROR: test_type_inference (numba.tests.test_vectorization_type_inference.TestVectTypeInfer)
ERROR: test_issue_651 (numba.tests.test_ufuncs.TestUfuncIssues)
ERROR: test_issue_713 (numba.tests.test_ufuncs.TestUfuncIssues)
ERROR: test_direct_dufunc_cache (numba.tests.npyufunc.test_caching.TestDUfuncCacheTest)
ERROR: test_indirect_dufunc_cache (numba.tests.npyufunc.test_caching.TestDUfuncCacheTest)
ERROR: test_direct_ufunc_cache (numba.tests.npyufunc.test_caching.TestUfuncCacheTest)
ERROR: test_direct_ufunc_cache_objmode (numba.tests.npyufunc.test_caching.TestUfuncCacheTest)
ERROR: test_indirect_ufunc_cache (numba.tests.npyufunc.test_caching.TestUfuncCacheTest)
ERROR: test_threading_concurrent_mix_use_masks (numba.tests.test_parallel_backend.TestParallelBackend)
ERROR: test_threading_concurrent_mix_use (numba.tests.test_parallel_backend.TestParallelBackend)
ERROR: test_random_concurrent_mix_use (numba.tests.test_parallel_backend.TestParallelBackend)
ERROR: test_random_concurrent_mix_use_masks (numba.tests.test_parallel_backend.TestParallelBackend)
```


```
 cat NUMPY_LOG.txt | grep "FAIL"
FAIL: test_threading_concurrent_mix_use_masks_omp (numba.tests.test_parallel_backend.TestSpecificBackend)
FAILED (errors=1)
FAIL: test_threading_concurrent_mix_use_omp (numba.tests.test_parallel_backend.TestSpecificBackend)
FAILED (errors=1)
FAIL: test_random_concurrent_mix_use_omp (numba.tests.test_parallel_backend.TestSpecificBackend)
FAILED (errors=1)
FAIL: test_random_concurrent_mix_use_masks_omp (numba.tests.test_parallel_backend.TestSpecificBackend)
FAILED (errors=1)
FAIL: test_lock (numba.tests.test_ufuncs.TestUFuncCompilationThreadSafety)
FAILED (failures=5, errors=66, skipped=748, expected failures=13)
```

[NUMPY_LOG.txt](https://github.com/numba/numba/files/7889143/NUMPY_LOG.txt)

@esc Thanks for posting the log - I've created issues for each distinct type of error and added them to this issue. It's quite probable that some of them have a common root cause, but I've considered them all separately in case there are distinct causes.
@gmarkall thank you! I imagine we can proceed to work on this once the Numpy 1.22 packages become available via https://anaconda.org/anaconda/numpy/files -- so that we can integrate this into our build farm and commence automated testing.
After installing numba it downgrades numpy and then I get this error message:
```
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
---------------------------------------------------------------------------
```
Maybe in future versions, numba install could be adjusted to not break other installations?

Possibly this upgrade round is a special situations, but it does have undesired side effects.
> After installing numba it downgrades numpy and then I get this error message:
> 
> ```
> ---------------------------------------------------------------------------
> RuntimeError                              Traceback (most recent call last)
> RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe
> ---------------------------------------------------------------------------
> ```
> 
> Maybe in future versions, numba install could be adjusted to not break other installations?
> 
> Possibly this upgrade round is a special situations, but it does have undesired side effects.

@2sn thank you for your report. Which Python version are you using and on which platform did this occur? This error message is reminiscent of the one reported (and fixed) at: https://github.com/numba/numba/issues/7747 can you check if that fixes it for you too since this may now be a duplicate.
I use current release versions on Pypi, including Python 3.10.1.

What happens is as follows:  FIrst Numpy 1.22.x was installed, then numba numba becomes available, it downgrades numpy to 1.21.5, which has a different API version, but some things were already compiled with the new version and cached.  After de-installing numpy and numba, deleting cache, re-installation from Pypi, then it works.  Just not out of the box.
> I use current release versions on Pypi, including Python 3.10.1.
> 
> What happens is as follows: FIrst Numpy 1.22.x was installed, then numba numba becomes available, it downgrades numpy to 1.21.5, which has a different API version, but some things were already compiled with the new version and cached. After de-installing numpy and numba, deleting cache, re-installation from Pypi, then it works. Just not out of the box.

Thank you for your response @2sn . It sounds a bit weird. I am glad you managed to workaround the issue. If the issue returns or persists, please feel free to open a new issue with details, thank you!
I posted it in the hope the solution may be useful to others.  I have seen it on both, my linux install and on M1/MacOS 12.1.

For me it occured because I had already installed numpy 1.22.x before installing numba, which downgraded it, maybe still used the newer numpy version to compile numba. 
Unfortunately, Numba doesn't have control over how package managers (in this case, pip) decide to use Numba's version constraint on NumPy.  In this case, it sounds like pip downgraded NumPy without checking if the downgraded NumPy was still compatible with the other packages in your environment. 

Hopefully we can get NumPy 1.22 support working for Numba 0.56.
Whereas not sure, I think what must have happened is that it used the installed numpy to compile numba - which was 1.22 - before replacing it.

Resolving patch:
diff --git a/numba/misc/numba_sysinfo.py b/numba/misc/numba_sysinfo.py
--- a/numba/misc/numba_sysinfo.py
+++ b/numba/misc/numba_sysinfo.py
@@ -10,6 +10,7 @@
 from datetime import datetime
 from io import StringIO
 from subprocess import check_output, PIPE, CalledProcessError
+import numpy as np
 import llvmlite.binding as llvmbind
 from llvmlite import __version__ as llvmlite_version
 from numba import cuda as cu, __version__ as version_number
@@ -61,6 +62,12 @@
 _cu_nvidia_bindings = 'NVIDIA CUDA Bindings'
 _cu_nvidia_bindings_used = 'NVIDIA CUDA Bindings In Use'
 _cu_detect_out, _cu_lib_test = 'CUDA Detect Output', 'CUDA Lib Test'
+# NumPy info
+_numpy_version = 'NumPy Version'
+_numpy_supported_simd_features = 'NumPy Supported SIMD features'
+_numpy_supported_simd_dispatch = 'NumPy Supported SIMD dispatch'
+_numpy_supported_simd_baseline = 'NumPy Supported SIMD baseline'
+_numpy_AVX512_SKX_detected = 'NumPy AVX512_SKX detected'
 # SVML info
 _svml_state, _svml_loaded = 'SVML State', 'SVML Lib Loaded'
 _llvm_svml_patched = 'LLVM SVML Patched'
@@ -381,6 +388,23 @@ def get_sysinfo():
                 "(device and driver present, runtime problem?)\n"
                 f"(cuda) {type(e)}: {e}")
 
+    # NumPy information
+    sys_info[_numpy_version] = np.version.full_version
+    try:
+        # NOTE: These consts were added in NumPy 1.20
+        from numpy.core._multiarray_umath import (__cpu_features__,
+                                                  __cpu_dispatch__,
+                                                  __cpu_baseline__,)
+    except ImportError:
+        sys_info[_numpy_AVX512_SKX_detected] = False
+    else:
+        feat_filtered = [k for k, v in __cpu_features__.items() if v]
+        sys_info[_numpy_supported_simd_features] = feat_filtered
+        sys_info[_numpy_supported_simd_dispatch] = __cpu_dispatch__
+        sys_info[_numpy_supported_simd_baseline] = __cpu_baseline__
+        sys_info[_numpy_AVX512_SKX_detected] = \
+            __cpu_features__.get("AVX512_SKX", False)
+
     # SVML information
     # Replicate some SVML detection logic from numba.__init__ here.
     # If SVML load fails in numba.__init__ the splitting of the logic
@@ -569,6 +593,20 @@ class DisplaySeqMaps(tuple):
         ("CUDA Libraries Test Output:",),
         (info.get(_cu_lib_test, "None"),),
         ("",),
+        ("__NumPy Information__",),
+        ("NumPy Version", info.get(_numpy_version, '?')),
+        ("NumPy Supported SIMD features",
+         DisplaySeq(info.get(_numpy_supported_simd_features, [])
+                    or ('None found.',))),
+        ("NumPy Supported SIMD dispatch",
+         DisplaySeq(info.get(_numpy_supported_simd_dispatch, [])
+                    or ('None found.',))),
+        ("NumPy Supported SIMD baseline",
+         DisplaySeq(info.get(_numpy_supported_simd_baseline, [])
+                    or ('None found.',))),
+        ("NumPy AVX512_SKX support detected",
+         info.get(_numpy_AVX512_SKX_detected, '?')),
+        ("",),
         ("__SVML Information__",),
         ("SVML State, config.USING_SVML", info.get(_svml_state, '?')),
         ("SVML Library Loaded", info.get(_svml_loaded, '?')),
diff --git a/numba/np/arraymath.py b/numba/np/arraymath.py
--- a/numba/np/arraymath.py
+++ b/numba/np/arraymath.py
@@ -8,6 +8,7 @@
 from enum import IntEnum
 from functools import partial
 import operator
+import warnings
 
 import llvmlite.ir
 import numpy as np
@@ -27,7 +28,7 @@
 from numba.core.extending import intrinsic
 from numba.core.errors import (RequireLiteralValue, TypingError,
                                NumbaValueError, NumbaNotImplementedError,
-                               NumbaTypeError)
+                               NumbaTypeError, NumbaDeprecationWarning)
 from numba.core.overload_glue import glue_lowering
 from numba.cpython.unsafe.tuple import tuple_setitem
 
@@ -4135,14 +4136,36 @@ def histogram_impl(a, bins=10, range=None):
 iinfo = namedtuple('iinfo', _iinfo_supported)
 
 
-@overload(np.MachAr)
-def MachAr_impl():
-    f = np.MachAr()
-    _mach_ar_data = tuple([getattr(f, x) for x in _mach_ar_supported])
+# This module is imported under the compiler lock which should deal with the
+# lack of thread safety in the warning filter.
+def _gen_np_machar():
+    np122plus = numpy_version >= (1, 22)
+    w = None
+    with warnings.catch_warnings(record=True) as w:
+        msg = r'`np.MachAr` is deprecated \(NumPy 1.22\)'
+        warnings.filterwarnings("always", message=msg,
+                                category=DeprecationWarning,
+                                module=r'.*numba.*arraymath')
+        np_MachAr = np.MachAr
+
+    @overload(np_MachAr)
+    def MachAr_impl():
+        f = np_MachAr()
+        _mach_ar_data = tuple([getattr(f, x) for x in _mach_ar_supported])
+
+        if np122plus and w:
+            wmsg = w[0]
+            warnings.warn_explicit(wmsg.message.args[0],
+                                   NumbaDeprecationWarning,
+                                   wmsg.filename,
+                                   wmsg.lineno)
+
+        def impl():
+            return MachAr(*_mach_ar_data)
+        return impl
 
-    def impl():
-        return MachAr(*_mach_ar_data)
-    return impl
+
+_gen_np_machar()
 
 
 def generate_xinfo(np_func, container, attr):
diff --git a/numba/np/ufunc_db.py b/numba/np/ufunc_db.py
--- a/numba/np/ufunc_db.py
+++ b/numba/np/ufunc_db.py
@@ -230,9 +230,12 @@ def _fill_ufunc_db(ufunc_db):
         'QQ->Q': npyfuncs.np_int_udiv_impl,
         'ff->f': npyfuncs.np_real_floor_div_impl,
         'dd->d': npyfuncs.np_real_floor_div_impl,
-        'FF->F': npyfuncs.np_complex_floor_div_impl,
-        'DD->D': npyfuncs.np_complex_floor_div_impl,
     }
+    if numpy_version < (1, 22): # removed in 1.22+
+        ufunc_db[np.floor_divide].update({
+            'FF->F': npyfuncs.np_complex_floor_div_impl,
+            'DD->D': npyfuncs.np_complex_floor_div_impl,
+        })
 
     ufunc_db[np.remainder] = {
         'bb->b': npyfuncs.np_int_srem_impl,


Test patch:
diff --git a/buildscripts/condarecipe.local/run_test.sh b/buildscripts/condarecipe.local/run_test.sh
--- a/buildscripts/condarecipe.local/run_test.sh
+++ b/buildscripts/condarecipe.local/run_test.sh
@@ -7,6 +7,21 @@ export NUMBA_DISABLE_ERROR_MESSAGE_HIGHLIGHTING=1
 export NUMBA_CAPTURED_ERRORS="new_style"
 export PYTHONFAULTHANDLER=1
 
+# Disable NumPy dispatching to AVX512_SKX feature extensions if the chip is
+# reported to support the feature and NumPy >= 1.22 as this results in the use
+# of low accuracy SVML libm replacements in ufunc loops.
+_NPY_CMD='from numba.misc import numba_sysinfo;\
+          sysinfo=numba_sysinfo.get_sysinfo();\
+          print(sysinfo["NumPy AVX512_SKX detected"] and
+                sysinfo["NumPy Version"]>="1.22")'
+NUMPY_DETECTS_AVX512_SKX_NP_GT_122=$(python -c "$_NPY_CMD")
+echo "NumPy >= 1.22 with AVX512_SKX detected: $NUMPY_DETECTS_AVX512_SKX_NP_GT_122"
+
+if [[ "$NUMPY_DETECTS_AVX512_SKX_NP_GT_122" == "True" ]]; then
+    export NPY_DISABLE_CPU_FEATURES="AVX512_SKX"
+fi
+
+
 unamestr=`uname`
 if [[ "$unamestr" == 'Linux' ]]; then
   SEGVCATCH=catchsegv
diff --git a/buildscripts/incremental/test.sh b/buildscripts/incremental/test.sh
--- a/buildscripts/incremental/test.sh
+++ b/buildscripts/incremental/test.sh
@@ -26,6 +26,20 @@ export PYTHONFAULTHANDLER=1
 # enable new style error handling
 export NUMBA_CAPTURED_ERRORS="new_style"
 
+# Disable NumPy dispatching to AVX512_SKX feature extensions if the chip is
+# reported to support the feature and NumPy >= 1.22 as this results in the use
+# of low accuracy SVML libm replacements in ufunc loops.
+_NPY_CMD='from numba.misc import numba_sysinfo;\
+          sysinfo=numba_sysinfo.get_sysinfo();\
+          print(sysinfo["NumPy AVX512_SKX detected"] and
+                sysinfo["NumPy Version"]>="1.22")'
+NUMPY_DETECTS_AVX512_SKX_NP_GT_122=$(python -c "$_NPY_CMD")
+echo "NumPy >= 1.22 with AVX512_SKX detected: $NUMPY_DETECTS_AVX512_SKX_NP_GT_122"
+
+if [[ "$NUMPY_DETECTS_AVX512_SKX_NP_GT_122" == "True" ]]; then
+    export NPY_DISABLE_CPU_FEATURES="AVX512_SKX"
+fi
+
 # deal with threading layers
 if [ -z ${TEST_THREADING+x} ]; then
     echo "INFO: Threading layer not explicitly set."
diff --git a/numba/tests/support.py b/numba/tests/support.py
--- a/numba/tests/support.py
+++ b/numba/tests/support.py
@@ -4,6 +4,7 @@
 
 import cmath
 import contextlib
+from collections import defaultdict
 import enum
 import gc
 import math
@@ -1119,3 +1120,48 @@ def define_pipelines(self):
 
         pipeline.finalize()
         return [pipeline]
+
+
+def print_azure_matrix():
+    """This is a utility function that prints out the map of NumPy to Python
+    versions and how many of that combination are being tested across all the
+    declared config for azure-pipelines. It is useful to run when updating the
+    azure-pipelines config to be able to quickly see what the coverage is."""
+    import yaml
+    from yaml import Loader
+    base_path = os.path.dirname(os.path.abspath(__file__))
+    azure_pipe = os.path.join(base_path, '..', '..', 'azure-pipelines.yml')
+    if not os.path.isfile(azure_pipe):
+        self.skipTest("'azure-pipelines.yml' is not available")
+    with open(os.path.abspath(azure_pipe), 'rt') as f:
+        data = f.read()
+    pipe_yml = yaml.load(data, Loader=Loader)
+
+    templates = pipe_yml['jobs']
+    # first look at the items in the first two templates, this is osx/linux
+    py2np_map = defaultdict(lambda: defaultdict(int))
+    for tmplt in templates[:2]:
+        matrix = tmplt['parameters']['matrix']
+        for setup in matrix.values():
+            py2np_map[setup['NUMPY']][setup['PYTHON']]+=1
+
+    # next look at the items in the windows only template
+    winpath = ['..', '..', 'buildscripts', 'azure', 'azure-windows.yml']
+    azure_windows = os.path.join(base_path, *winpath)
+    if not os.path.isfile(azure_windows):
+        self.skipTest("'azure-windows.yml' is not available")
+    with open(os.path.abspath(azure_windows), 'rt') as f:
+        data = f.read()
+    windows_yml = yaml.load(data, Loader=Loader)
+
+    # There's only one template in windows and its keyed differently to the
+    # above, get its matrix.
+    matrix = windows_yml['jobs'][0]['strategy']['matrix']
+    for setup in matrix.values():
+        py2np_map[setup['NUMPY']][setup['PYTHON']]+=1
+
+    print("NumPy | Python | Count")
+    print("-----------------------")
+    for npver, pys in sorted(py2np_map.items()):
+        for pyver, count in pys.items():
+            print(f" {npver} |  {pyver:<4}  |   {count}")
diff --git a/numba/tests/test_dataflow.py b/numba/tests/test_dataflow.py
--- a/numba/tests/test_dataflow.py
+++ b/numba/tests/test_dataflow.py
@@ -89,17 +89,6 @@ class TestDataFlow(TestCase):
 
     def setUp(self):
         self.cache = CompilationCache()
-        # All tests here should run without warnings
-        self.w_cm = warnings.catch_warnings()
-        self.w_cm.__enter__()
-        warnings.simplefilter("error")
-        # some builds of NumPy use a Cython that reports spurious
-        # ufunc object size mismatch warnings.  These are safe to
-        # ignore and not generated by later Cython versions.
-        warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
-
-    def tearDown(self):
-        self.w_cm.__exit__(None, None, None)
 
     def test_assignments(self, flags=force_pyobj_flags):
         pyfunc = assignments
diff --git a/numba/tests/test_np_functions.py b/numba/tests/test_np_functions.py
--- a/numba/tests/test_np_functions.py
+++ b/numba/tests/test_np_functions.py
@@ -4,6 +4,7 @@
 import math
 import platform
 from functools import partial
+import warnings
 
 import numpy as np
 
@@ -12,12 +13,12 @@
 from numba.core import types
 from numba.typed import List, Dict
 from numba.np.numpy_support import numpy_version
-from numba.core.errors import TypingError
+from numba.core.errors import TypingError, NumbaDeprecationWarning
 from numba.core.config import IS_WIN32, IS_32BITS
 from numba.core.utils import pysignature
 from numba.np.extensions import cross2d
 from numba.tests.support import (TestCase, CompilationCache, MemoryLeakMixin,
-                                 needs_blas)
+                                 needs_blas, needs_subprocess)
 import unittest
 
 
@@ -4794,6 +4795,32 @@ def test_iinfo(self):
             cfunc = jit(nopython=True)(iinfo)
             cfunc(np.float64(7))
 
+    @unittest.skipUnless(numpy_version >= (1, 22), "Needs NumPy >= 1.22")
+    @needs_subprocess
+    def test_np_MachAr_deprecation_np122_impl(self):
+        # Tests that Numba is replaying the NumPy 1.22 deprecation warning
+        # raised on the getattr of 'MachAr' on the NumPy module.
+        # Needs to be run in a subprocess as the warning is generated from the
+        # typing part of the `np.MachAr` overload, which may already have been
+        # executed for the given types and so an empty in memory cache is
+        # needed.
+        msg = r'`np.MachAr` is deprecated \(NumPy 1.22\)'
+        with warnings.catch_warnings(record=True) as w:
+            warnings.filterwarnings("always", message=msg,
+                                    category=NumbaDeprecationWarning,)
+            f = njit(lambda : np.MachAr().eps)
+            f()
+
+        self.assertEqual(len(w), 1)
+        self.assertIn('`np.MachAr` is deprecated', str(w[0]))
+
+    @unittest.skipUnless(numpy_version >= (1, 22), "Needs NumPy >= 1.22")
+    def test_np_MachAr_deprecation_np122(self):
+        test_name = 'test_np_MachAr_deprecation_np122_impl'
+        self.subprocess_test_runner(test_module=self.__module__,
+                                    test_class=type(self).__name__,
+                                    test_name=test_name,)
+
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/numba/tests/test_sysinfo.py b/numba/tests/test_sysinfo.py
--- a/numba/tests/test_sysinfo.py
+++ b/numba/tests/test_sysinfo.py
@@ -33,6 +33,7 @@ def setUp(self):
                 nsi._python_impl,
                 nsi._python_version,
                 nsi._llvm_version,
+                nsi._numpy_version,
             ),
             bool: (
                 nsi._cu_dev_init,
@@ -43,6 +44,7 @@ def setUp(self):
                 nsi._tbb_thread,
                 nsi._openmp_thread,
                 nsi._wkq_thread,
+                nsi._numpy_AVX512_SKX_detected,
             ),
             list: (
                 nsi._errors,
diff --git a/numba/tests/test_ufuncs.py b/numba/tests/test_ufuncs.py
--- a/numba/tests/test_ufuncs.py
+++ b/numba/tests/test_ufuncs.py
@@ -1277,6 +1277,8 @@ def foo(x1, x2):
         b = np.arange(10, dtype='f8')
         self.assertPreciseEqual(foo(a, b), (a + b) + (a + b))
 
+    @unittest.skipIf(numpy_support.numpy_version >= (1, 22),
+                     "Complex floor division support removed in NumPy 1.22")
     def test_issue_713(self):
         def foo(x,y):
             return np.floor_divide(x,y)