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,
52  // Indicates the last known dataless property.
54  // Exceeding 32 may cause ABI breaking change on some of OSes.
56 };
57 
58 // List of all properties with data IDs
69 };
70 
71 // Base class for dataless properties, needed to check that the type of an
72 // object passed to the property_list is a property.
74 
75 // Helper class for the dataless properties. Every such property is supposed
76 // to inherit from it. The ID template parameter should be one from
77 // DataLessPropKind.
78 template <int ID> class DataLessProperty : DataLessPropertyBase {
79 public:
80  static constexpr int getKind() { return ID; }
81 };
82 
83 // Base class for properties with data, needed to check that the type of an
84 // object passed to the property_list is a property and for checking if two
85 // properties with data are of the same type.
87 public:
88  PropertyWithDataBase(int ID) : MID(ID) {}
89  bool isSame(int ID) const { return ID == MID; }
90  virtual ~PropertyWithDataBase() = default;
91 
92 private:
93  int MID = -1;
94 };
95 
96 // Helper class for the properties with data. Every such property is supposed
97 // to inherit from it. The ID template parameter should be one from
98 // PropWithDataKind.
99 template <int ID> class PropertyWithData : public PropertyWithDataBase {
100 public:
102  static int getKind() { return ID; }
103 };
104 
105 } // namespace detail
106 
107 } // namespace _V1
108 } // namespace sycl
Definition: access.hpp:18