-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Fix broken uniqueness in make_device #6204
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
Conversation
Signed-off-by: JackAKirk <[email protected]>
Why is this not relying on the existing device-cache? I would expect that the new "device_impl" would not be created because of this code: llvm/sycl/source/detail/platform_impl.cpp Line 219 in f6420c7
I do not say it is not a problem, but where in the SYCL2020 OpenCL backend spec is it saying what should be returned by "make_device"? Do we need to update it?
Why context? I think only platform and device should be such, no?
Yes, please add such test(s). |
It is relying on device-cache in the platform class since this patch. Line 64 in 3c1d342
createSyclObjFromImpl<device> does not call the Platform->getOrMakeDeviceImpl method that checks the device-cache. This is why we needed to call device::get_devices that does check the device-cache and as far as I can tell is the only existing route that checks the device cache of all platforms within a backend.
I think you're right that this use-case and expected behaviour is not described in the OpenCL backend spec. However currently the runtime is allowing the creation of a second shared_ptr that takes ownership of the native object in the sample code here: #6055. I don't see any difference between the above motivation for device and the context case: however a |
That's why I am asking should we rather change the "make_device" to be aware of the device-cache instead of using
Would you spawn a spec issue to clarify this, please? |
Signed-off-by: JackAKirk <[email protected]>
OK |
Signed-off-by: JackAKirk <[email protected]>
The |
Signed-off-by: JackAKirk <[email protected]>
I don't think that we can directly use
until we have checked all platforms in the backend. I've followed through with your suggestion with a rough draft implementation using a new member:
However if we have something like this (perhaps unusual) case:
we will hit the assert because we have not updated the MDeviceCache (first we will have to find the platform associated with the device_impl that was made by the plugin). So we will need to create another route to find the correct platform and update I'm not sure that
Thanks |
@smaslov-intel What do you think about my above comment/questions? |
@smaslov-intel friendly ping on this, what are your thoughts on @JackAKirk's comments above? |
This is a general fix for #6055.
CUDA device interop is not available yet but a corresponding fix will be added to the CUDA specialization of
make_device
in #6202 shortly.If it is uncontroversial I will add an overload for
device::get_devices
that takes a backend argument and then only returns devices corresponding to that backend? This would allow removing thedev.get_backend() == Backend
check introduced in this PR and make the implementation more efficient.Note that I expect there could be similar uniqueness issues for other interop types such as context etc.. We will be considering such issues in #6055.
I think that interop tests basically comprising the code sample in #6055 would be useful. I can add such a test for device to intel/llvm-test-suite.
Signed-off-by: JackAKirk [email protected]