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/common.hpp>
14 
15 namespace sycl {
17 namespace ext {
18 namespace oneapi {
19 template <typename... PropsT> class accessor_property_list;
20 }
21 } // namespace ext
22 
27 
28  // The structs validate that all objects passed are SYCL properties
29  template <typename... Tail> struct AllProperties : std::true_type {};
30  template <typename T, typename... Tail>
31  struct AllProperties<T, Tail...>
32  : detail::conditional_t<is_property<T>::value, AllProperties<Tail...>,
33  std::false_type> {};
34 
35 public:
36  template <typename... PropsT, typename = typename std::enable_if_t<
37  AllProperties<PropsT...>::value>>
38  property_list(PropsT... Props) : detail::PropertyListBase(false) {
39  ctorHelper(Props...);
40  }
41 
42  template <typename PropT> PropT get_property() const {
43  if (!has_property<PropT>())
44  throw sycl::invalid_object_error("The property is not found",
45  PI_ERROR_INVALID_VALUE);
46 
47  return get_property_helper<PropT>();
48  }
49 
50  template <typename PropT> bool has_property() const noexcept {
51  return has_property_helper<PropT>();
52  }
53 
55  add_or_replace_accessor_properties_helper(PropertyList.MPropsWithData);
56  }
58  delete_accessor_property_helper(Kind);
59  }
60 
61  template <typename... T> operator ext::oneapi::accessor_property_list<T...>();
62 
63 private:
65  std::bitset<detail::DataLessPropKind::DataLessPropKindSize> DataLessProps,
66  std::vector<std::shared_ptr<detail::PropertyWithDataBase>> PropsWithData)
67  : sycl::detail::PropertyListBase(DataLessProps, PropsWithData) {}
68 
69  template <typename... PropsT>
71 };
72 
73 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
74 } // namespace sycl
std::vector< std::shared_ptr< PropertyWithDataBase > > MPropsWithData
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)
#define __SYCL_INLINE_VER_NAMESPACE(X)
typename std::conditional< B, T, F >::type conditional_t
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14