DPC++ Runtime
Runtime libraries for oneAPI Data Parallel C++
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 
12 #include <CL/sycl/id.hpp>
13 #include <CL/sycl/item.hpp>
14 #include <CL/sycl/range.hpp>
15 
17 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 } // namespace sycl
138 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::h_item::get_physical_local_range
size_t get_physical_local_range(int dimension) const
Definition: h_item.hpp:91
cl::sycl::h_item::h_item
h_item(const item< dimensions, false > &GL, const item< dimensions, false > &L)
Definition: h_item.hpp:119
cl::sycl::detail::Builder
Definition: helpers.hpp:68
cl::sycl::item< dimensions, false >
item.hpp
cl::sycl::h_item::get_physical_local_id
id< dimensions > get_physical_local_id() const
Definition: h_item.hpp:95
cl::sycl::id
A unique identifier of an item in an index space.
Definition: array.hpp:17
cl::sycl::h_item::get_local_id
id< dimensions > get_local_id() const
Definition: h_item.hpp:65
cl::sycl::group
Encapsulates all functionality required to represent a particular work-group within a parallel execut...
Definition: helpers.hpp:29
cl::sycl::h_item::get_physical_local_id
size_t get_physical_local_id(int dimension) const
Definition: h_item.hpp:99
cl::sycl::h_item::get_local_id
size_t get_local_id(int dimension) const
Definition: h_item.hpp:67
cl::sycl::h_item::get_physical_local_range
range< dimensions > get_physical_local_range() const
Definition: h_item.hpp:87
cl::sycl::h_item::get_global_range
size_t get_global_range(int dimension) const
Definition: h_item.hpp:49
cl::sycl::h_item::get_global_id
id< dimensions > get_global_id() const
Definition: h_item.hpp:53
cl::sycl::h_item::setLogicalLocalID
void setLogicalLocalID(const id< dimensions > &ID)
Definition: h_item.hpp:124
helpers.hpp
cl::sycl::h_item::get_physical_local
item< dimensions, false > get_physical_local() const
Definition: h_item.hpp:43
id.hpp
cl::sycl::range
Defines the iteration domain of either a single work-group in a parallel dispatch,...
Definition: buffer.hpp:24
cl::sycl::h_item::get_logical_local_id
size_t get_logical_local_id(int dimension) const
Definition: h_item.hpp:83
cl::sycl::h_item::get_logical_local_range
size_t get_logical_local_range(int dimension) const
Definition: h_item.hpp:75
cl::sycl::h_item
Identifies an instance of a group::parallel_for_work_item function object executing at each point in ...
Definition: helpers.hpp:33
cl::sycl::h_item::get_local
item< dimensions, false > get_local() const
Definition: h_item.hpp:39
cl::sycl::h_item::get_logical_local_id
id< dimensions > get_logical_local_id() const
Definition: h_item.hpp:79
cl::sycl::h_item::operator!=
bool operator!=(const h_item &rhs) const
Definition: h_item.hpp:108
range.hpp
cl::sycl::h_item::get_logical_local
item< dimensions, false > get_logical_local() const
Definition: h_item.hpp:41
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::h_item::get_global_range
range< dimensions > get_global_range() const
Definition: h_item.hpp:45
cl::sycl::h_item::get_global
item< dimensions, false > get_global() const
Definition: h_item.hpp:37
cl::sycl::h_item::get_logical_local_range
range< dimensions > get_logical_local_range() const
Definition: h_item.hpp:71
cl::sycl::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
cl::sycl::h_item::get_global_id
size_t get_global_id(int dimension) const
Definition: h_item.hpp:55
cl::sycl::h_item::get_local_range
range< dimensions > get_local_range() const
Definition: h_item.hpp:59
cl::sycl::h_item::get_local_range
size_t get_local_range(int dimension) const
Definition: h_item.hpp:61
cl::sycl::h_item::operator==
bool operator==(const h_item &rhs) const
Definition: h_item.hpp:103
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12