Skip to content

Defines TaggableCLArray - #111

Merged
inducer merged 6 commits into
inducer:mainfrom
kaushikcfd:taggable_pt_array_axes
Feb 15, 2022
Merged

Defines TaggableCLArray#111
inducer merged 6 commits into
inducer:mainfrom
kaushikcfd:taggable_pt_array_axes

Conversation

@kaushikcfd

@kaushikcfd kaushikcfd commented Oct 20, 2021

Copy link
Copy Markdown
Collaborator

@kaushikcfd
kaushikcfd force-pushed the taggable_pt_array_axes branch from 1b97811 to a5a22b1 Compare November 1, 2021 05:09
@kaushikcfd kaushikcfd changed the title Taggable pt array axes Allowing taggable frozen PytatoArrayContext arrays and tagging pt arrays' axes Nov 1, 2021
@kaushikcfd
kaushikcfd force-pushed the taggable_pt_array_axes branch from a5a22b1 to cb7eaee Compare November 1, 2021 18:47
@kaushikcfd
kaushikcfd force-pushed the taggable_pt_array_axes branch from cb7eaee to 7e27d1b Compare November 18, 2021 05:55
@kaushikcfd
kaushikcfd force-pushed the taggable_pt_array_axes branch 5 times, most recently from db03d5f to 3e9fa62 Compare January 14, 2022 01:07
@kaushikcfd kaushikcfd changed the title Allowing taggable frozen PytatoArrayContext arrays and tagging pt arrays' axes Defines TaggableCLArray Jan 14, 2022
@kaushikcfd
kaushikcfd requested a review from inducer January 14, 2022 01:08
@kaushikcfd
kaushikcfd marked this pull request as ready for review January 14, 2022 01:09
@kaushikcfd
kaushikcfd force-pushed the taggable_pt_array_axes branch from 3e9fa62 to 09c3ad3 Compare January 14, 2022 01:24

@inducer inducer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! Some thoughts from a first scroll below.

Comment thread arraycontext/impl/pyopencl/taggable_cl_array.py Outdated
Comment thread arraycontext/impl/pyopencl/taggable_cl_array.py Outdated
Comment thread arraycontext/impl/pyopencl/taggable_cl_array.py Outdated
Comment thread arraycontext/impl/pyopencl/__init__.py
Comment thread arraycontext/impl/pytato/__init__.py Outdated
@inducer

inducer commented Jan 15, 2022

Copy link
Copy Markdown
Owner

Unsubscribing... @-mention or request review once it's ready for a look or needs attention.

@kaushikcfd
kaushikcfd force-pushed the taggable_pt_array_axes branch 2 times, most recently from 295f82d to 97cbed9 Compare January 15, 2022 02:48
@kaushikcfd
kaushikcfd requested a review from inducer January 15, 2022 02:50
@kaushikcfd

Copy link
Copy Markdown
Collaborator Author

Tests should pass once inducer/pyopencl#531 (or something equivalent) lands.

@alexfikl

Copy link
Copy Markdown
Collaborator

Any chance this works with pytential too? That has a very "interesting" combination of using array contexts and direct calls to pyopencl, which is easy to break.

Maybe worth adding to the CI?

@kaushikcfd

Copy link
Copy Markdown
Collaborator Author

and direct calls to pyopencl

🤢

Thanks, added a CI here: kaushikcfd/pytential#1. Will see if anything "interesting" pops up.

@kaushikcfd

Copy link
Copy Markdown
Collaborator Author

@alexfikl: Thanks for catching that.

===== 136 failed, 65 passed, 1 skipped, 385 warnings in 828.91s (0:13:48) ======

There are quite a few failures in pytential.

Probably not a smart thing to require this type. So there are a couple of options I can do here:

  1. Fix pytential to not do this. (Unsure how involved this would be)
  2. Just keep this limited to PytatoPyOpenCLArrayContext.

@alexfikl

Copy link
Copy Markdown
Collaborator

@alexfikl: Thanks for catching that.

