DPC++ Runtime
Runtime libraries for oneAPI DPC++
owner_less.hpp
Go to the documentation of this file.
1 //==-------------- weak_object.hpp --- SYCL weak objects -------------------==//
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/access/access.hpp> // for access_mode
12 #include <sycl/accessor.hpp> // for host_acce...
13 #include <sycl/context.hpp> // for context
14 #include <sycl/device.hpp> // for device
15 #include <sycl/event.hpp> // for event
17 #include <sycl/ext/oneapi/weak_object.hpp> // for weak_object
18 #include <sycl/kernel.hpp> // for kernel
19 #include <sycl/kernel_bundle.hpp> // for kernel_id
20 #include <sycl/kernel_bundle_enums.hpp> // for bundle_state
21 #include <sycl/platform.hpp> // for platform
22 #include <sycl/properties/image_properties.hpp> // for sampled_i...
23 #include <sycl/queue.hpp> // for queue
24 #include <sycl/stream.hpp> // for stream
25 
26 namespace sycl {
27 inline namespace _V1 {
28 namespace ext::oneapi {
29 
30 namespace detail {
31 template <typename SyclObject> struct owner_less_base {
32  bool operator()(const SyclObject &lhs, const SyclObject &rhs) const noexcept {
33  return lhs.ext_oneapi_owner_before(rhs);
34  }
35 
37  const weak_object<SyclObject> &rhs) const noexcept {
38  return lhs.owner_before(rhs);
39  }
40 
41  bool operator()(const SyclObject &lhs,
42  const weak_object<SyclObject> &rhs) const noexcept {
43  return lhs.ext_oneapi_owner_before(rhs);
44  }
45 
47  const SyclObject &rhs) const noexcept {
48  return lhs.owner_before(rhs);
49  }
50 };
51 } // namespace detail
52 
53 template <typename SyclObject> struct owner_less;
54 
55 template <>
56 struct owner_less<context> : public detail::owner_less_base<context> {};
57 template <>
58 struct owner_less<device> : public detail::owner_less_base<device> {};
59 template <> struct owner_less<event> : public detail::owner_less_base<event> {};
60 template <>
61 struct owner_less<kernel> : public detail::owner_less_base<kernel> {};
62 template <>
63 struct owner_less<kernel_id> : public detail::owner_less_base<kernel_id> {};
64 template <>
65 struct owner_less<platform> : public detail::owner_less_base<platform> {};
66 template <> struct owner_less<queue> : public detail::owner_less_base<queue> {};
67 template <>
68 struct owner_less<stream> : public detail::owner_less_base<stream> {};
69 
70 template <bundle_state State>
71 struct owner_less<device_image<State>>
72  : public detail::owner_less_base<device_image<State>> {};
73 
74 template <bundle_state State>
75 struct owner_less<kernel_bundle<State>>
76  : public detail::owner_less_base<kernel_bundle<State>> {};
77 
78 template <typename DataT, int Dimensions, typename AllocatorT>
79 struct owner_less<buffer<DataT, Dimensions, AllocatorT>>
80  : public detail::owner_less_base<buffer<DataT, Dimensions, AllocatorT>> {};
81 
82 template <int Dimensions, typename AllocatorT>
84  : public detail::owner_less_base<unsampled_image<Dimensions, AllocatorT>> {
85 };
86 
87 template <int Dimensions, typename AllocatorT>
88 struct owner_less<sampled_image<Dimensions, AllocatorT>>
89  : public detail::owner_less_base<sampled_image<Dimensions, AllocatorT>> {};
90 
91 template <typename DataT, int Dimensions, access_mode AccessMode,
93 struct owner_less<
94  accessor<DataT, Dimensions, AccessMode, AccessTarget, isPlaceholder>>
95  : public detail::owner_less_base<accessor<DataT, Dimensions, AccessMode,
96  AccessTarget, isPlaceholder>> {};
97 
98 template <typename DataT, int Dimensions, access_mode AccessMode>
100  : public detail::owner_less_base<
101  host_accessor<DataT, Dimensions, AccessMode>> {};
102 
103 template <typename DataT, int Dimensions>
105  : public detail::owner_less_base<local_accessor<DataT, Dimensions>> {};
106 
107 template <typename DataT, int Dimensions, access_mode AccessMode,
108  image_target AccessTarget>
109 struct owner_less<
110  unsampled_image_accessor<DataT, Dimensions, AccessMode, AccessTarget>>
111  : public detail::owner_less_base<unsampled_image_accessor<
112  DataT, Dimensions, AccessMode, AccessTarget>> {};
113 
114 template <typename DataT, int Dimensions, access_mode AccessMode>
116  : public detail::owner_less_base<
117  host_unsampled_image_accessor<DataT, Dimensions, AccessMode>> {};
118 
119 template <typename DataT, int Dimensions, image_target AccessTarget>
120 struct owner_less<sampled_image_accessor<DataT, Dimensions, AccessTarget>>
121  : public detail::owner_less_base<
122  sampled_image_accessor<DataT, Dimensions, AccessTarget>> {};
123 
124 template <typename DataT, int Dimensions>
126  : public detail::owner_less_base<
127  host_sampled_image_accessor<DataT, Dimensions>> {};
128 
129 } // namespace ext::oneapi
130 } // namespace _V1
131 } // namespace sycl
The file contains implementations of accessor class.
Defines a shared array that can be used by kernels in queues.
Definition: buffer.hpp:168
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:50
Objects of the class represents an instance of an image in a specific state.
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:64
An event object can be used to synchronize memory transfers, enqueues of kernels and signaling barrie...
Definition: event.hpp:44
The kernel_bundle class represents collection of device images in a particular state.
Objects of the class identify kernel is some kernel_bundle related APIs.
Provides an abstraction of a SYCL kernel.
Definition: kernel.hpp:77
Encapsulates a SYCL platform on which kernels may be executed.
Definition: platform.hpp:99
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:111
image_target
Definition: access.hpp:74
class __SYCL_EBO __SYCL_SPECIAL_CLASS Dimensions
class __SYCL_EBO __SYCL_SPECIAL_CLASS AccessMode
Definition: access.hpp:18
_Abi const simd< _Tp, _Abi > & noexcept
Definition: simd.hpp:1324
bool operator()(const weak_object< SyclObject > &lhs, const weak_object< SyclObject > &rhs) const noexcept
Definition: owner_less.hpp:36
bool operator()(const SyclObject &lhs, const SyclObject &rhs) const noexcept
Definition: owner_less.hpp:32
bool operator()(const SyclObject &lhs, const weak_object< SyclObject > &rhs) const noexcept
Definition: owner_less.hpp:41
bool operator()(const weak_object< SyclObject > &lhs, const SyclObject &rhs) const noexcept
Definition: owner_less.hpp:46