From 487dce49e6ad21fb8275d8300806c53210fe91e5 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sun, 1 Oct 2023 20:49:47 -0700 Subject: [PATCH 01/21] [SYCL] Don't include iostream from sycl.hpp --- sycl/include/sycl/backend_types.hpp | 31 +----------- .../include/sycl/detail/accessor_iterator.hpp | 2 +- sycl/include/sycl/detail/device_filter.hpp | 2 +- sycl/include/sycl/detail/iostream_proxy.hpp | 2 +- sycl/include/sycl/exception_list.hpp | 17 +------ sycl/include/sycl/half_type.hpp | 13 +---- sycl/include/sycl/types.hpp | 2 +- sycl/include/syclcompat/device.hpp | 2 +- sycl/plugins/level_zero/tracing.cpp | 1 + sycl/source/CMakeLists.txt | 2 + sycl/source/backend_types.cpp | 47 +++++++++++++++++++ sycl/source/detail/spec_constant_impl.cpp | 1 + sycl/source/exception_list.cpp | 21 +++++++++ sycl/source/half_type.cpp | 31 ++++++++++++ sycl/source/spirv_ops.cpp | 1 + sycl/test/abi/sycl_symbols_linux.dump | 4 ++ 16 files changed, 119 insertions(+), 60 deletions(-) create mode 100644 sycl/source/backend_types.cpp create mode 100644 sycl/source/half_type.cpp diff --git a/sycl/include/sycl/backend_types.hpp b/sycl/include/sycl/backend_types.hpp index d1b89832064ce..72c951b8e924c 100644 --- a/sycl/include/sycl/backend_types.hpp +++ b/sycl/include/sycl/backend_types.hpp @@ -10,7 +10,7 @@ #include // for __SYCL2020_DEPRECATED -#include // for operator<<, ostream +#include // for operator<<, ostream namespace sycl { inline namespace _V1 { @@ -36,34 +36,7 @@ template using backend_return_t = typename backend_traits::template return_type; -inline std::ostream &operator<<(std::ostream &Out, backend be) { - switch (be) { - case backend::host: - Out << "host"; - break; - case backend::opencl: - Out << "opencl"; - break; - case backend::ext_oneapi_level_zero: - Out << "ext_oneapi_level_zero"; - break; - case backend::ext_oneapi_cuda: - Out << "ext_oneapi_cuda"; - break; - case backend::ext_intel_esimd_emulator: - Out << "ext_intel_esimd_emulator"; - break; - case backend::ext_oneapi_hip: - Out << "ext_oneapi_hip"; - break; - case backend::ext_native_cpu: - Out << "ext_native_cpu"; - break; - case backend::all: - Out << "all"; - } - return Out; -} +std::ostream &operator<<(std::ostream &Out, backend be); } // namespace _V1 } // namespace sycl diff --git a/sycl/include/sycl/detail/accessor_iterator.hpp b/sycl/include/sycl/detail/accessor_iterator.hpp index 97c5385bf3624..917139a12d952 100644 --- a/sycl/include/sycl/detail/accessor_iterator.hpp +++ b/sycl/include/sycl/detail/accessor_iterator.hpp @@ -13,8 +13,8 @@ #include // for id #include // for size_t +#include // for operator<<, ostream, ptrdiff_t #include // for random_access_iterator_tag -#include // for operator<<, ostream, ptrdiff_t /// \file accessor_iterator.hpp /// The file contains implementation of accessor iterator class. diff --git a/sycl/include/sycl/detail/device_filter.hpp b/sycl/include/sycl/detail/device_filter.hpp index 44e4a2d4ff3a9..85e7ada657d9f 100644 --- a/sycl/include/sycl/detail/device_filter.hpp +++ b/sycl/include/sycl/detail/device_filter.hpp @@ -12,8 +12,8 @@ #include #include +#include #include -#include #include namespace sycl { diff --git a/sycl/include/sycl/detail/iostream_proxy.hpp b/sycl/include/sycl/detail/iostream_proxy.hpp index 76f432d687d13..847e8017ec4d2 100644 --- a/sycl/include/sycl/detail/iostream_proxy.hpp +++ b/sycl/include/sycl/detail/iostream_proxy.hpp @@ -8,7 +8,7 @@ #pragma once -#include // for ostream, istream +#include // for ostream, istream // Hotfix to account for the different namespaces in libstdc++ and libc++ #ifdef _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/sycl/include/sycl/exception_list.hpp b/sycl/include/sycl/exception_list.hpp index 2a0202fa020a9..cf57d994acbf2 100644 --- a/sycl/include/sycl/exception_list.hpp +++ b/sycl/include/sycl/exception_list.hpp @@ -15,7 +15,7 @@ #include // for size_t #include // for exception_ptr, exception -#include // for operator<<, basic_ostream +#include // for operator<<, basic_ostream #include // for vector namespace sycl { @@ -55,20 +55,7 @@ class __SYCL_EXPORT exception_list { namespace detail { // Default implementation of async_handler used by queue and context when no // user-defined async_handler is specified. -inline void defaultAsyncHandler(exception_list Exceptions) { - std::cerr << "Default async_handler caught exceptions:"; - for (auto &EIt : Exceptions) { - try { - if (EIt) { - std::rethrow_exception(EIt); - } - } catch (const std::exception &E) { - std::cerr << "\n\t" << E.what(); - } - } - std::cerr << std::endl; - std::terminate(); -} +void defaultAsyncHandler(exception_list Exceptions); } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/include/sycl/half_type.hpp b/sycl/include/sycl/half_type.hpp index 1dac778320977..26130b44ae947 100644 --- a/sycl/include/sycl/half_type.hpp +++ b/sycl/include/sycl/half_type.hpp @@ -531,18 +531,9 @@ class [[__sycl_detail__::__uses_aspects__(aspect::fp16)]] half { } // Operator << and >> - inline friend std::ostream &operator<<(std::ostream &O, - sycl::half const &rhs) { - O << static_cast(rhs); - return O; - } + friend std::ostream &operator<<(std::ostream &O, sycl::half const &rhs); - inline friend std::istream &operator>>(std::istream &I, sycl::half &rhs) { - float ValFloat = 0.0f; - I >> ValFloat; - rhs = ValFloat; - return I; - } + friend std::istream &operator>>(std::istream &I, sycl::half &rhs); template friend struct std::hash; diff --git a/sycl/include/sycl/types.hpp b/sycl/include/sycl/types.hpp index e69397e8c72b9..c0d09280518cb 100644 --- a/sycl/include/sycl/types.hpp +++ b/sycl/include/sycl/types.hpp @@ -50,9 +50,9 @@ #include // for size_t, NULL, byte #include // for uint8_t, int16_t, int... #include // for divides, multiplies +#include // for operator<<, basic_ost... #include // for pair #include // for optional -#include // for operator<<, basic_ost... #include // for tuple #include // for enable_if_t, is_same #include // for index_sequence, make_... diff --git a/sycl/include/syclcompat/device.hpp b/sycl/include/syclcompat/device.hpp index be02a42aff4cf..c582820bf1569 100644 --- a/sycl/include/syclcompat/device.hpp +++ b/sycl/include/syclcompat/device.hpp @@ -33,7 +33,7 @@ #include #include -#include +#include #include #include #include diff --git a/sycl/plugins/level_zero/tracing.cpp b/sycl/plugins/level_zero/tracing.cpp index 0049c67a61701..ca78368030308 100644 --- a/sycl/plugins/level_zero/tracing.cpp +++ b/sycl/plugins/level_zero/tracing.cpp @@ -12,6 +12,7 @@ #endif #include +#include #include #include diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index 1bde471cd67ac..a9de6ddc5195c 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -217,6 +217,7 @@ set(SYCL_SOURCES "detail/util.cpp" "detail/xpti_registry.cpp" "accessor.cpp" + "backend_types.cpp" "buffer.cpp" "context.cpp" "device.cpp" @@ -224,6 +225,7 @@ set(SYCL_SOURCES "event.cpp" "exception.cpp" "exception_list.cpp" + "half_type.cpp" "handler.cpp" "image.cpp" "interop_handle.cpp" diff --git a/sycl/source/backend_types.cpp b/sycl/source/backend_types.cpp new file mode 100644 index 0000000000000..aee3e160a9592 --- /dev/null +++ b/sycl/source/backend_types.cpp @@ -0,0 +1,47 @@ +//==------------------- backend_types.cpp ----------------------------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#include +#include + +namespace sycl { +inline namespace _V1 { + +__SYCL_EXPORT std::ostream &operator<<(std::ostream &Out, backend be) { + switch (be) { + case backend::host: + Out << "host"; + break; + case backend::opencl: + Out << "opencl"; + break; + case backend::ext_oneapi_level_zero: + Out << "ext_oneapi_level_zero"; + break; + case backend::ext_oneapi_cuda: + Out << "ext_oneapi_cuda"; + break; + case backend::ext_intel_esimd_emulator: + Out << "ext_intel_esimd_emulator"; + break; + case backend::ext_oneapi_hip: + Out << "ext_oneapi_hip"; + break; + case backend::ext_native_cpu: + Out << "ext_native_cpu"; + break; + case backend::all: + Out << "all"; + } + return Out; +} + +} // namespace _V1 +} // namespace sycl \ No newline at end of file diff --git a/sycl/source/detail/spec_constant_impl.cpp b/sycl/source/detail/spec_constant_impl.cpp index 13fbf9fcc9bdd..4c77ff72e772b 100644 --- a/sycl/source/detail/spec_constant_impl.cpp +++ b/sycl/source/detail/spec_constant_impl.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include diff --git a/sycl/source/exception_list.cpp b/sycl/source/exception_list.cpp index 2b31ec3177501..63cfb1aba519d 100644 --- a/sycl/source/exception_list.cpp +++ b/sycl/source/exception_list.cpp @@ -9,6 +9,8 @@ // 4.9.2 Exception Class Interface #include +#include +#include #include namespace sycl { @@ -30,5 +32,24 @@ void exception_list::PushBack(value_type &&Value) { void exception_list::Clear() noexcept { MList.clear(); } +namespace detail { +// Default implementation of async_handler used by queue and context when no +// user-defined async_handler is specified. +__SYCL_EXPORT void defaultAsyncHandler(exception_list Exceptions) { + std::cerr << "Default async_handler caught exceptions:"; + for (auto &EIt : Exceptions) { + try { + if (EIt) { + std::rethrow_exception(EIt); + } + } catch (const std::exception &E) { + std::cerr << "\n\t" << E.what(); + } + } + std::cerr << std::endl; + std::terminate(); +} +} // namespace detail + } // namespace _V1 } // namespace sycl diff --git a/sycl/source/half_type.cpp b/sycl/source/half_type.cpp new file mode 100644 index 0000000000000..6cfbde14a9eff --- /dev/null +++ b/sycl/source/half_type.cpp @@ -0,0 +1,31 @@ +//==---------------- half-type.cpp - SYCL half type ------------------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#include +#include + +namespace sycl { +inline namespace _V1 { +namespace half_impl { + __SYCL_EXPORT std::ostream &operator<<(std::ostream &O, + sycl::half const &rhs) { + O << static_cast(rhs); + return O; + } + + __SYCL_EXPORT std::istream &operator>>(std::istream &I, sycl::half &rhs) { + float ValFloat = 0.0f; + I >> ValFloat; + rhs = ValFloat; + return I; + } +} // namespace half_impl +} // namespace _V1 +} // namespace sycl \ No newline at end of file diff --git a/sycl/source/spirv_ops.cpp b/sycl/source/spirv_ops.cpp index a635dea89d955..7787d0b5c0f4c 100644 --- a/sycl/source/spirv_ops.cpp +++ b/sycl/source/spirv_ops.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index a8a3db4b4e245..859cdb531fd7b 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3975,6 +3975,7 @@ _ZN4sycl3_V16detail18make_kernel_bundleEmRKNS0_7contextEbNS0_12bundle_stateENS0_ _ZN4sycl3_V16detail18stringifyErrorCodeEi _ZN4sycl3_V16detail19convertChannelOrderE23_pi_image_channel_order _ZN4sycl3_V16detail19convertChannelOrderENS0_19image_channel_orderE +_ZN4sycl3_V16detail19defaultAsyncHandlerENS0_14exception_listE _ZN4sycl3_V16detail19getImageElementSizeEhNS0_18image_channel_typeE _ZN4sycl3_V16detail19getPluginOpaqueDataILNS0_7backendE5EEEPvS4_ _ZN4sycl3_V16detail19kernel_bundle_plain32set_specialization_constant_implEPKcPvm @@ -4182,8 +4183,11 @@ _ZN4sycl3_V19exceptionC2EiRKNSt3_V214error_categoryERKNSt7__cxx1112basic_stringI _ZN4sycl3_V19exceptionD0Ev _ZN4sycl3_V19exceptionD1Ev _ZN4sycl3_V19exceptionD2Ev +_ZN4sycl3_V19half_impllsERSoRKNS0_6detail9half_impl4halfE +_ZN4sycl3_V19half_implrsERSiRNS0_6detail9half_impl4halfE _ZN4sycl3_V19kernel_idC1EPKc _ZN4sycl3_V19kernel_idC2EPKc +_ZN4sycl3_V1lsERSoNS0_7backendE _ZNK4sycl3_V112cpu_selectorclERKNS0_6deviceE _ZNK4sycl3_V112gpu_selectorclERKNS0_6deviceE _ZNK4sycl3_V113host_selectorclERKNS0_6deviceE From 43567c7068f139749f9fd65c150867ed00303e22 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sun, 1 Oct 2023 21:01:37 -0700 Subject: [PATCH 02/21] format --- sycl/source/half_type.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/sycl/source/half_type.cpp b/sycl/source/half_type.cpp index 6cfbde14a9eff..9c4d64506b36c 100644 --- a/sycl/source/half_type.cpp +++ b/sycl/source/half_type.cpp @@ -14,18 +14,17 @@ namespace sycl { inline namespace _V1 { namespace half_impl { - __SYCL_EXPORT std::ostream &operator<<(std::ostream &O, - sycl::half const &rhs) { - O << static_cast(rhs); - return O; - } +__SYCL_EXPORT std::ostream &operator<<(std::ostream &O, sycl::half const &rhs) { + O << static_cast(rhs); + return O; +} - __SYCL_EXPORT std::istream &operator>>(std::istream &I, sycl::half &rhs) { - float ValFloat = 0.0f; - I >> ValFloat; - rhs = ValFloat; - return I; - } +__SYCL_EXPORT std::istream &operator>>(std::istream &I, sycl::half &rhs) { + float ValFloat = 0.0f; + I >> ValFloat; + rhs = ValFloat; + return I; +} } // namespace half_impl } // namespace _V1 -} // namespace sycl \ No newline at end of file +} // namespace sycl From 7bfde94fb75bf4a438ef0212d7086c3d67dfeb16 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sun, 1 Oct 2023 21:44:06 -0700 Subject: [PATCH 03/21] fix export, half-NS --- sycl/include/sycl/backend_types.hpp | 3 ++- sycl/include/sycl/exception_list.hpp | 2 +- sycl/include/sycl/half_type.hpp | 4 ++-- sycl/source/backend_types.cpp | 3 +-- sycl/source/exception_list.cpp | 2 +- sycl/source/half_type.cpp | 10 +++++++--- sycl/test/abi/sycl_symbols_linux.dump | 4 ++-- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/sycl/include/sycl/backend_types.hpp b/sycl/include/sycl/backend_types.hpp index 72c951b8e924c..a6cdb3bf0aad7 100644 --- a/sycl/include/sycl/backend_types.hpp +++ b/sycl/include/sycl/backend_types.hpp @@ -11,6 +11,7 @@ #include // for __SYCL2020_DEPRECATED #include // for operator<<, ostream +#include namespace sycl { inline namespace _V1 { @@ -36,7 +37,7 @@ template using backend_return_t = typename backend_traits::template return_type; -std::ostream &operator<<(std::ostream &Out, backend be); +__SYCL_EXPORT std::ostream &operator<<(std::ostream &Out, backend be); } // namespace _V1 } // namespace sycl diff --git a/sycl/include/sycl/exception_list.hpp b/sycl/include/sycl/exception_list.hpp index cf57d994acbf2..bed33b7cc6c28 100644 --- a/sycl/include/sycl/exception_list.hpp +++ b/sycl/include/sycl/exception_list.hpp @@ -55,7 +55,7 @@ class __SYCL_EXPORT exception_list { namespace detail { // Default implementation of async_handler used by queue and context when no // user-defined async_handler is specified. -void defaultAsyncHandler(exception_list Exceptions); +__SYCL_EXPORT void defaultAsyncHandler(exception_list Exceptions); } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/include/sycl/half_type.hpp b/sycl/include/sycl/half_type.hpp index 26130b44ae947..faef7eafecfef 100644 --- a/sycl/include/sycl/half_type.hpp +++ b/sycl/include/sycl/half_type.hpp @@ -531,9 +531,9 @@ class [[__sycl_detail__::__uses_aspects__(aspect::fp16)]] half { } // Operator << and >> - friend std::ostream &operator<<(std::ostream &O, sycl::half const &rhs); + friend __SYCL_EXPORT std::ostream &operator<<(std::ostream &O, sycl::half const &rhs); - friend std::istream &operator>>(std::istream &I, sycl::half &rhs); + friend __SYCL_EXPORT std::istream &operator>>(std::istream &I, sycl::half &rhs); template friend struct std::hash; diff --git a/sycl/source/backend_types.cpp b/sycl/source/backend_types.cpp index aee3e160a9592..bc432c4be5a81 100644 --- a/sycl/source/backend_types.cpp +++ b/sycl/source/backend_types.cpp @@ -9,12 +9,11 @@ #include #include -#include namespace sycl { inline namespace _V1 { -__SYCL_EXPORT std::ostream &operator<<(std::ostream &Out, backend be) { +std::ostream &operator<<(std::ostream &Out, backend be) { switch (be) { case backend::host: Out << "host"; diff --git a/sycl/source/exception_list.cpp b/sycl/source/exception_list.cpp index 63cfb1aba519d..1a16f4df34f55 100644 --- a/sycl/source/exception_list.cpp +++ b/sycl/source/exception_list.cpp @@ -35,7 +35,7 @@ void exception_list::Clear() noexcept { MList.clear(); } namespace detail { // Default implementation of async_handler used by queue and context when no // user-defined async_handler is specified. -__SYCL_EXPORT void defaultAsyncHandler(exception_list Exceptions) { +void defaultAsyncHandler(exception_list Exceptions) { std::cerr << "Default async_handler caught exceptions:"; for (auto &EIt : Exceptions) { try { diff --git a/sycl/source/half_type.cpp b/sycl/source/half_type.cpp index 9c4d64506b36c..9fbbf46cae29f 100644 --- a/sycl/source/half_type.cpp +++ b/sycl/source/half_type.cpp @@ -13,18 +13,22 @@ namespace sycl { inline namespace _V1 { +namespace detail { namespace half_impl { -__SYCL_EXPORT std::ostream &operator<<(std::ostream &O, sycl::half const &rhs) { + +std::ostream &operator<<(std::ostream &O, half const &rhs) { O << static_cast(rhs); return O; } -__SYCL_EXPORT std::istream &operator>>(std::istream &I, sycl::half &rhs) { +std::istream &operator>>(std::istream &I, half &rhs) { float ValFloat = 0.0f; I >> ValFloat; rhs = ValFloat; return I; } + } // namespace half_impl +} // namespace detail } // namespace _V1 -} // namespace sycl +} // namespace sycl \ No newline at end of file diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 859cdb531fd7b..9e60496331c98 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -4034,6 +4034,8 @@ _ZN4sycl3_V16detail6OSUtil12alignedAllocEmm _ZN4sycl3_V16detail6OSUtil12getOSMemSizeEv _ZN4sycl3_V16detail6OSUtil16getCurrentDSODirB5cxx11Ev _ZN4sycl3_V16detail6OSUtil7makeDirEPKc +_ZN4sycl3_V16detail9half_impllsERSoRKNS2_4halfE +_ZN4sycl3_V16detail9half_implrsERSiRNS2_4halfE _ZN4sycl3_V16detail9join_implERKSt6vectorISt10shared_ptrINS1_18kernel_bundle_implEESaIS5_EENS0_12bundle_stateE _ZN4sycl3_V16detail9link_implERKSt6vectorINS0_13kernel_bundleILNS0_12bundle_stateE1EEESaIS5_EERKS2_INS0_6deviceESaISA_EERKNS0_13property_listE _ZN4sycl3_V16device11get_devicesENS0_4info11device_typeE @@ -4183,8 +4185,6 @@ _ZN4sycl3_V19exceptionC2EiRKNSt3_V214error_categoryERKNSt7__cxx1112basic_stringI _ZN4sycl3_V19exceptionD0Ev _ZN4sycl3_V19exceptionD1Ev _ZN4sycl3_V19exceptionD2Ev -_ZN4sycl3_V19half_impllsERSoRKNS0_6detail9half_impl4halfE -_ZN4sycl3_V19half_implrsERSiRNS0_6detail9half_impl4halfE _ZN4sycl3_V19kernel_idC1EPKc _ZN4sycl3_V19kernel_idC2EPKc _ZN4sycl3_V1lsERSoNS0_7backendE From 39a8d985932836d50dc9801471fe7350e0b652cc Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sun, 1 Oct 2023 21:45:51 -0700 Subject: [PATCH 04/21] format --- sycl/include/sycl/half_type.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sycl/include/sycl/half_type.hpp b/sycl/include/sycl/half_type.hpp index faef7eafecfef..4ee3eeace191b 100644 --- a/sycl/include/sycl/half_type.hpp +++ b/sycl/include/sycl/half_type.hpp @@ -531,9 +531,11 @@ class [[__sycl_detail__::__uses_aspects__(aspect::fp16)]] half { } // Operator << and >> - friend __SYCL_EXPORT std::ostream &operator<<(std::ostream &O, sycl::half const &rhs); + friend __SYCL_EXPORT std::ostream &operator<<(std::ostream &O, + sycl::half const &rhs); - friend __SYCL_EXPORT std::istream &operator>>(std::istream &I, sycl::half &rhs); + friend __SYCL_EXPORT std::istream &operator>>(std::istream &I, + sycl::half &rhs); template friend struct std::hash; From c4823f6c5250bb5b87622d085ce85aa202a68d69 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Tue, 3 Oct 2023 21:53:53 -0700 Subject: [PATCH 05/21] Fix has_builtin for gcc/msvc --- sycl/include/sycl/bit_cast.hpp | 11 ++++++----- sycl/include/sycl/half_type.hpp | 14 +++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/sycl/include/sycl/bit_cast.hpp b/sycl/include/sycl/bit_cast.hpp index e9f92b7cf6c50..e49e7a53300a5 100644 --- a/sycl/include/sycl/bit_cast.hpp +++ b/sycl/include/sycl/bit_cast.hpp @@ -14,9 +14,11 @@ #include // defines __cpp_lib_bit_cast #endif +#include // __has_builtin + #if __cpp_lib_bit_cast #include -#elif !defined(__has_builtin) || !__has_builtin(__builtin_bit_cast) +#elif !__has_builtin(__builtin_bit_cast) #include #endif @@ -24,8 +26,7 @@ namespace sycl { inline namespace _V1 { template -#if __cpp_lib_bit_cast || \ - (defined(__has_builtin) && __has_builtin(__builtin_bit_cast)) +#if __cpp_lib_bit_cast || __has_builtin(__builtin_bit_cast) constexpr #endif std::enable_if_t(from); #else // __cpp_lib_bit_cast -#if defined(__has_builtin) && __has_builtin(__builtin_bit_cast) +#if __has_builtin(__builtin_bit_cast) return __builtin_bit_cast(To, from); -#else // __has_builtin(__builtin_bit_cast) +#else // __has_builtin(__builtin_bit_cast) static_assert(std::is_trivially_default_constructible::value, "To must be trivially default constructible"); To to; diff --git a/sycl/include/sycl/half_type.hpp b/sycl/include/sycl/half_type.hpp index 4ee3eeace191b..0d90bdc9366e3 100644 --- a/sycl/include/sycl/half_type.hpp +++ b/sycl/include/sycl/half_type.hpp @@ -8,10 +8,11 @@ #pragma once -#include // for bit_cast -#include // for __SYCL_EXPORT -#include // for istream, ostream -#include // for vector_alignment +#include // for bit_cast +#include // for __has_builtin +#include // for __SYCL_EXPORT +#include // for istream, ostream +#include // for vector_alignment #ifdef __SYCL_DEVICE_ONLY__ #include @@ -24,7 +25,7 @@ #include // for hash #include // for enable_if_t -#if !defined(__has_builtin) || !__has_builtin(__builtin_expect) +#if !__has_builtin(__builtin_expect) #define __builtin_expect(a, b) (a) #endif @@ -32,8 +33,7 @@ // `constexpr` could work because the implicit conversion from `float` to // `_Float16` can be `constexpr`. #define __SYCL_CONSTEXPR_HALF constexpr -#elif __cpp_lib_bit_cast || \ - (defined(__has_builtin) && __has_builtin(__builtin_bit_cast)) +#elif __cpp_lib_bit_cast || __has_builtin(__builtin_bit_cast) #define __SYCL_CONSTEXPR_HALF constexpr #else #define __SYCL_CONSTEXPR_HALF From 08b490b17bf024efc6a367c2cd959c77b9b17988 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Tue, 3 Oct 2023 21:56:06 -0700 Subject: [PATCH 06/21] format --- sycl/include/sycl/bit_cast.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/sycl/bit_cast.hpp b/sycl/include/sycl/bit_cast.hpp index e49e7a53300a5..23dfef3ee82f3 100644 --- a/sycl/include/sycl/bit_cast.hpp +++ b/sycl/include/sycl/bit_cast.hpp @@ -40,7 +40,7 @@ constexpr #if __has_builtin(__builtin_bit_cast) return __builtin_bit_cast(To, from); -#else // __has_builtin(__builtin_bit_cast) +#else // __has_builtin(__builtin_bit_cast) static_assert(std::is_trivially_default_constructible::value, "To must be trivially default constructible"); To to; From 8255c42e0015c3da981812b7d4f2b70214402184 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Tue, 3 Oct 2023 22:47:40 -0700 Subject: [PATCH 07/21] windows symbols --- sycl/test/abi/sycl_symbols_windows.dump | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index f88e35e826ef6..72b2ed75c72d8 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -775,6 +775,9 @@ ??4stream_impl@detail@_V1@sycl@@QEAAAEAV0123@$$QEAV0123@@Z ??4stream_impl@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z ??4tls_code_loc_t@detail@_V1@sycl@@QEAAAEAV0123@AEBV0123@@Z +??5half_impl@detail@_V1@sycl@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@std@@AEAV45@AEAVhalf@0123@@Z +??6half_impl@detail@_V1@sycl@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV45@AEBVhalf@0123@@Z +??6_V1@sycl@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV23@W4backend@01@@Z ??8context@_V1@sycl@@QEBA_NAEBV012@@Z ??8device@_V1@sycl@@QEBA_NAEBV012@@Z ??8device_image_plain@detail@_V1@sycl@@QEBA_NAEBV0123@@Z @@ -973,6 +976,7 @@ ?create_image@experimental@oneapi@ext@_V1@sycl@@YA?AUunsampled_image_handle@12345@AEAVimage_mem@12345@AEBUimage_descriptor@12345@AEBVqueue@45@@Z ?create_image@experimental@oneapi@ext@_V1@sycl@@YA?AUunsampled_image_handle@12345@Uimage_mem_handle@12345@AEBUimage_descriptor@12345@AEBVdevice@45@AEBVcontext@45@@Z ?create_image@experimental@oneapi@ext@_V1@sycl@@YA?AUunsampled_image_handle@12345@Uimage_mem_handle@12345@AEBUimage_descriptor@12345@AEBVqueue@45@@Z +?defaultAsyncHandler@detail@_V1@sycl@@YAXVexception_list@23@@Z ?default_selector_v@_V1@sycl@@YAHAEBVdevice@12@@Z ?deleteAccProps@buffer_plain@detail@_V1@sycl@@IEAAXAEBW4PropWithDataKind@234@@Z ?deleteAccessorProperty@SYCLMemObjT@detail@_V1@sycl@@QEAAXAEBW4PropWithDataKind@234@@Z From 2f0cb11084a07889e2a6f9e84367ac4ad241ad5b Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Wed, 4 Oct 2023 23:44:58 -0700 Subject: [PATCH 08/21] keep it unless SYCL2020_CONFORMANT_APIS --- sycl/include/sycl/sycl.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/include/sycl/sycl.hpp b/sycl/include/sycl/sycl.hpp index 73c481129a5f1..be39ce8f86bc6 100644 --- a/sycl/include/sycl/sycl.hpp +++ b/sycl/include/sycl/sycl.hpp @@ -96,4 +96,5 @@ // We used to include those and some code might be reliant on that. #include #include +#include #endif From 8a51b319ce7c02024e7c5df7cf2a46578ba69833 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sat, 7 Oct 2023 18:56:25 -0700 Subject: [PATCH 09/21] Don't include sstream, add test also include headers unless SYCL2020_CONFORMANT_APIS --- sycl/doc/developer/ContributeToDPCPP.md | 4 +- .../include/sycl/detail/accessor_iterator.hpp | 34 +++++++++++----- sycl/include/sycl/detail/common.hpp | 5 +-- sycl/include/sycl/detail/device_filter.hpp | 40 +++---------------- sycl/include/sycl/detail/pi.hpp | 17 -------- sycl/include/sycl/exception_list.hpp | 3 +- .../intel/esimd/detail/half_type_traits.hpp | 3 ++ sycl/include/sycl/ext/intel/esimd/simd.hpp | 2 + sycl/include/sycl/half_type.hpp | 2 +- sycl/include/sycl/handler.hpp | 4 +- sycl/include/sycl/sycl.hpp | 5 ++- sycl/source/CMakeLists.txt | 1 + sycl/source/detail/accessor_iterator.cpp | 35 ++++++++++++++++ sycl/source/detail/config.hpp | 2 + sycl/source/detail/device_binary_image.hpp | 2 + sycl/source/detail/device_filter.cpp | 37 +++++++++++++++++ sycl/source/detail/device_info.hpp | 1 + .../detail/persistent_device_code_cache.hpp | 1 + sycl/source/detail/plugin.hpp | 1 + sycl/source/detail/plugin_printers.hpp | 2 + sycl/source/detail/posix_pi.cpp | 1 + .../esimd_emulator_device_interface.cpp | 2 + sycl/test/abi/sycl_symbols_linux.dump | 3 ++ sycl/test/basic_tests/no_iostream_include.cpp | 12 ++++++ sycl/unittests/pi/BackendString.hpp | 1 + sycl/unittests/pi/TestGetPlugin.hpp | 1 + 26 files changed, 147 insertions(+), 74 deletions(-) create mode 100644 sycl/source/detail/accessor_iterator.cpp create mode 100644 sycl/test/basic_tests/no_iostream_include.cpp diff --git a/sycl/doc/developer/ContributeToDPCPP.md b/sycl/doc/developer/ContributeToDPCPP.md index 63b7d4f4632a3..69fa6d7404c2f 100644 --- a/sycl/doc/developer/ContributeToDPCPP.md +++ b/sycl/doc/developer/ContributeToDPCPP.md @@ -42,8 +42,8 @@ According to the use `#include ` is forbidden in library files. Instead, the sycl/detail/iostream_proxy.hpp header offers the functionality of without its static constructor. -This header should be used in place of in DPC++ headers and runtime -library files. +This header should be used in place of in DPC++ and runtime +library files. In DPC++ header files only should be used. ## Tests development diff --git a/sycl/include/sycl/detail/accessor_iterator.hpp b/sycl/include/sycl/detail/accessor_iterator.hpp index 917139a12d952..5c993811dca23 100644 --- a/sycl/include/sycl/detail/accessor_iterator.hpp +++ b/sycl/include/sycl/detail/accessor_iterator.hpp @@ -45,6 +45,10 @@ class accessor; namespace detail { +struct accessor_iterator_data; +__SYCL_EXPORT std::ostream &operator<<(std::ostream &os, + const accessor_iterator_data &it); + template class accessor_iterator { public: using difference_type = std::ptrdiff_t; @@ -331,22 +335,30 @@ template class accessor_iterator { #ifndef NDEBUG // Could be useful for debugging, but not a part of the official API, // therefore only available in builds with assertions enabled. + friend struct accessor_iterator_data; friend std::ostream &operator<<(std::ostream &os, const accessor_iterator &it) { - os << "accessor_iterator {\n"; - os << "\tMLinearId: " << it.MLinearId << "\n"; - os << "\tMEnd: " << it.MEnd << "\n"; - os << "\tMStaticOffset: " << it.MStaticOffset << "\n"; - os << "\tMPerRowOffset: " << it.MPerRowOffset << "\n"; - os << "\tMPerSliceOffset: " << it.MPerSliceOffset << "\n"; - os << "\tMRowSize: " << it.MRowSize << "\n"; - os << "\tMSliceSize: " << it.MSliceSize << "\n"; - os << "\tMAccessorIsRanged: " << it.MAccessorIsRanged << "\n"; - os << "}"; - return os; + return os << accessor_iterator_data(it); } #endif // NDEBUG }; +// non-templated copy of accessor_iterator to pass to library +struct accessor_iterator_data { + template + accessor_iterator_data(accessor_iterator it) + : MLinearId(it.MLinearId), MEnd(it.MEnd), MStaticOffset(it.MStaticOffset), + MPerSliceOffset(it.MPerSliceOffset), MPerRowOffset(it.MPerRowOffset), + MRowSize(it.MRowSize), MSliceSize(it.MSliceSize), + MAccessorIsRanged(it.MAccessorIsRanged) {} + size_t MLinearId; + size_t MEnd; + size_t MStaticOffset; + size_t MPerSliceOffset; + size_t MPerRowOffset; + size_t MRowSize; + size_t MSliceSize; + bool MAccessorIsRanged; +}; } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/include/sycl/detail/common.hpp b/sycl/include/sycl/detail/common.hpp index a8c94e32d81c6..ca44038e59f19 100644 --- a/sycl/include/sycl/detail/common.hpp +++ b/sycl/include/sycl/detail/common.hpp @@ -173,14 +173,13 @@ inline std::string codeToString(pi_int32 code) { "Native API returns: " #ifndef __SYCL_SUPPRESS_PI_ERROR_REPORT -#include // TODO: rename all names with direct use of OCL/OPENCL to be backend agnostic. #define __SYCL_REPORT_PI_ERR_TO_STREAM(expr) \ { \ auto code = expr; \ if (code != PI_SUCCESS) { \ - std::cerr << __SYCL_PI_ERROR_REPORT << sycl::detail::codeToString(code) \ - << std::endl; \ + fprintf(stderr, __SYCL_PI_ERROR_REPORT "%s\n", \ + sycl::detail::codeToString(code)); \ } \ } #endif diff --git a/sycl/include/sycl/detail/device_filter.hpp b/sycl/include/sycl/detail/device_filter.hpp index 85e7ada657d9f..4b826cd579d47 100644 --- a/sycl/include/sycl/detail/device_filter.hpp +++ b/sycl/include/sycl/detail/device_filter.hpp @@ -23,11 +23,6 @@ namespace detail { // --------------------------------------- // ONEAPI_DEVICE_SELECTOR support -template -std::ostream &operator<<(std::ostream &os, std::optional const &opt) { - return opt ? os << opt.value() : os << "not set "; -} - // the ONEAPI_DEVICE_SELECTOR string gets broken down into these targets // will will match devices. If the target is negative, such as !opencl:* // then matching devices will not be made available to the user. @@ -97,36 +92,11 @@ class device_filter_list { const device_filter_list &List); }; -inline std::ostream &operator<<(std::ostream &Out, - const device_filter &Filter) { - Out << Filter.Backend << ":"; - if (Filter.DeviceType == info::device_type::host) { - Out << "host"; - } else if (Filter.DeviceType == info::device_type::cpu) { - Out << "cpu"; - } else if (Filter.DeviceType == info::device_type::gpu) { - Out << "gpu"; - } else if (Filter.DeviceType == info::device_type::accelerator) { - Out << "accelerator"; - } else if (Filter.DeviceType == info::device_type::all) { - Out << "*"; - } else { - Out << "unknown"; - } - if (Filter.DeviceNum) { - Out << ":" << Filter.DeviceNum.value(); - } - return Out; -} - -inline std::ostream &operator<<(std::ostream &Out, - const device_filter_list &List) { - for (const device_filter &Filter : List.FilterList) { - Out << Filter; - Out << ","; - } - return Out; -} +__SYCL_EXPORT std::ostream &operator<<(std::ostream &Out, + const device_filter &Filter); + +__SYCL_EXPORT std::ostream &operator<<(std::ostream &Out, + const device_filter_list &List); } // namespace detail } // namespace _V1 diff --git a/sycl/include/sycl/detail/pi.hpp b/sycl/include/sycl/detail/pi.hpp index c4ddfe9fd1b44..8b4c5381e30d5 100644 --- a/sycl/include/sycl/detail/pi.hpp +++ b/sycl/include/sycl/detail/pi.hpp @@ -20,7 +20,6 @@ #include // for uint64_t, uint32_t #include // for shared_ptr -#include // for operator<<, basic_ostream, string... #include // for size_t #include // for char_traits, string #include // for false_type, true_type @@ -108,22 +107,6 @@ bool trace(TraceLevel level); __SYCL_EXPORT void assertion(bool Condition, const char *Message = nullptr); -template -void handleUnknownParamName(const char *functionName, T parameter) { - std::stringstream stream; - stream << "Unknown parameter " << parameter << " passed to " << functionName - << "\n"; - auto str = stream.str(); - auto msg = str.c_str(); - die(msg); -} - -// This macro is used to report invalid enumerators being passed to PI API -// GetInfo functions. It will print the name of the function that invoked it -// and the value of the unknown enumerator. -#define __SYCL_PI_HANDLE_UNKNOWN_PARAM_NAME(parameter) \ - { sycl::detail::pi::handleUnknownParamName(__func__, parameter); } - using PiPlugin = ::pi_plugin; using PiResult = ::pi_result; using PiPlatform = ::pi_platform; diff --git a/sycl/include/sycl/exception_list.hpp b/sycl/include/sycl/exception_list.hpp index bed33b7cc6c28..80467b6e3f524 100644 --- a/sycl/include/sycl/exception_list.hpp +++ b/sycl/include/sycl/exception_list.hpp @@ -10,8 +10,7 @@ // 4.9.2 Exception Class Interface -#include // for __SYCL_EXPORT -#include // for cerr +#include // for __SYCL_EXPORT #include // for size_t #include // for exception_ptr, exception diff --git a/sycl/include/sycl/ext/intel/esimd/detail/half_type_traits.hpp b/sycl/include/sycl/ext/intel/esimd/detail/half_type_traits.hpp index d7c572b4eb5a1..bc9dab1b724d4 100644 --- a/sycl/include/sycl/ext/intel/esimd/detail/half_type_traits.hpp +++ b/sycl/include/sycl/ext/intel/esimd/detail/half_type_traits.hpp @@ -14,6 +14,9 @@ #include +#include +#include + /// @cond ESIMD_DETAIL namespace sycl { diff --git a/sycl/include/sycl/ext/intel/esimd/simd.hpp b/sycl/include/sycl/ext/intel/esimd/simd.hpp index 4165c282b5ef9..8e545a09b8b7f 100644 --- a/sycl/include/sycl/ext/intel/esimd/simd.hpp +++ b/sycl/include/sycl/ext/intel/esimd/simd.hpp @@ -10,6 +10,8 @@ #pragma once +#include + #include #include diff --git a/sycl/include/sycl/half_type.hpp b/sycl/include/sycl/half_type.hpp index 0d90bdc9366e3..1e58be02d6ab2 100644 --- a/sycl/include/sycl/half_type.hpp +++ b/sycl/include/sycl/half_type.hpp @@ -11,7 +11,6 @@ #include // for bit_cast #include // for __has_builtin #include // for __SYCL_EXPORT -#include // for istream, ostream #include // for vector_alignment #ifdef __SYCL_DEVICE_ONLY__ @@ -21,6 +20,7 @@ #include // for size_t #include // for uint16_t, uint32_t, uint8_t #include // for hash +#include // for istream, ostream #include // for float_denorm_style, float_r... #include // for hash #include // for enable_if_t diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index a99f1138a8e27..96e3759ac1c7a 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -1177,8 +1177,8 @@ class __SYCL_EXPORT handler { bool DidAdjust = false; auto Adjust = [&](int Dim, size_t Value) { if (this->RangeRoundingTrace()) - std::cout << "parallel_for range adjusted at dim " << Dim << " from " - << RoundedRange[Dim] << " to " << Value << std::endl; + printf("parallel_for range adjusted at dim %d from %uz to %uz\n", Dim, + RoundedRange[Dim], Value); RoundedRange[Dim] = Value; DidAdjust = true; }; diff --git a/sycl/include/sycl/sycl.hpp b/sycl/include/sycl/sycl.hpp index be39ce8f86bc6..5efdb298af936 100644 --- a/sycl/include/sycl/sycl.hpp +++ b/sycl/include/sycl/sycl.hpp @@ -96,5 +96,8 @@ // We used to include those and some code might be reliant on that. #include #include -#include +#include +#include +#include +#include #endif diff --git a/sycl/source/CMakeLists.txt b/sycl/source/CMakeLists.txt index a9de6ddc5195c..a8ede9817c5e1 100644 --- a/sycl/source/CMakeLists.txt +++ b/sycl/source/CMakeLists.txt @@ -160,6 +160,7 @@ set(SYCL_SOURCES "backend/level_zero.cpp" "backend.cpp" "detail/accessor_impl.cpp" + "detail/accessor_iterator.cpp" "detail/allowlist.cpp" "detail/bindless_images.cpp" "detail/buffer_impl.cpp" diff --git a/sycl/source/detail/accessor_iterator.cpp b/sycl/source/detail/accessor_iterator.cpp new file mode 100644 index 0000000000000..9be95c50c8cd5 --- /dev/null +++ b/sycl/source/detail/accessor_iterator.cpp @@ -0,0 +1,35 @@ +//==---------------- accessor_iterator.cpp - SYCL standard source file -----==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include + +#include + +namespace sycl { +inline namespace _V1 { + +namespace detail { + +__SYCL_EXPORT std::ostream &operator<<(std::ostream &os, + const accessor_iterator_data &it) { + os << "accessor_iterator {\n"; + os << "\tMLinearId: " << it.MLinearId << "\n"; + os << "\tMEnd: " << it.MEnd << "\n"; + os << "\tMStaticOffset: " << it.MStaticOffset << "\n"; + os << "\tMPerRowOffset: " << it.MPerRowOffset << "\n"; + os << "\tMPerSliceOffset: " << it.MPerSliceOffset << "\n"; + os << "\tMRowSize: " << it.MRowSize << "\n"; + os << "\tMSliceSize: " << it.MSliceSize << "\n"; + os << "\tMAccessorIsRanged: " << it.MAccessorIsRanged << "\n"; + os << "}"; + return os; +} + +} // namespace detail +} // namespace _V1 +} // namespace sycl \ No newline at end of file diff --git a/sycl/source/detail/config.hpp b/sycl/source/detail/config.hpp index 02ce094579df2..be5bc8f75f21d 100644 --- a/sycl/source/detail/config.hpp +++ b/sycl/source/detail/config.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include #include diff --git a/sycl/source/detail/device_binary_image.hpp b/sycl/source/detail/device_binary_image.hpp index b2a74febe392f..a3f835e689f94 100644 --- a/sycl/source/detail/device_binary_image.hpp +++ b/sycl/source/detail/device_binary_image.hpp @@ -8,12 +8,14 @@ #pragma once #include +#include #include #include #include #include #include +#include namespace sycl { inline namespace _V1 { diff --git a/sycl/source/detail/device_filter.cpp b/sycl/source/detail/device_filter.cpp index 99bbcad3d7a22..c5fb332085158 100644 --- a/sycl/source/detail/device_filter.cpp +++ b/sycl/source/detail/device_filter.cpp @@ -19,6 +19,12 @@ namespace sycl { inline namespace _V1 { namespace detail { +template +std::ostream &operator<<(std::ostream &os, std::optional const &opt) { + return opt ? os << opt.value() : os << "not set "; + return os; +} + std::vector tokenize(const std::string_view &Filter, const std::string &Delim) { std::vector Tokens; @@ -406,6 +412,37 @@ bool device_filter_list::deviceNumberCompatible(int DeviceNum) { }); } +__SYCL_EXPORT std::ostream &operator<<(std::ostream &Out, + const device_filter &Filter) { + Out << Filter.Backend << ":"; + if (Filter.DeviceType == info::device_type::host) { + Out << "host"; + } else if (Filter.DeviceType == info::device_type::cpu) { + Out << "cpu"; + } else if (Filter.DeviceType == info::device_type::gpu) { + Out << "gpu"; + } else if (Filter.DeviceType == info::device_type::accelerator) { + Out << "accelerator"; + } else if (Filter.DeviceType == info::device_type::all) { + Out << "*"; + } else { + Out << "unknown"; + } + if (Filter.DeviceNum) { + Out << ":" << Filter.DeviceNum.value(); + } + return Out; +} + +__SYCL_EXPORT std::ostream &operator<<(std::ostream &Out, + const device_filter_list &List) { + for (const device_filter &Filter : List.FilterList) { + Out << Filter; + Out << ","; + } + return Out; +} + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 0ff49fe7b64f2..989d7e6716a95 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -27,6 +27,7 @@ #include #include +#include #include namespace sycl { diff --git a/sycl/source/detail/persistent_device_code_cache.hpp b/sycl/source/detail/persistent_device_code_cache.hpp index 323d52b859579..ed397f99e7ae5 100644 --- a/sycl/source/detail/persistent_device_code_cache.hpp +++ b/sycl/source/detail/persistent_device_code_cache.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/sycl/source/detail/plugin.hpp b/sycl/source/detail/plugin.hpp index 853027bf7c6bb..063e2f2671ebc 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/plugin.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/sycl/source/detail/plugin_printers.hpp b/sycl/source/detail/plugin_printers.hpp index 0da8e1c0efc26..a251d9003b96d 100644 --- a/sycl/source/detail/plugin_printers.hpp +++ b/sycl/source/detail/plugin_printers.hpp @@ -10,8 +10,10 @@ #pragma once +#include #include +#include #include namespace sycl { diff --git a/sycl/source/detail/posix_pi.cpp b/sycl/source/detail/posix_pi.cpp index 220727f3bb59a..8481b10431319 100644 --- a/sycl/source/detail/posix_pi.cpp +++ b/sycl/source/detail/posix_pi.cpp @@ -11,6 +11,7 @@ #include #include +#include #include namespace sycl { diff --git a/sycl/source/esimd_emulator_device_interface.cpp b/sycl/source/esimd_emulator_device_interface.cpp index 599ff255976ba..5205f6b528c14 100644 --- a/sycl/source/esimd_emulator_device_interface.cpp +++ b/sycl/source/esimd_emulator_device_interface.cpp @@ -15,7 +15,9 @@ /// /// \ingroup sycl_pi_esimd_emulator +#include #include +#include #include namespace sycl { diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 9e60496331c98..61479f5b21e5b 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -4038,6 +4038,9 @@ _ZN4sycl3_V16detail9half_impllsERSoRKNS2_4halfE _ZN4sycl3_V16detail9half_implrsERSiRNS2_4halfE _ZN4sycl3_V16detail9join_implERKSt6vectorISt10shared_ptrINS1_18kernel_bundle_implEESaIS5_EENS0_12bundle_stateE _ZN4sycl3_V16detail9link_implERKSt6vectorINS0_13kernel_bundleILNS0_12bundle_stateE1EEESaIS5_EERKS2_INS0_6deviceESaISA_EERKNS0_13property_listE +_ZN4sycl3_V16detaillsERSoRKNS1_13device_filterE +_ZN4sycl3_V16detaillsERSoRKNS1_18device_filter_listE +_ZN4sycl3_V16detaillsERSoRKNS1_22accessor_iterator_dataE _ZN4sycl3_V16device11get_devicesENS0_4info11device_typeE _ZN4sycl3_V16device26ext_oneapi_architecture_isENS0_3ext6oneapi12experimental12architectureE _ZN4sycl3_V16device26ext_oneapi_can_access_peerERKS1_NS0_3ext6oneapi11peer_accessE diff --git a/sycl/test/basic_tests/no_iostream_include.cpp b/sycl/test/basic_tests/no_iostream_include.cpp new file mode 100644 index 0000000000000..7862293c11e53 --- /dev/null +++ b/sycl/test/basic_tests/no_iostream_include.cpp @@ -0,0 +1,12 @@ +// RUN: %clangxx -DSYCL2020_CONFORMANT_APIS=1 -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s +// Test that only iosfwd and not istream, ostream, and iostream_proxy +// are included. +#include + +void t(std::istream &i, std::ostream &o) { + char c; + i >> c; // expected-error {{invalid operands to binary expression}} + o << o; // expected-error {{invalid operands to binary expression}} + std::cout + << "\n"; // expected-error {{no member named 'cout' in namespace 'std'}} +} diff --git a/sycl/unittests/pi/BackendString.hpp b/sycl/unittests/pi/BackendString.hpp index ea90e3ff3eb54..e5ab476fbbe16 100644 --- a/sycl/unittests/pi/BackendString.hpp +++ b/sycl/unittests/pi/BackendString.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include #include namespace pi { diff --git a/sycl/unittests/pi/TestGetPlugin.hpp b/sycl/unittests/pi/TestGetPlugin.hpp index 774d65c02f420..ef6080cdeddf0 100644 --- a/sycl/unittests/pi/TestGetPlugin.hpp +++ b/sycl/unittests/pi/TestGetPlugin.hpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace pi { inline std::optional From 60806adf13e6353f139c16e47d788331f8c7ae13 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sat, 7 Oct 2023 18:57:14 -0700 Subject: [PATCH 10/21] fix test --- sycl/test/basic_tests/no_iostream_include.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sycl/test/basic_tests/no_iostream_include.cpp b/sycl/test/basic_tests/no_iostream_include.cpp index 7862293c11e53..37822135f63ff 100644 --- a/sycl/test/basic_tests/no_iostream_include.cpp +++ b/sycl/test/basic_tests/no_iostream_include.cpp @@ -5,8 +5,8 @@ void t(std::istream &i, std::ostream &o) { char c; - i >> c; // expected-error {{invalid operands to binary expression}} - o << o; // expected-error {{invalid operands to binary expression}} - std::cout - << "\n"; // expected-error {{no member named 'cout' in namespace 'std'}} + i >> c; // expected-error {{invalid operands to binary expression}} + o << o; // expected-error {{invalid operands to binary expression}} + std::cout // expected-error {{no member named 'cout' in namespace 'std'}} + << "\n"; } From f9e13e95fba8b5ba68baf50b2e657bcbafdef0bf Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sat, 7 Oct 2023 19:05:29 -0700 Subject: [PATCH 11/21] fix --- sycl/include/sycl/detail/common.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/sycl/detail/common.hpp b/sycl/include/sycl/detail/common.hpp index ca44038e59f19..c5433da6d60e2 100644 --- a/sycl/include/sycl/detail/common.hpp +++ b/sycl/include/sycl/detail/common.hpp @@ -179,7 +179,7 @@ inline std::string codeToString(pi_int32 code) { auto code = expr; \ if (code != PI_SUCCESS) { \ fprintf(stderr, __SYCL_PI_ERROR_REPORT "%s\n", \ - sycl::detail::codeToString(code)); \ + sycl::detail::codeToString(code).c_str()); \ } \ } #endif From 7f309e12d5944d256bee3e428996e81b8094083c Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sat, 7 Oct 2023 19:24:33 -0700 Subject: [PATCH 12/21] fix --- sycl/include/sycl/detail/device_filter.hpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/sycl/include/sycl/detail/device_filter.hpp b/sycl/include/sycl/detail/device_filter.hpp index 4b826cd579d47..7cb73362dbd90 100644 --- a/sycl/include/sycl/detail/device_filter.hpp +++ b/sycl/include/sycl/detail/device_filter.hpp @@ -72,8 +72,8 @@ struct device_filter { device_filter(){}; device_filter(const std::string &FilterString); - friend std::ostream &operator<<(std::ostream &Out, - const device_filter &Filter); + __SYCL_EXPORT friend std::ostream &operator<<(std::ostream &Out, + const device_filter &Filter); }; class device_filter_list { @@ -88,16 +88,10 @@ class device_filter_list { bool backendCompatible(backend Backend); bool deviceTypeCompatible(info::device_type DeviceType); bool deviceNumberCompatible(int DeviceNum); - friend std::ostream &operator<<(std::ostream &Out, - const device_filter_list &List); + __SYCL_EXPORT friend std::ostream &operator<<(std::ostream &Out, + const device_filter_list &List); }; -__SYCL_EXPORT std::ostream &operator<<(std::ostream &Out, - const device_filter &Filter); - -__SYCL_EXPORT std::ostream &operator<<(std::ostream &Out, - const device_filter_list &List); - } // namespace detail } // namespace _V1 } // namespace sycl From dff4c2a850c332a93a63a92399a81341b2eeb008 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sat, 7 Oct 2023 20:07:18 -0700 Subject: [PATCH 13/21] fix win symbol --- sycl/test/abi/sycl_symbols_windows.dump | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index 72b2ed75c72d8..96fec5c22ff6f 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -778,6 +778,9 @@ ??5half_impl@detail@_V1@sycl@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@std@@AEAV45@AEAVhalf@0123@@Z ??6half_impl@detail@_V1@sycl@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV45@AEBVhalf@0123@@Z ??6_V1@sycl@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV23@W4backend@01@@Z +??6detail@_V1@sycl@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV34@AEBUaccessor_iterator_data@012@@Z +??6detail@_V1@sycl@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV34@AEBUdevice_filter@012@@Z +??6detail@_V1@sycl@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV34@AEBVdevice_filter_list@012@@Z ??8context@_V1@sycl@@QEBA_NAEBV012@@Z ??8device@_V1@sycl@@QEBA_NAEBV012@@Z ??8device_image_plain@detail@_V1@sycl@@QEBA_NAEBV0123@@Z From 790dd892646561db89ac75cd3fee79cd50acb377 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sat, 7 Oct 2023 20:10:35 -0700 Subject: [PATCH 14/21] fix format string --- sycl/include/sycl/handler.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 96e3759ac1c7a..c8e3ce709a660 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -1177,7 +1177,7 @@ class __SYCL_EXPORT handler { bool DidAdjust = false; auto Adjust = [&](int Dim, size_t Value) { if (this->RangeRoundingTrace()) - printf("parallel_for range adjusted at dim %d from %uz to %uz\n", Dim, + printf("parallel_for range adjusted at dim %d from %zu to %zu\n", Dim, RoundedRange[Dim], Value); RoundedRange[Dim] = Value; DidAdjust = true; From ed42d2abf304322cd024c6097a89ea66ca1ea40c Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Sat, 7 Oct 2023 20:17:18 -0700 Subject: [PATCH 15/21] Fix syclcompat include --- sycl/include/syclcompat/device.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/include/syclcompat/device.hpp b/sycl/include/syclcompat/device.hpp index c582820bf1569..f91d7666e0a2c 100644 --- a/sycl/include/syclcompat/device.hpp +++ b/sycl/include/syclcompat/device.hpp @@ -50,6 +50,7 @@ #endif #include +#include #include #include #include From 07bbd525787c318af30756fe7d363a893ed936da Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Mon, 9 Oct 2023 20:31:56 -0700 Subject: [PATCH 16/21] Address @bader comments --- sycl/include/sycl/detail/common.hpp | 1 + sycl/include/sycl/detail/iostream_proxy.hpp | 3 +++ sycl/include/sycl/handler.hpp | 4 +++- sycl/source/backend_types.cpp | 2 +- sycl/source/detail/accessor_iterator.cpp | 2 +- sycl/source/half_type.cpp | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sycl/include/sycl/detail/common.hpp b/sycl/include/sycl/detail/common.hpp index c5433da6d60e2..5867d199deb0d 100644 --- a/sycl/include/sycl/detail/common.hpp +++ b/sycl/include/sycl/detail/common.hpp @@ -180,6 +180,7 @@ inline std::string codeToString(pi_int32 code) { if (code != PI_SUCCESS) { \ fprintf(stderr, __SYCL_PI_ERROR_REPORT "%s\n", \ sycl::detail::codeToString(code).c_str()); \ + fflush(stderr); \ } \ } #endif diff --git a/sycl/include/sycl/detail/iostream_proxy.hpp b/sycl/include/sycl/detail/iostream_proxy.hpp index 847e8017ec4d2..20ee1ad2b58d1 100644 --- a/sycl/include/sycl/detail/iostream_proxy.hpp +++ b/sycl/include/sycl/detail/iostream_proxy.hpp @@ -6,6 +6,9 @@ // //===----------------------------------------------------------------------===// +// TODO: Next time API changes are allowed this file should not be included +// from sycl.hpp anymore. Then this file should be moved to sycl/source. + #pragma once #include // for ostream, istream diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index c8e3ce709a660..090ce9416543e 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -1176,9 +1176,11 @@ class __SYCL_EXPORT handler { bool DidAdjust = false; auto Adjust = [&](int Dim, size_t Value) { - if (this->RangeRoundingTrace()) + if (this->RangeRoundingTrace()) { printf("parallel_for range adjusted at dim %d from %zu to %zu\n", Dim, RoundedRange[Dim], Value); + fflush(stdout); + } RoundedRange[Dim] = Value; DidAdjust = true; }; diff --git a/sycl/source/backend_types.cpp b/sycl/source/backend_types.cpp index bc432c4be5a81..97c9ad8f58be4 100644 --- a/sycl/source/backend_types.cpp +++ b/sycl/source/backend_types.cpp @@ -43,4 +43,4 @@ std::ostream &operator<<(std::ostream &Out, backend be) { } } // namespace _V1 -} // namespace sycl \ No newline at end of file +} // namespace sycl diff --git a/sycl/source/detail/accessor_iterator.cpp b/sycl/source/detail/accessor_iterator.cpp index 9be95c50c8cd5..315a45d92b04b 100644 --- a/sycl/source/detail/accessor_iterator.cpp +++ b/sycl/source/detail/accessor_iterator.cpp @@ -32,4 +32,4 @@ __SYCL_EXPORT std::ostream &operator<<(std::ostream &os, } // namespace detail } // namespace _V1 -} // namespace sycl \ No newline at end of file +} // namespace sycl diff --git a/sycl/source/half_type.cpp b/sycl/source/half_type.cpp index 9fbbf46cae29f..579e94b5314b7 100644 --- a/sycl/source/half_type.cpp +++ b/sycl/source/half_type.cpp @@ -31,4 +31,4 @@ std::istream &operator>>(std::istream &I, half &rhs) { } // namespace half_impl } // namespace detail } // namespace _V1 -} // namespace sycl \ No newline at end of file +} // namespace sycl From b4f156de1cf6ea47539d9241fa0fa06b3777a63c Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Wed, 11 Oct 2023 10:07:47 -0700 Subject: [PATCH 17/21] Remove "and" --- sycl/doc/developer/ContributeToDPCPP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/doc/developer/ContributeToDPCPP.md b/sycl/doc/developer/ContributeToDPCPP.md index 69fa6d7404c2f..7607657e235d4 100644 --- a/sycl/doc/developer/ContributeToDPCPP.md +++ b/sycl/doc/developer/ContributeToDPCPP.md @@ -42,7 +42,7 @@ According to the use `#include ` is forbidden in library files. Instead, the sycl/detail/iostream_proxy.hpp header offers the functionality of without its static constructor. -This header should be used in place of in DPC++ and runtime +This header should be used in place of in DPC++ runtime library files. In DPC++ header files only should be used. ## Tests development From 126e113798910bb02fd9afa9e7edfbc44da86266 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Wed, 11 Oct 2023 21:47:50 -0700 Subject: [PATCH 18/21] Remove include without guard --- sycl/include/sycl/detail/iostream_proxy.hpp | 4 ++-- sycl/include/sycl/sycl.hpp | 4 ---- sycl/source/half_type.cpp | 2 +- sycl/test/basic_tests/no_iostream_include.cpp | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/sycl/include/sycl/detail/iostream_proxy.hpp b/sycl/include/sycl/detail/iostream_proxy.hpp index 20ee1ad2b58d1..331ae7edde658 100644 --- a/sycl/include/sycl/detail/iostream_proxy.hpp +++ b/sycl/include/sycl/detail/iostream_proxy.hpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -// TODO: Next time API changes are allowed this file should not be included -// from sycl.hpp anymore. Then this file should be moved to sycl/source. +// TODO: Remove include from ext/intel/esimd and syclcompat. +// Then this file should be moved to sycl/source. #pragma once diff --git a/sycl/include/sycl/sycl.hpp b/sycl/include/sycl/sycl.hpp index 5efdb298af936..73c481129a5f1 100644 --- a/sycl/include/sycl/sycl.hpp +++ b/sycl/include/sycl/sycl.hpp @@ -96,8 +96,4 @@ // We used to include those and some code might be reliant on that. #include #include -#include -#include -#include -#include #endif diff --git a/sycl/source/half_type.cpp b/sycl/source/half_type.cpp index 579e94b5314b7..5cf33eb16df84 100644 --- a/sycl/source/half_type.cpp +++ b/sycl/source/half_type.cpp @@ -1,4 +1,4 @@ -//==---------------- half-type.cpp - SYCL half type ------------------------==// +//===--------------- half_type.cpp - SYCL half type -----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/sycl/test/basic_tests/no_iostream_include.cpp b/sycl/test/basic_tests/no_iostream_include.cpp index 37822135f63ff..abb9b0055b765 100644 --- a/sycl/test/basic_tests/no_iostream_include.cpp +++ b/sycl/test/basic_tests/no_iostream_include.cpp @@ -1,4 +1,4 @@ -// RUN: %clangxx -DSYCL2020_CONFORMANT_APIS=1 -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s +// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note %s // Test that only iosfwd and not istream, ostream, and iostream_proxy // are included. #include From bb3433757a75da25bfff2a9fec661d1d7e928cbf Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Wed, 11 Oct 2023 22:52:44 -0700 Subject: [PATCH 19/21] Fix tests --- sycl/include/sycl/sycl.hpp | 2 +- .../basic_tests/accessor/atomic_zero_dimension_accessor.cpp | 2 ++ .../basic_tests/accessor/const-type-non-readonly-accessor.cpp | 2 ++ sycl/test/basic_tests/no_iostream_include.cpp | 2 +- sycl/test/basic_tests/types.cpp | 1 + sycl/test/extensions/fpga.cpp | 1 + sycl/test/regression/half_host_subnormal_min.cpp | 2 ++ sycl/test/regression/host_half_nextafter.cpp | 2 ++ sycl/test/regression/host_tanpi_double_accuracy.cpp | 1 + 9 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sycl/include/sycl/sycl.hpp b/sycl/include/sycl/sycl.hpp index 5b55801796e01..274dbea1efb0d 100644 --- a/sycl/include/sycl/sycl.hpp +++ b/sycl/include/sycl/sycl.hpp @@ -98,5 +98,5 @@ #ifndef SYCL2020_CONFORMANT_APIS // We used to include those and some code might be reliant on that. #include -#include +#include //TODO: remove todo in no_iostream_include test #endif diff --git a/sycl/test/basic_tests/accessor/atomic_zero_dimension_accessor.cpp b/sycl/test/basic_tests/accessor/atomic_zero_dimension_accessor.cpp index ff53db7bf35b3..74ca08de4a20c 100644 --- a/sycl/test/basic_tests/accessor/atomic_zero_dimension_accessor.cpp +++ b/sycl/test/basic_tests/accessor/atomic_zero_dimension_accessor.cpp @@ -8,6 +8,8 @@ #include +#include + using namespace sycl; using atomic_t = sycl::atomic; diff --git a/sycl/test/basic_tests/accessor/const-type-non-readonly-accessor.cpp b/sycl/test/basic_tests/accessor/const-type-non-readonly-accessor.cpp index 32c20a0bff257..da3a87b511bb6 100644 --- a/sycl/test/basic_tests/accessor/const-type-non-readonly-accessor.cpp +++ b/sycl/test/basic_tests/accessor/const-type-non-readonly-accessor.cpp @@ -2,6 +2,8 @@ #include +#include + using namespace sycl; constexpr size_t dataSize = 1; diff --git a/sycl/test/basic_tests/no_iostream_include.cpp b/sycl/test/basic_tests/no_iostream_include.cpp index abb9b0055b765..c255112cd0965 100644 --- a/sycl/test/basic_tests/no_iostream_include.cpp +++ b/sycl/test/basic_tests/no_iostream_include.cpp @@ -5,7 +5,7 @@ void t(std::istream &i, std::ostream &o) { char c; - i >> c; // expected-error {{invalid operands to binary expression}} + i >> c; // expected-error-todo {{invalid operands to binary expression}} o << o; // expected-error {{invalid operands to binary expression}} std::cout // expected-error {{no member named 'cout' in namespace 'std'}} << "\n"; diff --git a/sycl/test/basic_tests/types.cpp b/sycl/test/basic_tests/types.cpp index 4b4738d99f36b..6036946ae0674 100644 --- a/sycl/test/basic_tests/types.cpp +++ b/sycl/test/basic_tests/types.cpp @@ -12,6 +12,7 @@ #include #include +#include #include using namespace std; diff --git a/sycl/test/extensions/fpga.cpp b/sycl/test/extensions/fpga.cpp index b952f00706f80..3df706ea8cebf 100644 --- a/sycl/test/extensions/fpga.cpp +++ b/sycl/test/extensions/fpga.cpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace intelfpga { diff --git a/sycl/test/regression/half_host_subnormal_min.cpp b/sycl/test/regression/half_host_subnormal_min.cpp index f0e0405e879dd..763453ae5f3a2 100644 --- a/sycl/test/regression/half_host_subnormal_min.cpp +++ b/sycl/test/regression/half_host_subnormal_min.cpp @@ -6,6 +6,8 @@ #include +#include + int main() { sycl::half SubnormalMin = sycl::bit_cast((uint16_t)0b0000000000000001u); diff --git a/sycl/test/regression/host_half_nextafter.cpp b/sycl/test/regression/host_half_nextafter.cpp index fe9bf949c65e3..a4e3efefdda4a 100644 --- a/sycl/test/regression/host_half_nextafter.cpp +++ b/sycl/test/regression/host_half_nextafter.cpp @@ -6,6 +6,8 @@ #include +#include + void check(uint16_t x, uint16_t y, uint16_t ref) { assert(sycl::nextafter(sycl::bit_cast(x), sycl::bit_cast(y)) == diff --git a/sycl/test/regression/host_tanpi_double_accuracy.cpp b/sycl/test/regression/host_tanpi_double_accuracy.cpp index d84a391b36e6a..6641c278aa4ef 100644 --- a/sycl/test/regression/host_tanpi_double_accuracy.cpp +++ b/sycl/test/regression/host_tanpi_double_accuracy.cpp @@ -6,6 +6,7 @@ #include #include +#include #include double get_ulp(double X) { From 0c454275160514d215b63417ff3c15f8155c7ed2 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Wed, 11 Oct 2023 22:53:26 -0700 Subject: [PATCH 20/21] Remove usage of iostream_proxy in esimd and compat --- sycl/include/sycl/ext/intel/esimd/simd.hpp | 4 ---- sycl/include/syclcompat/device.hpp | 11 +++++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/sycl/include/sycl/ext/intel/esimd/simd.hpp b/sycl/include/sycl/ext/intel/esimd/simd.hpp index 8e545a09b8b7f..96b3f3ed02dfc 100644 --- a/sycl/include/sycl/ext/intel/esimd/simd.hpp +++ b/sycl/include/sycl/ext/intel/esimd/simd.hpp @@ -23,10 +23,6 @@ #include -#ifndef __SYCL_DEVICE_ONLY__ -#include -#endif // __SYCL_DEVICE_ONLY__ - namespace sycl { inline namespace _V1 { namespace ext::intel::esimd { diff --git a/sycl/include/syclcompat/device.hpp b/sycl/include/syclcompat/device.hpp index f91d7666e0a2c..e8b653cdb081e 100644 --- a/sycl/include/syclcompat/device.hpp +++ b/sycl/include/syclcompat/device.hpp @@ -50,7 +50,6 @@ #endif #include -#include #include #include #include @@ -66,11 +65,11 @@ auto exception_handler = [](sycl::exception_list exceptions) { try { std::rethrow_exception(e); } catch (sycl::exception const &e) { - std::cerr << "[SYCLcompat] Caught asynchronous SYCL exception:" - << std::endl - << e.what() << std::endl - << "Exception caught at file:" << __FILE__ - << ", line:" << __LINE__ << std::endl; + fprintf(stderr, + "[SYCLcompat] Caught asynchronous SYCL exception:\n%s\n" + "Exception caught at file:" __FILE__ ", line:" __LINE__ "\n", + e.what().c_str()); + fflush(stderr); } } }; From f2c1de3272daa729a49889c92b71738172aada63 Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Wed, 11 Oct 2023 22:56:30 -0700 Subject: [PATCH 21/21] move iostream_proxy --- sycl/doc/developer/ContributeToDPCPP.md | 2 +- sycl/plugins/level_zero/tracing.cpp | 2 +- sycl/plugins/opencl/pi_opencl.cpp | 1 - sycl/source/detail/config.cpp | 2 +- sycl/source/detail/config.hpp | 2 +- sycl/source/detail/device_binary_image.hpp | 2 +- sycl/{include/sycl => source}/detail/iostream_proxy.hpp | 3 --- sycl/source/detail/platform_impl.cpp | 2 +- sycl/source/detail/plugin_printers.hpp | 2 +- sycl/source/detail/posix_pi.cpp | 2 +- sycl/source/detail/spec_constant_impl.cpp | 2 +- sycl/source/detail/spec_constant_impl.hpp | 2 +- sycl/source/esimd_emulator_device_interface.cpp | 2 +- 13 files changed, 11 insertions(+), 15 deletions(-) rename sycl/{include/sycl => source}/detail/iostream_proxy.hpp (91%) diff --git a/sycl/doc/developer/ContributeToDPCPP.md b/sycl/doc/developer/ContributeToDPCPP.md index 7607657e235d4..f7471a97b5205 100644 --- a/sycl/doc/developer/ContributeToDPCPP.md +++ b/sycl/doc/developer/ContributeToDPCPP.md @@ -40,7 +40,7 @@ to signify the component changed, e.g.: `[PI]`, `[CUDA]`, `[Doc]`. According to [LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html#include-iostream-is-forbidden), the use `#include ` is forbidden in library files. Instead, the -sycl/detail/iostream_proxy.hpp header offers the functionality of +detail/iostream_proxy.hpp header offers the functionality of without its static constructor. This header should be used in place of in DPC++ runtime library files. In DPC++ header files only should be used. diff --git a/sycl/plugins/level_zero/tracing.cpp b/sycl/plugins/level_zero/tracing.cpp index ca78368030308..396e384881cfc 100644 --- a/sycl/plugins/level_zero/tracing.cpp +++ b/sycl/plugins/level_zero/tracing.cpp @@ -16,7 +16,7 @@ #include #include -#include +#include <../../source/detail/iostream_proxy.hpp> constexpr auto ZE_CALL_STREAM_NAME = "sycl.experimental.level_zero.call"; constexpr auto ZE_DEBUG_STREAM_NAME = "sycl.experimental.level_zero.debug"; diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index b15418f35a3c8..ea78667b53c04 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include diff --git a/sycl/source/detail/config.cpp b/sycl/source/detail/config.cpp index d57f1dade20e8..89a3329fb24c5 100644 --- a/sycl/source/detail/config.cpp +++ b/sycl/source/detail/config.cpp @@ -7,9 +7,9 @@ //===----------------------------------------------------------------------===// #include +#include #include #include -#include #include #include diff --git a/sycl/source/detail/config.hpp b/sycl/source/detail/config.hpp index be5bc8f75f21d..53b9028aaa92c 100644 --- a/sycl/source/detail/config.hpp +++ b/sycl/source/detail/config.hpp @@ -9,10 +9,10 @@ #pragma once #include +#include #include #include #include -#include #include #include #include diff --git a/sycl/source/detail/device_binary_image.hpp b/sycl/source/detail/device_binary_image.hpp index a3f835e689f94..e53867122e9bc 100644 --- a/sycl/source/detail/device_binary_image.hpp +++ b/sycl/source/detail/device_binary_image.hpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #pragma once +#include #include -#include #include #include diff --git a/sycl/include/sycl/detail/iostream_proxy.hpp b/sycl/source/detail/iostream_proxy.hpp similarity index 91% rename from sycl/include/sycl/detail/iostream_proxy.hpp rename to sycl/source/detail/iostream_proxy.hpp index 331ae7edde658..847e8017ec4d2 100644 --- a/sycl/include/sycl/detail/iostream_proxy.hpp +++ b/sycl/source/detail/iostream_proxy.hpp @@ -6,9 +6,6 @@ // //===----------------------------------------------------------------------===// -// TODO: Remove include from ext/intel/esimd and syclcompat. -// Then this file should be moved to sycl/source. - #pragma once #include // for ostream, istream diff --git a/sycl/source/detail/platform_impl.cpp b/sycl/source/detail/platform_impl.cpp index 7ccbd43771c65..fc3eab70905b0 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -10,10 +10,10 @@ #include #include #include +#include #include #include #include -#include #include #include diff --git a/sycl/source/detail/plugin_printers.hpp b/sycl/source/detail/plugin_printers.hpp index a251d9003b96d..c442c573dbde9 100644 --- a/sycl/source/detail/plugin_printers.hpp +++ b/sycl/source/detail/plugin_printers.hpp @@ -10,7 +10,7 @@ #pragma once -#include +#include #include #include diff --git a/sycl/source/detail/posix_pi.cpp b/sycl/source/detail/posix_pi.cpp index 8481b10431319..ed0da13499f26 100644 --- a/sycl/source/detail/posix_pi.cpp +++ b/sycl/source/detail/posix_pi.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// +#include #include -#include #include #include diff --git a/sycl/source/detail/spec_constant_impl.cpp b/sycl/source/detail/spec_constant_impl.cpp index 4c77ff72e772b..f1f615cc213e4 100644 --- a/sycl/source/detail/spec_constant_impl.cpp +++ b/sycl/source/detail/spec_constant_impl.cpp @@ -8,9 +8,9 @@ #include +#include #include #include -#include #include #include #include diff --git a/sycl/source/detail/spec_constant_impl.hpp b/sycl/source/detail/spec_constant_impl.hpp index b576cc243b542..c629c3380ae93 100644 --- a/sycl/source/detail/spec_constant_impl.hpp +++ b/sycl/source/detail/spec_constant_impl.hpp @@ -8,8 +8,8 @@ #pragma once +#include #include -#include #include #include diff --git a/sycl/source/esimd_emulator_device_interface.cpp b/sycl/source/esimd_emulator_device_interface.cpp index 5205f6b528c14..904125ac236a3 100644 --- a/sycl/source/esimd_emulator_device_interface.cpp +++ b/sycl/source/esimd_emulator_device_interface.cpp @@ -15,9 +15,9 @@ /// /// \ingroup sycl_pi_esimd_emulator +#include #include #include -#include #include namespace sycl {