31 static MPI_Datatype datatype;
32 static MPI_Datatype vectortype;
34 static inline MPI_Datatype getType()
36 if(datatype==MPI_DATATYPE_NULL) {
37 MPI_Type_contiguous(
sizeof(T),MPI_BYTE,&datatype);
38 MPI_Type_commit(&datatype);
50 #define ComposeMPITraits(p,m) \
52 struct MPITraits<p>{ \
53 static inline MPI_Datatype getType(){ \
59 ComposeMPITraits(
char, MPI_CHAR);
60 ComposeMPITraits(
unsigned char,MPI_UNSIGNED_CHAR);
61 ComposeMPITraits(
short,MPI_SHORT);
62 ComposeMPITraits(
unsigned short,MPI_UNSIGNED_SHORT);
63 ComposeMPITraits(
int,MPI_INT);
64 ComposeMPITraits(
unsigned int,MPI_UNSIGNED);
65 ComposeMPITraits(
long,MPI_LONG);
66 ComposeMPITraits(
unsigned long,MPI_UNSIGNED_LONG);
67 ComposeMPITraits(
float,MPI_FLOAT);
68 ComposeMPITraits(
double,MPI_DOUBLE);
69 ComposeMPITraits(
long double,MPI_LONG_DOUBLE);
72 #undef ComposeMPITraits
75 template<
class T,
int _Rows,
int _Options>
class gsVector;
78 template<
class T,
int _Rows,
int _Options>
82 static inline MPI_Datatype getType()
84 if(datatype==MPI_DATATYPE_NULL)
87 MPI_Type_commit(&vectortype);
91 MPI_Get_address(&fvector, &base);
92 MPI_Get_address(&(fvector[0]), &displ);
96 MPI_Type_create_struct(1, length, &displ, &vectortype, &datatype);
97 MPI_Type_commit(&datatype);
103 static MPI_Datatype datatype;
104 static MPI_Datatype vectortype;
107 template<
class T,
int _Rows,
int _Options>
109 template<
class T,
int _Rows,
int _Options>
115 template<
class T,
int _Rows,
int _Cols,
int _Options>
class gsMatrix;
118 template<
class T,
int _Rows,
int _Cols,
int _Options>
122 static inline MPI_Datatype getType()
124 if(datatype==MPI_DATATYPE_NULL)
127 MPI_Type_commit(&matrixtype);
131 MPI_Get_address(&fmatrix, &base);
132 MPI_Get_address(&(fmatrix(0,0)), &displ);
136 MPI_Type_create_struct(1, length, &displ, &matrixtype, &datatype);
137 MPI_Type_commit(&datatype);
143 static MPI_Datatype datatype;
144 static MPI_Datatype matrixtype;
147 template<
class T,
int _Rows,
int _Cols,
int _Options>
149 template<
class T,
int _Rows,
int _Cols,
int _Options>
154 template<
typename T,
int _Options,
typename _Index>
class gsSparseMatrix;
156 template<
typename T,
int _Options,
typename _Index>
157 struct MPITraits<gsSparseMatrix<T, _Options, _Index> >
160 static inline MPI_Datatype getType()
162 if (datatype==MPI_DATATYPE_NULL)
164 gsSparseMatrix<T, _Options, _Index> mat;
166 MPI_Get_address(mat.data, &base);
181 static MPI_Datatype datatype;
182 static MPI_Datatype matrixtype;
185 template<
class T,
int _Options,
typename _Index>
186 MPI_Datatype MPITraits<gsSparseMatrix<T, _Options, _Index> >::datatype = MPI_DATATYPE_NULL;
187 template<
class T,
int _Options,
typename _Index>
188 MPI_Datatype MPITraits<gsSparseMatrix<T, _Options, _Index> >::matrixtype = {MPI_DATATYPE_NULL};
226 template<
typename T1,
typename T2>
227 struct MPITraits<std::pair<T1,T2> >
230 inline static MPI_Datatype getType();
232 static MPI_Datatype type;
234 template<
typename T1,
typename T2>
235 MPI_Datatype MPITraits<std::pair<T1,T2> >::getType()
237 if(type==MPI_DATATYPE_NULL)
239 int length[2] = {1, 1};
241 MPI_Datatype types[2] = {MPITraits<T1>::getType(),
242 MPITraits<T2>::getType()};
244 typedef std::pair<T1, T2> Pair;
246 disp[0] = offsetof(Pair, first);
247 disp[1] = offsetof(Pair, second);
250 MPI_Type_create_struct(2, length, disp, types, &tmp);
252 MPI_Type_create_resized(tmp, 0,
sizeof(Pair), &type);
253 MPI_Type_commit(&type);
259 template<
typename T1,
typename T2>
260 MPI_Datatype MPITraits<std::pair<T1,T2> >::type=MPI_DATATYPE_NULL;
263 template<
typename T1,
typename T2,
typename T3>
264 struct MPITraits<std::tuple<T1,T2,T3> >
267 inline static MPI_Datatype getType();
269 static MPI_Datatype type;
271 template<
typename T1,
typename T2,
typename T3>
272 MPI_Datatype MPITraits<std::tuple<T1,T2,T3> >::getType()
274 if(type==MPI_DATATYPE_NULL)
276 int length[3] = {1, 1, 1};
278 MPI_Datatype types[3] = {MPITraits<T1>::getType(),
279 MPITraits<T2>::getType(),
280 MPITraits<T3>::getType()};
282 typedef std::tuple<T1, T2, T3> Tuple3;
284 MPI_Aint base_address;
286 MPI_Get_address(&dummy_tuple, &base_address);
287 MPI_Get_address(&(std::get<0>(dummy_tuple)), &disp[0]);
288 MPI_Get_address(&(std::get<1>(dummy_tuple)), &disp[1]);
289 MPI_Get_address(&(std::get<2>(dummy_tuple)), &disp[2]);
290 disp[0] = MPI_Aint_diff(disp[0], base_address);
291 disp[1] = MPI_Aint_diff(disp[1], base_address);
292 disp[2] = MPI_Aint_diff(disp[2], base_address);
296 MPI_Type_create_struct(3, length, disp, types, &tmp);
298 MPI_Type_create_resized(tmp, 0,
sizeof(Tuple3), &type);
299 MPI_Type_commit(&type);
305 template<
typename T1,
typename T2,
typename T3>
306 MPI_Datatype MPITraits<std::tuple<T1,T2,T3> >::type=MPI_DATATYPE_NULL;
308 template<
typename T1,
typename T2,
typename T3,
typename T4>
309 struct MPITraits<std::tuple<T1,T2,T3,T4> >
312 inline static MPI_Datatype getType();
314 static MPI_Datatype type;
316 template<
typename T1,
typename T2,
typename T3,
typename T4>
317 MPI_Datatype MPITraits<std::tuple<T1,T2,T3,T4> >::getType()
319 if(type==MPI_DATATYPE_NULL)
321 int length[4] = {1, 1, 1, 1};
323 MPI_Datatype types[4] = {MPITraits<T1>::getType(),
324 MPITraits<T2>::getType(),
325 MPITraits<T3>::getType(),
326 MPITraits<T4>::getType()};
328 typedef std::tuple<T1, T2, T3, T4> Tuple4;
330 MPI_Aint base_address;
332 MPI_Get_address(&dummy_tuple, &base_address);
333 MPI_Get_address(&(std::get<0>(dummy_tuple)), &disp[0]);
334 MPI_Get_address(&(std::get<1>(dummy_tuple)), &disp[1]);
335 MPI_Get_address(&(std::get<2>(dummy_tuple)), &disp[2]);
336 MPI_Get_address(&(std::get<3>(dummy_tuple)), &disp[3]);
337 disp[0] = MPI_Aint_diff(disp[0], base_address);
338 disp[1] = MPI_Aint_diff(disp[1], base_address);
339 disp[2] = MPI_Aint_diff(disp[2], base_address);
340 disp[3] = MPI_Aint_diff(disp[3], base_address);
343 MPI_Type_create_struct(4, length, disp, types, &tmp);
345 MPI_Type_create_resized(tmp, 0,
sizeof(Tuple4), &type);
346 MPI_Type_commit(&type);
352 template<
typename T1,
typename T2,
typename T3,
typename T4>
353 MPI_Datatype MPITraits<std::tuple<T1,T2,T3,T4> >::type=MPI_DATATYPE_NULL;
355 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
356 struct MPITraits<std::tuple<T1,T2,T3,T4,T5> >
359 inline static MPI_Datatype getType();
361 static MPI_Datatype type;
363 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
364 MPI_Datatype MPITraits<std::tuple<T1,T2,T3,T4,T5> >::getType()
366 if(type==MPI_DATATYPE_NULL)
368 int length[5] = {1, 1, 1, 1, 1};
370 MPI_Datatype types[5] = {MPITraits<T1>::getType(),
371 MPITraits<T2>::getType(),
372 MPITraits<T3>::getType(),
373 MPITraits<T4>::getType(),
374 MPITraits<T5>::getType()};
376 typedef std::tuple<T1, T2, T3, T4, T5> Tuple5;
378 MPI_Aint base_address;
380 MPI_Get_address(&dummy_tuple, &base_address);
381 MPI_Get_address(&(std::get<0>(dummy_tuple)), &disp[0]);
382 MPI_Get_address(&(std::get<1>(dummy_tuple)), &disp[1]);
383 MPI_Get_address(&(std::get<2>(dummy_tuple)), &disp[2]);
384 MPI_Get_address(&(std::get<3>(dummy_tuple)), &disp[3]);
385 MPI_Get_address(&(std::get<4>(dummy_tuple)), &disp[4]);
386 disp[0] = MPI_Aint_diff(disp[0], base_address);
387 disp[1] = MPI_Aint_diff(disp[1], base_address);
388 disp[2] = MPI_Aint_diff(disp[2], base_address);
389 disp[3] = MPI_Aint_diff(disp[3], base_address);
390 disp[4] = MPI_Aint_diff(disp[4], base_address);
393 MPI_Type_create_struct(5, length, disp, types, &tmp);
395 MPI_Type_create_resized(tmp, 0,
sizeof(Tuple5), &type);
396 MPI_Type_commit(&type);
402 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
403 MPI_Datatype MPITraits<std::tuple<T1,T2,T3,T4,T5> >::type=MPI_DATATYPE_NULL;
405 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
406 struct MPITraits<std::tuple<T1,T2,T3,T4,T5,T6> >
409 inline static MPI_Datatype getType();
411 static MPI_Datatype type;
413 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
414 MPI_Datatype MPITraits<std::tuple<T1,T2,T3,T4,T5,T6> >::getType()
416 if(type==MPI_DATATYPE_NULL)
418 int length[6] = {1, 1, 1, 1, 1, 1};
420 MPI_Datatype types[6] = {MPITraits<T1>::getType(),
421 MPITraits<T2>::getType(),
422 MPITraits<T3>::getType(),
423 MPITraits<T4>::getType(),
424 MPITraits<T5>::getType(),
425 MPITraits<T6>::getType()};
427 typedef std::tuple<T1, T2, T3, T4, T5, T6> Tuple6;
429 MPI_Aint base_address;
431 MPI_Get_address(&dummy_tuple, &base_address);
432 MPI_Get_address(&(std::get<0>(dummy_tuple)), &disp[0]);
433 MPI_Get_address(&(std::get<1>(dummy_tuple)), &disp[1]);
434 MPI_Get_address(&(std::get<2>(dummy_tuple)), &disp[2]);
435 MPI_Get_address(&(std::get<3>(dummy_tuple)), &disp[3]);
436 MPI_Get_address(&(std::get<4>(dummy_tuple)), &disp[4]);
437 MPI_Get_address(&(std::get<5>(dummy_tuple)), &disp[5]);
438 disp[0] = MPI_Aint_diff(disp[0], base_address);
439 disp[1] = MPI_Aint_diff(disp[1], base_address);
440 disp[2] = MPI_Aint_diff(disp[2], base_address);
441 disp[3] = MPI_Aint_diff(disp[3], base_address);
442 disp[4] = MPI_Aint_diff(disp[4], base_address);
443 disp[5] = MPI_Aint_diff(disp[5], base_address);
446 MPI_Type_create_struct(6, length, disp, types, &tmp);
448 MPI_Type_create_resized(tmp, 0,
sizeof(Tuple6), &type);
449 MPI_Type_commit(&type);
455 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
456 MPI_Datatype MPITraits<std::tuple<T1,T2,T3,T4,T5,T6> >::type=MPI_DATATYPE_NULL;
458 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
459 struct MPITraits<std::tuple<T1,T2,T3,T4,T5,T6,T7> >
462 inline static MPI_Datatype getType();
464 static MPI_Datatype type;
466 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
467 MPI_Datatype MPITraits<std::tuple<T1,T2,T3,T4,T5,T6,T7> >::getType()
469 if(type==MPI_DATATYPE_NULL)
471 int length[7] = {1, 1, 1, 1, 1, 1, 1};
473 MPI_Datatype types[7] = {MPITraits<T1>::getType(),
474 MPITraits<T2>::getType(),
475 MPITraits<T3>::getType(),
476 MPITraits<T4>::getType(),
477 MPITraits<T5>::getType(),
478 MPITraits<T6>::getType(),
479 MPITraits<T7>::getType()};
481 typedef std::tuple<T1, T2, T3, T4, T5, T6, T7> Tuple7;
483 MPI_Aint base_address;
485 MPI_Get_address(&dummy_tuple, &base_address);
486 MPI_Get_address(&(std::get<0>(dummy_tuple)), &disp[0]);
487 MPI_Get_address(&(std::get<1>(dummy_tuple)), &disp[1]);
488 MPI_Get_address(&(std::get<2>(dummy_tuple)), &disp[2]);
489 MPI_Get_address(&(std::get<3>(dummy_tuple)), &disp[3]);
490 MPI_Get_address(&(std::get<4>(dummy_tuple)), &disp[4]);
491 MPI_Get_address(&(std::get<5>(dummy_tuple)), &disp[5]);
492 MPI_Get_address(&(std::get<6>(dummy_tuple)), &disp[6]);
493 disp[0] = MPI_Aint_diff(disp[0], base_address);
494 disp[1] = MPI_Aint_diff(disp[1], base_address);
495 disp[2] = MPI_Aint_diff(disp[2], base_address);
496 disp[3] = MPI_Aint_diff(disp[3], base_address);
497 disp[4] = MPI_Aint_diff(disp[4], base_address);
498 disp[5] = MPI_Aint_diff(disp[5], base_address);
499 disp[6] = MPI_Aint_diff(disp[6], base_address);
502 MPI_Type_create_struct(7, length, disp, types, &tmp);
504 MPI_Type_create_resized(tmp, 0,
sizeof(Tuple7), &type);
505 MPI_Type_commit(&type);
511 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7>
512 MPI_Datatype MPITraits<std::tuple<T1,T2,T3,T4,T5,T6,T7> >::type=MPI_DATATYPE_NULL;
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition: gsMatrix.h:38
A traits class describing the mapping of types onto MPI_Datatypes.
Definition: gsMpiTraits.h:26
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition: gsVector.h:35