ESyS-Particle  2.3.4
gettype.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 //=== PAIR ====
14 template<typename T1,typename T2>
15 MPI_Datatype SGetType::operator()(const pair<T1,T2>& P)
16 {
18  MPI_Aint addr_first,addr_second;
19  MPI_Aint disp[2];
20  MPI_Datatype type[2];
21  int blocklen[2]={1,1};
22 
23  MPI_Get_address((void*)&P.first,&addr_first);
24  MPI_Get_address((void*)&P.second,&addr_second);
25  disp[0]=MPI_Aint(0);
26  disp[1]=addr_second-addr_first;
27  type[0]=GetType(P.first);
28  type[1]=GetType(P.second);
29  MPI_Type_create_struct(2,blocklen,disp,type,&tml_pair<T1,T2>::type);
30  MPI_Type_commit(&tml_pair<T1,T2>::type);
32  }
33  return tml_pair<T1,T2>::type;
34 }
35 
36 // === TRIPLET===
37 template<typename T1, typename T2, typename T3>
39 {
42  MPI_Aint addr[3];
43  MPI_Aint disp[3];
44  MPI_Datatype type[3];
45  int blocklen[3]={1,1,1};
46 
47  MPI_Get_address(static_cast<void *>(&(P.template get<0>())), &(addr[0]));
48  MPI_Get_address(static_cast<void *>(&(P.template get<1>())), &(addr[1]));
49  MPI_Get_address(static_cast<void *>(&(P.template get<2>())), &(addr[2]));
50  disp[0]=MPI_Aint(0);
51  disp[1]=addr[1]-addr[0];
52  disp[2]=addr[2]-addr[0];
53  type[0]=GetType(P.template get<0>());
54  type[1]=GetType(P.template get<1>());
55  type[2]=GetType(P.template get<2>());
56  MPI_Type_create_struct(3,blocklen,disp,type,&tml_trip<T1,T2,T3>::type);
57  MPI_Type_commit(&tml_trip<T1,T2,T3>::type);
59  }
61 }
62 
63 //=== QUAD ===
64 template<typename T1, typename T2, typename T3, typename T4>
66 {
69  MPI_Aint addr[4];
70  MPI_Aint disp[4];
71  MPI_Datatype type[4];
72  int blocklen[4]={1,1,1,1};
73 
74  MPI_Get_address(static_cast<void *>(&(P.template get<0>())), &(addr[0]));
75  MPI_Get_address(static_cast<void *>(&(P.template get<1>())), &(addr[1]));
76  MPI_Get_address(static_cast<void *>(&(P.template get<2>())), &(addr[2]));
77  MPI_Get_address(static_cast<void *>(&(P.template get<3>())), &(addr[3]));
78  disp[0]=MPI_Aint(0);
79  disp[1]=addr[1]-addr[0];
80  disp[2]=addr[2]-addr[0];
81  disp[3]=addr[3]-addr[0];
82  type[0]=GetType(P.template get<0>());
83  type[1]=GetType(P.template get<1>());
84  type[2]=GetType(P.template get<2>());
85  type[3]=GetType(P.template get<3>());
86  MPI_Type_create_struct(4,blocklen,disp,type,&tml_quad<T1,T2,T3,T4>::type);
87  MPI_Type_commit(&tml_quad<T1,T2,T3,T4>::type);
89  }
91 }
92 
93 //=== QUINT ===
94 template<typename T1, typename T2, typename T3, typename T4, typename T5>
96 {
99  MPI_Aint addr[5];
100  MPI_Aint disp[5];
101  MPI_Datatype type[5];
102  int blocklen[5]={1,1,1,1,1};
103 
104  MPI_Get_address(static_cast<void *>(&(P.template get<0>())), &(addr[0]));
105  MPI_Get_address(static_cast<void *>(&(P.template get<1>())), &(addr[1]));
106  MPI_Get_address(static_cast<void *>(&(P.template get<2>())), &(addr[2]));
107  MPI_Get_address(static_cast<void *>(&(P.template get<3>())), &(addr[3]));
108  MPI_Get_address(static_cast<void *>(&(P.template get<4>())), &(addr[4]));
109  disp[0]=MPI_Aint(0);
110  disp[1]=addr[1]-addr[0];
111  disp[2]=addr[2]-addr[0];
112  disp[3]=addr[3]-addr[0];
113  disp[4]=addr[4]-addr[0];
114  type[0]=GetType(P.template get<0>());
115  type[1]=GetType(P.template get<1>());
116  type[2]=GetType(P.template get<2>());
117  type[3]=GetType(P.template get<3>());
118  type[4]=GetType(P.template get<4>());
119  MPI_Type_create_struct(5,blocklen,disp,type,&tml_quin<T1,T2,T3,T4,T5>::type);
120  MPI_Type_commit(&tml_quin<T1,T2,T3,T4,T5>::type);
122  }
124 }
SGetType::operator()
MPI_Datatype operator()(const T &)
tml_pair
Definition: gettype.h:55
tml_trip
Definition: gettype.h:66
GetType
static SGetType GetType
Definition: gettype.h:95
esys::lsm::triplet
Definition: triplet.h:24
tml_quin
Definition: gettype.h:88
esys::lsm::quadtuple
Definition: quadtuple.h:25
tml_quad
Definition: gettype.h:77
esys::lsm::quintuple
Definition: quintuple.h:25