From 7791ebc2b1219576bfe4fd6de1c7f79d27db864d Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Thu, 11 Sep 2025 15:59:57 -0700 Subject: [PATCH] [NFC][SYCL] Add `sycl/detail/fwd/accessor.hpp` helper --- sycl/include/sycl/accessor.hpp | 15 +++---- sycl/include/sycl/buffer.hpp | 4 +- .../include/sycl/detail/accessor_iterator.hpp | 10 +---- sycl/include/sycl/detail/fwd/accessor.hpp | 42 +++++++++++++++++++ .../ext/oneapi/accessor_property_list.hpp | 12 ++---- sycl/include/sycl/handler.hpp | 3 -- sycl/include/sycl/image.hpp | 17 -------- sycl/include/sycl/multi_ptr.hpp | 8 +--- .../sycl/properties/accessor_properties.hpp | 23 +--------- sycl/include/sycl/sampler.hpp | 13 ++---- sycl/test/include_deps/sycl_accessor.hpp.cpp | 3 +- sycl/test/include_deps/sycl_buffer.hpp.cpp | 3 +- .../include_deps/sycl_detail_core.hpp.cpp | 3 +- 13 files changed, 66 insertions(+), 90 deletions(-) create mode 100644 sycl/include/sycl/detail/fwd/accessor.hpp diff --git a/sycl/include/sycl/accessor.hpp b/sycl/include/sycl/accessor.hpp index af3ceb06e45ee..3f48859aefed3 100644 --- a/sycl/include/sycl/accessor.hpp +++ b/sycl/include/sycl/accessor.hpp @@ -221,13 +221,6 @@ namespace ext::intel::esimd::detail { class AccessorPrivateProxy; } // namespace ext::intel::esimd::detail -template > -class accessor; - namespace ext::oneapi::experimental { template class dynamic_local_accessor; } @@ -616,9 +609,11 @@ class __SYCL_EXPORT LocalAccessorBaseHost { /// \sa buffer /// /// \ingroup sycl_api_acc -template +template > class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : #ifndef __SYCL_DEVICE_ONLY__ public detail::AccessorBaseHost, diff --git a/sycl/include/sycl/buffer.hpp b/sycl/include/sycl/buffer.hpp index 004236e9b0d6a..4c0d9575c7807 100644 --- a/sycl/include/sycl/buffer.hpp +++ b/sycl/include/sycl/buffer.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -51,9 +52,6 @@ template class range; template using buffer_allocator = detail::sycl_memory_object_allocator; -template -class host_accessor; - template class buffer; diff --git a/sycl/include/sycl/detail/accessor_iterator.hpp b/sycl/include/sycl/detail/accessor_iterator.hpp index 97c5385bf3624..e8f753173ad47 100644 --- a/sycl/include/sycl/detail/accessor_iterator.hpp +++ b/sycl/include/sycl/detail/accessor_iterator.hpp @@ -10,7 +10,8 @@ #include // for mode, placeholder, target #include // for range -#include // for id +#include +#include #include // for size_t #include // for random_access_iterator_tag @@ -37,14 +38,7 @@ namespace sycl { inline namespace _V1 { - -template -class accessor; - namespace detail { - template class accessor_iterator { public: using difference_type = std::ptrdiff_t; diff --git a/sycl/include/sycl/detail/fwd/accessor.hpp b/sycl/include/sycl/detail/fwd/accessor.hpp new file mode 100644 index 0000000000000..8cbe1fbeb1f60 --- /dev/null +++ b/sycl/include/sycl/detail/fwd/accessor.hpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#pragma once + +#include +#include + +namespace sycl { +inline namespace _V1 { + +template +class accessor; +template +class host_accessor; +template +class __SYCL_EBO + __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor; + +namespace detail { +template +class image_accessor; +} + +template +class unsampled_image_accessor; +template +class sampled_image_accessor; +template +class host_unsampled_image_accessor; +template class host_sampled_image_accessor; +} // namespace _V1 +} // namespace sycl diff --git a/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp b/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp index 3fd3648671cb4..aa6335bd6cda6 100644 --- a/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp +++ b/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp @@ -8,12 +8,13 @@ #pragma once -#include // for mode, placeholder, target -#include // for __SYCL_TYPE +#include // for mode, placeholder, target +#include // for __SYCL_TYPE +#include #include // for DataLessPropKind, Prop... #include // for PropertyListBase #include -#include // for property_list +#include // for property_list #include // for bitset #include // for shared_ptr @@ -22,11 +23,6 @@ namespace sycl { inline namespace _V1 { -// Forward declaration -template -class accessor; namespace detail { // This helper template must be specialized for nested instance template // of each compile-time-constant property. diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 44b46d4960910..9c10c9486f63a 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -208,9 +208,6 @@ class queue_impl; class stream_impl; class event_impl; class context_impl; -template -class image_accessor; class HandlerAccess; class HostTask; diff --git a/sycl/include/sycl/image.hpp b/sycl/include/sycl/image.hpp index 004763c8d601d..cff83ee1efd0b 100644 --- a/sycl/include/sycl/image.hpp +++ b/sycl/include/sycl/image.hpp @@ -413,25 +413,8 @@ class unsampled_image_common : public image_common { }); } }; - -template -class image_accessor; - } // namespace detail -template -class unsampled_image_accessor; - -template -class host_unsampled_image_accessor; - -template -class sampled_image_accessor; - -template class host_sampled_image_accessor; - /// Defines a shared image data. /// /// Images can be 1-, 2-, and 3-dimensional. They have to be accessed using the diff --git a/sycl/include/sycl/multi_ptr.hpp b/sycl/include/sycl/multi_ptr.hpp index 4a30322ec9936..a4112edfee485 100644 --- a/sycl/include/sycl/multi_ptr.hpp +++ b/sycl/include/sycl/multi_ptr.hpp @@ -12,6 +12,7 @@ #include // for half #include #include // for __SYCL2020_DEPRECATED +#include #include #include // for const_if_const_AS #include // for BIsRepresentationT @@ -66,13 +67,6 @@ struct LegacyReferenceTypes -class accessor; -template class local_accessor; - /// Provides constructors for address space qualified and non address space /// qualified pointers to allow interoperability between plain C++ and OpenCL C. /// diff --git a/sycl/include/sycl/properties/accessor_properties.hpp b/sycl/include/sycl/properties/accessor_properties.hpp index dd09ce3b80247..82785748b49a7 100644 --- a/sycl/include/sycl/properties/accessor_properties.hpp +++ b/sycl/include/sycl/properties/accessor_properties.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -91,28 +92,6 @@ struct is_compile_time_property : std::true_type {}; } // namespace ext::oneapi -// Forward declaration -template -class accessor; -template -class host_accessor; -template -class __SYCL_EBO - __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor; -template -class image_accessor; -template -class unsampled_image_accessor; -template -class sampled_image_accessor; -template -class host_unsampled_image_accessor; -template class host_sampled_image_accessor; - namespace detail::acc_properties { template struct is_accessor : std::false_type {}; template // for mode, placeholder, target -#include // for __SYCL_SPECIAL_CLASS, __SYCL_TYPE -#include // for __SYCL_EXPORT +#include // for mode, placeholder, target +#include // for __SYCL_SPECIAL_CLASS, __SYCL_TYPE +#include // for __SYCL_EXPORT +#include #include // for getSyclObjImpl #include // for property_list @@ -39,12 +40,6 @@ enum class coordinate_normalization_mode : unsigned int { unnormalized = 0 }; -namespace detail { -template -class image_accessor; -} - namespace detail { #ifdef __SYCL_DEVICE_ONLY__ class __SYCL_EXPORT sampler_impl { diff --git a/sycl/test/include_deps/sycl_accessor.hpp.cpp b/sycl/test/include_deps/sycl_accessor.hpp.cpp index ad9871ddf513b..2901a4fbc0c7a 100644 --- a/sycl/test/include_deps/sycl_accessor.hpp.cpp +++ b/sycl/test/include_deps/sycl_accessor.hpp.cpp @@ -18,9 +18,10 @@ // CHECK-NEXT: stl_wrappers/cassert // CHECK-NEXT: stl_wrappers/assert.h // CHECK-NEXT: __spirv/spirv_vars.hpp +// CHECK-NEXT: detail/fwd/accessor.hpp +// CHECK-NEXT: detail/defines.hpp // CHECK-NEXT: detail/helpers.hpp // CHECK-NEXT: __spirv/spirv_types.hpp -// CHECK-NEXT: detail/defines.hpp // CHECK-NEXT: memory_enums.hpp // CHECK-NEXT: detail/iostream_proxy.hpp // CHECK-NEXT: detail/is_device_copyable.hpp diff --git a/sycl/test/include_deps/sycl_buffer.hpp.cpp b/sycl/test/include_deps/sycl_buffer.hpp.cpp index d7bba03c556fe..cc4537177202d 100644 --- a/sycl/test/include_deps/sycl_buffer.hpp.cpp +++ b/sycl/test/include_deps/sycl_buffer.hpp.cpp @@ -17,9 +17,10 @@ // CHECK-NEXT: stl_wrappers/cassert // CHECK-NEXT: stl_wrappers/assert.h // CHECK-NEXT: __spirv/spirv_vars.hpp +// CHECK-NEXT: detail/fwd/accessor.hpp +// CHECK-NEXT: detail/defines.hpp // CHECK-NEXT: detail/helpers.hpp // CHECK-NEXT: __spirv/spirv_types.hpp -// CHECK-NEXT: detail/defines.hpp // CHECK-NEXT: memory_enums.hpp // CHECK-NEXT: detail/iostream_proxy.hpp // CHECK-NEXT: detail/is_device_copyable.hpp diff --git a/sycl/test/include_deps/sycl_detail_core.hpp.cpp b/sycl/test/include_deps/sycl_detail_core.hpp.cpp index 6fd0a7acddb0a..a87fb75117f27 100644 --- a/sycl/test/include_deps/sycl_detail_core.hpp.cpp +++ b/sycl/test/include_deps/sycl_detail_core.hpp.cpp @@ -19,9 +19,10 @@ // CHECK-NEXT: stl_wrappers/cassert // CHECK-NEXT: stl_wrappers/assert.h // CHECK-NEXT: __spirv/spirv_vars.hpp +// CHECK-NEXT: detail/fwd/accessor.hpp +// CHECK-NEXT: detail/defines.hpp // CHECK-NEXT: detail/helpers.hpp // CHECK-NEXT: __spirv/spirv_types.hpp -// CHECK-NEXT: detail/defines.hpp // CHECK-NEXT: memory_enums.hpp // CHECK-NEXT: detail/iostream_proxy.hpp // CHECK-NEXT: detail/is_device_copyable.hpp