-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6335 from stuartarchibald/wip/enable_more_vectori…
…zation_1 Split optimisation passes.
- Loading branch information
Showing
2 changed files
with
54 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import numpy as np | ||
from numba import njit, types | ||
from unittest import TestCase | ||
from numba.tests.support import override_env_config | ||
|
||
_DEBUG = False | ||
if _DEBUG: | ||
from llvmlite import binding as llvm | ||
# Prints debug info from the LLVMs vectorizer | ||
llvm.set_option("", "--debug-only=loop-vectorize") | ||
|
||
|
||
class TestVectorization(TestCase): | ||
""" | ||
Tests to assert that code which should vectorize does indeed vectorize | ||
""" | ||
def gen_ir(self, func, args_tuple, **flags): | ||
with override_env_config( | ||
"NUMBA_CPU_NAME", "skylake-avx512" | ||
), override_env_config("NUMBA_CPU_FEATURES", ""): | ||
jobj = njit(**flags)(func) | ||
jobj.compile(args_tuple) | ||
ol = jobj.overloads[jobj.signatures[0]] | ||
return ol.library.get_llvm_str() | ||
|
||
def test_nditer_loop(self): | ||
# see https://github.com/numba/numba/issues/5033 | ||
def do_sum(x): | ||
acc = 0 | ||
for v in np.nditer(x): | ||
acc += v.item() | ||
return acc | ||
|
||
llvm_ir = self.gen_ir(do_sum, (types.float64[::1],), fastmath=True) | ||
self.assertIn("vector.body", llvm_ir) | ||
self.assertIn("llvm.loop.isvectorized", llvm_ir) |