Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions sycl/include/sycl/backend/opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 22 additions & 5 deletions sycl/source/backend/opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions sycl/test/abi/sycl_symbols_windows.dump
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down