pyopencl icon indicating copy to clipboard operation
pyopencl copied to clipboard

Add events to ElementwiseKernel args

Open alexfikl opened this issue 3 years ago • 1 comments

This is what I was trying to ask today, i.e. if the input / output args of ElementwiseKernel get the event that gets generated. Currently they do not. Should they?

For context, this is about removing the manual event handling in boxtree for something like the GappyCopyAndMapKernel https://github.com/inducer/boxtree/blob/529e8d62f365350a80c9f16a0b12b9fb2c1a140e/boxtree/tools.py#L453-L509 which has a bunch of arguments.

alexfikl avatar Sep 16 '22 17:09 alexfikl

Hmm, thanks for the reminder. #303 is related. One complexity here is that ElementwiseKernel (at least without additional help) has no way to find out which array is being written. Tthough, in keeping with #303, read-after-write and write-after-read are also real dependencies. Part of me feels that we should just unconditionally add events to everything (reads and writes), but then another part of me would like to start tackling #303 first, by separating read events and write events.

inducer avatar Sep 16 '22 23:09 inducer

You closed this, but didn't leave a comment. Could you explain?

inducer avatar Sep 30 '22 22:09 inducer

@inducer From your comment, it seemed like #303 is needed before anything useful can be done here. And adding events unconditionally could also be done in boxtree as a stopgap, so I didn't think this was needed.

Do you think it would be better to do something like that (maybe under a flag) for the various kernel classes in here?

alexfikl avatar Oct 01 '22 04:10 alexfikl

I'm not sure it makes sense to clutter up boxtree with event management code. I think the desired goal state, from my perspective, would be to have array events split into read and write, and for that to be an effective change, for arguments to ElementwiseKernel to declare whether they're reading or writing. At that point, boxtree would need to be updated to declare read/write, and we could call this done. I'll reopen this to track that change. Sound fair?

inducer avatar Oct 01 '22 17:10 inducer

Or... since this is a PR, maybe not. I'll reclose it and make an issue. Sorry about the back-and-forth.

inducer avatar Oct 01 '22 17:10 inducer

Even better. I'll add this as an item under #303.

inducer avatar Oct 01 '22 17:10 inducer

Sound fair?

Yeah, that sounds like a good plan to me!

alexfikl avatar Oct 02 '22 11:10 alexfikl