Merged
Conversation
Contributor
Author
|
Another example showcasing In [1]: import dpctl
In [2]: cpu_d = dpctl.SyclDevice("cpu")
In [3]: sd0, sd1 = cpu_d.create_sub_devices(partition=(6,6))
In [4]: sd0.parent_device == cpu_d
Out[4]: True
In [5]: sd1.parent_device == cpu_d
Out[5]: True |
85ec30d to
b7284f5
Compare
diptorupd
previously approved these changes
Apr 7, 2021
This returns None for root devices, but returns a SyclDevice for
a sub-device.
Added cpdef method equals, and Python method __eq__
```
Python 3.7.9 (default, Mar 10 2021, 05:18:00)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.22.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import dpctl
In [2]: cpu_device = dpctl.SyclDevice("cpu")
In [3]: cpu_device == cpu_device
Out[3]: True
In [4]: cpu_device2 = dpctl.SyclDevice("cpu")
In [5]: cpu_device == cpu_device2
Out[5]: True
In [6]: [d1, d2, d3 ] =cpu_device.create_sub_devices(partition=4)
In [7]: d1.parent_device == cpu_device
Out[7]: True
In [8]: d2.parent_device == cpu_device
Out[8]: True
In [9]: d3.parent_device == cpu_device
Out[9]: True
```
This computes the relative id (position in the vector) inside p.get_devices( sycl_device_type(DRef) ). Returns -1 is the device was not found (expected to happen for sub-devices).
b7284f5 to
fb95799
Compare
```
In [1]: import dpctl
In [2]: dpctl.SyclDevice("cpu").filter_string
Out[2]: 'opencl:cpu:0'
In [3]: dpctl.SyclDevice("gpu").filter_string
Out[3]: 'level_zero:gpu:0'
In [4]: dpctl.SyclDevice("opencl:gpu").filter_string
Out[4]: 'opencl:gpu:0'
In [5]: dpctl.SyclDevice().filter_string
Out[5]: 'level_zero:gpu:0'
In [6]: dpctl.SyclDevice("0").filter_string
Out[6]: 'opencl:accelerator:0'
In [7]: dpctl.SyclDevice("1").filter_string
Out[7]: 'opencl:cpu:0'
In [8]: dpctl.SyclDevice("2").filter_string
Out[8]: 'opencl:cpu:0'
In [9]: dpctl.SyclDevice("3").filter_string
Out[9]: 'opencl:gpu:0'
In [10]: dpctl.SyclDevice("4").filter_string
Out[10]: 'level_zero:gpu:0'
```
fb95799 to
f2c900c
Compare
diptorupd
approved these changes
Apr 8, 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.
This PR adds two functions to C-API:
DPCTLDevice_GetParentDevice(const DPCTLSyclDeviceRef DRef)- gives opaque reference to parentsycl::deviceifDRefis associated with a root device, or anullptrotherwise.DPCTLDeviceMgr_GetRelativeId(const DPCTLSyclDeviceRef DRef)- gives index ofsycl::devicereferenced byDRefinDRef_platform.get_device( DRef_device_type ), or-1is the device was not found (expected for sub-devices).Implemented
parent_deviceproperty inSyclDeviceas well as propertiesdevice_filter_tupleanddevice_filter_string.