===== 136 failed, 65 passed, 1 skipped, 385 warnings in 828.91s (0:13:48) ======

There are quite a few failures in pytential.

Not bad! 🚀

Probably not a smart thing to require this type. So there are a couple of options I can do here:
1. Fix pytential to not do this. (Unsure how involved this would be)
2. Just keep this limited to PytatoPyOpenCLArrayContext.

I imagine it would be quite a bit of work to get pytential to work. Besides calling pyopencl.array directly, it also calls loopy directly (without actx.call_loopy) and a few algorithms from pyopencl (ElementwiseKernel?).. so, yeah, a bit of work!

Would it be possible to just have the pyopencl array context handle both the tagged and untagged arrays?

@kaushikcfd
kaushikcfd force-pushed the taggable_pt_array_axes branch from 97cbed9 to f4d1eb4 Compare January 15, 2022 04:38
@kaushikcfd

Copy link
Copy Markdown
Collaborator Author

I imagine it would be quite a bit of work to get pytential to work. Besides calling pyopencl.array directly, it also calls loopy directly (without actx.call_loopy) and a few algorithms from pyopencl (ElementwiseKernel?).. so, yeah, a bit of work!

Ah, thanks! Yep, I'll just go with not requiring TaggableCLArray in PyOpenCLArrayContext.

@kaushikcfd
kaushikcfd force-pushed the taggable_pt_array_axes branch 2 times, most recently from d26faf5 to 9f4f766 Compare January 15, 2022 17:45
@kaushikcfd

kaushikcfd commented Jan 15, 2022

Copy link
Copy Markdown
Collaborator Author

not requiring TaggableCLArray in PyOpenCLArrayContext.

Yep, doing that seems to fix the CIs in pytential as well! (Thanks!)

This PR is ready for review.

@kaushikcfd
kaushikcfd force-pushed the taggable_pt_array_axes branch 2 times, most recently from c78083c to 3355f1c Compare January 21, 2022 16:43

@inducer inducer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! Good to go after these fixes.

Comment thread arraycontext/impl/pyopencl/taggable_cl_array.py Outdated
tags=tags, axes=axes)
else:
new_with_queue = super().copy(queue=queue)
return self.__class__(None, new_with_queue.shape,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Is the code duplication of the two constructor calls here avoidable? (Maybe by setting a base_instance variable?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Indeed, using base_instance was helpful.

Comment thread arraycontext/impl/pyopencl/taggable_cl_array.py Outdated
Comment thread arraycontext/impl/pytato/__init__.py
Comment on lines +117 to +127
return TaggableCLArray(None, ary.shape,
ary.dtype,
allocator=ary.allocator,
strides=ary.strides,
data=ary.base_data,
offset=ary.offset,
events=ary.events, _fast=True,
_context=ary.context,
_queue=ary.queue, _size=ary.size,
axes=axes,
tags=tags)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't love the idea of hardcoding so much of the internal structure of cla.Array here. Is there a copy method in Array that we could use instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not quite, see cla.Array.copy. But tried to avoid the duplication by invoking TaggableCLArray.copy. So there's only one source location where we rely on the structure on cl.array.Array.__init__'s signature.

Comment thread arraycontext/impl/pytato/__init__.py
@kaushikcfd
kaushikcfd force-pushed the taggable_pt_array_axes branch 3 times, most recently from dc5c01b to f273e3d Compare February 8, 2022 20:31
@kaushikcfd
kaushikcfd requested a review from inducer February 8, 2022 20:32

@inducer inducer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! LGTM once these few concerns are addressed.

Comment thread arraycontext/impl/pyopencl/__init__.py
Comment thread arraycontext/impl/pyopencl/__init__.py
Comment thread arraycontext/impl/pytato/__init__.py
Comment thread arraycontext/impl/pytato/compile.py
@inducer

inducer commented Feb 15, 2022

Copy link
Copy Markdown
Owner

LGTM, thanks!

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.

3 participants