OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
common.hpp
1#ifndef COMMON_HPP
2#define COMMON_HPP
3
4#include <type_traits>
5#include <random>
6#include "memory/memory.hpp"
7#include "util/for_each_ref.hpp"
8#include "util/variadic_to_vmpl.hpp"
9
10constexpr int RUN_ON_DEVICE = 1024;
11
12#define GCC_VERSION (__GNUC__ * 10000 \
13 + __GNUC_MINOR__ * 100 \
14 + __GNUC_PATCHLEVEL__)
15
16
17template<unsigned int N,typename T>
19{
20 T sa[N];
21};
22
23namespace std
24{
25 // We need the definition of std::to_string that work on string
26 inline static std::string to_string(std::string s)
27 {
28 return s;
29 }
30}
31
32
40namespace openfpm
41{
42 template <class T>
43 constexpr typename std::add_const<T>::type & as_const(T& t) noexcept
44 {
45 return t;
46 }
47
48 template <typename> struct Debug;
49}
50
52 // {3,3,3,3,3,3,.....}
53 template<size_t index, size_t N> struct Fill_three {
54 enum { value = 3 };
55 };
56
58 template<size_t index, size_t N> struct Fill_zero {
59 enum { value = 0 };
60 };
61
63 template<size_t index, size_t N> struct Fill_two {
64 enum { value = 2 };
65 };
66
68 template<size_t index, size_t N> struct Fill_one {
69 enum { value = 1 };
70 };
71
73template<typename> struct Void
74{
76 typedef void type;
77};
78
79template<typename T, typename Sfinae = void>
80struct has_attributes: std::false_type {};
81
82
94template<typename T>
95struct has_attributes<T, typename Void<decltype( T::attributes::name[0] )>::type> : std::true_type
96{};
97
98template<typename T, typename Sfinae = void>
99struct has_typedef_type: std::false_type {};
100
111template<typename T>
112struct has_typedef_type<T, typename Void< typename T::type>::type> : std::true_type
113{};
114
115template<typename T, typename Sfinae = void>
116struct has_vector_kernel: std::false_type {};
117
127template<typename T>
128struct has_vector_kernel<T, typename Void< typename T::vector_kernel >::type> : std::true_type
129{};
130
131template<typename T, typename Sfinae = void>
132struct has_set_d: std::false_type {};
133
137template<typename T>
138struct has_set_d<T, typename Void<decltype( std::declval<T>().set_d(0,0) )>::type> : std::true_type
139{};
140
141template<typename T, typename Sfinae = void>
142struct has_data: std::false_type {};
143
153template<typename T>
154struct has_data<T, typename Void<decltype( T::data )>::type> : std::true_type
155{};
156
157template<typename T, typename Sfinae = void>
158struct has_posMask: std::false_type {};
159
167template<typename T>
168struct has_posMask<T, typename Void<decltype( T::stag_mask )>::type> : std::true_type
169{};
170
171
188template<bool cond, typename T>
190{
191 enum
192 {
193 value = std::is_same<decltype(std::declval<T>().data),typename T::type>::value
194 };
195};
196
197
198template<typename T>
200{
201 enum
202 {
203 value = false
204 };
205};
206
207
208template<typename T, typename Sfinae = void>
209struct has_noPointers: std::false_type {};
210
211
223template<typename T>
224struct has_noPointers<T, typename Void<decltype( T::noPointers() )>::type> : std::true_type
225{};
226
239template<typename ObjType, typename Sfinae = void>
240struct has_pack: std::false_type {};
241
242template<typename ObjType>
243struct has_pack<ObjType, typename Void<decltype( ObjType::pack() )>::type> : std::true_type
244{};
245
258template<typename ObjType, typename Sfinae = void>
259struct has_toKernel: std::false_type {};
260
261template<typename ObjType>
262struct has_toKernel<ObjType, typename Void<decltype( std::declval<ObjType>().toKernel() )>::type> : std::true_type
263{};
264
277template<typename ObjType, typename Sfinae = void>
278struct has_packRequest: std::false_type {};
279
280template<typename ObjType>
281struct has_packRequest<ObjType, typename Void<decltype( ObjType::packRequest() )>::type> : std::true_type
282{};
283
284
297template<typename ObjType, typename Sfinae = void>
298struct has_packMem: std::false_type {};
299
308template<typename ObjType>
309struct has_packMem<ObjType, typename Void<decltype( ObjType::packMem() )>::type> : std::true_type
310{};
311
322template<typename T, bool = is_typedef_and_data_same<has_typedef_type<T>::value && has_data<T>::value,T>::value>
323struct is_openfpm_native : std::false_type
324{};
325
326
327template<typename T>
328struct is_openfpm_native<T,true> : std::true_type
329{};
330
331template<typename T, typename Sfinae = void>
332struct has_value_type_ofp: std::false_type {};
333
343template<typename T>
344struct has_value_type_ofp<T, typename Void< typename T::value_type>::type> : std::true_type
345{};
346
347
349template<size_t index, size_t N> struct MetaFunc {
350 enum { value = index + N };
351};
352
353
354template<size_t index, size_t N> struct MetaFuncOrd {
355 enum { value = index };
356};
357
359
360template<typename ObjType, typename Sfinae = void>
361struct isDynStruct: std::false_type
362{
363 constexpr static bool value()
364 {
365 return false;
366 }
367};
368
369template<typename ObjType>
370struct isDynStruct<ObjType, typename Void<decltype( ObjType::isCompressed() )>::type> : std::true_type
371{
372 constexpr static bool value()
373 {
374 return ObjType::isCompressed();
375 }
376};
377
378template<typename T, typename Sfinae = void>
379struct is_Box: std::false_type {};
380
381
387template<typename T>
388struct is_Box<T, typename Void< typename T::yes_is_box>::type> : std::true_type
389{};
390
391template<typename T, typename Sfinae = void>
392struct is_Point: std::false_type {};
393
394
400template<typename T>
401struct is_Point<T, typename Void< typename T::yes_is_point>::type> : std::true_type
402{};
403
404#endif
convert a type into constant type
{1,1,1,1,....}
Definition common.hpp:68
Compile time array functor needed to generate array at compile-time of type.
Definition common.hpp:53
{2,2,2,2,....}
Definition common.hpp:63
{0,0,0,0,....}
Definition common.hpp:58
[Metafunction definition]
Definition common.hpp:349
Void structure.
Definition common.hpp:74
void type
define void type
Definition common.hpp:76
has_calculateMem check if a type has defined a method called calculateMem
Definition common.hpp:298
has_packRequest check if a type has defined a method called packRequest
Definition common.hpp:278
has_Pack check if a type has defined a method called Pack
Definition common.hpp:240
has_toKernel check if a type has defined a method called toKernel
Definition common.hpp:259
is_openfpm_native check if a type is an openfpm native structure type
Definition common.hpp:324
check if T::type and T.data has the same type
Definition common.hpp:190