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 support for execution spaces instances #209

Merged
merged 17 commits into from
Oct 26, 2023

Conversation

NaderAlAwar
Copy link
Contributor

No description provided.

@NaderAlAwar NaderAlAwar requested a review from gliga October 25, 2023 23:13
@NaderAlAwar NaderAlAwar merged commit 8545ae4 into kokkos:main Oct 26, 2023
4 of 5 checks passed
s1 = cp.cuda.Stream()
s2 = cp.cuda.Stream()

instance1 = pk.ExecutionSpaceInstance(space, s1)
Copy link
Contributor

Choose a reason for hiding this comment

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

ExecutionSpaceInstance => ExecutionSpace

Copy link
Contributor

Choose a reason for hiding this comment

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

if we are instantiating a stream on top of a space, we could also go with space.make(stream). (And potentially have also a version that does not accept a stream but uses a new stream for each call.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does seem like a better interface. I'll address this in a new PR

if __name__ == "__main__":
space = pk.Cuda

s1 = cp.cuda.Stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use pk.Stream to avoid importing cupy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The motivation here is that users might have pre-existing CuPy code they want to integrate with pykokkos, and this example shows how.

Copy link
Contributor

Choose a reason for hiding this comment

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

but the example only uses cupy to create streams not to use cupy arrays; would be good to then use cupy for all parts

@@ -311,7 +312,7 @@ def generate_call(operation: str, functor: str, members: PyKokkosMembers, tag: c
call += f"}} else {{ {custom_call} }}"

call += generate_copy_back(members)
call += generate_fence_call()
# call += generate_fence_call()
Copy link
Contributor

Choose a reason for hiding this comment

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

including a comment to explain the reason this is commented out would be good

class ExecutionSpaceInstance:
"""
An instance of the execution space, corresponding to Cuda/HIP
Copy link
Contributor

Choose a reason for hiding this comment

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

If this only corresponds to streams, should we call it that way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically users can create an instance for OpenMP (which doesn't have streams), although I don't think it does anything right now. Future execution spaces might have use for this and they might not use the terminology "Streams".

Copy link
Contributor

Choose a reason for hiding this comment

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

Stream would at least reflect the current usage. In the future, you could reconsider the name if needed. ExecutionSpaceInstace sounds like an instance of a class, but then instance of an instance sounds like a meta level. This is something to be discussed in the next pykokkos meeting, but seems unnecessarily complex in my view.

Copy link
Contributor

@gliga gliga left a comment

Choose a reason for hiding this comment

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

Looks good.

A few comments for a future PR.
The difference between execution space and execution space instance is confusing: it could be due to names used, so considering switching to Stream for instances.

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.

2 participants