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/pi.h> // for PI_ERROR_INVALID_VALUE
12 #include <sycl/detail/property_helper.hpp> // for DataLessPropKind, Pro...
13 #include <sycl/detail/property_list_base.hpp> // for PropertyListBase
14 #include <sycl/exception.hpp> // for invalid_object_error
15 #include <sycl/properties/property_traits.hpp> // for is_property
16 
17 #include <bitset> // for bitset
18 #include <memory> // for shared_ptr
19 #include <type_traits> // for conditional_t, enable...
20 #include <vector> // for vector
21 
22 namespace sycl {
23 inline namespace _V1 {
24 namespace ext::oneapi {
25 template <typename... PropsT> class accessor_property_list;
26 } // namespace ext::oneapi
27 
32 
33  // The structs validate that all objects passed are SYCL properties
34  template <typename... Tail> struct AllProperties : std::true_type {};
35  template <typename T, typename... Tail>
36  struct AllProperties<T, Tail...>
37  : std::conditional_t<is_property<T>::value, AllProperties<Tail...>,
38  std::false_type> {};
39 
40 public:
41  template <typename... PropsT, typename = typename std::enable_if_t<
42  AllProperties<PropsT...>::value>>
43  property_list(PropsT... Props) : detail::PropertyListBase(false) {
44  ctorHelper(Props...);
45  }
46 
47  template <typename PropT> PropT get_property() const {
48  if (!has_property<PropT>())
49  throw sycl::invalid_object_error("The property is not found",
50  PI_ERROR_INVALID_VALUE);
51 
52  return get_property_helper<PropT>();
53  }
54 
55  template <typename PropT> bool has_property() const noexcept {
56  return has_property_helper<PropT>();
57  }
58 
61  }
64  }
65 
66  template <typename... T> operator ext::oneapi::accessor_property_list<T...>();
67 
68 private:
70  std::bitset<detail::DataLessPropKind::DataLessPropKindSize> DataLessProps,
71  std::vector<std::shared_ptr<detail::PropertyWithDataBase>> PropsWithData)
72  : sycl::detail::PropertyListBase(DataLessProps, PropsWithData) {}
73 
74  template <typename... PropsT>
76 };
77 
78 } // namespace _V1
79 } // 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)
Definition: access.hpp:18
_Abi const simd< _Tp, _Abi > & noexcept
Definition: simd.hpp:1324