DPC++ Runtime
Runtime libraries for oneAPI DPC++
h_item.hpp
Go to the documentation of this file.
1 //==-------------- h_item.hpp - SYCL standard header file ------------------==//
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/helpers.hpp> // for Builder, group
12 #include <sycl/detail/item_base.hpp> // for id, range
13 #include <sycl/id.hpp> // for id
14 #include <sycl/item.hpp> // for item
15 #include <sycl/range.hpp> // for range
16 
17 #include <stddef.h> // for size_t
18 
19 namespace sycl {
20 inline namespace _V1 {
21 
22 namespace detail {
23 class Builder;
24 }
25 
31 template <int Dimensions> class h_item {
32 public:
33  static constexpr int dimensions = Dimensions;
34 
35  h_item() = delete;
36 
37  h_item(const h_item &hi) = default;
38 
39  h_item &operator=(const h_item &hi) = default;
40 
41  /* -- public interface members -- */
42  item<Dimensions, false> get_global() const { return globalItem; }
43 
45 
46  item<Dimensions, false> get_logical_local() const { return logicalLocalItem; }
47 
48  item<Dimensions, false> get_physical_local() const { return localItem; }
49 
51  return get_global().get_range();
52  }
53 
54  size_t get_global_range(int Dimension) const {
55  return get_global().get_range(Dimension);
56  }
57 
59 
60  size_t get_global_id(int Dimension) const {
61  return get_global().get_id(Dimension);
62  }
63 
65 
66  size_t get_local_range(int Dimension) const {
67  return get_local().get_range(Dimension);
68  }
69 
70  id<Dimensions> get_local_id() const { return get_local().get_id(); }
71 
72  size_t get_local_id(int Dimension) const {
73  return get_local().get_id(Dimension);
74  }
75 
77  return get_logical_local().get_range();
78  }
79 
80  size_t get_logical_local_range(int Dimension) const {
81  return get_logical_local().get_range(Dimension);
82  }
83 
85  return get_logical_local().get_id();
86  }
87 
88  size_t get_logical_local_id(int Dimension) const {
89  return get_logical_local().get_id(Dimension);
90  }
91 
93  return get_physical_local().get_range();
94  }
95 
96  size_t get_physical_local_range(int Dimension) const {
97  return get_physical_local().get_range(Dimension);
98  }
99 
101  return get_physical_local().get_id();
102  }
103 
104  size_t get_physical_local_id(int Dimension) const {
105  return get_physical_local().get_id(Dimension);
106  }
107 
108  bool operator==(const h_item &rhs) const {
109  return (rhs.localItem == localItem) && (rhs.globalItem == globalItem) &&
110  (rhs.logicalLocalItem == logicalLocalItem);
111  }
112 
113  bool operator!=(const h_item &rhs) const { return !((*this) == rhs); }
114 
115 protected:
116  friend class detail::Builder;
117  friend class group<Dimensions>;
119  const range<Dimensions> &flexLocalRange)
120  : globalItem(GL), localItem(L),
121  logicalLocalItem(detail::Builder::createItem<Dimensions, false>(
122  flexLocalRange, L.get_id())) {}
123 
125  : globalItem(GL), localItem(L),
126  logicalLocalItem(detail::Builder::createItem<Dimensions, false>(
127  localItem.get_range(), localItem.get_id())) {}
128 
130  detail::Builder::updateItemIndex(logicalLocalItem, ID);
131  }
132 
133 private:
135  item<Dimensions, false> localItem;
137  item<Dimensions, false> globalItem;
139  item<Dimensions, false> logicalLocalItem;
140 };
141 
142 } // namespace _V1
143 } // namespace sycl
static void updateItemIndex(sycl::item< Dims, WithOffset > &Item, const id< Dims > &NextIndex)
Definition: helpers.hpp:125
Identifies an instance of a group::parallel_for_work_item function object executing at each point in ...
Definition: h_item.hpp:31
h_item(const item< Dimensions, false > &GL, const item< Dimensions, false > &L, const range< Dimensions > &flexLocalRange)
Definition: h_item.hpp:118
id< Dimensions > get_physical_local_id() const
Definition: h_item.hpp:100
item< Dimensions, false > get_logical_local() const
Definition: h_item.hpp:46
size_t get_global_range(int Dimension) const
Definition: h_item.hpp:54
size_t get_logical_local_id(int Dimension) const
Definition: h_item.hpp:88
void setLogicalLocalID(const id< Dimensions > &ID)
Definition: h_item.hpp:129
item< Dimensions, false > get_global() const
Definition: h_item.hpp:42
size_t get_logical_local_range(int Dimension) const
Definition: h_item.hpp:80
range< Dimensions > get_global_range() const
Definition: h_item.hpp:50
h_item(const h_item &hi)=default
range< Dimensions > get_logical_local_range() const
Definition: h_item.hpp:76
id< Dimensions > get_local_id() const
Definition: h_item.hpp:70
static constexpr int dimensions
Definition: h_item.hpp:33
range< Dimensions > get_local_range() const
Definition: h_item.hpp:64
h_item(const item< Dimensions, false > &GL, const item< Dimensions, false > &L)
Definition: h_item.hpp:124
id< Dimensions > get_logical_local_id() const
Definition: h_item.hpp:84
size_t get_physical_local_id(int Dimension) const
Definition: h_item.hpp:104
size_t get_physical_local_range(int Dimension) const
Definition: h_item.hpp:96
h_item & operator=(const h_item &hi)=default
bool operator==(const h_item &rhs) const
Definition: h_item.hpp:108
bool operator!=(const h_item &rhs) const
Definition: h_item.hpp:113
item< Dimensions, false > get_local() const
Definition: h_item.hpp:44
size_t get_local_id(int Dimension) const
Definition: h_item.hpp:72
size_t get_local_range(int Dimension) const
Definition: h_item.hpp:66
id< Dimensions > get_global_id() const
Definition: h_item.hpp:58
item< Dimensions, false > get_physical_local() const
Definition: h_item.hpp:48
size_t get_global_id(int Dimension) const
Definition: h_item.hpp:60
range< Dimensions > get_physical_local_range() const
Definition: h_item.hpp:92
A unique identifier of an item in an index space.
Definition: id.hpp:36
id< Dimensions > get_id() const
Definition: item.hpp:55
range< Dimensions > get_range() const
Definition: item.hpp:69
class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor class __SYCL_EBO __SYCL_SPECIAL_CLASS Dimensions
Definition: accessor.hpp:3233
Definition: access.hpp:18