Skip to content

Commit

Permalink
Merge pull request numba#8852 from stuartarchibald/wip/slp_disabled_b…
Browse files Browse the repository at this point in the history
…y_default

Disable SLP vectorisation due to miscompilations.
  • Loading branch information
sklam authored Mar 27, 2023
2 parents f202a87 + 09caec1 commit 24b7628
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion docs/source/reference/envvars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,10 @@ Compilation options
.. envvar:: NUMBA_SLP_VECTORIZE

If set to non-zero, enable LLVM superword-level parallelism vectorization.
Note that use of this feature has occasionally resulted in LLVM producing
miscompilations, hence it is off by default.

*Default value:* 1
*Default value:* 0

.. envvar:: NUMBA_ENABLE_AVX

Expand Down
5 changes: 3 additions & 2 deletions numba/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,9 @@ def optional_str(x):
LOOP_VECTORIZE = _readenv("NUMBA_LOOP_VECTORIZE", int,
not (IS_WIN32 and IS_32BITS))

# Switch on superword-level parallelism vectorization, default is on.
SLP_VECTORIZE = _readenv("NUMBA_SLP_VECTORIZE", int, 1)
# Enable superword-level parallelism vectorization, default is off
# since #8705 (miscompilation).
SLP_VECTORIZE = _readenv("NUMBA_SLP_VECTORIZE", int, 0)

# Force dump of generated assembly
DUMP_ASSEMBLY = _readenv("NUMBA_DUMP_ASSEMBLY", int, DEBUG)
Expand Down
13 changes: 10 additions & 3 deletions numba/tests/test_vectorization.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import platform
import numpy as np
from numba import types
from unittest import TestCase, skipIf
from numba.tests.support import override_env_config
import unittest
from numba.tests.support import override_env_config, TestCase
from numba.core.compiler import compile_isolated, Flags
from numba.core.cpu_options import FastMathOptions

Expand All @@ -13,7 +13,7 @@
llvm.set_option("", "--debug-only=loop-vectorize")


@skipIf(platform.machine() != 'x86_64', 'x86_64 only test')
@unittest.skipIf(platform.machine() != 'x86_64', 'x86_64 only test')
class TestVectorization(TestCase):
"""
Tests to assert that code which should vectorize does indeed vectorize
Expand All @@ -40,6 +40,9 @@ def do_sum(x):
self.assertIn("vector.body", llvm_ir)
self.assertIn("llvm.loop.isvectorized", llvm_ir)

# SLP is off by default due to miscompilations, see #8705. Put this into a
# subprocess to isolate any potential issues.
@TestCase.run_test_in_subprocess(envvars={'NUMBA_SLP_VECTORIZE': '1'})
def test_slp(self):
# Sample translated from:
# https://www.llvm.org/docs/Vectorizers.html#the-slp-vectorizer
Expand Down Expand Up @@ -71,3 +74,7 @@ def sum_sqrt_list(lst):
fastmath=True)
self.assertIn("vector.body", llvm_ir)
self.assertIn("llvm.loop.isvectorized", llvm_ir)


if __name__ == '__main__':
unittest.main()

0 comments on commit 24b7628

Please sign in to comment.