-
Notifications
You must be signed in to change notification settings - Fork 788
[SYCL] Implement new env var SYCL_FORCE_PI and extend device_selector::select_device #2214
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
Extended select_device to take optional parameters device_type and backend. The current implementation of select_device returns different devices depending on the env var such as SYCL_BE and SYCL_DEVICE_TYPE, and uses heuristic. This extension of select_device will allow users to set the desired device type and possibly also backend if multiple devices are the same device type. Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Extended select_device to take optional parameters device_type and backend. The current implementation of select_device returns different devices depending on the env var such as SYCL_BE and SYCL_DEVICE_TYPE, and uses heuristic. This extension of select_device will allow users to set the desired device type and possibly also backend if multiple devices are the same device type. Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
…o select-device
Extended select_device to take optional parameters device_type and backend. The current implementation of select_device returns different devices depending on the env var such as SYCL_BE and SYCL_DEVICE_TYPE, and uses heuristic. This extension of select_device will allow users to set the desired device type and possibly also backend if multiple devices are the same device type. Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
…o select-device
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
This reverts commit a43dcc2.
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.
How is it going to affect user-defined selectors? Why don't users use custom selectors? If someone needs to control device selection with environment variables, why don't they create a special device selector?
// deviceType is an optional parameter to set the desired device | ||
// info::device_type::all means a heuristic is used to select a device with | ||
// highest score | ||
device select_device(info::device_type deviceType = info::device_type::all, | ||
backend BE = backend::level0) const; |
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.
Can we implement it as a non-breaking change?
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.
This change won't affect existing abi. The existing code will continue to work as before based on a heuristic since no parameters are passed.
sycl/source/device_selector.cpp
Outdated
device device_selector::select_device(info::device_type deviceType, | ||
backend be) const { | ||
// return if a requested deviceType is found | ||
if (deviceType != info::device_type::all) { | ||
if (deviceType == info::device_type::host) { | ||
vector_class<device> devices; | ||
devices.resize(1); | ||
return devices[0]; | ||
} | ||
|
||
const vector_class<detail::plugin> &plugins = RT::initialize(); | ||
for (unsigned int i = 0; i < plugins.size(); i++) { | ||
pi_uint32 numPlatforms = 0; | ||
plugins[i].call<detail::PiApiKind::piPlatformsGet>(0, nullptr, | ||
&numPlatforms); | ||
if (numPlatforms) { | ||
vector_class<RT::PiPlatform> piPlatforms(numPlatforms); | ||
plugins[i].call<detail::PiApiKind::piPlatformsGet>( | ||
numPlatforms, piPlatforms.data(), nullptr); | ||
for (const auto &piPlatform : piPlatforms) { | ||
platform pltf = detail::createSyclObjFromImpl<platform>( | ||
std::make_shared<detail::platform_impl>(piPlatform, plugins[i])); | ||
if (!pltf.is_host()) { | ||
vector_class<device> devices = pltf.get_devices(deviceType); | ||
for (uint32_t i = 0; i < devices.size(); i++) { | ||
if (deviceType != info::device_type::gpu) { | ||
return devices[i]; | ||
} else if (devices[i].is_gpu() && be == pltf.get_backend()) { | ||
return devices[i]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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.
This seem to violate the spirit of device_selector
. Why not just give some boost to matching device scores?
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 problem is that SYCL_BE=PI_LEVEL0 will hide CPU and ACC devices from available devices in the system. So giving bonus points won't work.
As I mentioned above, the existing calls to select_device() with no parameter specified will continue to work and does not violate the existing code.
sycl/source/device_selector.cpp
Outdated
vector_class<device> devices; | ||
devices.resize(1); | ||
return devices[0]; |
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.
vector_class<device> devices; | |
devices.resize(1); | |
return devices[0]; | |
return device{}; |
} | ||
|
||
const vector_class<detail::plugin> &plugins = RT::initialize(); | ||
for (unsigned int i = 0; i < plugins.size(); i++) { |
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.
Range-based for?
if (deviceType != info::device_type::gpu) { | ||
return devices[i]; | ||
} else if (devices[i].is_gpu() && be == pltf.get_backend()) { | ||
return devices[i]; | ||
} |
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.
If we ever have a non-OpenCL based backend for other devices, this will be a bug.
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.
As described in the comment, the second parameter 'be' is meant to designate specific GPU device backend, and not used for other device types.
@@ -3858,7 +3858,7 @@ _ZNK2cl4sycl14interop_handle12getNativeMemEPNS0_6detail16AccessorImplHostE | |||
_ZNK2cl4sycl14interop_handle14getNativeQueueEv | |||
_ZNK2cl4sycl14interop_handle15getNativeDeviceEv | |||
_ZNK2cl4sycl14interop_handle16getNativeContextEv | |||
_ZNK2cl4sycl15device_selector13select_deviceEv | |||
_ZNK2cl4sycl15device_selector13select_deviceENS0_4info11device_typeENS0_7backendE |
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.
If you still want to break ABI, please, uplift DEV_ABI version.
sycl/source/detail/pi.cpp
Outdated
// to be loaded. Note that SYCL_BE=PI_LEVEL0 prevents from other OCL CPU | ||
// devices to be discovered. | ||
|
||
const char *envVal = std::getenv("SYCL_FORCE_PI"); |
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.
SYCLConfig
?
Enables partial specialization of atomic_ref for pointer types. Implementation assumes that both host and device pointers can be stored in a uintptr_t, but uses compare_exchange to implement pointer arithmetic rather than make assumptions about how pointers will be represented on different devices. Signed-off-by: John Pennycook <[email protected]>
Do I understand correctly that SYCL_FORCE_PI is the same as SYCL_BE but support several plugins specified? |
…xtension (intel#2221) Signed-off-by: Michael Kinsner <[email protected]>
…tel#2025) PI_LEVEL0 -> PI_LEVEL_ZERO. PI_LEVEL0 is still accepted and handled correctly. Signed-off-by: Gail Lyons <[email protected]>
This version supports side-by-side installation of OpenCL RT for Intel CPU and OpenCL RT for Intel FPGA emulation.
It seems I have to clarify the difference between SYCL_BE and SYCL_FORCE_PI. Another clarification may be needed between select_device() vs specific device_selector. |
All different kinds of device selectors are governed by SYCL_BE and SYCL_DEVICE_TYPE. For example, CPU and ACC devices are not available as soon as the user sets SYCL_BE=PI_LEVEL0 for GPU. There was a request for customer request to "select" their favorite device regardless of these env vars. |
Co-authored-by: Romanov Vlad <[email protected]>
I explained the difference between SYCL_FORCE_PI and SYCL_BE. I hope I clarified your questions. |
Extended select_device to take optional parameters device_type and backend. The current implementation of select_device returns different devices depending on the env var such as SYCL_BE and SYCL_DEVICE_TYPE, and uses heuristic. This extension of select_device will allow users to set the desired device type and possibly also backend if multiple devices are the same device type. Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Extended select_device to take optional parameters device_type and backend. The current implementation of select_device returns different devices depending on the env var such as SYCL_BE and SYCL_DEVICE_TYPE, and uses heuristic. This extension of select_device will allow users to set the desired device type and possibly also backend if multiple devices are the same device type. Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
Co-authored-by: Romanov Vlad <[email protected]>
…o select-device Signed-off-by: Byoungro So <[email protected]>
Signed-off-by: Byoungro So <[email protected]>
I am closing this PR and will create a new one based on our discussion today. |
This PR aims to introduce entities related to OpCooperativeMatrixApplyFunctionINTEL in llvm-spirv translator, according to https://github.com/intel/llvm/blob/sycl/sycl/doc/design/spirv-extensions/SPV_INTEL_joint_matrix.asciidoc. Co-authored-by: Sidorov, Dmitry <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@467edf9
This PR responds to several requests for user controls to loading only specific plugins into SYCL RT, and a way to request a specific device regardless of SYCL_BE setting.
For the first request, this PR introduced a new env var SYCL_FORCE_PI. The possible values are any combination of {opencl, level0, cuda}. Only the specified plugins will be loaded into SYCL RT.
For the second request, this PR extends device_selector::select_device() to take optional parameters device_type and backend.
In current implementation, device availability is heavily depending on the env var SYCL_BE and SYCL_DEVICE_TYPE. The user wanted a control in API to pin down specific device regardless of SYCL_BE setting.
Note that SYCL_BE=PI_LEVEL0 prevents users from using CPU and ACC devices.