DPC++ Runtime
Runtime libraries for oneAPI DPC++
property_list.hpp
Go to the documentation of this file.
1 //==--------- property_list.hpp --- SYCL property list ---------------------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <sycl/detail/property_helper.hpp> // for DataLessPropKind, Pro...
12 #include <sycl/detail/property_list_base.hpp> // for PropertyListBase
13 #include <sycl/exception.hpp>
14 #include <sycl/properties/property_traits.hpp> // for is_property
15 
16 #include <bitset> // for bitset
17 #include <memory> // for shared_ptr
18 #include <type_traits> // for conditional_t, enable...
19 #include <vector> // for vector
20 
21 namespace sycl {
22 inline namespace _V1 {
23 namespace ext::oneapi {
24 template <typename... PropsT> class accessor_property_list;
25 } // namespace ext::oneapi
26 
31 
32  // The structs validate that all objects passed are SYCL properties
33  template <typename... Tail> struct AllProperties : std::true_type {};
34  template <typename T, typename... Tail>
35  struct AllProperties<T, Tail...>
36  : std::conditional_t<is_property<T>::value, AllProperties<Tail...>,
37  std::false_type> {};
38 
39 public:
40  template <typename... PropsT, typename = typename std::enable_if_t<
41  AllProperties<PropsT...>::value>>
42  property_list(PropsT... Props) : detail::PropertyListBase(false) {
43  ctorHelper(Props...);
44  }
45 
46  template <typename PropT> PropT get_property() const {
47  if (!has_property<PropT>())
49  "The property is not found");
50 
51  return get_property_helper<PropT>();
52  }
53 
54  template <typename PropT> bool has_property() const noexcept {
55  return has_property_helper<PropT>();
56  }
57 
60  }
63  }
64 
65  template <typename... T> operator ext::oneapi::accessor_property_list<T...>();
66 
67 private:
69  std::bitset<detail::DataLessPropKind::DataLessPropKindSize> DataLessProps,
70  std::vector<std::shared_ptr<detail::PropertyWithDataBase>> PropsWithData)
71  : sycl::detail::PropertyListBase(DataLessProps, PropsWithData) {}
72 
73  template <typename... PropsT>
75 };
76 
77 } // namespace _V1
78 } // namespace sycl
PropertyListBase(std::bitset< DataLessPropKind::DataLessPropKindSize > DataLessProps)
std::vector< std::shared_ptr< PropertyWithDataBase > > MPropsWithData
void delete_accessor_property_helper(const PropWithDataKind &Kind)
void add_or_replace_accessor_properties_helper(const std::vector< std::shared_ptr< PropertyWithDataBase >> &PropsWithData)
Objects of the property_list class are containers for the SYCL properties.
bool has_property() const noexcept
void delete_accessor_property(const sycl::detail::PropWithDataKind &Kind)
void add_or_replace_accessor_properties(const property_list &PropertyList)
property_list(PropsT... Props)
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
Definition: exception.cpp:64
Definition: access.hpp:18
_Abi const simd< _Tp, _Abi > & noexcept
Definition: simd.hpp:1324