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>
12 #include <sycl/id.hpp>
13 #include <sycl/item.hpp>
14 #include <sycl/range.hpp>
15 
16 namespace sycl {
18 
19 namespace detail {
20 class Builder;
21 }
22 
28 template <int dimensions> class h_item {
29 public:
30  h_item() = delete;
31 
32  h_item(const h_item &hi) = default;
33 
34  h_item &operator=(const h_item &hi) = default;
35 
36  /* -- public interface members -- */
37  item<dimensions, false> get_global() const { return globalItem; }
38 
39  item<dimensions, false> get_local() const { return get_logical_local(); }
40 
41  item<dimensions, false> get_logical_local() const { return logicalLocalItem; }
42 
43  item<dimensions, false> get_physical_local() const { return localItem; }
44 
46  return get_global().get_range();
47  }
48 
49  size_t get_global_range(int dimension) const {
50  return get_global().get_range(dimension);
51  }
52 
53  id<dimensions> get_global_id() const { return get_global().get_id(); }
54 
55  size_t get_global_id(int dimension) const {
56  return get_global().get_id(dimension);
57  }
58 
59  range<dimensions> get_local_range() const { return get_local().get_range(); }
60 
61  size_t get_local_range(int dimension) const {
62  return get_local().get_range(dimension);
63  }
64 
65  id<dimensions> get_local_id() const { return get_local().get_id(); }
66 
67  size_t get_local_id(int dimension) const {
68  return get_local().get_id(dimension);
69  }
70 
72  return get_logical_local().get_range();
73  }
74 
75  size_t get_logical_local_range(int dimension) const {
76  return get_logical_local().get_range(dimension);
77  }
78 
80  return get_logical_local().get_id();
81  }
82 
83  size_t get_logical_local_id(int dimension) const {
84  return get_logical_local().get_id(dimension);
85  }
86 
88  return get_physical_local().get_range();
89  }
90 
91  size_t get_physical_local_range(int dimension) const {
92  return get_physical_local().get_range(dimension);
93  }
94 
96  return get_physical_local().get_id();
97  }
98 
99  size_t get_physical_local_id(int dimension) const {
100  return get_physical_local().get_id(dimension);
101  }
102 
103  bool operator==(const h_item &rhs) const {
104  return (rhs.localItem == localItem) && (rhs.globalItem == globalItem) &&
105  (rhs.logicalLocalItem == logicalLocalItem);
106  }
107 
108  bool operator!=(const h_item &rhs) const { return !((*this) == rhs); }
109 
110 protected:
111  friend class detail::Builder;
112  friend class group<dimensions>;
114  const range<dimensions> &flexLocalRange)
115  : globalItem(GL), localItem(L),
116  logicalLocalItem(detail::Builder::createItem<dimensions, false>(
117  flexLocalRange, L.get_id())) {}
118 
120  : globalItem(GL), localItem(L),
121  logicalLocalItem(detail::Builder::createItem<dimensions, false>(
122  localItem.get_range(), localItem.get_id())) {}
123 
125  detail::Builder::updateItemIndex(logicalLocalItem, ID);
126  }
127 
128 private:
130  item<dimensions, false> localItem;
132  item<dimensions, false> globalItem;
134  item<dimensions, false> logicalLocalItem;
135 };
136 
137 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
138 } // namespace sycl
sycl::_V1::h_item::get_logical_local_id
id< dimensions > get_logical_local_id() const
Definition: h_item.hpp:79
sycl::_V1::h_item::operator!=
bool operator!=(const h_item &rhs) const
Definition: h_item.hpp:108
sycl::_V1::detail::Builder
Definition: helpers.hpp:61
sycl::_V1::h_item::h_item
h_item(const item< dimensions, false > &GL, const item< dimensions, false > &L, const range< dimensions > &flexLocalRange)
Definition: h_item.hpp:113
sycl::_V1::h_item::get_physical_local
item< dimensions, false > get_physical_local() const
Definition: h_item.hpp:43
sycl::_V1::h_item::get_local_range
range< dimensions > get_local_range() const
Definition: h_item.hpp:59
sycl::_V1::h_item::get_physical_local_id
size_t get_physical_local_id(int dimension) const
Definition: h_item.hpp:99
item.hpp
__SYCL_INLINE_VER_NAMESPACE
#define __SYCL_INLINE_VER_NAMESPACE(X)
Definition: defines_elementary.hpp:11
sycl::_V1::h_item::get_logical_local_range
range< dimensions > get_logical_local_range() const
Definition: h_item.hpp:71
sycl::_V1::h_item::operator==
bool operator==(const h_item &rhs) const
Definition: h_item.hpp:103
sycl::_V1::h_item::get_global_range
size_t get_global_range(int dimension) const
Definition: h_item.hpp:49
helpers.hpp
sycl
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14
sycl::_V1::id
A unique identifier of an item in an index space.
Definition: array.hpp:17
id.hpp
sycl::_V1::range
Defines the iteration domain of either a single work-group in a parallel dispatch,...
Definition: buffer.hpp:28
sycl::_V1::h_item::get_global_range
range< dimensions > get_global_range() const
Definition: h_item.hpp:45
sycl::_V1::h_item::get_local_range
size_t get_local_range(int dimension) const
Definition: h_item.hpp:61
sycl::_V1::item< dimensions, false >
sycl::_V1::ext::oneapi::experimental::operator=
annotated_arg & operator=(annotated_arg &)=default
range.hpp
sycl::_V1::h_item::get_local
item< dimensions, false > get_local() const
Definition: h_item.hpp:39
sycl::_V1::h_item
Identifies an instance of a group::parallel_for_work_item function object executing at each point in ...
Definition: helpers.hpp:34
sycl::_V1::h_item::get_logical_local_range
size_t get_logical_local_range(int dimension) const
Definition: h_item.hpp:75
sycl::_V1::h_item::get_physical_local_id
id< dimensions > get_physical_local_id() const
Definition: h_item.hpp:95
sycl::_V1::h_item::get_logical_local_id
size_t get_logical_local_id(int dimension) const
Definition: h_item.hpp:83
sycl::_V1::h_item::get_physical_local_range
range< dimensions > get_physical_local_range() const
Definition: h_item.hpp:87
sycl::_V1::h_item::h_item
h_item(const item< dimensions, false > &GL, const item< dimensions, false > &L)
Definition: h_item.hpp:119
sycl::_V1::h_item::get_global_id
size_t get_global_id(int dimension) const
Definition: h_item.hpp:55
sycl::_V1::h_item::get_global
item< dimensions, false > get_global() const
Definition: h_item.hpp:37
sycl::_V1::h_item::get_logical_local
item< dimensions, false > get_logical_local() const
Definition: h_item.hpp:41
sycl::_V1::h_item::get_local_id
size_t get_local_id(int dimension) const
Definition: h_item.hpp:67
sycl::_V1::h_item::get_global_id
id< dimensions > get_global_id() const
Definition: h_item.hpp:53
sycl::_V1::h_item::get_local_id
id< dimensions > get_local_id() const
Definition: h_item.hpp:65
sycl::_V1::h_item::get_physical_local_range
size_t get_physical_local_range(int dimension) const
Definition: h_item.hpp:91
sycl::_V1::group
Definition: helpers.hpp:30
sycl::_V1::h_item::setLogicalLocalID
void setLogicalLocalID(const id< dimensions > &ID)
Definition: h_item.hpp:124