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 #include <sycl/detail/common.hpp>
12 
13 namespace sycl {
15 
16 namespace detail {
17 
18 // All properties are split here to dataless properties and properties with
19 // data. A dataless property is one which has no data stored in it. A property
20 // with data is one which has data stored in it and usually provides and access
21 // to it. For dataless property we just store a bool which indicates if a
22 // property is set or not. For properties with data we store a pointer to the
23 // base class because we do not know the size of such properties beforehand.
24 
25 // List of all dataless properties' IDs
30  InOrder = 3,
31  NoInit = 4,
46  // Indicates the last known dataless property.
48  // Exceeding 32 may cause ABI breaking change on some of OSes.
50 };
51 
52 // List of all properties with data IDs
61 };
62 
63 // Base class for dataless properties, needed to check that the type of an
64 // object passed to the property_list is a property.
66 
67 // Helper class for the dataless properties. Every such property is supposed
68 // to inherit from it. The ID template parameter should be one from
69 // DataLessPropKind.
70 template <int ID> class DataLessProperty : DataLessPropertyBase {
71 public:
72  static constexpr int getKind() { return ID; }
73 };
74 
75 // Base class for properties with data, needed to check that the type of an
76 // object passed to the property_list is a property and for checking if two
77 // properties with data are of the same type.
79 public:
80  PropertyWithDataBase(int ID) : MID(ID) {}
81  bool isSame(int ID) const { return ID == MID; }
82  virtual ~PropertyWithDataBase() = default;
83 
84 private:
85  int MID = -1;
86 };
87 
88 // Helper class for the properties with data. Every such property is supposed
89 // to inherit from it. The ID template parameter should be one from
90 // PropWithDataKind.
91 template <int ID> class PropertyWithData : public PropertyWithDataBase {
92 public:
94  static int getKind() { return ID; }
95 };
96 
97 } // namespace detail
98 
99 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
100 } // namespace sycl
#define __SYCL_INLINE_VER_NAMESPACE(X)
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14