-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Wrong list result with parallel=True despite no resizing and no cross-thread access of the list #9529
Comments
EDIT - to clarify, Soeren is of course correct. The below is what seems to be happening, even though it shouldn't. If you look at the prange semantics here and search for "allocation hoisting", you can see that the array allocated by Replacing To fix your issue, you should avoid treating objects returned by Not sure if this is still a bug in numba or not though - the behaviour does seem pretty unexpected and not-transparent. |
From my understanding of the documentation, allocation hoisting is supposed to only be done when it doesn't change the semantics of the code, i.e., the link you posted is not a description of how semantics change in the presence of prange, but a description of techniques that numba uses to make it more efficient.
|
I believe this is an invalid hoisting. out = np.zeros(1)
out[0] = i
# The line below should have prevented the hoisting as the reference is captured
outputs[i] = (inputs[i], out) (CC @DrTodd13) |
Reporting a bug
visible in the release notes
(https://numba.readthedocs.io/en/stable/release-notes-overview.html).
i.e. it's possible to run as 'python bug.py'.
prints
The output of the
weird
function is aList[(Dict, array)]
, and each array is supposed to just hold the corresponding loop index.In the non-parallel execution the zeroth entry of the output list is
(somedict, [0.0])
, as it should.In the parallel execution, the zeroth entry of the out output list is incorrectly equal to the first entry of the output list,
(somedict, [1.0])
.This stops happening if
9
to an8
(on my laptop with 8 logical cores)Dict
component of theoutputs
tuples.PS: I'd appreciate if you know of a way to circumvent this in the meantime. In my real problem, I have quite the messy datatype in the list.
Python version: '3.12.2 (main, Feb 25 2024, 16:36:57) [GCC 9.4.0]'
numba version: 0.59.1
numpy version: 1.26.4
OS: NAME="Ubuntu" VERSION="20.04.6 LTS (Focal Fossa)"
The text was updated successfully, but these errors were encountered: