|
17 | 17 | namespace sycl { |
18 | 18 | inline namespace _V1 { |
19 | 19 | namespace opencl { |
20 | | -using namespace detail; |
21 | 20 |
|
22 | 21 | //---------------------------------------------------------------------------- |
23 | 22 | // Free functions to query OpenCL backend extensions |
| 23 | + |
| 24 | +namespace detail { |
| 25 | +using namespace sycl::detail; |
| 26 | + |
24 | 27 | __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, |
25 | | - const std::string &Extension) { |
| 28 | + detail::string_view Extension) { |
26 | 29 | if (SyclPlatform.get_backend() != sycl::backend::opencl) { |
27 | 30 | throw sycl::exception( |
28 | 31 | errc::backend_mismatch, |
@@ -50,11 +53,12 @@ __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, |
50 | 53 | nullptr); |
51 | 54 |
|
52 | 55 | std::string_view ExtensionsString(Result.get()); |
53 | | - return ExtensionsString.find(Extension) != std::string::npos; |
| 56 | + return ExtensionsString.find(std::string_view{Extension.data()}) != |
| 57 | + std::string::npos; |
54 | 58 | } |
55 | 59 |
|
56 | 60 | __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, |
57 | | - const std::string &Extension) { |
| 61 | + detail::string_view Extension) { |
58 | 62 | if (SyclDevice.get_backend() != sycl::backend::opencl) { |
59 | 63 | throw sycl::exception( |
60 | 64 | errc::backend_mismatch, |
@@ -82,8 +86,21 @@ __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, |
82 | 86 | ResultSize, Result.get(), nullptr); |
83 | 87 |
|
84 | 88 | std::string_view ExtensionsString(Result.get()); |
85 | | - return ExtensionsString.find(Extension) != std::string::npos; |
| 89 | + return ExtensionsString.find(std::string_view{Extension.data()}) != |
| 90 | + std::string::npos; |
| 91 | +} |
| 92 | +} // namespace detail |
| 93 | + |
| 94 | +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES |
| 95 | +__SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, |
| 96 | + const std::string &Extension) { |
| 97 | + return detail::has_extension(SyclDevice, detail::string_view{Extension}); |
| 98 | +} |
| 99 | +__SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, |
| 100 | + const std::string &Extension) { |
| 101 | + return detail::has_extension(SyclPlatform, detail::string_view{Extension}); |
86 | 102 | } |
| 103 | +#endif |
87 | 104 | } // namespace opencl |
88 | 105 | } // namespace _V1 |
89 | 106 | } // namespace sycl |
0 commit comments