OpenFPM  5.2.0
Project that contain the implementation of distributed structures
operators.hpp
1 #pragma once
2 
3 namespace gpu {
4 
5 template<typename type_t>
6 struct less_t : public std::binary_function<type_t, type_t, bool> {
7  __forceinline__ __device__ __host__ bool operator()(type_t a, type_t b) const {
8  return a < b;
9  }
10 };
11 
12 template<typename type_t>
13 struct less_equal_t : public std::binary_function<type_t, type_t, bool> {
14  __forceinline__ __device__ __host__ bool operator()(type_t a, type_t b) const {
15  return a <= b;
16  }
17 };
18 
19 template<typename type_t>
20 struct greater_t : public std::binary_function<type_t, type_t, bool> {
21  __forceinline__ __device__ __host__ bool operator()(type_t a, type_t b) const {
22  return a > b;
23  }
24 };
25 
26 template<typename type_t>
27 struct greater_equal_t : public std::binary_function<type_t, type_t, bool> {
28  __forceinline__ __device__ __host__ bool operator()(type_t a, type_t b) const {
29  return a >= b;
30  }
31 };
32 
33 template<typename type_t>
34 struct equal_to_t : public std::binary_function<type_t, type_t, bool> {
35  __forceinline__ __device__ __host__ bool operator()(type_t a, type_t b) const {
36  return a == b;
37  }
38 };
39 
40 template<typename type_t>
41 struct not_equal_to_t : public std::binary_function<type_t, type_t, bool> {
42  __forceinline__ __device__ __host__ bool operator()(type_t a, type_t b) const {
43  return a != b;
44  }
45 };
46 
47 template<typename type_t>
48 struct plus_t : public std::binary_function<type_t, type_t, type_t> {
49  __forceinline__ __device__ __host__ type_t operator()(type_t a, type_t b) const {
50  return a + b;
51  }
52 
53  __forceinline__ __device__ __host__ type_t reduceInitValue() const {
54  return 0;
55  }
56 };
57 
58 template<typename type_t>
59 struct minus_t : public std::binary_function<type_t, type_t, type_t> {
60  __forceinline__ __device__ __host__ type_t operator()(type_t a, type_t b) const {
61  return a - b;
62  }
63 
64  __forceinline__ __device__ __host__ type_t reduceInitValue() const {
65  return 0;
66  }
67 };
68 
69 template<typename type_t>
70 struct multiplies_t : public std::binary_function<type_t, type_t, type_t> {
71  __forceinline__ __device__ __host__ type_t operator()(type_t a, type_t b) const {
72  return a * b;
73  }
74 };
75 
76 template<typename type_t>
77 struct maximum_t : public std::binary_function<type_t, type_t, type_t> {
78  __forceinline__ __device__ __host__ type_t operator()(type_t a, type_t b) const {
79  return (a < b) ? b : a;
80  }
81 
82  __forceinline__ __device__ __host__ type_t reduceInitValue() const {
83  return std::numeric_limits<type_t>::min();
84  }
85 };
86 
87 template<typename type_t>
88 struct minimum_t : public std::binary_function<type_t, type_t, type_t> {
89  __forceinline__ __device__ __host__ type_t operator()(type_t a, type_t b) const {
90  return (b < a) ? b : a;
91  }
92 
93  __forceinline__ __device__ __host__ type_t reduceInitValue() const {
94  return std::numeric_limits<type_t>::max();
95  }
96 };
97 
98 }