DPC++ Runtime
Runtime libraries for oneAPI DPC++
property_helper.hpp
Go to the documentation of this file.
1 //==--------- property_helper.hpp --- SYCL property helper -----------------==//
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 namespace sycl {
12 inline namespace _V1 {
13 
14 namespace detail {
15 
16 // All properties are split here to dataless properties and properties with
17 // data. A dataless property is one which has no data stored in it. A property
18 // with data is one which has data stored in it and usually provides and access
19 // to it. For dataless property we just store a bool which indicates if a
20 // property is set or not. For properties with data we store a pointer to the
21 // base class because we do not know the size of such properties beforehand.
22 
23 // List of all dataless properties' IDs
28  InOrder = 3,
29  NoInit = 4,
51  // Indicates the last known dataless property.
53  // Exceeding 32 may cause ABI breaking change on some of OSes.
55 };
56 
57 // List of all properties with data IDs
68 };
69 
70 // Base class for dataless properties, needed to check that the type of an
71 // object passed to the property_list is a property.
73 
74 // Helper class for the dataless properties. Every such property is supposed
75 // to inherit from it. The ID template parameter should be one from
76 // DataLessPropKind.
77 template <int ID> class DataLessProperty : DataLessPropertyBase {
78 public:
79  static constexpr int getKind() { return ID; }
80 };
81 
82 // Base class for properties with data, needed to check that the type of an
83 // object passed to the property_list is a property and for checking if two
84 // properties with data are of the same type.
86 public:
87  PropertyWithDataBase(int ID) : MID(ID) {}
88  bool isSame(int ID) const { return ID == MID; }
89  virtual ~PropertyWithDataBase() = default;
90 
91 private:
92  int MID = -1;
93 };
94 
95 // Helper class for the properties with data. Every such property is supposed
96 // to inherit from it. The ID template parameter should be one from
97 // PropWithDataKind.
98 template <int ID> class PropertyWithData : public PropertyWithDataBase {
99 public:
101  static int getKind() { return ID; }
102 };
103 
104 } // namespace detail
105 
106 } // namespace _V1
107 } // namespace sycl
Definition: access.hpp:18