diff --git a/sycl/include/sycl/backend/opencl.hpp b/sycl/include/sycl/backend/opencl.hpp index d7b2861363d87..7774bfd33d6fc 100644 --- a/sycl/include/sycl/backend/opencl.hpp +++ b/sycl/include/sycl/backend/opencl.hpp @@ -19,10 +19,21 @@ namespace sycl { inline namespace _V1 { namespace opencl { +namespace detail { +using namespace sycl::detail; __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, - const std::string &Extension); + detail::string_view Extension); __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, - const std::string &Extension); + detail::string_view Extension); +} // namespace detail +inline bool has_extension(const sycl::platform &SyclPlatform, + const std::string &Extension) { + return detail::has_extension(SyclPlatform, detail::string_view{Extension}); +} +inline bool has_extension(const sycl::device &SyclDevice, + const std::string &Extension) { + return detail::has_extension(SyclDevice, detail::string_view{Extension}); +} } // namespace opencl } // namespace _V1 } // namespace sycl diff --git a/sycl/source/backend/opencl.cpp b/sycl/source/backend/opencl.cpp index e0c669cb8c267..17b08627039ab 100644 --- a/sycl/source/backend/opencl.cpp +++ b/sycl/source/backend/opencl.cpp @@ -17,12 +17,15 @@ namespace sycl { inline namespace _V1 { namespace opencl { -using namespace detail; //---------------------------------------------------------------------------- // Free functions to query OpenCL backend extensions + +namespace detail { +using namespace sycl::detail; + __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, - const std::string &Extension) { + detail::string_view Extension) { if (SyclPlatform.get_backend() != sycl::backend::opencl) { throw sycl::exception( errc::backend_mismatch, @@ -50,11 +53,12 @@ __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, nullptr); std::string_view ExtensionsString(Result.get()); - return ExtensionsString.find(Extension) != std::string::npos; + return ExtensionsString.find(std::string_view{Extension.data()}) != + std::string::npos; } __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, - const std::string &Extension) { + detail::string_view Extension) { if (SyclDevice.get_backend() != sycl::backend::opencl) { throw sycl::exception( errc::backend_mismatch, @@ -82,8 +86,21 @@ __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, ResultSize, Result.get(), nullptr); std::string_view ExtensionsString(Result.get()); - return ExtensionsString.find(Extension) != std::string::npos; + return ExtensionsString.find(std::string_view{Extension.data()}) != + std::string::npos; +} +} // namespace detail + +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES +__SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice, + const std::string &Extension) { + return detail::has_extension(SyclDevice, detail::string_view{Extension}); +} +__SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform, + const std::string &Extension) { + return detail::has_extension(SyclPlatform, detail::string_view{Extension}); } +#endif } // namespace opencl } // namespace _V1 } // namespace sycl diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index a5134a7a524ca..d9d722c5d0106 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3451,6 +3451,8 @@ _ZN4sycl3_V16native13__divide_implENS0_3vecIfLi8EEES3_ _ZN4sycl3_V16native13__divide_implEff _ZN4sycl3_V16opencl13has_extensionERKNS0_6deviceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE _ZN4sycl3_V16opencl13has_extensionERKNS0_8platformERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE +_ZN4sycl3_V16opencl6detail13has_extensionERKNS0_6deviceENS0_6detail11string_viewE +_ZN4sycl3_V16opencl6detail13has_extensionERKNS0_8platformENS0_6detail11string_viewE _ZN4sycl3_V16streamC1EmmRNS0_7handlerE _ZN4sycl3_V16streamC1EmmRNS0_7handlerERKNS0_13property_listE _ZN4sycl3_V16streamC2EmmRNS0_7handlerE diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index a6e6a5e47c137..fdb0dc6f36f1d 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -4082,6 +4082,8 @@ ?has@device@_V1@sycl@@QEBA_NW4aspect@23@@Z ?has@platform@_V1@sycl@@QEBA_NW4aspect@23@@Z ?has_context@exception@_V1@sycl@@QEBA_NXZ +?has_extension@detail@opencl@_V1@sycl@@YA_NAEBVdevice@34@Vstring_view@134@@Z +?has_extension@detail@opencl@_V1@sycl@@YA_NAEBVplatform@34@Vstring_view@134@@Z ?has_extension@device@_V1@sycl@@AEBA_NVstring_view@detail@23@@Z ?has_extension@device@_V1@sycl@@QEBA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z ?has_extension@opencl@_V1@sycl@@YA_NAEBVdevice@23@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z