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

Add read_events and write_events to Array #616

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alexfikl
Copy link
Contributor

@alexfikl alexfikl commented Oct 2, 2022

Takes care of the first point from #303.

  • Adds a read_events and write_events to Array.
  • Teaches all the functions in cl.array to use those and not wait on read events when they don't need to.
  • Teaches all the functions in cl.clmath to play nice as well
  • The rest of the code just does a straight port form events -> write_events. This still needs work.

TODO:

  • Needs corresponding loopy change

@alexfikl alexfikl force-pushed the war-events branch 4 times, most recently from 372671e to d05756d Compare October 3, 2022 17:39
@alexfikl
Copy link
Contributor Author

alexfikl commented Oct 3, 2022

@inducer This should be in a non-horrible state now. Can you take a quick look to see if it's doing what you had in mind?

From going through it, it seems like several things still need work

  • elwise_kernel_runner could probably add to write_events for the first arg and to read_events for the rest of them, so we don't clutter all the rest of the code. Does that sound reasonable?
  • It seems to me that something like an C = AXPBY would need wait for read_events on C and write_events on A and B. Does that sound right? (+ similar logic for the other elementwise kernels)

@alexfikl alexfikl force-pushed the war-events branch 4 times, most recently from 456b628 to e2819b6 Compare October 3, 2022 19:33
@inducer
Copy link
Owner

inducer commented Oct 3, 2022

  • elwise_kernel_runner could probably add to write_events for the first arg and to read_events for the rest of them, so we don't clutter all the rest of the code. Does that sound reasonable?

Does.

  • It seems to me that something like an C = AXPBY would need wait for read_events on C and write_events on A and B. Does that sound right? (+ similar logic for the other elementwise kernels)

The way I see it, it wouldn't have to wait on read_events, because read-after-read does not need synchronization. Or am I missing something?

@alexfikl
Copy link
Contributor Author

alexfikl commented Oct 4, 2022

The way I see it, it wouldn't have to wait on read_events, because read-after-read does not need synchronization. Or am I missing something?

In that example, C would be a write-after-read, right? That's why I was thinking that all the reads should finish before it gets modified.

@inducer
Copy link
Owner

inducer commented Oct 4, 2022

  • It seems to me that something like an C = AXPBY would need wait for read_events on C and write_events on A and B. Does that sound right? (+ similar logic for the other elementwise kernels)

C would need to wait for read_events and write_events, unless you'd make the two subsets of each other.

@alexfikl alexfikl force-pushed the war-events branch 7 times, most recently from 7bb4980 to d261472 Compare October 6, 2022 08:37
@alexfikl alexfikl marked this pull request as ready for review October 6, 2022 08:39
@alexfikl
Copy link
Contributor Author

alexfikl commented Oct 6, 2022

@inducer This should be ready for a look. It could probably use some more tests, but I'm not quite sure what we can do there. Any ideas?

@alexfikl alexfikl force-pushed the war-events branch 3 times, most recently from 27f78a4 to 4f5a2fe Compare October 13, 2022 07:09
pyopencl/invoker.py Show resolved Hide resolved
pyopencl/invoker.py Show resolved Hide resolved
@alexfikl
Copy link
Contributor Author

@inducer This is the macos error I was worried about
https://github.com/inducer/pyopencl/actions/runs/3210604562/jobs/5248179538
but it seems to be happening on other branches as well, e.g.
https://github.com/inducer/pyopencl/actions/runs/3254926391/jobs/5343705664
so it's likely no biggie (?). With that in mind, I feel better about this not introducing any cool new bugs :D

pyopencl/array.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants