DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
memory_enums.hpp
Go to the documentation of this file.
1 //==-------------- memory_enums.hpp --- SYCL enums -------------------------==//
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 
12 
14 namespace sycl {
15 
16 enum class memory_order : int {
17  relaxed = 0,
18  acquire = 1,
20  2, // helps optimizer when mapping to std::memory_order
21  release = 3,
22  acq_rel = 4,
23  seq_cst = 5
24 };
25 
26 enum class memory_scope : int {
27  work_item = 0,
28  sub_group = 1,
29  work_group = 2,
30  device = 3,
31  system = 4
32 };
33 
34 #if __cplusplus >= 201703L
35 inline constexpr auto memory_scope_work_item = memory_scope::work_item;
36 inline constexpr auto memory_scope_sub_group = memory_scope::sub_group;
37 inline constexpr auto memory_scope_work_group = memory_scope::work_group;
38 inline constexpr auto memory_scope_device = memory_scope::device;
39 inline constexpr auto memory_scope_system = memory_scope::system;
40 
41 inline constexpr auto memory_order_relaxed = memory_order::relaxed;
42 inline constexpr auto memory_order_acquire = memory_order::acquire;
43 inline constexpr auto memory_order_release = memory_order::release;
44 inline constexpr auto memory_order_acq_rel = memory_order::acq_rel;
45 inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;
46 #endif
47 
48 namespace detail {
49 
50 inline std::vector<memory_order>
52  std::vector<memory_order> result;
53  if (bits & PI_MEMORY_ORDER_RELAXED)
54  result.push_back(memory_order::relaxed);
55  if (bits & PI_MEMORY_ORDER_ACQUIRE)
56  result.push_back(memory_order::acquire);
57  if (bits & PI_MEMORY_ORDER_RELEASE)
58  result.push_back(memory_order::release);
59  if (bits & PI_MEMORY_ORDER_ACQ_REL)
60  result.push_back(memory_order::acq_rel);
61  if (bits & PI_MEMORY_ORDER_SEQ_CST)
62  result.push_back(memory_order::seq_cst);
63  return result;
64 }
65 
66 #ifndef __SYCL_DEVICE_ONLY__
68  switch (order) {
69  case memory_order::relaxed:
70  return std::memory_order_relaxed;
71  case memory_order::__consume_unsupported:
72  return std::memory_order_consume;
73  case memory_order::acquire:
74  return std::memory_order_acquire;
75  case memory_order::release:
76  return std::memory_order_release;
77  case memory_order::acq_rel:
78  return std::memory_order_acq_rel;
79  case memory_order::seq_cst:
80  return std::memory_order_seq_cst;
81  }
82 }
83 #endif // __SYCL_DEVICE_ONLY__
84 
85 } // namespace detail
86 } // namespace sycl
87 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::memory_order
memory_order
Definition: memory_enums.hpp:16
cl::sycl::info::device
device
Definition: info_desc.hpp:50
defines_elementary.hpp
PI_MEMORY_ORDER_ACQUIRE
constexpr pi_memory_order_capabilities PI_MEMORY_ORDER_ACQUIRE
Definition: pi.h:535
cl::sycl::memory_order::__consume_unsupported
@ __consume_unsupported
cl::sycl::detail::getStdMemoryOrder
static constexpr std::memory_order getStdMemoryOrder(sycl::memory_order order)
Definition: memory_enums.hpp:67
detail
Definition: pi_opencl.cpp:86
cl::sycl::memory_order::acq_rel
@ acq_rel
cl::sycl::memory_order::acquire
@ acquire
cl::sycl::memory_scope
memory_scope
Definition: memory_enums.hpp:26
PI_MEMORY_ORDER_RELAXED
constexpr pi_memory_order_capabilities PI_MEMORY_ORDER_RELAXED
Definition: pi.h:534
cl::sycl::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:35
cl::sycl::memory_scope::system
@ system
PI_MEMORY_ORDER_SEQ_CST
constexpr pi_memory_order_capabilities PI_MEMORY_ORDER_SEQ_CST
Definition: pi.h:538
cl::sycl::memory_scope::work_item
@ work_item
PI_MEMORY_ORDER_RELEASE
constexpr pi_memory_order_capabilities PI_MEMORY_ORDER_RELEASE
Definition: pi.h:536
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::readMemoryOrderBitfield
std::vector< memory_order > readMemoryOrderBitfield(pi_memory_order_capabilities bits)
Definition: memory_enums.hpp:51
cl::sycl::memory_order::seq_cst
@ seq_cst
cl::sycl::memory_order::relaxed
@ relaxed
cl::sycl::ext::oneapi::sub_group
Definition: sub_group.hpp:108
PI_MEMORY_ORDER_ACQ_REL
constexpr pi_memory_order_capabilities PI_MEMORY_ORDER_ACQ_REL
Definition: pi.h:537
cl::sycl::memory_scope::work_group
@ work_group
cl::sycl::memory_order::release
@ release
pi_memory_order_capabilities
pi_bitfield pi_memory_order_capabilities
Definition: pi.h:533
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12