libMesh
Public Member Functions | Protected Attributes | List of all members
libMesh::Parallel::StandardType< std::tuple< Types... > > Class Template Reference

#include <standard_type.h>

Inheritance diagram for libMesh::Parallel::StandardType< std::tuple< Types... > >:
[legend]

Public Member Functions

 StandardType (const std::tuple< Types... > *example=nullptr)
 
 StandardType (const StandardType< std::tuple< Types... >> &t)
 
 ~StandardType ()
 
 operator const data_type & () const
 
 operator data_type & ()
 
void commit ()
 
void free ()
 

Protected Attributes

data_type _datatype
 

Detailed Description

template<typename... Types>
class libMesh::Parallel::StandardType< std::tuple< Types... > >

Definition at line 261 of file standard_type.h.

Constructor & Destructor Documentation

◆ StandardType() [1/2]

template<typename... Types>
libMesh::Parallel::StandardType< std::tuple< Types... > >::StandardType ( const std::tuple< Types... > *  example = nullptr)
explicit

Definition at line 265 of file standard_type.h.

References libMesh::Parallel::DataType::_datatype, and libMesh::Parallel::DataType::commit().

265  {
266  // We need an example for MPI_Address to use
267  static const std::tuple<Types...> t;
268  if (!example)
269  example = &t;
270 
271 #ifdef LIBMESH_HAVE_MPI
272  MPI_Aint start;
273 
274  libmesh_call_mpi
275  (MPI_Get_address (example, &start));
276 
277  const std::size_t tuplesize = sizeof...(Types);
278 
279  std::vector<std::unique_ptr<DataType>> subtypes;
280  BuildStandardTypeVector<sizeof...(Types)>::build(subtypes, *example);
281 
282  std::array<MPI_Aint, sizeof...(Types)> displs;
283  FillDisplacementArray<sizeof...(Types)>::fill(displs, *example);
284 
285  std::array<MPI_Datatype, sizeof...(Types)> types;
286  std::array<int, sizeof...(Types)> blocklengths;
287 
288  for (std::size_t i = 0; i != tuplesize; ++i)
289  {
290  displs[i] -= start;
291  types[i] = (data_type)(*subtypes[i]);
292  blocklengths[i] = 1;
293  }
294 
295  // create a prototype structure
296  MPI_Datatype tmptype;
297  libmesh_call_mpi
298  (MPI_Type_create_struct (tuplesize, blocklengths.data(), displs.data(), types.data(),
299  &tmptype));
300  libmesh_call_mpi
301  (MPI_Type_commit (&tmptype));
302 
303  // resize the structure type to account for padding, if any
304  libmesh_call_mpi
305  (MPI_Type_create_resized (tmptype, 0,
306  sizeof(std::tuple<Types...>),
307  &_datatype));
308  libmesh_call_mpi
309  (MPI_Type_free (&tmptype));
310 
311  this->commit();
312 
313 #endif // LIBMESH_HAVE_MPI
314 
315  }
MPI_Datatype data_type
Data types for communication.
Definition: data_type.h:46

◆ StandardType() [2/2]

template<typename... Types>
libMesh::Parallel::StandardType< std::tuple< Types... > >::StandardType ( const StandardType< std::tuple< Types... >> &  t)

Definition at line 317 of file standard_type.h.

References libMesh::Parallel::DataType::_datatype.

318  {
319  libmesh_call_mpi
320  (MPI_Type_dup (t._datatype, &_datatype));
321  }

◆ ~StandardType()

template<typename... Types>
libMesh::Parallel::StandardType< std::tuple< Types... > >::~StandardType ( )

Definition at line 323 of file standard_type.h.

References libMesh::Parallel::DataType::free().

323 { this->free(); }

Member Function Documentation

◆ commit()

void libMesh::Parallel::DataType::commit ( )
inherited

Definition at line 103 of file data_type.h.

References libMesh::Parallel::DataType::_datatype.

Referenced by libMesh::Parallel::DataType::DataType(), libMesh::Parallel::StandardType< std::pair< T1, T2 > >::StandardType(), and StandardType().

104  {
105  libmesh_call_mpi
106  (MPI_Type_commit (&_datatype));
107  }

◆ free()

void libMesh::Parallel::DataType::free ( )
inherited

◆ operator const data_type &()

libMesh::Parallel::DataType::operator const data_type & ( ) const
inherited

Definition at line 91 of file data_type.h.

References libMesh::Parallel::DataType::_datatype.

92  { return _datatype; }

◆ operator data_type &()

libMesh::Parallel::DataType::operator data_type & ( )
inherited

Definition at line 94 of file data_type.h.

References libMesh::Parallel::DataType::_datatype.

95  { return _datatype; }

Member Data Documentation

◆ _datatype

data_type libMesh::Parallel::DataType::_datatype
protectedinherited

The documentation for this class was generated from the following file: