DPC++ Runtime
Runtime libraries for oneAPI DPC++
image_properties.hpp
Go to the documentation of this file.
1 //==----------- image_properties.hpp --- SYCL image 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 <type_traits> // for true_type
17 #include <utility> // for move
18 
19 namespace sycl {
20 inline namespace _V1 {
21 namespace property::image {
22 class use_host_ptr : public detail::DataLessProperty<detail::ImageUseHostPtr> {
23 };
24 
25 class use_mutex : public detail::PropertyWithData<detail::ImageUseMutex> {
26 public:
27  use_mutex(std::mutex &MutexRef) : MMutex(MutexRef) {}
28 
29  std::mutex *get_mutex_ptr() const { return &MMutex; }
30 
31 private:
32  std::mutex &MMutex;
33 };
34 
36  : public detail::PropertyWithData<detail::ImageContextBound> {
37 public:
38  context_bound(sycl::context BoundContext) : MCtx(std::move(BoundContext)) {}
39 
40  sycl::context get_context() const { return MCtx; }
41 
42 private:
43  sycl::context MCtx;
44 };
45 } // namespace property::image
46 
47 // Forward declaration
48 template <int Dimensions, typename AllocatorT> class image;
49 template <int Dimensions, typename AllocatorT> class sampled_image;
50 template <int Dimensions, typename AllocatorT> class unsampled_image;
51 
52 // SYCL 1.2.1 image property trait specializations
53 template <int Dimensions, typename AllocatorT>
54 struct is_property_of<property::image::use_host_ptr,
55  image<Dimensions, AllocatorT>> : std::true_type {};
56 template <int Dimensions, typename AllocatorT>
57 struct is_property_of<property::image::use_mutex, image<Dimensions, AllocatorT>>
58  : std::true_type {};
59 template <int Dimensions, typename AllocatorT>
60 struct is_property_of<property::image::context_bound,
61  image<Dimensions, AllocatorT>> : std::true_type {};
62 
63 // SYCL 2020 image property trait specializations
64 template <int Dimensions, typename AllocatorT>
65 struct is_property_of<property::image::use_host_ptr,
66  sampled_image<Dimensions, AllocatorT>> : std::true_type {
67 };
68 template <int Dimensions, typename AllocatorT>
69 struct is_property_of<property::image::use_mutex,
70  sampled_image<Dimensions, AllocatorT>> : std::true_type {
71 };
72 template <int Dimensions, typename AllocatorT>
73 struct is_property_of<property::image::context_bound,
74  sampled_image<Dimensions, AllocatorT>> : std::true_type {
75 };
76 template <int Dimensions, typename AllocatorT>
77 struct is_property_of<property::image::use_host_ptr,
78  unsampled_image<Dimensions, AllocatorT>>
79  : std::true_type {};
80 template <int Dimensions, typename AllocatorT>
81 struct is_property_of<property::image::use_mutex,
82  unsampled_image<Dimensions, AllocatorT>>
83  : std::true_type {};
84 template <int Dimensions, typename AllocatorT>
85 struct is_property_of<property::image::context_bound,
86  unsampled_image<Dimensions, AllocatorT>>
87  : std::true_type {};
88 
89 } // namespace _V1
90 } // namespace sycl
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:51
Defines a shared image data.
Definition: image.hpp:443
context_bound(sycl::context BoundContext)
Definition: access.hpp:18