Skip to content

Conversation

@isuruf
Copy link
Collaborator

@isuruf isuruf commented May 10, 2022

Adds a _disable_translation_classes hidden option so that we can check the non translation classes kernel.

@isuruf isuruf force-pushed the translation_classes_data branch from 2fde1ff to aa51f8d Compare May 10, 2022 00:09
@inducer inducer enabled auto-merge (rebase) May 10, 2022 00:16
@inducer
Copy link
Owner

inducer commented May 10, 2022

Thx!

sumpy/fmm.py Outdated
Comment on lines 361 to 363
with cl.CommandQueue(self.tree_indep.cl_context) as queue:
translation_classes_data = SumpyTranslationClassesData(queue,
self.traversal)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does this work? Doesn't the queue get destroyed when it exits the context manager leaving SumpyTranslationClassesData holding an invalid reference?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the queue completes and gets destroyed, but the data itself doesn't get destroyed. i.e. the data has queue=None. When a new queue needs this data, they are accessed with .with_queue(queue)

Copy link
Collaborator

@alexfikl alexfikl May 10, 2022

Choose a reason for hiding this comment

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

sumpy/sumpy/fmm.py

Lines 244 to 249 in a2c830a

def __init__(self, queue, trav, is_translation_per_level=True):
# FIXME: Queues should not be part of data.
self.queue = queue
self.trav = trav
self.tree = trav.tree
self.is_translation_per_level = is_translation_per_level

Hm, but the constructor doesn't do any work. The actual work is being done when calling some of those memoized methods below, which should be after the context manager exits.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The tests don't seem to crash and burn, so this is probably just some misunderstanding on my side. Hm..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, you are right. I guess since the constructor keeps a reference to the queue, it doesn't get destroyed.

Copy link
Owner

Choose a reason for hiding this comment

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

I'll try to come up with a way to make PyOpenCL warn if a reference to the queue continues to be held past __exit__.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That would be really cool!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed the implementation to build the data objects eagerly instead of lazily.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't speak for the eager vs lazy, but the queue stuff makes sense to me now 👍

Copy link
Owner

Choose a reason for hiding this comment

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

@isuruf isuruf disabled auto-merge May 10, 2022 00:44
@inducer
Copy link
Owner

inducer commented May 12, 2022

LGTM, thanks!

@isuruf isuruf deleted the translation_classes_data branch May 13, 2022 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants