DPC++ Runtime
Runtime libraries for oneAPI DPC++
owner_less_base.hpp
Go to the documentation of this file.
1 //==-- owner_less_base.hpp --- Common base class for owner-based ordering --==//
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/impl_utils.hpp> // for getSyclObjImpl
12 #include <sycl/ext/oneapi/weak_object_base.hpp> // for getSyclWeakObjImpl
13 
14 namespace sycl {
15 inline namespace _V1 {
16 namespace detail {
17 
18 // Common CRTP base class supplying a common definition of owner-before ordering
19 // for SYCL objects.
20 template <class SyclObjT> class OwnerLessBase {
21 public:
22 #ifndef __SYCL_DEVICE_ONLY__
30  const noexcept {
31  return getSyclObjImpl(*static_cast<const SyclObjT *>(this))
32  .owner_before(ext::oneapi::detail::getSyclWeakObjImpl(Other));
33  }
34 
40  bool ext_oneapi_owner_before(const SyclObjT &Other) const noexcept {
41  return getSyclObjImpl(*static_cast<const SyclObjT *>(this))
42  .owner_before(getSyclObjImpl(Other));
43  }
44 #else
45  // On device calls to these functions are disallowed, so declare them but
46  // don't define them to avoid compilation failures.
49  const noexcept;
50  bool ext_oneapi_owner_before(const SyclObjT &Other) const noexcept;
51 #endif
52 };
53 
54 } // namespace detail
55 } // namespace _V1
56 } // namespace sycl
bool ext_oneapi_owner_before(const ext::oneapi::detail::weak_object_base< SyclObjT > &Other) const noexcept
Compares the object against a weak object using an owner-based implementation-defined ordering.
bool ext_oneapi_owner_before(const SyclObjT &Other) const noexcept
Compares the object against another object using an owner-based implementation-defined ordering.
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
Definition: impl_utils.hpp:30
decltype(weak_object_base< SYCLObjT >::MObjWeakPtr) getSyclWeakObjImpl(const weak_object_base< SYCLObjT > &WeakObj)
Definition: access.hpp:18
_Abi const simd< _Tp, _Abi > & noexcept
Definition: simd.hpp:1324