Merged
Conversation
diptorupd
reviewed
May 19, 2021
DPCLTDeviceMgr_GetDevices should not rely of the cached unordered map
of root sycl devices to sycl contexts. Because unordered map can change
the ordering.
Changed implementation to iterate over device::get_devices instead.
Confirmation of the fix:
```
In [1]: import dpctl
In [2]: d0 = dpctl.SyclDevice("gpu:0")
In [3]: d0.filter_string
Out[3]: 'opencl:gpu:0'
In [4]: [i for i, di in enumerate(dpctl.get_devices(dpctl.backend_type.all, dpctl.device_type.gpu)) if di == d0]
Out[4]: [0]
In [5]: d0 == dpctl.SyclDevice(d0.filter_string)
Out[5]: True
In [6]: d1 = dpctl.SyclDevice("gpu:1")
In [7]: d1.filter_string
Out[7]: 'level_zero:gpu:0'
In [8]: [i for i, di in enumerate(dpctl.get_devices(dpctl.backend_type.all, dpctl.device_type.gpu)) if di == d1]
Out[8]: [1]
In [9]: d1 == dpctl.SyclDevice(d1.filter_string)
Out[9]: True
```
699e35e to
00cb985
Compare
DeviceType enums now are [0, 8), BackendType enums have lower 16 bits zero, and span [1<<16, 1<<20)
3caf382 to
e19e0f7
Compare
Contributor
Author
|
@diptorupd Ready to merge? |
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.
Closes #447
The root cause for 447 was that
devices.get_devicesrelied on cached unordered map, which does not guarantee the ordering.The fix was to change implementation of
DPCLDeviceMgr_GetDevicesto iterate overdevice::get_devices(which is also internally cached by SYCL runtime) which would guarantee the same ordering as used by filter selector.Python tests were added.