@@ -488,7 +488,6 @@ class command_graph<graph_state::executable>
488
488
namespace detail {
489
489
class __SYCL_EXPORT dynamic_parameter_base {
490
490
public:
491
- dynamic_parameter_base () = default ;
492
491
dynamic_parameter_base (
493
492
sycl::ext::oneapi::experimental::command_graph<graph_state::modifiable>
494
493
Graph);
@@ -526,37 +525,55 @@ class __SYCL_EXPORT dynamic_parameter_base {
526
525
sycl::detail::getSyclObjImpl(const Obj &SyclObject);
527
526
};
528
527
529
- } // namespace detail
530
-
531
- template <typename T> struct is_unbounded_array : std::false_type {};
532
-
533
- template <typename T> struct is_unbounded_array <T[]> : std::true_type {};
528
+ class dynamic_work_group_memory_base
529
+ #ifndef __SYCL_DEVICE_ONLY__
530
+ : public dynamic_parameter_base
531
+ #endif
532
+ {
533
+ public:
534
+ dynamic_work_group_memory_base () = default ;
535
+ dynamic_work_group_memory_base (
536
+ experimental::command_graph<graph_state::modifiable> Graph, size_t Size)
537
+ :
538
+ #ifndef __SYCL_DEVICE_ONLY__
539
+ dynamic_parameter_base (Graph),
540
+ #endif
541
+ BufferSize (Size) {
542
+ }
534
543
535
- template <typename T>
536
- inline constexpr bool is_unbounded_array_v = is_unbounded_array<T>::value;
544
+ private:
545
+ #ifdef __SYCL_DEVICE_ONLY__
546
+ [[maybe_unused]] char padding[sizeof (dynamic_parameter_base)];
547
+ #endif
548
+ size_t BufferSize{};
549
+ friend class sycl ::handler;
550
+ };
551
+ } // namespace detail
537
552
538
553
template <typename DataT,
539
- typename = std::enable_if_t <is_unbounded_array_v<DataT>>>
540
-
554
+ typename = std::enable_if_t <detail::is_unbounded_array_v<DataT>>>
541
555
class __SYCL_SPECIAL_CLASS
542
556
__SYCL_TYPE (dynamic_work_group_memory) dynamic_work_group_memory
557
+ : public detail::dynamic_work_group_memory_base {
558
+ private:
559
+ work_group_memory<DataT> WorkGroupMem;
560
+
561
+ using value_type = std::remove_all_extents_t <DataT>;
562
+ using decoratedPtr = typename sycl::detail::DecoratedType<
563
+ value_type, access::address_space::local_space>::type *;
564
+
543
565
#ifdef __SYCL_DEVICE_ONLY__
544
- : detail::dynamic_parameter_base
545
- #else
546
- : public detail::dynamic_parameter_base
566
+ void __init (decoratedPtr Ptr) { this ->WorkGroupMem .__init (Ptr); }
547
567
#endif
548
- {
568
+
549
569
public:
550
- dynamic_work_group_memory () = default ;
551
570
// / Constructs a new dynamic_work_group_memory object.
552
571
// / @param Graph The graph associated with this object.
553
572
// / @param Num Number of elements in the unbounded array DataT.
554
573
dynamic_work_group_memory (
555
- experimental::command_graph<graph_state::modifiable> Graph, size_t Num) {
556
- auto &WorkGroupMemImpl =
557
- static_cast <detail::work_group_memory_impl &>(WorkGroupMem);
558
- WorkGroupMemImpl.buffer_size = Num * sizeof (std::remove_extent_t <DataT>);
559
- }
574
+ experimental::command_graph<graph_state::modifiable> Graph, size_t Num)
575
+ : detail::dynamic_work_group_memory_base (
576
+ Graph, Num * sizeof (std::remove_extent_t <DataT>)) {}
560
577
561
578
// / Updates this dynamic_work_group_memory and all registered nodes with a new
562
579
// / number of elements.
@@ -567,19 +584,15 @@ __SYCL_TYPE(dynamic_work_group_memory) dynamic_work_group_memory
567
584
Num * sizeof (std::remove_extent_t <DataT>));
568
585
#endif
569
586
}
570
-
571
- const work_group_memory<DataT> &get () const { return WorkGroupMem; }
572
-
573
- private:
574
- work_group_memory<DataT> WorkGroupMem;
575
- #ifdef __SYCL_DEVICE_ONLY__
576
- // [[maybe_unused]] char padding[sizeof(detail::dynamic_parameter_base)];
577
- using value_type = std::remove_all_extents_t <DataT>;
578
- using decoratedPtr = typename sycl::detail::DecoratedType<
579
- value_type, access::address_space::local_space>::type *;
580
-
581
- void __init (decoratedPtr Ptr) { this ->WorkGroupMem .__init (Ptr); }
582
- #endif
587
+ work_group_memory<DataT> get () const { return WorkGroupMem; }
588
+
589
+ // Frontend requires special types to have a default constructor in order to
590
+ // have a uniform way of initializing an object of special type to then call
591
+ // the __init method on it. This is purely an implementation detail and not
592
+ // part of the spec.
593
+ // TODO: Revisit this once https://github.com/intel/llvm/issues/16061 is
594
+ // closed.
595
+ dynamic_work_group_memory () = default ;
583
596
};
584
597
585
598
template <typename ValueT>
0 commit comments