Skip to content

Commit 34b4aa6

Browse files
committed
[SYCL] Provide extension to query for unsupported platforms
1 parent 404fb8a commit 34b4aa6

File tree

8 files changed

+134
-7
lines changed

8 files changed

+134
-7
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
= sycl_ext_oneapi_get_unsupported_platforms
2+
3+
:source-highlighter: coderay
4+
:coderay-linenums-mode: table
5+
6+
// This section needs to be after the document title.
7+
:doctype: book
8+
:toc2:
9+
:toc: left
10+
:encoding: utf-8
11+
:lang: en
12+
:dpcpp: pass:[DPC++]
13+
14+
// Set the default source code type in this document to C++,
15+
// for syntax highlighting purposes. This is needed because
16+
// docbook uses c++ and html5 uses cpp.
17+
:language: {basebackend@docbook:c++:cpp}
18+
19+
20+
== Notice
21+
22+
[%hardbreaks]
23+
Copyright (C) 2024 Intel Corporation. All rights reserved.
24+
25+
Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks
26+
of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by
27+
permission by Khronos.
28+
29+
30+
== Contact
31+
32+
To report problems with this extension, please open a new issue at:
33+
34+
https://github.com/intel/llvm/issues
35+
36+
37+
== Dependencies
38+
39+
This extension is written against the SYCL 2020 revision 8 specification. All
40+
references below to the "core SYCL specification" or to section numbers in the
41+
SYCL specification refer to that revision.
42+
43+
44+
== Status
45+
46+
This is an experimental extension specification, intended to provide early
47+
access to features and gather community feedback. Interfaces defined in this
48+
specification are implemented in {dpcpp}, but they are not finalized and may
49+
change incompatibly in future versions of {dpcpp} without prior notice.
50+
*Shipping software products should not rely on APIs defined in this
51+
specification.*
52+
53+
54+
== Overview
55+
56+
The implementation of `sycl::platform` already allows querying for supported
57+
platforms - `static std::vector<platform> get_platforms()` - which returns all
58+
available SYCL platforms in the system (the resulting vector always contains a
59+
single SYCL host platform instance). This extension adds an API entry to list
60+
all unsupported platforms; the platform is considered unsupported if it is
61+
non-SYCL, or does not have any devices associated.
62+
63+
This extension exists to solve a specific problem: listing of all platforms
64+
(supported and not) in verbose mode of `sycl-ls` binary.
65+
66+
67+
== Specification
68+
69+
=== Feature test macro
70+
71+
This extension provides a feature-test macro as described in the core SYCL
72+
specification. An implementation supporting this extension must predefine the
73+
macro `SYCL_EXT_ONEAPI_GET_UNSUPPORTED_PLATFORMS` to one of the values defined in
74+
the table below. Applications can test for the existence of this macro to
75+
determine if the implementation supports this feature, or applications can test
76+
the macro's value to determine which of the extension's features the
77+
implementation supports.
78+
79+
[%header,cols="1,5"]
80+
|===
81+
|Value
82+
|Description
83+
84+
|1
85+
|The API of this experimental extension is not versioned, so the feature-test
86+
macro always has this value.
87+
|===
88+
89+
=== New SYCL platform API
90+
91+
This extension adds the following new API to the existing `sycl::platform` class:
92+
93+
[source, c++]
94+
----
95+
namespace sycl {
96+
97+
class platform {
98+
...
99+
100+
static std::vector<platform> ext_oneapi_get_unsupported_platforms();
101+
102+
...
103+
}
104+
105+
} // namespace sycl
106+
----
107+
108+
The new API has the following behaviour:
109+
110+
--
111+
[options="header"]
112+
|====
113+
| Function Definition | Description
114+
a|
115+
[source, c++]
116+
----
117+
static std::vector<platform> ext_oneapi_get_unsupported_platforms();
118+
----
119+
| Returns a vector containing all unsupported (non-SYCL, or device-less)
120+
platforms in the system.
121+
122+
|====
123+
--

sycl/include/sycl/platform.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
197197
/// Returns all unsupported (non-SYCL) platforms in the system.
198198
///
199199
/// \return a vector of all unsupported non-SYCL platforms.
200-
static std::vector<platform> get_unsupported_platforms();
200+
static std::vector<platform> ext_oneapi_get_unsupported_platforms();
201201

202202
/// Returns the backend associated with this platform.
203203
///

sycl/source/detail/platform_impl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ static bool IsBannedPlatform(platform Platform) {
9696
IsMatchingOpenCL(Platform, "AMD Accelerated Parallel Processing");
9797
}
9898

