1 | /* |
2 | * MPI_AllGather.hpp |
3 | * |
4 | * Created on: Oct 26, 2015 |
5 | * Author: i-bird |
6 | */ |
7 | |
8 | #ifndef OPENFPM_VCLUSTER_SRC_MPI_WRAPPER_MPI_IALLGATHER_HPP_ |
9 | #define OPENFPM_VCLUSTER_SRC_MPI_WRAPPER_MPI_IALLGATHER_HPP_ |
10 | |
11 | |
12 | /*! \brief Set of wrapping classing for MPI_Irecv |
13 | * |
14 | * The purpose of these classes is to correctly choose the right call based on the type we want to receive |
15 | * |
16 | */ |
17 | |
18 | /*! \brief General gather for general buffers |
19 | * |
20 | * \param proc processor from which to receive |
21 | * \param tag |
22 | * \param buf buffer where to store the data |
23 | * \param sz size to receive |
24 | * \param req MPI request |
25 | * |
26 | */ |
27 | |
28 | class MPI_IAllGatherWB |
29 | { |
30 | public: |
31 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
32 | { |
33 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_BYTE, rbuf, sz_r, MPI_BYTE, MPI_COMM_WORLD,&req)); |
34 | } |
35 | }; |
36 | |
37 | /*! \brief General recv for vector of |
38 | * |
39 | * \tparam any type |
40 | * |
41 | */ |
42 | |
43 | template<typename T> class MPI_IAllGatherW |
44 | { |
45 | public: |
46 | |
47 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
48 | { |
49 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sizeof(T) * sz_s,MPI_BYTE, rbuf, sz_r * sizeof(T), MPI_BYTE, MPI_COMM_WORLD,&req)); |
50 | } |
51 | }; |
52 | |
53 | |
54 | /*! \brief specialization for vector of integer |
55 | * |
56 | */ |
57 | template<> class MPI_IAllGatherW<int> |
58 | { |
59 | public: |
60 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
61 | { |
62 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_INT, rbuf, sz_r, MPI_INT, MPI_COMM_WORLD,&req)); |
63 | } |
64 | }; |
65 | |
66 | /*! \brief specialization for vector of unsigned integer |
67 | * |
68 | */ |
69 | template<> class MPI_IAllGatherW<unsigned int> |
70 | { |
71 | public: |
72 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
73 | { |
74 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_UNSIGNED, rbuf, sz_r, MPI_UNSIGNED, MPI_COMM_WORLD,&req)); |
75 | } |
76 | }; |
77 | |
78 | /*! \brief specialization for vector of short |
79 | * |
80 | */ |
81 | template<> class MPI_IAllGatherW<short> |
82 | { |
83 | public: |
84 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
85 | { |
86 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_SHORT, rbuf, sz_r, MPI_SHORT, MPI_COMM_WORLD,&req)); |
87 | } |
88 | }; |
89 | |
90 | |
91 | /*! \brief specialization for vector of short |
92 | * |
93 | */ |
94 | template<> class MPI_IAllGatherW<unsigned short> |
95 | { |
96 | public: |
97 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
98 | { |
99 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_UNSIGNED_SHORT, rbuf, sz_r, MPI_UNSIGNED_SHORT, MPI_COMM_WORLD,&req)); |
100 | } |
101 | }; |
102 | |
103 | |
104 | /*! \brief specialization for vector of char |
105 | * |
106 | */ |
107 | template<> class MPI_IAllGatherW<char> |
108 | { |
109 | public: |
110 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
111 | { |
112 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_CHAR, rbuf, sz_r, MPI_CHAR, MPI_COMM_WORLD,&req)); |
113 | } |
114 | }; |
115 | |
116 | |
117 | /*! \brief specialization for vector of unsigned char |
118 | * |
119 | */ |
120 | template<> class MPI_IAllGatherW<unsigned char> |
121 | { |
122 | public: |
123 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
124 | { |
125 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_UNSIGNED_CHAR, rbuf, sz_r, MPI_UNSIGNED_CHAR, MPI_COMM_WORLD,&req)); |
126 | } |
127 | }; |
128 | |
129 | /*! \brief specialization for vector of size_t |
130 | * |
131 | */ |
132 | template<> class MPI_IAllGatherW<size_t> |
133 | { |
134 | public: |
135 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
136 | { |
137 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_UNSIGNED_LONG, rbuf, sz_r, MPI_UNSIGNED_LONG, MPI_COMM_WORLD,&req)); |
138 | } |
139 | }; |
140 | |
141 | /*! \brief specialization for vector of long int |
142 | * |
143 | */ |
144 | template<> class MPI_IAllGatherW<long int> |
145 | { |
146 | public: |
147 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
148 | { |
149 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_LONG, rbuf, sz_r, MPI_LONG, MPI_COMM_WORLD,&req)); |
150 | } |
151 | }; |
152 | |
153 | /*! \brief specialization for vector of float |
154 | * |
155 | */ |
156 | template<> class MPI_IAllGatherW<float> |
157 | { |
158 | public: |
159 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
160 | { |
161 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_FLOAT, rbuf, sz_r, MPI_FLOAT, MPI_COMM_WORLD,&req)); |
162 | } |
163 | }; |
164 | |
165 | /*! \brief specialization for vector of double |
166 | * |
167 | */ |
168 | template<> class MPI_IAllGatherW<double> |
169 | { |
170 | public: |
171 | static inline void gather(void * sbuf, size_t sz_s ,void * rbuf, size_t sz_r, MPI_Request & req) |
172 | { |
173 | MPI_SAFE_CALL(MPI_Iallgather(sbuf,sz_s,MPI_DOUBLE, rbuf, sz_r, MPI_DOUBLE, MPI_COMM_WORLD,&req)); |
174 | } |
175 | }; |
176 | |
177 | |
178 | #endif /* OPENFPM_VCLUSTER_SRC_MPI_WRAPPER_MPI_IALLGATHER_HPP_ */ |
179 | |