DPC++ Runtime
Runtime libraries for oneAPI DPC++
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 inline std::vector<memory_scope>
68  std::vector<memory_scope> result;
69  if (bits & PI_MEMORY_SCOPE_WORK_ITEM)
70  result.push_back(memory_scope::work_item);
71  if (bits & PI_MEMORY_SCOPE_SUB_GROUP)
72  result.push_back(memory_scope::sub_group);
73  if (bits & PI_MEMORY_SCOPE_WORK_GROUP)
74  result.push_back(memory_scope::work_group);
75  if (bits & PI_MEMORY_SCOPE_DEVICE)
76  result.push_back(memory_scope::device);
77  if (bits & PI_MEMORY_SCOPE_SYSTEM)
78  result.push_back(memory_scope::system);
79  return result;
80 }
81 
82 #ifndef __SYCL_DEVICE_ONLY__
84  switch (order) {
85  case memory_order::relaxed:
86  return std::memory_order_relaxed;
87  case memory_order::__consume_unsupported:
88  return std::memory_order_consume;
89  case memory_order::acquire:
90  return std::memory_order_acquire;
91  case memory_order::release:
92  return std::memory_order_release;
93  case memory_order::acq_rel:
94  return std::memory_order_acq_rel;
95  case memory_order::seq_cst:
96  return std::memory_order_seq_cst;
97  }
98 }
99 #endif // __SYCL_DEVICE_ONLY__
100 
101 } // namespace detail
102 } // namespace sycl
103 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::memory_order
memory_order
Definition: memory_enums.hpp:16
defines_elementary.hpp
PI_MEMORY_ORDER_ACQUIRE
constexpr pi_memory_order_capabilities PI_MEMORY_ORDER_ACQUIRE
Definition: pi.h:501
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:83
PI_MEMORY_SCOPE_WORK_ITEM
constexpr pi_memory_scope_capabilities PI_MEMORY_SCOPE_WORK_ITEM
Definition: pi.h:507
sycl
Definition: invoke_simd.hpp:68
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:500
cl::sycl::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:36
cl::sycl::memory_scope::system
@ system
PI_MEMORY_SCOPE_DEVICE
constexpr pi_memory_scope_capabilities PI_MEMORY_SCOPE_DEVICE
Definition: pi.h:510
PI_MEMORY_SCOPE_SYSTEM
constexpr pi_memory_scope_capabilities PI_MEMORY_SCOPE_SYSTEM
Definition: pi.h:511
PI_MEMORY_SCOPE_SUB_GROUP
constexpr pi_memory_scope_capabilities PI_MEMORY_SCOPE_SUB_GROUP
Definition: pi.h:508
PI_MEMORY_ORDER_SEQ_CST
constexpr pi_memory_order_capabilities PI_MEMORY_ORDER_SEQ_CST
Definition: pi.h:504
cl::sycl::memory_scope::work_item
@ work_item
PI_MEMORY_ORDER_RELEASE
constexpr pi_memory_order_capabilities PI_MEMORY_ORDER_RELEASE
Definition: pi.h:502
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
pi_memory_scope_capabilities
pi_bitfield pi_memory_scope_capabilities
Definition: pi.h:506
cl::sycl::memory_order::relaxed
@ relaxed
cl::sycl::ext::oneapi::sub_group
Definition: sub_group.hpp:108
PI_MEMORY_SCOPE_WORK_GROUP
constexpr pi_memory_scope_capabilities PI_MEMORY_SCOPE_WORK_GROUP
Definition: pi.h:509
PI_MEMORY_ORDER_ACQ_REL
constexpr pi_memory_order_capabilities PI_MEMORY_ORDER_ACQ_REL
Definition: pi.h:503
cl::sycl::memory_scope::work_group
@ work_group
cl::sycl::memory_order::release
@ release
cl::sycl::info::device
device
Definition: info_desc.hpp:53
cl::sycl::detail::readMemoryScopeBitfield
std::vector< memory_scope > readMemoryScopeBitfield(pi_memory_scope_capabilities bits)
Definition: memory_enums.hpp:67
pi_memory_order_capabilities
pi_bitfield pi_memory_order_capabilities
Definition: pi.h:499
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12