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 <CL/sycl/context.hpp>
14 
16 namespace sycl {
17 
18 namespace property {
19 namespace buffer {
20 class use_host_ptr : public detail::DataLessProperty<detail::BufferUseHostPtr> {
21 };
22 
23 class use_mutex : public detail::PropertyWithData<detail::BufferUseMutex> {
24 public:
25  use_mutex(std::mutex &MutexRef) : MMutex(MutexRef) {}
26 
27  std::mutex *get_mutex_ptr() const { return &MMutex; }
28 
29 private:
30  std::mutex &MMutex;
31 };
32 
34  : public detail::PropertyWithData<detail::BufferContextBound> {
35 public:
36  context_bound(sycl::context BoundContext) : MCtx(std::move(BoundContext)) {}
37 
38  sycl::context get_context() const { return MCtx; }
39 
40 private:
41  sycl::context MCtx;
42 };
43 
45  detail::PropWithDataKind::BufferMemChannel> {
46 public:
47  mem_channel(uint32_t Channel) : MChannel(Channel) {}
48  uint32_t get_channel() const { return MChannel; }
49 
50 private:
51  uint32_t MChannel;
52 };
53 
54 namespace detail {
57  sycl::detail::PropWithDataKind::AccPropBufferLocation> {
58 public:
59  buffer_location(uint64_t Location) : MLocation(Location) {}
60  uint64_t get_buffer_location() const { return MLocation; }
61 
62 private:
63  uint64_t MLocation;
64 };
65 } // namespace detail
66 } // namespace buffer
67 } // namespace property
68 
69 namespace ext {
70 namespace oneapi {
71 namespace property {
72 namespace buffer {
73 
75  sycl::detail::BufferUsePinnedHostMemory> {};
76 } // namespace buffer
77 } // namespace property
78 } // namespace oneapi
79 } // namespace ext
80 
81 // Forward declaration
82 template <typename T, int Dimensions, typename AllocatorT, typename Enable>
83 class buffer;
84 
85 // Buffer property trait specializations
86 template <>
87 struct is_property<property::buffer::use_host_ptr> : std::true_type {};
88 template <> struct is_property<property::buffer::use_mutex> : std::true_type {};
89 template <>
90 struct is_property<property::buffer::detail::buffer_location> : std::true_type {
91 };
92 template <>
93 struct is_property<property::buffer::context_bound> : std::true_type {};
94 template <>
95 struct is_property<property::buffer::mem_channel> : std::true_type {};
96 template <>
97 struct is_property<ext::oneapi::property::buffer::use_pinned_host_memory>
98  : std::true_type {};
99 
100 template <typename T, int Dimensions, typename AllocatorT>
101 struct is_property_of<property::buffer::use_host_ptr,
102  buffer<T, Dimensions, AllocatorT, void>>
103  : std::true_type {};
104 template <typename T, int Dimensions, typename AllocatorT>
105 struct is_property_of<property::buffer::use_mutex,
106  buffer<T, Dimensions, AllocatorT, void>>
107  : std::true_type {};
108 template <typename T, int Dimensions, typename AllocatorT>
109 struct is_property_of<property::buffer::detail::buffer_location,
110  buffer<T, Dimensions, AllocatorT, void>>
111  : std::true_type {};
112 template <typename T, int Dimensions, typename AllocatorT>
113 struct is_property_of<property::buffer::context_bound,
114  buffer<T, Dimensions, AllocatorT, void>>
115  : std::true_type {};
116 template <typename T, int Dimensions, typename AllocatorT>
117 struct is_property_of<property::buffer::mem_channel,
118  buffer<T, Dimensions, AllocatorT, void>>
119  : std::true_type {};
120 template <typename T, int Dimensions, typename AllocatorT>
121 struct is_property_of<ext::oneapi::property::buffer::use_pinned_host_memory,
122  buffer<T, Dimensions, AllocatorT, void>>
123  : std::true_type {};
124 
125 } // namespace sycl
126 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::property::buffer::context_bound
Definition: buffer_properties.hpp:33
cl::sycl::property::buffer::use_host_ptr
Definition: buffer_properties.hpp:20
property_traits.hpp
cl::sycl::property::buffer::context_bound::get_context
sycl::context get_context() const
Definition: buffer_properties.hpp:38
context.hpp
cl::sycl::property::buffer::use_mutex::get_mutex_ptr
std::mutex * get_mutex_ptr() const
Definition: buffer_properties.hpp:27
sycl
Definition: invoke_simd.hpp:68
cl::sycl::buffer
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:58
cl::sycl::is_property
Definition: property_traits.hpp:15
cl::sycl::detail::DataLessProperty
Definition: property_helper.hpp:62
cl::sycl::is_property_of
Definition: property_traits.hpp:18
cl::sycl::property::buffer::mem_channel::mem_channel
mem_channel(uint32_t Channel)
Definition: buffer_properties.hpp:47
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::property::buffer::detail::buffer_location::buffer_location
buffer_location(uint64_t Location)
Definition: buffer_properties.hpp:59
property_helper.hpp
cl::sycl::property::buffer::mem_channel
Definition: buffer_properties.hpp:44
cl::sycl::property::buffer::use_mutex
Definition: buffer_properties.hpp:23
cl::sycl::property::buffer::detail::buffer_location
Definition: buffer_properties.hpp:55
std
Definition: accessor.hpp:2616
cl::sycl::property::buffer::mem_channel::get_channel
uint32_t get_channel() const
Definition: buffer_properties.hpp:48
cl::sycl::property::buffer::context_bound::context_bound
context_bound(sycl::context BoundContext)
Definition: buffer_properties.hpp:36
cl::sycl::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:35
cl::sycl::property::buffer::use_mutex::use_mutex
use_mutex(std::mutex &MutexRef)
Definition: buffer_properties.hpp:25
cl::sycl::property::buffer::detail::buffer_location::get_buffer_location
uint64_t get_buffer_location() const
Definition: buffer_properties.hpp:60
cl::sycl::ext::oneapi::property::buffer::use_pinned_host_memory
Definition: buffer_properties.hpp:74
cl::sycl::detail::PropertyWithData
Definition: property_helper.hpp:83
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12