From 396eb5ac4b55e0537f6a559237c689c1a51ba8d0 Mon Sep 17 00:00:00 2001 From: Artem Radzikhovskyy Date: Mon, 20 Nov 2023 01:01:38 -0800 Subject: [PATCH] Removed inheritance in fpga_mem (#11917) Currently the SPIRV translator has a hard time translating annotations that are in nested types. This bug is actively being worked on. In the mean time, this change removes class inheritance from `fpga_mem`, allowing SPIRV translator to properly translate annotations in more cases. --- .../intel/experimental/fpga_mem/fpga_mem.hpp | 104 ++++++------------ 1 file changed, 36 insertions(+), 68 deletions(-) diff --git a/sycl/include/sycl/ext/intel/experimental/fpga_mem/fpga_mem.hpp b/sycl/include/sycl/ext/intel/experimental/fpga_mem/fpga_mem.hpp index b4f590d64919e..a1badeeabc7ea 100644 --- a/sycl/include/sycl/ext/intel/experimental/fpga_mem/fpga_mem.hpp +++ b/sycl/include/sycl/ext/intel/experimental/fpga_mem/fpga_mem.hpp @@ -20,11 +20,30 @@ namespace sycl { inline namespace _V1 { namespace ext::intel::experimental { -namespace detail { -// Hide the base implementation in details so that manipulation -// of properties parameter pack can be modularized away from main logic -template class fpga_mem_base { +// Primary template should never be deduced. Needed to establish which +// parameters fpga_mem can be templated on +template +class fpga_mem { + + static_assert( + ext::oneapi::experimental::is_property_list::value, + "Property list is invalid."); +}; + +// Template specialization that all calls should use. Separates Props from +// properties_t which allows the class to apply Props as attributes. +template +class +#ifdef __SYCL_DEVICE_ONLY__ + [[__sycl_detail__::add_ir_attributes_global_variable( + "sycl-resource", + ext::oneapi::experimental::detail::PropertyMetaInfo::name..., + "DEFAULT", + ext::oneapi::experimental::detail::PropertyMetaInfo::value...)]] +#endif + fpga_mem> { protected: T val @@ -47,14 +66,14 @@ template class fpga_mem_base { // All the initialization // constexpr is used as a hint to the compiler to try and evaluate the // constructor at compile-time - template constexpr fpga_mem_base(S... args) : val{args...} {} + template constexpr fpga_mem(S... args) : val{args...} {} - fpga_mem_base() = default; + fpga_mem() = default; - fpga_mem_base(const fpga_mem_base &) = default; - fpga_mem_base(fpga_mem_base &&) = default; - fpga_mem_base &operator=(const fpga_mem_base &) = default; - fpga_mem_base &operator=(fpga_mem_base &&) = default; + fpga_mem(const fpga_mem &) = default; + fpga_mem(fpga_mem &&) = default; + fpga_mem &operator=(const fpga_mem &) = default; + fpga_mem &operator=(fpga_mem &&) = default; T &get() noexcept { return val; } @@ -66,75 +85,24 @@ template class fpga_mem_base { // Allows for implicit conversion from this to T constexpr operator const T &() const noexcept { return get(); } - fpga_mem_base &operator=(const T &newValue) noexcept { + fpga_mem &operator=(const T &newValue) noexcept { val = newValue; return *this; } - // Note that there is no need for "fpga_mem_base" to define member functions + // Note that there is no need for "fpga_mem" to define member functions // for operators like "++", "[]", "->", comparison, etc. Instead, the type // "T" need only define these operators as non-member functions. Because - // there is an implicit conversion from "fpga_mem_base" to "T&". -}; -} // namespace detail - -// alias for proper namespace -template -using properties_t = ext::oneapi::experimental::detail::properties_t; - -// Empty property list specialization -template -class -#ifdef __SYCL_DEVICE_ONLY__ - [[__sycl_detail__::add_ir_attributes_global_variable("sycl-resource", - "DEFAULT")]] -#endif - fpga_mem : public detail::fpga_mem_base { - - using property_list_t = ext::oneapi::experimental::empty_properties_t; - - // Inherits the base class' constructors - using detail::fpga_mem_base::fpga_mem_base; - -public: - template static constexpr bool has_property() { - return property_list_t::template has_property(); - } - - template static constexpr auto get_property() { - return property_list_t::template get_property(); - } -}; - -template -class -#ifdef __SYCL_DEVICE_ONLY__ - [[__sycl_detail__::add_ir_attributes_global_variable( - "sycl-resource", - ext::oneapi::experimental::detail::PropertyMetaInfo::name..., - "DEFAULT", - ext::oneapi::experimental::detail::PropertyMetaInfo::value...)]] -#endif - fpga_mem> - : public detail::fpga_mem_base { - - using property_list_t = properties_t; - - // Inherits the base class' constructors - using detail::fpga_mem_base::fpga_mem_base; - -public: - static_assert( - ext::oneapi::experimental::is_property_list::value, - "Property list is invalid."); + // there is an implicit conversion from "fpga_mem" to "T&". template static constexpr bool has_property() { - return property_list_t::template has_property(); + return ext::oneapi::experimental::detail::properties_t< + Props...>::template has_property(); } template static constexpr auto get_property() { - return property_list_t::template get_property(); + return ext::oneapi::experimental::detail::properties_t< + Props...>::template get_property(); } };