DASH  0.3.0
Types.h
1 #ifndef DASH__TYPES_H_
2 #define DASH__TYPES_H_
3 
5 #include <dash/internal/Unit.h>
6 
7 #include <cpp17/cstddef.h>
8 
9 #include <array>
10 #include <cstddef>
11 #include <type_traits>
12 
13 
14 namespace dash {
15 
16 typedef enum MemArrange {
17  MEM_ARRANGE_UNDEFINED = 0,
18  ROW_MAJOR,
19  COL_MAJOR
20 } MemArrange;
21 
22 namespace internal {
23 
24 typedef enum DistributionType {
25  DIST_UNDEFINED = 0,
26  DIST_NONE,
27  DIST_BLOCKED, // = BLOCKCYCLIC(ceil(nelem/nunits))
28  DIST_CYCLIC, // = BLOCKCYCLIC(1) Will be removed
29  DIST_BLOCKCYCLIC,
30  DIST_TILE
31 } DistributionType; // general blocked distribution
32 
33 } // namespace internal
34 
39 typedef int dim_t;
40 
41 namespace internal {
42 
43 #if defined(DASH_ENABLE_DEFAULT_INDEX_TYPE_LONG)
44  typedef long default_signed_index;
45  typedef unsigned long default_unsigned_index;
46 #elif defined(DASH_ENABLE_DEFAULT_INDEX_TYPE_INT)
47  typedef int default_signed_index;
48  typedef unsigned int default_unsigned_index;
49 #else
50  typedef ssize_t default_signed_index;
51  typedef size_t default_unsigned_index;
52 #endif
53 
54 } // namespace internal
55 
59 typedef internal::default_signed_index default_index_t;
60 
64 typedef internal::default_unsigned_index default_extent_t;
65 
69 typedef internal::default_unsigned_index default_size_t;
70 
74 typedef internal::default_signed_index gptrdiff_t;
75 
76 template<
77  dash::dim_t NumDimensions,
78  typename IndexType = dash::default_index_t>
79 struct Point {
80  ::std::array<IndexType, NumDimensions> coords;
81 };
82 
83 template<
84  dash::dim_t NumDimensions,
85  typename SizeType = dash::default_extent_t>
86 struct Extent {
87  ::std::array<SizeType, NumDimensions> sizes;
88 };
89 
90 #ifdef DOXYGEN
91 
95 template<typename Type>
96 struct dart_datatype {
97  static constexpr const dart_datatype_t value;
98 };
99 
103 template <typename T>
105  static constexpr const dart_datatype_t value;
106 };
107 
108 #else
109 
110 template<typename Type>
111 struct dart_datatype {
112  static constexpr const dart_datatype_t value = DART_TYPE_UNDEFINED;
113 };
114 
115 template<>
116 struct dart_datatype<char> {
117  static constexpr const dart_datatype_t value = DART_TYPE_BYTE;
118 };
119 
120 template<>
121 struct dart_datatype<unsigned char> {
122  static constexpr const dart_datatype_t value = DART_TYPE_BYTE;
123 };
124 
125 template<>
126 struct dart_datatype<short> {
127  static constexpr const dart_datatype_t value = DART_TYPE_SHORT;
128 };
129 
130 template<>
131 struct dart_datatype<unsigned short> {
132  static constexpr const dart_datatype_t value = DART_TYPE_SHORT;
133 };
134 
135 template<>
136 struct dart_datatype<int> {
137  static constexpr const dart_datatype_t value = DART_TYPE_INT;
138 };
139 
140 template<>
141 struct dart_datatype<unsigned int> {
142  static constexpr const dart_datatype_t value = DART_TYPE_UINT;
143 };
144 
145 template<>
146 struct dart_datatype<long> {
147  static constexpr const dart_datatype_t value = DART_TYPE_LONG;
148 };
149 
150 template<>
151 struct dart_datatype<unsigned long> {
152  static constexpr const dart_datatype_t value = DART_TYPE_ULONG;
153 };
154 
155 template<>
156 struct dart_datatype<long long> {
157  static constexpr const dart_datatype_t value = DART_TYPE_LONGLONG;
158 };
159 
160 template<>
161 struct dart_datatype<unsigned long long> {
162  static constexpr const dart_datatype_t value = DART_TYPE_ULONGLONG;
163 };
164 
165 template<>
166 struct dart_datatype<float> {
167  static constexpr const dart_datatype_t value = DART_TYPE_FLOAT;
168 };
169 
170 template<>
171 struct dart_datatype<double> {
172  static constexpr const dart_datatype_t value = DART_TYPE_DOUBLE;
173 };
174 
175 template<>
176 struct dart_datatype<long double> {
177  static constexpr const dart_datatype_t value = DART_TYPE_LONG_DOUBLE;
178 };
179 
180 template<typename T>
181 struct dart_datatype<const T> : public dart_datatype<T> { };
182 
183 template<typename T>
184 struct dart_datatype<volatile T> : public dart_datatype<T> { };
185 
186 
187 namespace internal {
188 
189 template <std::size_t Size>
190 struct dart_pun_datatype_size
191 : public std::integral_constant<dart_datatype_t, DART_TYPE_UNDEFINED>
192 { };
193 
194 template <>
195 struct dart_pun_datatype_size<1>
196 : public std::integral_constant<dart_datatype_t, DART_TYPE_BYTE>
197 { };
198 
199 template <>
200 struct dart_pun_datatype_size<2>
201 : public std::integral_constant<dart_datatype_t, DART_TYPE_SHORT>
202 { };
203 
204 template <>
205 struct dart_pun_datatype_size<4>
206 : public std::integral_constant<dart_datatype_t, DART_TYPE_INT>
207 { };
208 
209 template <>
210 struct dart_pun_datatype_size<8>
211 : public std::integral_constant<dart_datatype_t, DART_TYPE_LONGLONG>
212 { };
213 
214 } // namespace internal
215 
216 template <typename T>
217 struct dart_punned_datatype {
218  static constexpr const dart_datatype_t value
219  = std::conditional<
220  // only use type punning if T is not a DART
221  // data type:
223  == DART_TYPE_UNDEFINED,
224  internal::dart_pun_datatype_size<sizeof(T)>,
226  >::type::value;
227 };
228 
229 #endif // DOXYGEN
230 
235 template <class T>
237  public std::integral_constant<bool,
238  std::is_standard_layout<T>::value
239 #ifdef DASH_HAVE_STD_TRIVIALLY_COPYABLE
240  && std::is_trivially_copyable<T>::value
241 #elif defined DASH_HAVE_TRIVIAL_COPY_INTRINSIC
242  && __has_trivial_copy(T)
243 #endif
244  >
245 { };
246 
251 template <typename T>
253 : public std::integral_constant<bool, std::is_arithmetic<T>::value>
254 { };
255 
260 template <typename T>
262 : public std::integral_constant<
263  bool,
264  dash::dart_datatype<T>::value != DART_TYPE_UNDEFINED >
265 { };
266 
275 template<class T, class EqualTo>
277 {
278  template<class U, class V>
279  static auto test(U*) -> decltype(std::declval<U>() == std::declval<V>());
280  template<typename, typename>
281  static auto test(...) -> std::false_type;
282 
283  using type = typename std::is_same<bool, decltype(test<T, EqualTo>(0))>::type;
284 };
285 
286 template<class T, class EqualTo = T>
287 struct has_operator_equal : has_operator_equal_impl<T, EqualTo>::type {};
288 
294 template<typename T>
295 struct dart_storage {
296  const size_t nelem;
297  static constexpr const dart_datatype_t dtype =
298  (dart_datatype<T>::value == DART_TYPE_UNDEFINED)
300 
301  constexpr
302  dart_storage(size_t nvalues) noexcept
303  : nelem(
304  (dart_datatype<T>::value == DART_TYPE_UNDEFINED)
305  ? nvalues * sizeof(T) : nvalues)
306  { }
307 };
308 
319 typedef struct
320 dash::unit_id<dash::local_unit, dart_team_unit_t>
322 
332 typedef struct
333 dash::unit_id<dash::global_unit, dart_global_unit_t>
335 
342 
349 
350 typedef typename std::max_align_t max_align_t;
351 
352 } // namespace dash
353 
354 #endif // DASH__TYPES_H_
internal::default_signed_index gptrdiff_t
Difference type for global pointers.
Definition: Types.h:74
constexpr team_unit_t UNDEFINED_TEAM_UNIT_ID
Invalid local unit ID.
Definition: Types.h:341
internal::default_unsigned_index default_extent_t
Unsigned integer type used as default for extent values.
Definition: Types.h:64
internal::default_unsigned_index default_size_t
Unsigned integer type used as default for size values.
Definition: Types.h:69
This class is a simple memory pool which holds allocates elements of size ValueType.
Definition: AllOf.h:8
struct dash::unit_id< dash::global_unit, dart_global_unit_t > global_unit_t
Unit ID to use for global IDs.
Definition: Types.h:332
intptr_t dart_datatype_t
Raw data types supported by the DART interface.
Definition: dart_types.h:121
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
Type trait for mapping to punned DART data type for reduce operations.
Definition: Types.h:104
internal::default_signed_index default_index_t
Signed integer type used as default for index values.
Definition: Types.h:59
Type trait indicating whether a type can be used for global atomic operations.
Definition: Types.h:252
#define DART_TYPE_BYTE
integral data types
Definition: dart_types.h:125
constexpr global_unit_t UNDEFINED_GLOBAL_UNIT_ID
Invalid global unit ID.
Definition: Types.h:348
Type trait for mapping to DART data types.
Definition: Types.h:96
#define DART_TYPE_FLOAT
floating point data types
Definition: dart_types.h:134
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
Definition: Types.h:319
Type trait indicating whether a type has a comparision operator== defined.
Definition: Types.h:276
Type trait indicating whether the specified type is eligible for elements of DASH containers...
Definition: Types.h:236
#define DART_UNDEFINED_UNIT_ID
Undefined unit ID.
Definition: dart_types.h:160
Convencience wrapper to determine the DART type and number of elements required for the given templat...
Definition: Types.h:295
Type trait indicating whether a type can be used for arithmetic operations in global memory space...
Definition: Types.h:261