1#ifndef MPI_ISEND_HPP
2#define MPI_ISEND_HPP
3
4
5#include <mpi.h>
6
7/*! \brief Set of wrapping classing for MPI_Isend
8 *
9 * The purpose of these classes is to correctly choose the right call based on the type we want to send
10 *
11 */
12
13/*! \brief General send for a buffer
14 *
15 */
16class MPI_IsendWB
17{
18public:
19 static inline void send(size_t proc , size_t tag ,const void * buf, size_t sz, MPI_Request & req)
20 {
21 MPI_Isend(buf, sz,MPI_BYTE, proc, tag , MPI_COMM_WORLD,&req);
22 }
23};
24
25/*! \brief General send for a vector of any type
26 *
27 * \tparam any type
28 *
29 */
30
31template<typename T, typename Mem, template<typename> class gr> class MPI_IsendW
32{
33public:
34 static inline void send(size_t proc , size_t tag ,openfpm::vector<T,Mem,gr> & v, MPI_Request & req)
35 {
36 MPI_Isend(v.getPointer(), v.size() * sizeof(T),MPI_BYTE, proc, tag , MPI_COMM_WORLD,&req);
37 }
38};
39
40
41/*! \brief specialization for vector of integer
42 *
43 */
44template<typename Mem, template<typename> class gr> class MPI_IsendW<int,Mem,gr>
45{
46public:
47 static inline void send(size_t proc , size_t tag ,openfpm::vector<int,Mem,gr> & v, MPI_Request & req)
48 {
49 MPI_Isend(v.getPointer(), v.size(),MPI_INT, proc, tag , MPI_COMM_WORLD,&req);
50 }
51};
52
53/*! \brief specialization for unsigned integer
54 *
55 */
56template<typename Mem, template<typename> class gr> class MPI_IsendW<unsigned int,Mem,gr>
57{
58public:
59 static inline void send(size_t proc , size_t tag ,openfpm::vector<unsigned int,Mem,gr> & v, MPI_Request & req)
60 {
61 MPI_Isend(v.getPointer(), v.size(),MPI_UNSIGNED, proc, tag , MPI_COMM_WORLD,&req);
62 }
63};
64
65/*! \brief specialization for short
66 *
67 */
68template<typename Mem, template<typename> class gr> class MPI_IsendW<short,Mem,gr>
69{
70public:
71 static inline void send(size_t proc , size_t tag ,openfpm::vector<short,Mem,gr> & v, MPI_Request & req)
72 {
73 MPI_Isend(v.getPointer(), v.size(),MPI_SHORT, proc, tag , MPI_COMM_WORLD,&req);
74 }
75};
76
77/*! \brief specialization for short
78 *
79 */
80template<typename Mem, template<typename> class gr> class MPI_IsendW<unsigned short,Mem,gr>
81{
82public:
83 static inline void send(size_t proc , size_t tag ,openfpm::vector<unsigned short,Mem,gr> & v, MPI_Request & req)
84 {
85 MPI_Isend(v.getPointer(), v.size(),MPI_UNSIGNED_SHORT, proc, tag , MPI_COMM_WORLD,&req);
86 }
87};
88
89/*! \brief specialization for char
90 *
91 */
92template<typename Mem, template<typename> class gr> class MPI_IsendW<char,Mem,gr>
93{
94public:
95 static inline void send(size_t proc , size_t tag ,openfpm::vector<char,Mem,gr> & v, MPI_Request & req)
96 {
97 MPI_Isend(v.getPointer(), v.size(),MPI_CHAR, proc, tag , MPI_COMM_WORLD,&req);
98 }
99};
100
101/*! \brief specialization for char
102 *
103 */
104template<typename Mem, template<typename> class gr> class MPI_IsendW<unsigned char,Mem,gr>
105{
106public:
107 static inline void send(size_t proc , size_t tag ,openfpm::vector<unsigned char,Mem,gr> & v, MPI_Request & req)
108 {
109 MPI_Isend(v.getPointer(), v.size(),MPI_UNSIGNED_CHAR, proc, tag , MPI_COMM_WORLD,&req);
110 }
111};
112
113/*! \brief specialization for size_t
114 *
115 */
116template<typename Mem, template<typename> class gr> class MPI_IsendW<size_t,Mem,gr>
117{
118public:
119 static inline void send(size_t proc , size_t tag ,openfpm::vector<size_t,Mem,gr> & v, MPI_Request & req)
120 {
121 MPI_Isend(v.getPointer(), v.size(),MPI_UNSIGNED_LONG, proc, tag , MPI_COMM_WORLD,&req);
122 }
123};
124
125/*! \brief specialization for size_t
126 *
127 */
128template<typename Mem, template<typename> class gr> class MPI_IsendW<long int,Mem,gr>
129{
130public:
131 static inline void send(size_t proc , size_t tag ,openfpm::vector<long int,Mem,gr> & v, MPI_Request & req)
132 {
133 MPI_Isend(v.getPointer(), v.size(),MPI_LONG, proc, tag , MPI_COMM_WORLD,&req);
134 }
135};
136
137/*! \brief specialization for float
138 *
139 */
140template<typename Mem, template<typename> class gr> class MPI_IsendW<float,Mem,gr>
141{
142public:
143 static inline void send(size_t proc , size_t tag ,openfpm::vector<float,Mem,gr> & v, MPI_Request & req)
144 {
145 MPI_Isend(v.getPointer(), v.size(),MPI_FLOAT, proc, tag , MPI_COMM_WORLD,&req);
146 }
147};
148
149/*! \brief specialization for double
150 *
151 */
152template<typename Mem, template<typename> class gr> class MPI_IsendW<double,Mem,gr>
153{
154public:
155 static inline void send(size_t proc , size_t tag ,openfpm::vector<double,Mem,gr> & v, MPI_Request & req)
156 {
157 MPI_Isend(v.getPointer(), v.size(),MPI_DOUBLE, proc, tag , MPI_COMM_WORLD,&req);
158 }
159};
160
161#endif
162