Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6102. Problem with non-unique label. #6116

Merged
merged 3 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions numba/parfors/parfor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2700,6 +2700,9 @@ class ParforPass(ParforPassStates):
def _pre_run(self):
# run array analysis, a pre-requisite for parfor translation
self.array_analysis.run(self.func_ir.blocks)
# NOTE: Prepare _max_label. See #6102
ir_utils._max_label = max(ir_utils._max_label,
ir_utils.find_max_label(self.func_ir.blocks))

def run(self):
"""run parfor conversion pass: replace Numpy calls
Expand Down
23 changes: 22 additions & 1 deletion numba/tests/test_parfors.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from numba.tests.support import (TestCase, captured_stdout, MemoryLeakMixin,
override_env_config, linux_only, tag,
skip_parfors_unsupported, _32bit, needs_blas,
needs_lapack, disabled_test)
needs_lapack, disabled_test, skip_unless_scipy)
import cmath
import unittest

Expand Down Expand Up @@ -3102,6 +3102,27 @@ def test_impl(d, k):

self.check(test_impl, d, k)

@skip_parfors_unsupported
@skip_unless_scipy
def test_issue6102(self):
# The problem is originally observed on Python3.8 because of the
# changes in how loops are represented in 3.8 bytecode.
@njit(parallel=True)
def f(r):
for ir in prange(r.shape[0]):
dist = np.inf
tr = np.array([0, 0, 0], dtype=np.float32)
for i in [1, 0, -1]:
dist_t = np.linalg.norm(r[ir, :] + i)
if dist_t < dist:
dist = dist_t
tr = np.array([i, i, i], dtype=np.float32)
r[ir, :] += tr
return r

r = np.array([[0., 0., 0.], [0., 0., 1.]])
self.assertPreciseEqual(f(r), f.py_func(r))


class TestParforsOptions(TestParforsBase):

Expand Down