DPC++ Runtime
Runtime libraries for oneAPI DPC++
buffer_properties.hpp
Go to the documentation of this file.
1 //==----------- buffer_properties.hpp --- SYCL buffer properties -----------==//
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/context.hpp> // for context
12 #include <sycl/detail/property_helper.hpp> // for PropWithDataKind, Dat...
13 #include <sycl/properties/property_traits.hpp> // for is_property_of
14 
15 #include <mutex> // for mutex
16 #include <stdint.h> // for uint32_t, uint64_t
17 #include <type_traits> // for true_type
18 #include <utility> // for move
19 
20 namespace sycl {
21 inline namespace _V1 {
22 
23 namespace property::buffer {
24 class use_host_ptr : public detail::DataLessProperty<detail::BufferUseHostPtr> {
25 };
26 
27 class use_mutex : public detail::PropertyWithData<detail::BufferUseMutex> {
28 public:
29  use_mutex(std::mutex &MutexRef) : MMutex(MutexRef) {}
30 
31  std::mutex *get_mutex_ptr() const { return &MMutex; }
32 
33 private:
34  std::mutex &MMutex;
35 };
36 
38  : public detail::PropertyWithData<detail::BufferContextBound> {
39 public:
40  context_bound(sycl::context BoundContext) : MCtx(std::move(BoundContext)) {}
41 
42  sycl::context get_context() const { return MCtx; }
43 
44 private:
45  sycl::context MCtx;
46 };
47 
49  detail::PropWithDataKind::BufferMemChannel> {
50 public:
51  mem_channel(uint32_t Channel) : MChannel(Channel) {}
52  uint32_t get_channel() const { return MChannel; }
53 
54 private:
55  uint32_t MChannel;
56 };
57 
58 namespace detail {
61  sycl::detail::PropWithDataKind::AccPropBufferLocation> {
62 public:
63  buffer_location(uint64_t Location) : MLocation(Location) {}
64  uint64_t get_buffer_location() const { return MLocation; }
65 
66 private:
67  uint64_t MLocation;
68 };
69 } // namespace detail
70 } // namespace property::buffer
71 
72 namespace ext::oneapi::property::buffer {
73 
75  sycl::detail::BufferUsePinnedHostMemory> {};
76 } // namespace ext::oneapi::property::buffer
77 
78 // Forward declaration
79 template <typename T, int Dimensions, typename AllocatorT, typename Enable>
80 class buffer;
81 
82 // Buffer property trait specializations
83 template <typename T, int Dimensions, typename AllocatorT>
84 struct is_property_of<property::buffer::use_host_ptr,
85  buffer<T, Dimensions, AllocatorT, void>>
86  : std::true_type {};
87 template <typename T, int Dimensions, typename AllocatorT>
88 struct is_property_of<property::buffer::use_mutex,
89  buffer<T, Dimensions, AllocatorT, void>>
90  : std::true_type {};
91 template <typename T, int Dimensions, typename AllocatorT>
93  buffer<T, Dimensions, AllocatorT, void>>
94  : std::true_type {};
95 template <typename T, int Dimensions, typename AllocatorT>
96 struct is_property_of<property::buffer::context_bound,
97  buffer<T, Dimensions, AllocatorT, void>>
98  : std::true_type {};
99 template <typename T, int Dimensions, typename AllocatorT>
100 struct is_property_of<property::buffer::mem_channel,
101  buffer<T, Dimensions, AllocatorT, void>>
102  : std::true_type {};
103 template <typename T, int Dimensions, typename AllocatorT>
104 struct is_property_of<ext::oneapi::property::buffer::use_pinned_host_memory,
105  buffer<T, Dimensions, AllocatorT, void>>
106  : std::true_type {};
107 
108 } // namespace _V1
109 } // namespace sycl
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:169
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:51
constexpr buffer_location_key::value_t< N > buffer_location
Definition: access.hpp:18