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
7 changes: 6 additions & 1 deletion sycl/include/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase<context> {
/// Queries this SYCL context for SYCL backend-specific information.
///
/// The return type depends on information being queried.
template <typename Param>
template <typename Param
#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
,
int = detail::emit_get_backend_info_error<context, Param>()
#endif
>
typename detail::is_backend_info_desc<Param>::return_type
get_backend_info() const;

Expand Down
12 changes: 12 additions & 0 deletions sycl/include/sycl/detail/info_desc_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ struct IsKernelInfo<info::kernel_device_specific::ext_codeplay_num_regs>
#include <sycl/info/sycl_backend_traits.def>
#undef __SYCL_PARAM_TRAITS_SPEC

template <typename SyclObject, typename Param>
constexpr int emit_get_backend_info_error() {
// Implementation of get_backend_info doesn't seem to be aligned with the
// spec and is likely going to be deprecated/removed. However, in pre-C++11
// ABI mode if result in ABI mismatch and causes crashes, so emit
// compile-time error under those conditions.
constexpr bool False = !std::is_same_v<Param, Param>;
static_assert(False,
"This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0");
return 0;
}

} // namespace detail
} // namespace _V1
} // namespace sycl
7 changes: 6 additions & 1 deletion sycl/include/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ class __SYCL_EXPORT device : public detail::OwnerLessBase<device> {
/// Queries this SYCL device for SYCL backend-specific information.
///
/// The return type depends on information being queried.
template <typename Param>
template <typename Param
#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
,
int = detail::emit_get_backend_info_error<device, Param>()
#endif
>
typename detail::is_backend_info_desc<Param>::return_type
get_backend_info() const;

Expand Down
7 changes: 6 additions & 1 deletion sycl/include/sycl/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ class __SYCL_EXPORT event : public detail::OwnerLessBase<event> {
/// Queries this SYCL event for SYCL backend-specific information.
///
/// \return depends on information being queried.
template <typename Param>
template <typename Param
#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
,
int = detail::emit_get_backend_info_error<event, Param>()
#endif
>
typename detail::is_backend_info_desc<Param>::return_type
get_backend_info() const;

Expand Down
7 changes: 6 additions & 1 deletion sycl/include/sycl/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ class __SYCL_EXPORT kernel : public detail::OwnerLessBase<kernel> {
/// Queries the kernel object for SYCL backend-specific information.
///
/// The return type depends on information being queried.
template <typename Param>
template <typename Param
#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
,
int = detail::emit_get_backend_info_error<kernel, Param>()
#endif
>
typename detail::is_backend_info_desc<Param>::return_type
get_backend_info() const;

Expand Down
7 changes: 6 additions & 1 deletion sycl/include/sycl/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
/// Queries this SYCL platform for SYCL backend-specific info.
///
/// The return type depends on information being queried.
template <typename Param>
template <typename Param
#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
,
int = detail::emit_get_backend_info_error<platform, Param>()
#endif
>
typename detail::is_backend_info_desc<Param>::return_type
get_backend_info() const;

Expand Down
7 changes: 6 additions & 1 deletion sycl/include/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,12 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
/// Queries SYCL queue for SYCL backend-specific information.
///
/// The return type depends on information being queried.
template <typename Param>
template <typename Param
#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
,
int = detail::emit_get_backend_info_error<queue, Param>()
#endif
>
typename detail::is_backend_info_desc<Param>::return_type
get_backend_info() const;

Expand Down
28 changes: 28 additions & 0 deletions sycl/test-e2e/Basic/backend_info.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
//
// RUN: %{build} -DTEST_ERRORS -D_GLIBCXX_USE_CXX11_ABI=0 -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note

//==--- backend_info.cpp - SYCL backend info test---------------------------==//
//
Expand All @@ -17,13 +18,19 @@
using namespace sycl;

int main() {
#if (defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI != 0) || \
!defined(_GLIBCXX_USE_CXX11_ABI) || TEST_ERRORS
try {
// Test get_backend_info for sycl::platform
std::vector<platform> platform_list = platform::get_platforms();
for (const auto &platform : platform_list) {
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::device::version, $1 = (no value)]}}
std::cout << " Backend device version: "
<< platform.get_backend_info<info::device::version>()
<< std::endl;
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::platform::version, $1 = (no value)]}}
std::cout << " Backend platform version: "
<< platform.get_backend_info<info::platform::version>()
<< std::endl;
Expand All @@ -33,32 +40,48 @@ int main() {
std::vector<device> device_list =
device::get_devices(info::device_type::gpu);
for (const auto &device : device_list) {
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::device::version, $1 = (no value)]}}
std::cout << " Backend device version: "
<< device.get_backend_info<info::device::version>()
<< std::endl;
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::platform::version, $1 = (no value)]}}
std::cout << " Backend platform version: "
<< device.get_backend_info<info::platform::version>()
<< std::endl;
}

// Test get_backend_info for sycl::queue
queue q;
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::device::version, $1 = (no value)]}}
std::cout << " Backend device version: "
<< q.get_backend_info<info::device::version>() << std::endl;
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::platform::version, $1 = (no value)]}}
std::cout << " Backend platform version: "
<< q.get_backend_info<info::platform::version>() << std::endl;

// Test get_backend_info for sycl::context
context Ctx = q.get_context();
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::device::version, $1 = (no value)]}}
std::cout << " Backend device version: "
<< Ctx.get_backend_info<info::device::version>() << std::endl;
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::platform::version, $1 = (no value)]}}
std::cout << " Backend platform version: "
<< Ctx.get_backend_info<info::platform::version>() << std::endl;

// Test get_backend_info for sycl::event
event e = q.single_task([=]() { return; });
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::device::version, $1 = (no value)]}}
std::cout << " Backend device version: "
<< e.get_backend_info<info::device::version>() << std::endl;
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::platform::version, $1 = (no value)]}}
std::cout << " Backend platform version: "
<< e.get_backend_info<info::platform::version>() << std::endl;

Expand All @@ -73,8 +96,12 @@ int main() {
auto acc = buf.get_access<access::mode::read_write>(cgh);
cgh.single_task<class SingleTask>(krn, [=]() { acc[0] = acc[0] + 1; });
});
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::device::version, $1 = (no value)]}}
std::cout << " Backend device version: "
<< krn.get_backend_info<info::device::version>() << std::endl;
// expected-error@*:* {{static assertion failed due to requirement 'False': This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0}}
// expected-note@+2 {{while substituting deduced template arguments into function template 'get_backend_info' [with Param = info::platform::version, $1 = (no value)]}}
std::cout << " Backend platform version: "
<< krn.get_backend_info<info::platform::version>() << std::endl;
} catch (exception e) {
Expand All @@ -93,5 +120,6 @@ int main() {
assert(has_non_opencl_backend && "unexpected error code");
}
std::cout << " Backend info query tests passed" << std::endl;
#endif
return 0;
}
Loading