99-
// Get the vector of platforms supported by a given UR plugin
100-
// replace uses of this with a helper in plugin object, the plugin
99+
// When `Supported` is `true` gets the vector of platforms supported by a given
100+
// UR `Plugin`. Otherwise a vector of all unsupported (non-SYCL, or
101+
// device-less) platforms.
102+
// Replace uses of this with a helper in plugin object, the plugin
101103
// objects will own the ur adapter handles and they'll need to pass them to
102104
// urPlatformsGet - so urPlatformsGet will need to be wrapped with a helper
103105
std::vector<platform> platform_impl::getPluginPlatforms(PluginPtr &Plugin,

sycl/source/feature_test.hpp.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ inline namespace _V1 {
108108
#define SYCL_EXT_ONEAPI_RAW_KERNEL_ARG 1
109109
#define SYCL_EXT_ONEAPI_PROFILING_TAG 1
110110
#define SYCL_EXT_ONEAPI_ENQUEUE_NATIVE_COMMAND 1
111+
#define SYCL_EXT_ONEAPI_GET_UNSUPPORTED_PLATFORMS 1
111112
// In progress yet
112113
#define SYCL_EXT_ONEAPI_ATOMIC16 0
113114

sycl/source/platform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ std::vector<platform> platform::get_platforms() {
5252
return detail::platform_impl::get_platforms();
5353
}
5454

55-
std::vector<platform> platform::get_unsupported_platforms() {
55+
std::vector<platform> platform::ext_oneapi_get_unsupported_platforms() {
5656
return detail::platform_impl::get_unsupported_platforms();
5757
}
5858

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3545,7 +3545,7 @@ _ZN4sycl3_V17samplerC1EP11_cl_samplerRKNS0_7contextE
35453545
_ZN4sycl3_V17samplerC2ENS0_29coordinate_normalization_modeENS0_15addressing_modeENS0_14filtering_modeERKNS0_13property_listE
35463546
_ZN4sycl3_V17samplerC2EP11_cl_samplerRKNS0_7contextE
35473547
_ZN4sycl3_V18platform13get_platformsEv
3548-
_ZN4sycl3_V18platform25get_unsupported_platformsEv
3548+
_ZN4sycl3_V18platform36ext_oneapi_get_unsupported_platformsEv
35493549
_ZN4sycl3_V18platformC1EP15_cl_platform_id
35503550
_ZN4sycl3_V18platformC1ERKNS0_15device_selectorE
35513551
_ZN4sycl3_V18platformC1ERKNS0_6deviceE

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4035,7 +4035,7 @@
40354035
?get_platform@context@_V1@sycl@@QEBA?AVplatform@23@XZ
40364036
?get_platform@device@_V1@sycl@@QEBA?AVplatform@23@XZ
40374037
?get_platforms@platform@_V1@sycl@@SA?AV?$vector@Vplatform@_V1@sycl@@V?$allocator@Vplatform@_V1@sycl@@@std@@@std@@XZ
4038-
?get_unsupported_platforms@platform@_V1@sycl@@SA?AV?$vector@Vplatform@_V1@sycl@@V?$allocator@Vplatform@_V1@sycl@@@std@@@std@@XZ
4038+
?ext_oneapi_get_unsupported_platforms@platform@_V1@sycl@@SA?AV?$vector@Vplatform@_V1@sycl@@V?$allocator@Vplatform@_V1@sycl@@@std@@@std@@XZ
40394039
?get_pointer_device@_V1@sycl@@YA?AVdevice@12@PEBXAEBVcontext@12@@Z
40404040
?get_pointer_type@_V1@sycl@@YA?AW4alloc@usm@12@PEBXAEBVcontext@12@@Z
40414041
?get_precision@stream@_V1@sycl@@QEBA_KXZ

sycl/tools/sycl-ls/sycl-ls.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ int main(int argc, char **argv) {
430430
std::cout << "\nPlatforms: " << Platforms.size() << std::endl;
431431
printVerbosePlatformInfo(Platforms, DeviceNums, SuppressNumberPrinting);
432432

433-
const auto &UnsupportedPlatforms = platform::get_unsupported_platforms();
433+
const auto &UnsupportedPlatforms =
434+
platform::ext_oneapi_get_unsupported_platforms();
434435
std::cout << "\nUnsupported Platforms: " << UnsupportedPlatforms.size()
435436
<< std::endl;
436437
printVerbosePlatformInfo(UnsupportedPlatforms, DeviceNums,

0 commit comments

Comments
 (0)