Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH: NpyIter: add a flag to handle read/write operand overlap #8026

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

Closed
wants to merge 2 commits into from

Conversation

pv
Copy link
Member

@pv pv commented Sep 6, 2016

Add a new NPY_ITER_COPY_IF_OVERLAP iterator flag to NpyIter, which
instructs it to check if read operands overlap with write operands in
memory, and make temporary copies to eliminate detected overlap.

Thanks to @seberg (whose code it mostly is).

The idea here is to approach gh-6272 in small steps --- I've been looking at what changes are needed to deal with it everywhere, and I think it will go better if done in small side-effect free pieces. (The rest here).

@seberg
Copy link
Member

seberg commented Sep 7, 2016

Oh, wow you figered out how to do it right, I guess :)! I want to stil read it carefullyonce, but I guess we can pretty much put this in and then the next step should be ufuncs. Goodbye a += a.T ;).

i = nditer([a, b], ['copy_if_overlap'], [['readonly'], ['readwrite']])
assert_(not np.shares_memory(*i.operands))

# Copy not needed, 2 ops, no overlap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment slightly off, overlap but identical.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But ok...

@seberg
Copy link
Member

seberg commented Sep 7, 2016

OK, since its new API, just wrote a mail to the list (not that I expect much feedback). Might be good to add a release note (which would probably keep growing with more changes).

Add a new NPY_ITER_COPY_IF_OVERLAP iterator flag to NpyIter, which
instructs it to check if read operands overlap with write operands in
memory, and make temporary copies to eliminate detected overlap.

Thanks to Sebastian Berg.
@pv
Copy link
Member Author

pv commented Sep 11, 2016

Closing, maybe better to discuss as a part of gh-8043

@pv pv closed this Sep 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants