-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Fix devices available when SYCL_BE is set. #2125
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: Byoungro So <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add a regression test.
sycl/source/device_selector.cpp
Outdated
@@ -21,11 +22,17 @@ namespace sycl { | |||
// Utility function to check if device is of the preferred backend. | |||
// Currently preference is given to the level0 backend. | |||
static bool isDeviceOfPreferredSyclBe(const device &Device) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static bool isDeviceOfPreferredSyclBe(const device &Device) { | |
static bool isLevelZeroGPUDevice(const device &Device) { |
New code below using this function with current generic name is very confusing. It seems like it should work with any device type and old code applied this function to all device type looks reasonable. Now it's applied only to GPU device type and it's not obvious why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bader This function is used to just give a bonus point (+50) when deciding which device to choose when multiple devices are available with the same score.
So, it is mainly used for GPU devices for now.
This function will give a bonus point if the device "Device" is matched with SYCL_BE. Not only for Level0. So your naming suggestion is not quite right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isPreferredGPUDevice
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes more sense. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like that @againull and @smaslov-intel approve
sycl/source/device_selector.cpp
Outdated
Score += 500; | ||
// Give preference to device of SYCL BE. | ||
if (isDeviceOfPreferredSyclBe(dev)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think preferred BE should work for all devices, not only for GPU.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current usage of this function is only used to give a bonus point for the device that is matched with SYCL_BE.
We don't need to give a bonus point for non-GPU device at this moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@romanovvlad
Current options for SYCL_BE are useful only for GPU devices.
When we have multiple BE options for other devices, we can remove this condition later.
I think we do need a way (SYCL_BE seems a good fit to me) to force SYCL RT do device discovery/selection among devices of specified backend only. The fact that this ninja setting overrides the default/standard behavior does not seem to be a problem. | SYCL_DEVICE_TYPE | One of: CPU, GPU, ACC, HOST | Force SYCL to use the specified device type. If unset, default selection rules are applied. If set to any unlisted value, this control has no effect. If the requested device type is not found, a If people want to see everything (including seeing the same physical device multiple times through different backends) then they should just not use the SYCL_BE. The preferred BE is hardcoded for such cases, and I am not sure we need to give a way to control the preferred BE to end users, other than the more strict SYCL_BE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should instead make SYCL_BE even more strict and affect not only device selection, but device discovery as well.
Co-authored-by: Alexey Bader <[email protected]>
SYCL_BE is already honored by SYCL RT. SYCL RT uses its desired BE when choosing the plugin. |
I am not sure what "more strict" means, but yes SYCL_BE is currently used to force SYCL RT to use the desired BE. This PR is not intended to relieve this behavior. |
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Done. |
By more strict I mean make SYCL_BE force the devices of the specified BE only be discovered/selected. This way we'd provide deterministic behavior (unlike current prefer semantics) needed for robust testing scenarios, at least. |
It is already deterministic. SYCL_BE is forced as long as the desired device is found on the system. |
I agree with comment form @smaslov-intel: #2125 (comment) This PR changes logic of SYCL_BE from "force" to "prefer". But we already have "prefer" logic hardcoded in isDeviceOfPreferredSyclBe => we prefer level zero. As a result, when someone runs application with SYCL_BE=PI_LEVEL0, it will not be possible to be sure (without tracing) which backend was really used. It can be even cuda backend if level0 and opencl runtimes are not available.
I believe it is possible when SYCL_BE is not provided => preferred and available backend will be used for each device. Or when SYCL_BE=PI_OPENCL is provided, because opencl is supported for all devices - cpu, gpu, acc... |
When SYCL_BE is not set, all devices can be used. |
I am quite sure, this statement is wrong for SYCL_BE=PI_OPENCL. CPU doesn't support level0, so when someone forces level0 backend I find it correct that CPU is not available.
Sorry, but I am sure there is no such thing as SYCL_BE in the spec at all. |
I strongly disagree with this PR. SYCL_BE is a hammer that is supposed to filter out all existence of devices that:
If you don't want that behavior - don't use SYCL_BE. |
When translating the `spirv.Extension` metadata of an LLVM Module, report an error when encountering an extension that has been explicitly disabled. Original commit: KhronosGroup/SPIRV-LLVM-Translator@2e917c9
When translating the `spirv.Extension` metadata of an LLVM Module, report an error when encountering an extension that has been explicitly disabled. Original commit: KhronosGroup/SPIRV-LLVM-Translator@2e917c9
Currently when SYCL_BE is set, other devices (such CPU) is filtered out from the available devices list.
This does not conform to the spec of device::get_devices().
Basically, setting SYCL_BE should not limit the available devices (e.g., CPU) in the system.
The current implementation does not allow the usage of multiple devices when SYCL_BE is set because it filter out devices other than the only SYCL_BE setting device.
Signed-off-by: Byoungro So [email protected]