-
Notifications
You must be signed in to change notification settings - Fork 44
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
remove multiple exit from prange #1901
Conversation
closes #1900 Signed-off-by: Edoardo Pasca <14138589+paskino@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you break
in a prange
to stop all other threads?
I couldn't find any documentation about breaking a prange, did you? |
No, which is why I asked... |
The following code seems to suggest that import numba as nb
import numpy as np
@nb.njit(parallel=True)
def break_prange(x, n):
accumulator = np.zeros(nb.get_num_threads(), dtype=np.float64)
for i in nb.prange(x.size):
if i > n:
break
else:
accumulator[i] = i
return accumulator
x = np.arange(nb.get_num_threads() + 10)
x = np.asarray(x, dtype=np.float32)
y = break_prange(x,10)
print (y) it returns
Swapping |
Signed-off-by: Edoardo Pasca <14138589+paskino@users.noreply.github.com>
Signed-off-by: Edoardo Pasca <14138589+paskino@users.noreply.github.com>
Signed-off-by: Edoardo Pasca <14138589+paskino@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Edo, this looks sensible to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change log needs to move to 24.3.0 rather than the released 24.2. Otherwise it looks good to me.
Description
Changes
accumulator
array with each array adding to a location within it depending on thethread_id
accumulator
arraynp.inf
using a single int. Numba might be doing some atomic checks for writing to that int, but race conditions may happen very seldom (after discussion with @gfardell )Testing you performed
Related issues/links
Checklist
Contribution Notes
Please read and adhere to the developer guide and local patterns and conventions.