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
Numba appears to merge consecutive prange calls #8515
Comments
Thanks for the report @adetunji-david. Which Numba version are you using? I think that #7864 may have fixed this issue, the first version it is present in is Numba 0.56.0. |
@stuartarchibald |
Thanks for confirming @adetunji-david. I've been using this as a possible reproducer: from numba import njit, prange
import numpy as np
@njit
def work():
x = 0.0
for k in range(100):
x += np.random.standard_normal()
return x
@njit(parallel=True)
def foo(n):
r = np.zeros(n, dtype=np.intp)
c = np.zeros(n, dtype=np.intp)
for i in prange(n):
for j in range(i):
work()
c[i] += 1
for i in prange(n):
if i == 0:
continue
r[i] = c[i] - c[i - 1]
return r[1:]
print(foo(15))
foo.parallel_diagnostics(level=4) running this on
the loop fusion algorithm reports that |
During the issue triage meeting this week @guilhermeleobas managed to get this to reproduce locally with the OP issue against |
Reporting a bug
visible in the change log (https://github.com/numba/numba/blob/main/CHANGE_LOG).
i.e. it's possible to run as 'python bug.py'.
Consider the following code that uses parallelization to create a range from
0 - 15
and subtracts each element from the previous element in the array.This prints
The expected result is an array of
1
s, but the parallelized variant without any intervening code between the prange blocks gives an incorrect result that changes with each invocation.The text was updated successfully, but these errors were encountered: