Merged
Conversation
Contributor
Author
|
It builds! Let's merge it :) |
diptorupd
reviewed
Apr 1, 2021
oleksandr-pavlyk
commented
Apr 1, 2021
6e4546c to
030a52c
Compare
SyclQueue instance implements _get_capsule() method that produces
"SyclQueueRef" named capsule
This capsule can be used to construct a new instance of SyclQueue,
doing so renames the capsule to avoid reuse.
```
In [1]: import dpctl
In [2]: q = dpctl.SyclQueue("level_zero:gpu")
In [3]: cap = q._get_capsule()
In [4]: q1 = dpctl.SyclQueue(cap)
In [5]: q1.equals(q)
Out[5]: True
In [6]: cap
Out[6]: <capsule object "used_SyclQueueRef" at 0x7f0e651689f0>
In [7]: quit
```
The recognized capsule must be named "SyclContextRef", and is renamed to
"used_SyclContextRef" once consumed.
```
In [1]: import dpctl
In [2]: c = dpctl.SyclContext("gpu")
In [3]: c
Out[3]: <dpctl.SyclContext at 0x7fc1123818d0>
In [4]: caps = c._get_capsule()
In [5]: caps
Out[5]: <capsule object "SyclContextRef" at 0x7fc0eb1acb70>
In [6]: c_copy = dpctl.SyclContext(caps)
In [7]: c.equals(c_copy)
Out[7]: True
```
06ab5d9 to
4f326c8
Compare
diptorupd
approved these changes
Apr 2, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SyclQueueandSyclContextcan now be constructed from named capsule objects, with expected names being "SyclContextRef" and "SyclQueueRef".Classes also acquire a method
_get_capsule(sef)to construct a capsule from the instance.Examples: