diff --git a/sycl/include/sycl/context.hpp b/sycl/include/sycl/context.hpp index 3e113b588c124..a28dc9f37b61c 100644 --- a/sycl/include/sycl/context.hpp +++ b/sycl/include/sycl/context.hpp @@ -176,7 +176,12 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase { /// Queries this SYCL context for SYCL backend-specific information. /// /// The return type depends on information being queried. - template + template () +#endif + > typename detail::is_backend_info_desc::return_type get_backend_info() const; diff --git a/sycl/include/sycl/detail/info_desc_helpers.hpp b/sycl/include/sycl/detail/info_desc_helpers.hpp index 60ad8bb007cc3..d281f4df4d9c8 100644 --- a/sycl/include/sycl/detail/info_desc_helpers.hpp +++ b/sycl/include/sycl/detail/info_desc_helpers.hpp @@ -129,6 +129,18 @@ struct IsKernelInfo #include #undef __SYCL_PARAM_TRAITS_SPEC +template +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; + static_assert(False, + "This interface is incompatible with _GLIBCXX_USE_CXX11_ABI=0"); + return 0; +} + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/include/sycl/device.hpp b/sycl/include/sycl/device.hpp index 57b193b4987b3..9de06804fe5bd 100644 --- a/sycl/include/sycl/device.hpp +++ b/sycl/include/sycl/device.hpp @@ -221,7 +221,12 @@ class __SYCL_EXPORT device : public detail::OwnerLessBase { /// Queries this SYCL device for SYCL backend-specific information. /// /// The return type depends on information being queried. - template + template () +#endif + > typename detail::is_backend_info_desc::return_type get_backend_info() const; diff --git a/sycl/include/sycl/event.hpp b/sycl/include/sycl/event.hpp index 2f3974dca5e39..2fdbe7ee96587 100644 --- a/sycl/include/sycl/event.hpp +++ b/sycl/include/sycl/event.hpp @@ -111,7 +111,12 @@ class __SYCL_EXPORT event : public detail::OwnerLessBase { /// Queries this SYCL event for SYCL backend-specific information. /// /// \return depends on information being queried. - template + template () +#endif + > typename detail::is_backend_info_desc::return_type get_backend_info() const; diff --git a/sycl/include/sycl/kernel.hpp b/sycl/include/sycl/kernel.hpp index 654373c104c85..d550a0e49dd3e 100644 --- a/sycl/include/sycl/kernel.hpp +++ b/sycl/include/sycl/kernel.hpp @@ -131,7 +131,12 @@ class __SYCL_EXPORT kernel : public detail::OwnerLessBase { /// Queries the kernel object for SYCL backend-specific information. /// /// The return type depends on information being queried. - template + template () +#endif + > typename detail::is_backend_info_desc::return_type get_backend_info() const; diff --git a/sycl/include/sycl/platform.hpp b/sycl/include/sycl/platform.hpp index ec57731141b32..4f7df0c2362a7 100644 --- a/sycl/include/sycl/platform.hpp +++ b/sycl/include/sycl/platform.hpp @@ -149,7 +149,12 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase { /// Queries this SYCL platform for SYCL backend-specific info. /// /// The return type depends on information being queried. - template + template () +#endif + > typename detail::is_backend_info_desc::return_type get_backend_info() const; diff --git a/sycl/include/sycl/queue.hpp b/sycl/include/sycl/queue.hpp index e4fce00ff0288..ffe7b5fa469d9 100644 --- a/sycl/include/sycl/queue.hpp +++ b/sycl/include/sycl/queue.hpp @@ -342,7 +342,12 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase { /// Queries SYCL queue for SYCL backend-specific information. /// /// The return type depends on information being queried. - template + template () +#endif + > typename detail::is_backend_info_desc::return_type get_backend_info() const; diff --git a/sycl/test-e2e/Basic/backend_info.cpp b/sycl/test-e2e/Basic/backend_info.cpp index 2a33d3b394f34..f61b1809a6e46 100644 --- a/sycl/test-e2e/Basic/backend_info.cpp +++ b/sycl/test-e2e/Basic/backend_info.cpp @@ -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---------------------------==// // @@ -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_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() << 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() << std::endl; @@ -33,9 +40,13 @@ int main() { std::vector 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() << 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() << std::endl; @@ -43,22 +54,34 @@ int main() { // 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() << 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() << 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() << 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() << 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() << 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() << std::endl; @@ -73,8 +96,12 @@ int main() { auto acc = buf.get_access(cgh); cgh.single_task(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() << 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() << std::endl; } catch (exception e) { @@ -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; }